Example usage for javax.swing Action ACCELERATOR_KEY

List of usage examples for javax.swing Action ACCELERATOR_KEY

Introduction

In this page you can find the example usage for javax.swing Action ACCELERATOR_KEY.

Prototype

String ACCELERATOR_KEY

To view the source code for javax.swing Action ACCELERATOR_KEY.

Click Source Link

Document

The key used for storing a KeyStroke to be used as the accelerator for the action.

Usage

From source file:org.colombbus.tangara.EditorFrame.java

/**
 * Returns the copy action/*from w  ww .ja  va2 s.  c o m*/
 *
 * @return
 */
public Action getCopyAction() {
    if (copyAction == null) {
        copyAction = new AbstractAction(Messages.getString("Banner.menu.copy")) { //$NON-NLS-1$

            @Override
            public void actionPerformed(ActionEvent e) {
                copy();
            }
        };
        copyAction.setEnabled(false);
        copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C"));
    }
    return copyAction;
}

From source file:org.colombbus.tangara.EditorFrame.java

/**
 * Returns the paste action//www.ja v a2  s. c  o  m
 *
 * @return
 */
public Action getPasteAction() {
    if (pasteAction == null) {
        pasteAction = new AbstractAction(Messages.getString("Banner.menu.paste")) { //$NON-NLS-1$

            @Override
            public void actionPerformed(ActionEvent e) {
                paste();
            }
        };
        pasteAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V"));
    }

    return pasteAction;
}

From source file:org.colombbus.tangara.EditorFrame.java

/**
 * Returns the undo action/*w  w  w . j a v a  2s.  c  o m*/
 *
 * @return
 */
public Action getUndoAction() {
    if (undoAction == null) {
        undoAction = new AbstractAction(Messages.getString("Banner.menu.undo")) { //$NON-NLS-1$

            @Override
            public void actionPerformed(ActionEvent e) {
                programUndo();
            }
        };
        undoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control Z"));
    }
    return undoAction;
}

From source file:org.colombbus.tangara.EditorFrame.java

/**
  * Returns the undo action// w ww  .  j  a  v  a  2  s  .c o m
  *
  * @return
  */
public Action getRedoAction() {
    if (redoAction == null) {
        redoAction = new AbstractAction(Messages.getString("Banner.menu.redo")) { //$NON-NLS-1$

            @Override
            public void actionPerformed(ActionEvent e) {
                programRedo();
            }
        };
        redoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control Y"));
    }
    return redoAction;
}

From source file:org.executequery.gui.browser.FindAction.java

public FindAction() {

    super("Incremental Search");

    putValue(Action.ACCELERATOR_KEY, INVOKE_KEY_STROKE);
    putValue(Action.SMALL_ICON, GUIUtilities.loadIcon("Zoom16.png"));

    init();// w w  w.j av a 2  s. c om
}

From source file:org.executequery.gui.editor.QueryEditorTextPanel.java

public void deregisterAutoCompletePopup() {

    if (autoCompletePopup != null) {

        Action autoCompletePopupAction = autoCompletePopup.getPopupAction();

        queryPane.getActionMap().remove(AUTO_COMPLETE_POPUP_ACTION_KEY);
        queryPane.getInputMap().remove((KeyStroke) autoCompletePopupAction.getValue(Action.ACCELERATOR_KEY));

        autoCompletePopup = null;// w  w w.  j av  a 2  s  .  c  o  m
    }

}

From source file:org.executequery.gui.editor.QueryEditorTextPanel.java

public void registerAutoCompletePopup(AutoCompletePopupProvider autoCompletePopup) {

    this.autoCompletePopup = autoCompletePopup;

    Action autoCompletePopupAction = autoCompletePopup.getPopupAction();

    queryPane.getActionMap().put(AUTO_COMPLETE_POPUP_ACTION_KEY, autoCompletePopupAction);
    queryPane.getInputMap().put((KeyStroke) autoCompletePopupAction.getValue(Action.ACCELERATOR_KEY),
            AUTO_COMPLETE_POPUP_ACTION_KEY);
}

From source file:org.jcurl.demo.tactics.old.ActionRegistry.java

/** Create a disabled {@link Action}. */
private Action createAction(final Object controller, final Method m, final JCAction a) {
    final Action ac = new AbstractAction() {
        private static final long serialVersionUID = 2349356576661476730L;

        public void actionPerformed(final ActionEvent e) {
            try {
                m.invoke(controller, (Object[]) null);
            } catch (final IllegalArgumentException e1) {
                throw new RuntimeException("Unhandled", e1);
            } catch (final IllegalAccessException e1) {
                throw new RuntimeException("Unhandled", e1);
            } catch (final InvocationTargetException e1) {
                throw new RuntimeException("Unhandled", e1);
            }//from  www  .j a  va2 s  .c o m
        }
    };
    ac.putValue(Action.NAME, stripMnemonic(a.title()));
    ac.putValue(Action.ACCELERATOR_KEY, findAccelerator(a.accelerator()));
    if (false) {
        final Character mne = findMnemonic(a.title());
        if (mne != null)
            ac.putValue(Action.MNEMONIC_KEY, KeyStroke.getKeyStroke(mne));
    }
    ac.setEnabled(false);
    return ac;
}

From source file:org.nuclos.client.main.MainController.java

private Action createEntityAction(EntityMetaDataVO entitymetavo, String label, final boolean isNew,
        final Long processId, final String customUsage) {
    String entity = entitymetavo.getEntity();
    if (!getSecurityCache().isReadAllowedForEntity(entity)) {
        return null;
    }//from   w  ww .j  a  v a  2  s .  co m

    if (isNew && entitymetavo.isStateModel()
            && !getSecurityCache().isNewAllowedForModuleAndProcess(IdUtils.unsafeToId(entitymetavo.getId()),
                    IdUtils.unsafeToId(processId))) {
        return null;
    }

    Action action = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cmdCollectMasterData(evt, isNew, processId, customUsage);
        }
    };
    Pair<String, Character> nameAndMnemonic = MenuGenerator.getMnemonic(label);
    action.putValue(Action.NAME,
            customUsage == null ? nameAndMnemonic.x : String.format("%s (%s)", nameAndMnemonic.x, customUsage));
    if (nameAndMnemonic.y != null) {
        action.putValue(Action.MNEMONIC_KEY, (int) nameAndMnemonic.y.charValue());
    }
    action.setEnabled(true);
    action.putValue(Action.SMALL_ICON,
            MainFrame.resizeAndCacheTabIcon(Main.getInstance().getMainFrame().getEntityIcon(entity)));
    action.putValue(Action.ACTION_COMMAND_KEY, entity);
    if (!isNew && processId == null) {
        if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator())
                && entitymetavo.getAcceleratorModifier() != null) {
            int keycode = entitymetavo.getAccelerator().charAt(0);
            if (keycode > 90)
                keycode -= 32;

            action.putValue(Action.ACCELERATOR_KEY,
                    KeyStroke.getKeyStroke(keycode, entitymetavo.getAcceleratorModifier().intValue()));
        } else if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator())) {
            action.putValue(Action.ACCELERATOR_KEY,
                    KeyStroke.getKeyStroke(entitymetavo.getAccelerator().charAt(0)));
        }
    }

    return action;
}

From source file:org.pdfsam.guiclient.commons.business.actions.SetOutputPathSelectionTableAction.java

/**
 * @param selectionPanel//from   w  w  w  .  j a v  a2  s. c o  m
 * @param destinationField
 *            the JTextField to update
 * @param defaultOutputFileName
 *            the output file name. If null it's ignored.
 */
public SetOutputPathSelectionTableAction(JPdfSelectionPanel selectionPanel, JTextField destinationField,
        String defaultOutputFileName) {
    super(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Set destination"));
    this.setEnabled(true);
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK));
    this.putValue(Action.SHORT_DESCRIPTION, GettextResource
            .gettext(Configuration.getInstance().getI18nResourceBundle(), "Set the destination path"));
    this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass().getResource("/images/set_outfile.png")));
    this.selectionPanel = selectionPanel;
    this.destinationField = destinationField;
    this.defaultOutputFileName = defaultOutputFileName;
}