Search in sources :

Example 1 with Mapollage

use of se.trixon.mapollage.Mapollage in project java-mapollage by trixon.

the class MainFrame method initActions.

private void initActions() {
    mActionManager = ActionManager.getInstance().init(getRootPane().getActionMap(), getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    InputMap inputMap = mPopupMenu.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = mPopupMenu.getActionMap();
    Action action = new AbstractAction("HideMenu") {

        @Override
        public void actionPerformed(ActionEvent e) {
            mPopupMenu.setVisible(false);
        }
    };
    String key = "HideMenu";
    actionMap.put(key, action);
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    inputMap.put(keyStroke, key);
    // about
    PomInfo pomInfo = new PomInfo(Mapollage.class, "se.trixon", "mapollage");
    AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(Mapollage.class, "about"), SystemHelper.getResourceAsImageIcon(MainFrame.class, "icon-1024px.png"));
    aboutModel.setAppVersion(pomInfo.getVersion());
    AboutPanel aboutPanel = new AboutPanel(aboutModel);
    action = AboutPanel.getAction(MainFrame.this, aboutPanel);
    getRootPane().getActionMap().put(ActionManager.ABOUT, action);
    // File
    quitMenuItem.setAction(mActionManager.getAction(ActionManager.QUIT));
    // Profile
    addMenuItem.setAction(mActionManager.getAction(ActionManager.ADD));
    cloneMenuItem.setAction(mActionManager.getAction(ActionManager.CLONE));
    renameMenuItem.setAction(mActionManager.getAction(ActionManager.RENAME));
    removeMenuItem.setAction(mActionManager.getAction(ActionManager.REMOVE));
    removeAllMenuItem.setAction(mActionManager.getAction(ActionManager.REMOVE_ALL));
    // Tools
    optionsMenuItem.setAction(mActionManager.getAction(ActionManager.OPTIONS));
    // Help
    helpMenuItem.setAction(mActionManager.getAction(ActionManager.HELP));
    aboutDateFormatMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT_DATE_FORMAT));
    aboutMenuItem.setAction(mActionManager.getAction(ActionManager.ABOUT));
    // Toolbar
    startButton.setAction(mActionManager.getAction(ActionManager.START));
    cancelButton.setAction(mActionManager.getAction(ActionManager.CANCEL));
    menuButton.setAction(mActionManager.getAction(ActionManager.MENU));
    SwingHelper.clearText(toolBar);
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) PomInfo(se.trixon.almond.util.PomInfo) Mapollage(se.trixon.mapollage.Mapollage) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap) AboutModel(se.trixon.almond.util.swing.dialogs.about.AboutModel) AboutPanel(se.trixon.almond.util.swing.dialogs.about.AboutPanel) AbstractAction(javax.swing.AbstractAction)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 Action (javax.swing.Action)1 ActionMap (javax.swing.ActionMap)1 InputMap (javax.swing.InputMap)1 KeyStroke (javax.swing.KeyStroke)1 PomInfo (se.trixon.almond.util.PomInfo)1 AboutModel (se.trixon.almond.util.swing.dialogs.about.AboutModel)1 AboutPanel (se.trixon.almond.util.swing.dialogs.about.AboutPanel)1 Mapollage (se.trixon.mapollage.Mapollage)1