Changeset 1424 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-02-17T19:00:17+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r1332 r1424 417 417 } 418 418 419 synchronized public Color getDefaultColor(String colName) { 420 String colStr = defaults.get("color."+colName); 421 return colStr.equals("") ? null : ColorHelper.html2color(colStr); 422 } 423 419 424 synchronized public boolean putColor(String colName, Color val) { 420 425 return put("color."+colName, val != null ? ColorHelper.color2html(val) : null); -
trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java
r1415 r1424 18 18 import java.util.Vector; 19 19 20 import javax.swing.Box; 20 21 import javax.swing.JButton; 21 22 import javax.swing.JColorChooser; … … 148 149 int sel = colors.getSelectedRow(); 149 150 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); 151 154 if (answer == JOptionPane.OK_OPTION) 152 155 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 } 153 182 } 154 183 }); … … 161 190 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 162 191 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)); 164 198 gui.displaycontent.addTab(tr("Colors"), panel); 165 199 }
Note:
See TracChangeset
for help on using the changeset viewer.