Changeset 16594 in josm for trunk/src/org
- Timestamp:
- 2020-06-11T00:16:44+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r16562 r16594 54 54 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 55 55 import org.openstreetmap.josm.gui.util.GuiHelper; 56 import org.openstreetmap.josm.gui.widgets.FilterField; 56 57 import org.openstreetmap.josm.tools.CheckParameterUtil; 57 58 import org.openstreetmap.josm.tools.ColorHelper; … … 138 139 info.getName(), info.getDefaultValue()); 139 140 } 141 142 @Override 143 public String toString() { 144 return "ColorEntry{" + getDisplay() + ' ' + ColorHelper.color2html(getDisplayColor()) + '}'; 145 } 140 146 } 141 147 … … 259 265 colorEdit.addActionListener(e -> { 260 266 int sel = colors.getSelectedRow(); 267 sel = colors.convertRowIndexToModel(sel); 261 268 ColorEntry ce = tableModel.getEntry(sel); 262 269 JColorChooser chooser = new JColorChooser(ce.getDisplayColor()); … … 273 280 defaultSet.addActionListener(e -> { 274 281 int sel = colors.getSelectedRow(); 282 sel = colors.convertRowIndexToModel(sel); 275 283 ColorEntry ce = tableModel.getEntry(sel); 276 284 Color c = ce.info.getDefaultValue(); … … 293 301 remove.addActionListener(e -> { 294 302 int sel = colors.getSelectedRow(); 303 sel = colors.convertRowIndexToModel(sel); 295 304 tableModel.removeEntry(sel); 296 305 }); … … 300 309 301 310 colors = new JTable(tableModel); 311 colors.setAutoCreateRowSorter(true); 312 FilterField colorFilter = new FilterField().filter(colors, tableModel); 302 313 colors.addMouseListener(new MouseAdapter() { 303 314 @Override … … 353 364 JPanel panel = new JPanel(new GridBagLayout()); 354 365 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 366 panel.add(colorFilter, GBC.eol().fill(GBC.HORIZONTAL)); 355 367 JScrollPane scrollpane = new JScrollPane(colors); 356 368 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); … … 425 437 private void updateEnabledState() { 426 438 int sel = colors.getSelectedRow(); 427 ColorEntry ce = sel >= 0 && sel < tableModel.getRowCount() ? tableModel.getEntry(sel) : null; 439 if (sel < 0 || sel >= tableModel.getRowCount()) { 440 return; 441 } 442 sel = colors.convertRowIndexToModel(sel); 443 ColorEntry ce = tableModel.getEntry(sel); 428 444 remove.setEnabled(ce != null && isRemoveColor(ce)); 429 445 colorEdit.setEnabled(ce != null);
Note:
See TracChangeset
for help on using the changeset viewer.