Changeset 11657 in josm


Ignore:
Timestamp:
2017-03-03T23:38:13+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #14451 - Local imagery toolbar buttons disappear on restart

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r11654 r11657  
    3030import org.openstreetmap.josm.gui.layer.AlignImageryPanel;
    3131import org.openstreetmap.josm.gui.layer.ImageryLayer;
     32import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    3233import org.openstreetmap.josm.gui.preferences.imagery.WMSLayerTree;
    3334import org.openstreetmap.josm.gui.util.GuiHelper;
     
    6566    public AddImageryLayerAction(ImageryInfo info) {
    6667        super(info.getMenuName(), /* ICON */"imagery_menu", tr("Add imagery layer {0}", info.getName()), null,
    67                 true, "imagery_" + info.getToolbarName(), false);
     68                true, ToolbarPreferences.IMAGERY_PREFIX + info.getToolbarName(), false);
    6869        putValue("help", ht("/Preferences/Imagery"));
    6970        setTooltip(info.getToolTipText().replaceAll("</?html>", ""));
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r11654 r11657  
    6262import org.openstreetmap.josm.actions.ActionParameter;
    6363import org.openstreetmap.josm.actions.AdaptableAction;
     64import org.openstreetmap.josm.actions.AddImageryLayerAction;
    6465import org.openstreetmap.josm.actions.JosmAction;
    6566import org.openstreetmap.josm.actions.ParameterizedAction;
    6667import org.openstreetmap.josm.actions.ParameterizedActionDecorator;
     68import org.openstreetmap.josm.data.imagery.ImageryInfo;
     69import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
    6770import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    6871import org.openstreetmap.josm.tools.GBC;
     
    7780
    7881    private static final String EMPTY_TOOLBAR_MARKER = "<!-empty-!>";
     82
     83    /**
     84     * The prefix for imagery toolbar entries.
     85     * @since 11657
     86     */
     87    public static final String IMAGERY_PREFIX = "imagery_";
    7988
    8089    /**
     
    253262        }
    254263
     264        /**
     265         * Loads the action definition from its toolbar name.
     266         * @param actionName action toolbar name
     267         * @return action definition or null
     268         */
    255269        public ActionDefinition loadAction(String actionName) {
    256270            index = 0;
     
    259273            String name = readTillChar('(', '{');
    260274            Action action = actions.get(name);
     275
     276            if (action == null && name.startsWith(IMAGERY_PREFIX)) {
     277                String imageryName = name.substring(IMAGERY_PREFIX.length());
     278                for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) {
     279                    if (imageryName.equalsIgnoreCase(i.getName())) {
     280                        action = new AddImageryLayerAction(i);
     281                        break;
     282                    }
     283                }
     284            }
    261285
    262286            if (action == null)
     
    10071031                        String toolbar = (String) tb;
    10081032                        Action r = actions.get(toolbar);
    1009                         if (r != null && r != action && !toolbar.startsWith("imagery_")) {
     1033                        if (r != null && r != action && !toolbar.startsWith(IMAGERY_PREFIX)) {
    10101034                            Main.info(tr("Toolbar action {0} overwritten: {1} gets {2}",
    10111035                            toolbar, r.getClass().getName(), action.getClass().getName()));
Note: See TracChangeset for help on using the changeset viewer.