Ignore:
Timestamp:
2009-02-17T19:00:17+01:00 (15 years ago)
Author:
stoecker
Message:

fixed #2181

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java

    r1415 r1424  
    1818import java.util.Vector;
    1919
     20import javax.swing.Box;
    2021import javax.swing.JButton;
    2122import javax.swing.JColorChooser;
     
    148149                int sel = colors.getSelectedRow();
    149150                JColorChooser chooser = new JColorChooser((Color)colors.getValueAt(sel, 1));
    150                 int answer = JOptionPane.showConfirmDialog(gui, chooser, tr("Choose a color for {0}", colors.getValueAt(sel, 0)), JOptionPane.OK_CANCEL_OPTION);
     151                int answer = JOptionPane.showConfirmDialog(gui, chooser,
     152                tr("Choose a color for {0}", getName((String)colors.getValueAt(sel, 0))),
     153                JOptionPane.OK_CANCEL_OPTION);
    151154                if (answer == JOptionPane.OK_OPTION)
    152155                    colors.setValueAt(chooser.getColor(), sel, 1);
     156            }
     157        });
     158        JButton defaultSet = new JButton(tr("Set to default"));
     159        defaultSet.addActionListener(new ActionListener(){
     160            public void actionPerformed(ActionEvent e) {
     161                if (colors.getSelectedRowCount() == 0) {
     162                    JOptionPane.showMessageDialog(gui, tr("Please select a color."));
     163                    return;
     164                }
     165                int sel = colors.getSelectedRow();
     166                String name = (String)colors.getValueAt(sel, 0);
     167                Color c = Main.pref.getDefaultColor(name);
     168                if (c != null)
     169                    colors.setValueAt(c, sel, 1);
     170            }
     171        });
     172        JButton defaultAll = new JButton(tr("Set all to default"));
     173        defaultAll.addActionListener(new ActionListener(){
     174            public void actionPerformed(ActionEvent e) {
     175                for(int i = 0; i < colors.getRowCount(); ++i)
     176                {
     177                  String name = (String)colors.getValueAt(i, 0);
     178                  Color c = Main.pref.getDefaultColor(name);
     179                  if (c != null)
     180                      colors.setValueAt(c, i, 1);
     181                }
    153182            }
    154183        });
     
    161190        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    162191        panel.add(scrollpane, GBC.eol().fill(GBC.BOTH));
    163         panel.add(colorEdit, GBC.eol().anchor(GBC.EAST));
     192        JPanel buttonPanel = new JPanel(new GridBagLayout());
     193        panel.add(buttonPanel, GBC.eol().insets(5,0,5,5).fill(GBC.HORIZONTAL));
     194        buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
     195        buttonPanel.add(colorEdit, GBC.std().insets(0,5,0,0));
     196        buttonPanel.add(defaultSet, GBC.std().insets(5,5,5,0));
     197        buttonPanel.add(defaultAll, GBC.std().insets(0,5,0,0));
    164198        gui.displaycontent.addTab(tr("Colors"), panel);
    165199    }
Note: See TracChangeset for help on using the changeset viewer.