Changeset 18321 in josm for trunk/src/org
- Timestamp:
- 2021-11-09T13:42:26+01:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r18208 r18321 77 77 import org.openstreetmap.josm.gui.help.HelpUtil; 78 78 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 79 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetListener; 80 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 79 81 import org.openstreetmap.josm.gui.util.GuiHelper; 80 82 import org.openstreetmap.josm.gui.util.ReorderableTableModel; … … 91 93 * @since 172 92 94 */ 93 public class ToolbarPreferences implements PreferenceSettingFactory {95 public class ToolbarPreferences implements PreferenceSettingFactory, TaggingPresetListener { 94 96 95 97 private static final String EMPTY_TOOLBAR_MARKER = "<!-empty-!>"; … … 1023 1025 }); 1024 1026 MapFrame.TOOLBAR_VISIBLE.addListener(e -> refreshToolbarControl()); 1027 TaggingPresets.addListener(this); 1025 1028 } 1026 1029 … … 1139 1142 } 1140 1143 if (toolbar != null) { 1144 actions.put(toolbar, action); 1141 1145 regactions.put(toolbar, action); 1142 1146 } … … 1153 1157 Object toolbar = action.getValue("toolbar"); 1154 1158 if (toolbar instanceof String) { 1159 actions.remove(toolbar); 1155 1160 return regactions.remove(toolbar); 1156 1161 } … … 1285 1290 1286 1291 private static final DataFlavor ACTION_FLAVOR = new DataFlavor(ActionDefinition.class, "ActionItem"); 1292 1293 @Override 1294 public void taggingPresetsModified() { 1295 refreshToolbarControl(); 1296 } 1287 1297 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r18221 r18321 178 178 */ 179 179 public TaggingPreset() { 180 MainApplication.getLayerManager().addActiveLayerChangeListener(this);181 180 updateEnabledState(); 182 181 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
r18281 r18321 91 91 if (!(tp instanceof TaggingPresetSeparator)) { 92 92 MainApplication.getToolbar().register(tp); 93 MainApplication.getLayerManager().addActiveLayerChangeListener(tp); 93 94 } 94 95 } … … 138 139 public static void destroy() { 139 140 ToolbarPreferences toolBar = MainApplication.getToolbar(); 140 taggingPresets.forEach(toolBar::unregister); 141 for (TaggingPreset tp: taggingPresets) { 142 toolBar.unregister(tp); 143 if (!(tp instanceof TaggingPresetSeparator)) { 144 MainApplication.getLayerManager().removeActiveLayerChangeListener(tp); 145 } 146 } 141 147 taggingPresets.clear(); 142 148 PRESET_TAG_CACHE.clear(); 143 149 PRESET_ROLE_CACHE.clear(); 144 150 MainApplication.getMenu().presetsMenu.removeAll(); 145 listeners.forEach(TaggingPresetListener::taggingPresetsModified);146 151 } 147 152
Note:
See TracChangeset
for help on using the changeset viewer.