- Timestamp:
- 2020-02-05T22:19:42+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/autofilter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java
r14206 r15818 8 8 import java.awt.event.ActionEvent; 9 9 10 import javax.swing.AbstractAction; 10 11 import javax.swing.BorderFactory; 11 12 import javax.swing.JButton; 12 13 13 14 import org.openstreetmap.josm.actions.JosmAction; 15 import org.openstreetmap.josm.actions.PreferencesAction; 14 16 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 15 17 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.gui.preferences.display.DrawingPreference; 16 19 17 20 /** … … 63 66 super.paintComponent(g); 64 67 } 68 69 static AutoFilterButton forOsmKey(String key) { 70 final String name = key + ":"; 71 final AutoFilterButton button = new AutoFilterButton(new AutoFilter(key, "", null)); 72 button.setAction(new AbstractAction(name) { 73 @Override 74 public void actionPerformed(ActionEvent e) { 75 PreferencesAction.forPreferenceSubTab("", "null", DrawingPreference.class).actionPerformed(e); 76 } 77 }); 78 return button; 79 } 65 80 } -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
r15817 r15818 182 182 183 183 private synchronized void addNewButtons(NavigableSet<String> values) { 184 if (values.isEmpty()) { 185 return; 186 } 184 187 int i = 0; 185 188 int maxWidth = 16; 186 MapView mapView = MainApplication.getMap().mapView; 189 final AutoFilterButton keyButton = AutoFilterButton.forOsmKey(enabledRule.getKey()); 190 addButton(keyButton, Integer.toString(Integer.MIN_VALUE), i++); 187 191 for (final String value : values.descendingSet()) { 188 192 CompiledFilter filter = new CompiledFilter(enabledRule.getKey(), value); … … 193 197 button.getModel().setPressed(true); 194 198 } 195 buttons.put(value, button);196 199 maxWidth = Math.max(maxWidth, button.getPreferredSize().width); 197 mapView.add(button).setLocation(3, 60 + 22*i++);200 addButton(button, value, i++); 198 201 } 199 202 for (AutoFilterButton b : buttons.values()) { 200 b.setSize(maxWidth, 20); 201 } 202 mapView.validate(); 203 b.setSize(b == keyButton ? b.getPreferredSize().width : maxWidth, 20); 204 } 205 MainApplication.getMap().mapView.validate(); 206 } 207 208 private void addButton(AutoFilterButton button, String value, int i) { 209 MapView mapView = MainApplication.getMap().mapView; 210 buttons.put(value, button); 211 mapView.add(button).setLocation(3, 60 + 22*i); 203 212 } 204 213
Note:
See TracChangeset
for help on using the changeset viewer.