Ticket #21446: 21360-v3.patch
| File 21360-v3.patch, 4.0 KB (added by , 4 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
76 76 import org.openstreetmap.josm.gui.MapFrame; 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; 81 83 import org.openstreetmap.josm.spi.preferences.Config; … … 90 92 * Toolbar preferences. 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-!>"; 96 98 … … 1022 1024 control.setComponentPopupMenu(popupMenu); 1023 1025 }); 1024 1026 MapFrame.TOOLBAR_VISIBLE.addListener(e -> refreshToolbarControl()); 1027 TaggingPresets.addListener(this); 1025 1028 } 1026 1029 1027 1030 private void loadAction(DefaultMutableTreeNode node, MenuElement menu) { … … 1138 1141 } 1139 1142 } 1140 1143 if (toolbar != null) { 1144 actions.put(toolbar, action); 1141 1145 regactions.put(toolbar, action); 1142 1146 } 1143 1147 return action; … … 1152 1156 public Action unregister(Action action) { 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 } 1157 1162 return null; … … 1284 1289 } 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 } -
src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
177 177 * Use this as default item for "do not select anything". 178 178 */ 179 179 public TaggingPreset() { 180 MainApplication.getLayerManager().addActiveLayerChangeListener(this);181 180 updateEnabledState(); 182 181 } 183 182 -
src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
90 90 for (TaggingPreset tp: taggingPresets) { 91 91 if (!(tp instanceof TaggingPresetSeparator)) { 92 92 MainApplication.getToolbar().register(tp); 93 MainApplication.getLayerManager().addActiveLayerChangeListener(tp); 93 94 } 94 95 } 95 96 if (taggingPresets.isEmpty()) { … … 137 138 */ 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 148 153 /**
