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.pdfsam.plugin.merge.actions.SaveListAsXmlAction.java

/**
 * @param selectionPanel/*w  ww .  j ava 2 s.  c o  m*/
 */
public SaveListAsXmlAction(JPdfSelectionPanel selectionPanel) {
    super(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Export as xml"));
    this.setEnabled(true);
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_DOWN_MASK));
    this.putValue(Action.SHORT_DESCRIPTION, GettextResource.gettext(
            Configuration.getInstance().getI18nResourceBundle(), "Export the selection list in xml format"));
    this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass().getResource("/images/saveXml.png")));
    this.selectionPanel = selectionPanel;
}

From source file:org.pentaho.reporting.designer.core.actions.global.LaunchHelpAction.java

public LaunchHelpAction() {
    putValue(Action.NAME, ActionMessages.getString("LaunchHelpAction.Text"));
    putValue(Action.SHORT_DESCRIPTION, ActionMessages.getString("LaunchHelpAction.Description"));
    putValue(Action.MNEMONIC_KEY, ActionMessages.getOptionalMnemonic("LaunchHelpAction.Mnemonic"));
    putValue(Action.ACCELERATOR_KEY, ActionMessages.getOptionalKeyStroke("LaunchHelpAction.Accelerator"));
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingButton.java

protected void uninstallAction(final Action oldAction) {
    if (oldAction != null) {
        getButton().setAction(null);/* w  w w .  java 2s  . co m*/
        final Object o = oldAction.getValue(Action.ACCELERATOR_KEY);
        if (o instanceof KeyStroke) {
            final KeyStroke k = (KeyStroke) o;
            getButton().unregisterKeyboardAction(k);
        }
        oldAction.removePropertyChangeListener(actionChangeHandler);
    }
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingButton.java

protected void installAction(final Action newAction) {
    if (newAction != null) {
        setTooltiptext((String) action.getValue(Action.SHORT_DESCRIPTION));
        setLabel((String) action.getValue(Action.NAME));
        setDisabled(action.isEnabled() == false);
        setIcon((Icon) action.getValue(Action.SMALL_ICON));

        getButton().setAction(newAction);
        newAction.addPropertyChangeListener(actionChangeHandler);

        final Object o = newAction.getValue(Action.ACCELERATOR_KEY);
        if (o instanceof KeyStroke) {
            final KeyStroke k = (KeyStroke) o;
            getButton().registerKeyboardAction(newAction, k, JComponent.WHEN_IN_FOCUSED_WINDOW);
        }/* w  ww. j  a  v a 2s .  c  o  m*/

        if (newAction instanceof ToggleStateAction) {
            final ToggleStateAction tsa = (ToggleStateAction) action;
            setSelected(tsa.isSelected());
        }
    }

}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java

protected void uninstallAction(final Action oldAction) {
    if (oldAction != null) {
        menuitem.removeActionListener(oldAction);
        oldAction.removePropertyChangeListener(actionChangeHandler);

        final Object o = oldAction.getValue(Action.ACCELERATOR_KEY);
        if (o instanceof KeyStroke) {
            final KeyStroke k = (KeyStroke) o;
            menuitem.unregisterKeyboardAction(k);
        }//from  w  w  w .  java 2s .co m
    }
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java

private void refreshKeystroke(final Action actionImpl) {
    final Object keyStroke = actionImpl.getValue(Action.ACCELERATOR_KEY);
    if (keyStroke instanceof KeyStroke == false) {
        setAcceltext(null);//  ww  w . j a  v  a  2 s  .c om
    } else {
        setAcceltext(keyStroke.toString());
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.actions.ExportAction.java

/**
 * Defines an <code>Action</code> object with a default description string and default icon.
 *//*from   ww  w  .j  a  v a 2 s .com*/
public ExportAction(final ExportActionPlugin actionPlugin, final PreviewPane previewPane) {
    if (actionPlugin == null) {
        throw new NullPointerException();
    }
    if (previewPane == null) {
        throw new NullPointerException();
    }

    this.actionPlugin = actionPlugin;
    this.previewPane = previewPane;
    putValue(Action.NAME, actionPlugin.getDisplayName());
    putValue(Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription());
    putValue(Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey());
    putValue(Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey());
    putValue(Action.SMALL_ICON, actionPlugin.getSmallIcon());
    putValue(SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon());
    this.actionPlugin.addPropertyChangeListener("enabled", new EnableChangeListener()); //$NON-NLS-1$

    setEnabled(actionPlugin.isEnabled());
}

From source file:org.pmedv.blackboard.commands.AddDiodeCommand.java

public AddDiodeCommand() {
    putValue(Action.NAME, resources.getResourceByKey("AddDiodeCommand.name"));
    putValue(Action.SMALL_ICON, resources.getIcon("icon.diode"));
    putValue(Action.SHORT_DESCRIPTION, resources.getResourceByKey("AddDiodeCommand.description"));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    setEnabled(false);/*from www.  j a va2 s .c o m*/
}

From source file:org.pmedv.blackboard.commands.AddResistorCommand.java

public AddResistorCommand() {
    putValue(Action.NAME, resources.getResourceByKey("AddResistorCommand.name"));
    putValue(Action.SMALL_ICON, resources.getIcon("icon.resistor"));
    putValue(Action.SHORT_DESCRIPTION, resources.getResourceByKey("AddResistorCommand.description"));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));
    setEnabled(false);//w ww .  j  a  v  a 2s.  c  o m
}

From source file:org.pmedv.blackboard.commands.AddTextCommand.java

public AddTextCommand() {
    putValue(Action.NAME, resources.getResourceByKey("AddTextCommand.name"));
    putValue(Action.SMALL_ICON, resources.getIcon("icon.addtext"));
    putValue(Action.SHORT_DESCRIPTION, resources.getResourceByKey("AddTextCommand.description"));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK));
    setEnabled(false);//from  ww w  .  j ava 2  s  .c  o m
}