Changeset 12639 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-08-25T01:37:31+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate shortcut handling and mapframe listener methods in Main. Replacement: same methods in gui.MainApplication

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

Legend:

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

    r12638 r12639  
    2828
    2929import javax.swing.Action;
    30 import javax.swing.InputMap;
    31 import javax.swing.JComponent;
    32 import javax.swing.KeyStroke;
    3330
    3431import org.openstreetmap.josm.actions.JosmAction;
     
    156153
    157154    /**
    158      * The same main panel, required to be static for {@code MapFrameListener} handling.
    159      */
    160     protected static MainPanel mainPanel;
    161 
    162     /**
    163      * The private content pane of {@code MainFrame}, required to be static for shortcut handling.
    164      */
    165     protected static JComponent contentPanePrivate;
    166 
    167     /**
    168155     * The file watcher service.
    169156     */
     
    649636     * Registers a {@code JosmAction} and its shortcut.
    650637     * @param action action defining its own shortcut
    651      */
     638     * @deprecated use {@link MainApplication#registerActionShortcut(JosmAction)} instead
     639     */
     640    @Deprecated
    652641    public static void registerActionShortcut(JosmAction action) {
    653         registerActionShortcut(action, action.getShortcut());
     642        MainApplication.registerActionShortcut(action);
    654643    }
    655644
     
    658647     * @param action action to register
    659648     * @param shortcut shortcut to associate to {@code action}
    660      */
     649     * @deprecated use {@link MainApplication#registerActionShortcut(Action, Shortcut)} instead
     650     */
     651    @Deprecated
    661652    public static void registerActionShortcut(Action action, Shortcut shortcut) {
    662         KeyStroke keyStroke = shortcut.getKeyStroke();
    663         if (keyStroke == null)
    664             return;
    665 
    666         InputMap inputMap = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    667         Object existing = inputMap.get(keyStroke);
    668         if (existing != null && !existing.equals(action)) {
    669             Logging.info(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action));
    670         }
    671         inputMap.put(keyStroke, action);
    672 
    673         contentPanePrivate.getActionMap().put(action, action);
     653        MainApplication.registerActionShortcut(action, shortcut);
    674654    }
    675655
     
    677657     * Unregisters a shortcut.
    678658     * @param shortcut shortcut to unregister
    679      */
     659     * @deprecated use {@link MainApplication#unregisterShortcut(Shortcut)} instead
     660     */
     661    @Deprecated
    680662    public static void unregisterShortcut(Shortcut shortcut) {
    681         contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortcut.getKeyStroke());
     663        MainApplication.unregisterShortcut(shortcut);
    682664    }
    683665
     
    685667     * Unregisters a {@code JosmAction} and its shortcut.
    686668     * @param action action to unregister
    687      */
     669     * @deprecated use {@link MainApplication#unregisterActionShortcut(JosmAction)} instead
     670     */
     671    @Deprecated
    688672    public static void unregisterActionShortcut(JosmAction action) {
    689         unregisterActionShortcut(action, action.getShortcut());
     673        MainApplication.unregisterActionShortcut(action);
    690674    }
    691675
     
    694678     * @param action action to unregister
    695679     * @param shortcut shortcut to unregister
    696      */
     680     * @deprecated use {@link MainApplication#unregisterActionShortcut(Action, Shortcut)} instead
     681     */
     682    @Deprecated
    697683    public static void unregisterActionShortcut(Action action, Shortcut shortcut) {
    698         unregisterShortcut(shortcut);
    699         contentPanePrivate.getActionMap().remove(action);
     684        MainApplication.unregisterActionShortcut(action, shortcut);
    700685    }
    701686
     
    704689     * @param shortcut The shortcut to look for
    705690     * @return the registered action for the given shortcut
     691     * @deprecated use {@link MainApplication#getRegisteredActionShortcut(Shortcut)} instead
    706692     * @since 5696
    707693     */
     694    @Deprecated
    708695    public static Action getRegisteredActionShortcut(Shortcut shortcut) {
    709         KeyStroke keyStroke = shortcut.getKeyStroke();
    710         if (keyStroke == null)
    711             return null;
    712         Object action = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(keyStroke);
    713         if (action instanceof Action)
    714             return (Action) action;
    715         return null;
     696        return MainApplication.getRegisteredActionShortcut(shortcut);
    716697    }
    717698
     
    936917     * @return {@code true} if the listeners collection changed as a result of the call
    937918     * @see #addMapFrameListener
     919     * @deprecated use {@link MainApplication#addAndFireMapFrameListener} instead
    938920     * @since 11904
    939921     */
     922    @Deprecated
    940923    public static boolean addAndFireMapFrameListener(MapFrameListener listener) {
    941         return mainPanel != null && mainPanel.addAndFireMapFrameListener(listener);
     924        return MainApplication.addAndFireMapFrameListener(listener);
    942925    }
    943926
     
    947930     * @return {@code true} if the listeners collection changed as a result of the call
    948931     * @see #addAndFireMapFrameListener
     932     * @deprecated use {@link MainApplication#addMapFrameListener} instead
    949933     * @since 5957
    950934     */
     935    @Deprecated
    951936    public static boolean addMapFrameListener(MapFrameListener listener) {
    952         return mainPanel != null && mainPanel.addMapFrameListener(listener);
     937        return MainApplication.addMapFrameListener(listener);
    953938    }
    954939
     
    957942     * @param listener The MapFrameListener
    958943     * @return {@code true} if the listeners collection changed as a result of the call
     944     * @deprecated use {@link MainApplication#removeMapFrameListener} instead
    959945     * @since 5957
    960946     */
     947    @Deprecated
    961948    public static boolean removeMapFrameListener(MapFrameListener listener) {
    962         return mainPanel != null && mainPanel.removeMapFrameListener(listener);
     949        return MainApplication.removeMapFrameListener(listener);
    963950    }
    964951
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r12636 r12639  
    394394        //
    395395        MapView.addZoomChangeListener(new ZoomChangeAdapter());
    396         Main.addMapFrameListener(new MapFrameAdapter());
     396        MainApplication.addMapFrameListener(new MapFrameAdapter());
    397397        initEnabledState();
    398398    }
  • trunk/src/org/openstreetmap/josm/actions/CopyAction.java

    r10605 r12639  
    1616import org.openstreetmap.josm.data.osm.DataSet;
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
     18import org.openstreetmap.josm.gui.MainApplication;
    1819import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    1920import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable;
     
    3637        putValue("help", ht("/Action/Copy"));
    3738        // CUA shortcut for copy (https://en.wikipedia.org/wiki/IBM_Common_User_Access#Description)
    38         Main.registerActionShortcut(this,
     39        MainApplication.registerActionShortcut(this,
    3940                Shortcut.registerShortcut("system:copy:cua", tr("Edit: {0}", tr("Copy")), KeyEvent.VK_INSERT, Shortcut.CTRL));
    4041    }
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r12637 r12639  
    7979        sc = shortcut;
    8080        if (sc != null && !sc.isAutomatic()) {
    81             Main.registerActionShortcut(this, sc);
     81            MainApplication.registerActionShortcut(this, sc);
    8282        }
    8383        setTooltip(tooltip);
     
    218218    public void destroy() {
    219219        if (sc != null && !sc.isAutomatic()) {
    220             Main.unregisterActionShortcut(this);
     220            MainApplication.unregisterActionShortcut(this);
    221221        }
    222222        if (layerChangeAdapter != null) {
  • trunk/src/org/openstreetmap/josm/actions/JumpToAction.java

    r12630 r12639  
    216216        super.installAdapters();
    217217        // make this action listen to mapframe change events
    218         Main.addMapFrameListener((o, n) -> updateEnabledState());
     218        MainApplication.addMapFrameListener((o, n) -> updateEnabledState());
    219219    }
    220220}
  • trunk/src/org/openstreetmap/josm/actions/PasteAction.java

    r10766 r12639  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.tools.Shortcut;
    1212
     
    2525        putValue("help", ht("/Action/Paste"));
    2626        // CUA shortcut for paste (https://en.wikipedia.org/wiki/IBM_Common_User_Access#Description)
    27         Main.registerActionShortcut(this,
     27        MainApplication.registerActionShortcut(this,
    2828                Shortcut.registerShortcut("system:paste:cua", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_INSERT, Shortcut.SHIFT));
    2929    }
  • trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java

    r12636 r12639  
    7575                null, toolbar, "save_as-session", installAdapters);
    7676        putValue("help", ht("/Action/SessionSaveAs"));
    77         Main.addMapFrameListener(this);
     77        MainApplication.addMapFrameListener(this);
    7878    }
    7979
  • trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java

    r12636 r12639  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.gui.MainApplication;
    1211import org.openstreetmap.josm.tools.Shortcut;
     
    3231        putValue("help", ht("/Action/ZoomIn"));
    3332        // On standard QWERTY, AZERTY and other common layouts the '+' key is obtained with Shift+EQUALS
    34         Main.registerActionShortcut(this,
     33        MainApplication.registerActionShortcut(this,
    3534                Shortcut.registerShortcut("view:zoominbis", tr("View: {0}", tr("Zoom In")),
    3635                    KeyEvent.VK_EQUALS, Shortcut.SHIFT));
    3736        // But on some systems (Belgian keyboard under Ubuntu) it seems not to work, so use also EQUALS
    38         Main.registerActionShortcut(this,
     37        MainApplication.registerActionShortcut(this,
    3938                Shortcut.registerShortcut("view:zoominter", tr("View: {0}", tr("Zoom In")),
    4039                    KeyEvent.VK_EQUALS, Shortcut.DIRECT));
    4140        // make numpad + behave like +
    42         Main.registerActionShortcut(this,
     41        MainApplication.registerActionShortcut(this,
    4342            Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")),
    4443                KeyEvent.VK_ADD, Shortcut.DIRECT));
  • trunk/src/org/openstreetmap/josm/actions/ZoomOutAction.java

    r12636 r12639  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.gui.MainApplication;
    1211import org.openstreetmap.josm.tools.Shortcut;
     
    2625        putValue("help", ht("/Action/ZoomOut"));
    2726        // make numpad - behave like -
    28         Main.registerActionShortcut(this,
     27        MainApplication.registerActionShortcut(this,
    2928            Shortcut.registerShortcut("view:zoomoutkeypad", tr("View: {0}", tr("Zoom Out (Keypad)")),
    3029                KeyEvent.VK_SUBTRACT, Shortcut.DIRECT));
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r12636 r12639  
    274274        MapFrame map = MainApplication.getMap();
    275275        map.statusLine.getAnglePanel().addMouseListener(snapHelper.anglePopupListener);
    276         Main.registerActionShortcut(backspaceAction, backspaceShortcut);
     276        MainApplication.registerActionShortcut(backspaceAction, backspaceShortcut);
    277277
    278278        map.mapView.addMouseListener(this);
     
    294294        map.mapView.removeTemporaryLayer(this);
    295295        SelectionEventManager.getInstance().removeSelectionListener(this);
    296         Main.unregisterActionShortcut(backspaceAction, backspaceShortcut);
     296        MainApplication.unregisterActionShortcut(backspaceAction, backspaceShortcut);
    297297        snapHelper.unsetFixedMode();
    298298        snapCheckboxMenuItem.getAction().setEnabled(false);
  • trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java

    r12636 r12639  
    5959        );
    6060        launchAction = new LaunchEditorAction();
    61         Main.registerActionShortcut(launchAction, shortcut);
     61        MainApplication.registerActionShortcut(launchAction, shortcut);
    6262    }
    6363
     
    115115    @Override
    116116    public void destroy() {
    117         Main.unregisterActionShortcut(launchAction, shortcut);
     117        MainApplication.unregisterActionShortcut(launchAction, shortcut);
    118118        super.destroy();
    119119    }
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12638 r12639  
    4444
    4545import javax.net.ssl.SSLSocketFactory;
     46import javax.swing.Action;
     47import javax.swing.InputMap;
    4648import javax.swing.JComponent;
    4749import javax.swing.JOptionPane;
     50import javax.swing.KeyStroke;
    4851import javax.swing.LookAndFeel;
    4952import javax.swing.RepaintManager;
     
    5558import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
    5659import org.openstreetmap.josm.Main;
     60import org.openstreetmap.josm.actions.JosmAction;
    5761import org.openstreetmap.josm.actions.OpenFileAction;
    5862import org.openstreetmap.josm.actions.PreferencesAction;
     
    131135
    132136    /**
     137     * The same panel as {@link Main#panel}, required to be static for {@link MapFrameListener} handling.
     138     */
     139    static MainPanel mainPanel;
     140
     141    /**
     142     * The private content pane of {@link MainFrame}, required to be static for shortcut handling.
     143     */
     144    static JComponent contentPanePrivate;
     145
     146    /**
    133147     * The MapFrame.
    134148     */
     
    390404    public static void redirectToMainContentPane(JComponent source) {
    391405        RedirectInputMap.redirect(source, contentPanePrivate);
     406    }
     407
     408    /**
     409     * Registers a new {@code MapFrameListener} that will be notified of MapFrame changes.
     410     * <p>
     411     * It will fire an initial mapFrameInitialized event when the MapFrame is present.
     412     * Otherwise will only fire when the MapFrame is created or destroyed.
     413     * @param listener The MapFrameListener
     414     * @return {@code true} if the listeners collection changed as a result of the call
     415     * @see #addMapFrameListener
     416     * @since 12639 (as a replacement to {@code Main.addAndFireMapFrameListener})
     417     */
     418    @SuppressWarnings("deprecation")
     419    public static boolean addAndFireMapFrameListener(MapFrameListener listener) {
     420        return mainPanel != null && mainPanel.addAndFireMapFrameListener(listener);
     421    }
     422
     423    /**
     424     * Registers a new {@code MapFrameListener} that will be notified of MapFrame changes
     425     * @param listener The MapFrameListener
     426     * @return {@code true} if the listeners collection changed as a result of the call
     427     * @see #addAndFireMapFrameListener
     428     * @since 12639 (as a replacement to {@code Main.addMapFrameListener})
     429     */
     430    @SuppressWarnings("deprecation")
     431    public static boolean addMapFrameListener(MapFrameListener listener) {
     432        return mainPanel != null && mainPanel.addMapFrameListener(listener);
     433    }
     434
     435    /**
     436     * Unregisters the given {@code MapFrameListener} from MapFrame changes
     437     * @param listener The MapFrameListener
     438     * @return {@code true} if the listeners collection changed as a result of the call
     439     * @since 12639 (as a replacement to {@code Main.removeMapFrameListener})
     440     */
     441    @SuppressWarnings("deprecation")
     442    public static boolean removeMapFrameListener(MapFrameListener listener) {
     443        return mainPanel != null && mainPanel.removeMapFrameListener(listener);
     444    }
     445
     446    /**
     447     * Registers a {@code JosmAction} and its shortcut.
     448     * @param action action defining its own shortcut
     449     * @since 12639 (as a replacement to {@code Main.registerActionShortcut})
     450     */
     451    @SuppressWarnings("deprecation")
     452    public static void registerActionShortcut(JosmAction action) {
     453        registerActionShortcut(action, action.getShortcut());
     454    }
     455
     456    /**
     457     * Registers an action and its shortcut.
     458     * @param action action to register
     459     * @param shortcut shortcut to associate to {@code action}
     460     * @since 12639 (as a replacement to {@code Main.registerActionShortcut})
     461     */
     462    @SuppressWarnings("deprecation")
     463    public static void registerActionShortcut(Action action, Shortcut shortcut) {
     464        KeyStroke keyStroke = shortcut.getKeyStroke();
     465        if (keyStroke == null)
     466            return;
     467
     468        InputMap inputMap = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
     469        Object existing = inputMap.get(keyStroke);
     470        if (existing != null && !existing.equals(action)) {
     471            Logging.info(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action));
     472        }
     473        inputMap.put(keyStroke, action);
     474
     475        contentPanePrivate.getActionMap().put(action, action);
     476    }
     477
     478    /**
     479     * Unregisters a shortcut.
     480     * @param shortcut shortcut to unregister
     481     * @since 12639 (as a replacement to {@code Main.unregisterShortcut})
     482     */
     483    @SuppressWarnings("deprecation")
     484    public static void unregisterShortcut(Shortcut shortcut) {
     485        contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortcut.getKeyStroke());
     486    }
     487
     488    /**
     489     * Unregisters a {@code JosmAction} and its shortcut.
     490     * @param action action to unregister
     491     * @since 12639 (as a replacement to {@code Main.unregisterActionShortcut})
     492     */
     493    @SuppressWarnings("deprecation")
     494    public static void unregisterActionShortcut(JosmAction action) {
     495        unregisterActionShortcut(action, action.getShortcut());
     496    }
     497
     498    /**
     499     * Unregisters an action and its shortcut.
     500     * @param action action to unregister
     501     * @param shortcut shortcut to unregister
     502     * @since 12639 (as a replacement to {@code Main.unregisterActionShortcut})
     503     */
     504    @SuppressWarnings("deprecation")
     505    public static void unregisterActionShortcut(Action action, Shortcut shortcut) {
     506        unregisterShortcut(shortcut);
     507        contentPanePrivate.getActionMap().remove(action);
     508    }
     509
     510    /**
     511     * Replies the registered action for the given shortcut
     512     * @param shortcut The shortcut to look for
     513     * @return the registered action for the given shortcut
     514     * @since 12639 (as a replacement to {@code Main.getRegisteredActionShortcut})
     515     */
     516    @SuppressWarnings("deprecation")
     517    public static Action getRegisteredActionShortcut(Shortcut shortcut) {
     518        KeyStroke keyStroke = shortcut.getKeyStroke();
     519        if (keyStroke == null)
     520            return null;
     521        Object action = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(keyStroke);
     522        if (action instanceof Action)
     523            return (Action) action;
     524        return null;
    392525    }
    393526
     
    551684        final MainFrame mainFrame = new MainFrame(geometry);
    552685        if (mainFrame.getContentPane() instanceof JComponent) {
    553             Main.contentPanePrivate = (JComponent) mainFrame.getContentPane();
    554         }
    555         Main.mainPanel = mainFrame.getPanel();
     686            contentPanePrivate = (JComponent) mainFrame.getContentPane();
     687        }
     688        mainPanel = mainFrame.getPanel();
    556689        Main.parent = mainFrame;
    557690
  • trunk/src/org/openstreetmap/josm/gui/MapMover.java

    r12630 r12639  
    153153
    154154    private void registerActionShortcut(ZoomerAction action, Shortcut shortcut) {
    155         Main.registerActionShortcut(action, shortcut);
     155        MainApplication.registerActionShortcut(action, shortcut);
    156156        registeredShortcuts.add(new Pair<>(action, shortcut));
    157157    }
     
    271271    public void destroy() {
    272272        for (Pair<ZoomerAction, Shortcut> shortcut : registeredShortcuts) {
    273             Main.unregisterActionShortcut(shortcut.a, shortcut.b);
     273            MainApplication.unregisterActionShortcut(shortcut.a, shortcut.b);
    274274        }
    275275    }
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r12630 r12639  
    672672                final boolean activeLayerSupported = mode.layerIsSupported(layerManager.getActiveLayer());
    673673                if (activeLayerSupported) {
    674                     Main.registerActionShortcut(mode, mode.getShortcut()); //fix #6876
     674                    MainApplication.registerActionShortcut(mode, mode.getShortcut()); //fix #6876
    675675                } else {
    676                     Main.unregisterShortcut(mode.getShortcut());
     676                    MainApplication.unregisterShortcut(mode.getShortcut());
    677677                }
    678678                b.setEnabled(activeLayerSupported);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r12636 r12639  
    161161                    tr("Toggle visibility of layer: {0}", i1), KeyEvent.VK_0 + (i1 % 10), Shortcut.ALT);
    162162            visibilityToggleActions[i] = new ToggleLayerIndexVisibility(i);
    163             Main.registerActionShortcut(visibilityToggleActions[i], visibilityToggleShortcuts[i]);
     163            MainApplication.registerActionShortcut(visibilityToggleActions[i], visibilityToggleShortcuts[i]);
    164164        }
    165165    }
     
    372372    public void destroy() {
    373373        for (int i = 0; i < 10; i++) {
    374             Main.unregisterActionShortcut(visibilityToggleActions[i], visibilityToggleShortcuts[i]);
     374            MainApplication.unregisterActionShortcut(visibilityToggleActions[i], visibilityToggleShortcuts[i]);
    375375        }
    376376        MultikeyActionsHandler.getInstance().removeAction(activateLayerAction);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r12636 r12639  
    515515        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    516516        for (JosmAction action : josmActions) {
    517             Main.registerActionShortcut(action);
     517            MainApplication.registerActionShortcut(action);
    518518        }
    519519        updateSelection();
     
    526526        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    527527        for (JosmAction action : josmActions) {
    528             Main.unregisterActionShortcut(action);
     528            MainApplication.unregisterActionShortcut(action);
    529529        }
    530530    }
     
    13351335            putValue(SHORT_DESCRIPTION, tr("Copy the key and value of all the tags to clipboard"));
    13361336            Shortcut sc = Shortcut.registerShortcut("system:copytags", tr("Edit: {0}", tr("Copy Tags")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
    1337             Main.registerActionShortcut(this, sc);
     1337            MainApplication.registerActionShortcut(this, sc);
    13381338            sc.setAccelerator(this);
    13391339        }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r12636 r12639  
    2222import javax.swing.JToggleButton;
    2323
    24 import org.openstreetmap.josm.Main;
    2524import org.openstreetmap.josm.gui.MainApplication;
    2625import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action;
     
    101100                "geoimage:previous", tr("Geoimage: {0}", tr("Show previous Image")), KeyEvent.VK_PAGE_UP, Shortcut.DIRECT);
    102101        final String previousImage = "Previous Image";
    103         Main.registerActionShortcut(prevAction, scPrev);
     102        MainApplication.registerActionShortcut(prevAction, scPrev);
    104103        btnPrevious.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scPrev.getKeyStroke(), previousImage);
    105104        btnPrevious.getActionMap().put(previousImage, prevAction);
     
    112111        Shortcut scDelete = Shortcut.registerShortcut(
    113112                "geoimage:deleteimagefromlayer", tr("Geoimage: {0}", tr("Remove photo from layer")), KeyEvent.VK_DELETE, Shortcut.SHIFT);
    114         Main.registerActionShortcut(delAction, scDelete);
     113        MainApplication.registerActionShortcut(delAction, scDelete);
    115114        btnDelete.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scDelete.getKeyStroke(), removePhoto);
    116115        btnDelete.getActionMap().put(removePhoto, delAction);
     
    123122                "geoimage:deletefilefromdisk", tr("Geoimage: {0}", tr("Delete File from disk")), KeyEvent.VK_DELETE, Shortcut.CTRL_SHIFT);
    124123        final String deleteImage = "Delete image file from disk";
    125         Main.registerActionShortcut(delFromDiskAction, scDeleteFromDisk);
     124        MainApplication.registerActionShortcut(delFromDiskAction, scDeleteFromDisk);
    126125        btnDeleteFromDisk.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scDeleteFromDisk.getKeyStroke(), deleteImage);
    127126        btnDeleteFromDisk.getActionMap().put(deleteImage, delFromDiskAction);
     
    133132                "geoimage:copypath", tr("Geoimage: {0}", tr("Copy image path")), KeyEvent.VK_C, Shortcut.ALT_CTRL_SHIFT);
    134133        final String copyImage = "Copy image path";
    135         Main.registerActionShortcut(copyPathAction, scCopyPath);
     134        MainApplication.registerActionShortcut(copyPathAction, scCopyPath);
    136135        btnCopyPath.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scCopyPath.getKeyStroke(), copyImage);
    137136        btnCopyPath.getActionMap().put(copyImage, copyPathAction);
     
    143142                "geoimage:next", tr("Geoimage: {0}", tr("Show next Image")), KeyEvent.VK_PAGE_DOWN, Shortcut.DIRECT);
    144143        final String nextImage = "Next Image";
    145         Main.registerActionShortcut(nextAction, scNext);
     144        MainApplication.registerActionShortcut(nextAction, scNext);
    146145        btnNext.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scNext.getKeyStroke(), nextImage);
    147146        btnNext.getActionMap().put(nextImage, nextAction);
    148147        btnNext.setEnabled(false);
    149148
    150         Main.registerActionShortcut(
     149        MainApplication.registerActionShortcut(
    151150                new ImageAction(COMMAND_FIRST, null, null),
    152151                Shortcut.registerShortcut(
    153152                        "geoimage:first", tr("Geoimage: {0}", tr("Show first Image")), KeyEvent.VK_HOME, Shortcut.DIRECT)
    154153        );
    155         Main.registerActionShortcut(
     154        MainApplication.registerActionShortcut(
    156155                new ImageAction(COMMAND_LAST, null, null),
    157156                Shortcut.registerShortcut(
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r12637 r12639  
    12451245            sc = Shortcut.registerShortcut("toolbar:"+name, tr("Toolbar: {0}", desc),
    12461246                KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
    1247             Main.unregisterShortcut(sc);
    1248             Main.registerActionShortcut(act, sc);
     1247            MainApplication.unregisterShortcut(sc);
     1248            MainApplication.registerActionShortcut(act, sc);
    12491249
    12501250            // add shortcut info to the tooltip if needed
  • trunk/src/org/openstreetmap/josm/gui/widgets/DisableShortcutsOnFocusGainedTextField.java

    r8929 r12639  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.actions.JosmAction;
     19import org.openstreetmap.josm.gui.MainApplication;
    1920import org.openstreetmap.josm.tools.Pair;
    2021import org.openstreetmap.josm.tools.Shortcut;
     
    147148            KeyStroke ks = shortcut.getKeyStroke();
    148149            if (hasToBeDisabled(ks)) {
    149                 Action action = Main.getRegisteredActionShortcut(shortcut);
     150                Action action = MainApplication.getRegisteredActionShortcut(shortcut);
    150151                if (action != null) {
    151                     Main.unregisterActionShortcut(action, shortcut);
     152                    MainApplication.unregisterActionShortcut(action, shortcut);
    152153                    unregisteredActionShortcuts.add(new Pair<>(action, shortcut));
    153154                }
     
    182183    protected void restoreActionShortcuts() {
    183184        for (Pair<Action, Shortcut> p : unregisteredActionShortcuts) {
    184             Main.registerActionShortcut(p.a, p.b);
     185            MainApplication.registerActionShortcut(p.a, p.b);
    185186        }
    186187        unregisteredActionShortcuts.clear();
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r12634 r12639  
    781781                PluginProxy pluginProxy = plugin.load(klass, pluginClassLoader);
    782782                pluginList.add(pluginProxy);
    783                 Main.addAndFireMapFrameListener(pluginProxy);
     783                MainApplication.addAndFireMapFrameListener(pluginProxy);
    784784            }
    785785            msg = null;
  • trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java

    r12630 r12639  
    212212            MyAction myAction = new MyAction(action);
    213213            myActions.put(action, myAction);
    214             Main.registerActionShortcut(myAction, myAction.shortcut);
     214            MainApplication.registerActionShortcut(myAction, myAction.shortcut);
    215215        }
    216216    }
     
    223223        MyAction a = myActions.get(action);
    224224        if (a != null) {
    225             Main.unregisterActionShortcut(a, a.shortcut);
     225            MainApplication.unregisterActionShortcut(a, a.shortcut);
    226226            myActions.remove(action);
    227227        }
Note: See TracChangeset for help on using the changeset viewer.