Example usage for javax.swing Action getValue

List of usage examples for javax.swing Action getValue

Introduction

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

Prototype

public Object getValue(String key);

Source Link

Document

Gets one of this object's properties using the associated key.

Usage

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.j  av  a  2  s  .  com
        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);
        }//from w ww.j a  v a 2  s  .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.  j a  va 2  s  .  c o  m*/
    }
}

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

protected void installAction(final Action newAction) {
    if (newAction != null) {
        menuitem.addActionListener(newAction);
        newAction.addPropertyChangeListener(actionChangeHandler);

        setLabel((String) (newAction.getValue(Action.NAME)));
        setTooltiptext((String) (newAction.getValue(Action.SHORT_DESCRIPTION)));
        setDisabled(this.action.isEnabled() == false);

        refreshMnemonic(newAction);//  ww  w  . jav  a  2 s . com
        refreshKeystroke(newAction);

        final Object rawSelectedSwing = action.getValue(Action.SELECTED_KEY);
        if (rawSelectedSwing != null) {
            setSelected(Boolean.TRUE.equals(rawSelectedSwing));
        } else {
            final Object rawSelectedPrd = action.getValue("selected");
            setSelected(Boolean.TRUE.equals(rawSelectedPrd));
        }

        final Object rawVisible = action.getValue("visible");
        if (rawVisible != null) {
            setVisible(Boolean.TRUE.equals(rawVisible));
        }
    }
}

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);//from  w  w  w. j a v a2s .  co  m
    } else {
        setAcceltext(keyStroke.toString());
    }
}

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

private void refreshMnemonic(final Action actionImpl) {
    final Object o = actionImpl.getValue(Action.MNEMONIC_KEY);
    if (o != null) {
        if (o instanceof Character) {
            final Character c = (Character) o;
            setAccesskey(String.valueOf(c.charValue()));
        } else if (o instanceof Integer) {
            final Integer c = (Integer) o;
            setAccesskey(String.valueOf(c.intValue()));
        }//from  w  w w  .  ja v  a2s  .c  om
    } else {
        setAccesskey("\0");
    }
}

From source file:org.underworldlabs.swing.plaf.base.AcceleratorToolTipUI.java

private String getAcceleratorString(JToolTip tip) {

    String acceleratorString = null;
    Action action = ((AbstractButton) tip.getComponent()).getAction();

    if (action != null) {

        KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
        if (keyStroke != null) {

            int mod = keyStroke.getModifiers();
            acceleratorString = KeyEvent.getKeyModifiersText(mod);

            if (!MiscUtils.isNull(acceleratorString)) {

                acceleratorString += DELIMITER;
            }//w w w.  j a  va  2 s  .  com

            String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode());
            if (!MiscUtils.isNull(keyText)) {

                acceleratorString += keyText;
            }

        }

    }

    return acceleratorString;
}

From source file:org.wings.SAbstractButton.java

protected void configurePropertiesFromAction(Action a) {
    // uncomment if compiled against < jdk 1.3
    //   setActionCommand((a != null
    //                  ? (String)a.getValue(Action.ACTION_COMMAND_KEY)
    //                  : null));
    setText((a != null ? (String) a.getValue(Action.NAME) : null));
    setIcon((a != null ? (SIcon) a.getValue(Action.SMALL_ICON) : null));
    setEnabled((a != null ? a.isEnabled() : true));
    setToolTipText((a != null ? (String) a.getValue(Action.SHORT_DESCRIPTION) : null));
}

From source file:plugin.notes.gui.NotesView.java

/**
 *  Searches a text component for a particular action.
 *
 *@param  textComponent  Text component to search for the action in
 *@param  name           name of the action to get
 *@return                the action//from   w  w w. j a  v a 2 s . c om
 */
private Action getActionByName(JTextComponent textComponent, String name) {
    // TODO: This should be static in a GUIUtilities file
    for (Action a : textComponent.getActions()) {
        if (a.getValue(Action.NAME).equals(name)) {
            return a;
        }
    }

    return null;
}

From source file:ro.nextreports.designer.NextReports.java

void start() {
    long time = System.currentTimeMillis();

    final SplashScreen splash = new SplashScreen("splash");

    Runnable runnable = new Runnable() {

        public void run() {
            for (int i = 0; i <= 100; i += 5) {
                if (stop) {
                    break;
                }//from w  ww  .java  2  s .co  m
                splash.updateSplash(i);
                try {
                    Thread.sleep(250);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    };
    Thread t = new Thread(runnable);
    t.start();

    // redirect output
    redirectOutput();

    // set engine properties
    System.setProperty(EngineProperties.RUN_PRIORITY_PROPERTY, String.valueOf(Thread.MIN_PRIORITY));
    System.setProperty(EngineProperties.RECORDS_YIELD_PROPERTY, String.valueOf(5000));
    System.setProperty(EngineProperties.MILLIS_YIELD_PROPERTY, String.valueOf(100));

    // set pdf font and encoding
    Globals.setPdfEncoding();
    Globals.setPdfFont();
    // set pdf direction and arabic
    Globals.setPdfDirection();
    Globals.setPdfArabicOptions();

    // set oracle client path
    Globals.setOracleClientPath();

    // set locale
    Globals.setLocale();

    FontUtil.registerFonts(Globals.getFontDirectories());

    // print parameters
    printParameters();

    // create the main frame
    final MainFrame mainFrame = createMainFrame();

    // add global actions
    GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance();
    InputMap inputMap = hotkeyManager.getInputMap();
    ActionMap actionMap = hotkeyManager.getActionMap();
    Action queryPerspectiveAction = new OpenQueryPerspectiveAction();
    inputMap.put((KeyStroke) queryPerspectiveAction.getValue(Action.ACCELERATOR_KEY), "queryPerspective");
    actionMap.put("queryPerspective", queryPerspectiveAction);
    Action reportPerspectiveAction = new OpenReportPerspectiveAction();
    inputMap.put((KeyStroke) reportPerspectiveAction.getValue(Action.ACCELERATOR_KEY), "reportPerspective");
    actionMap.put("reportPerspective", reportPerspectiveAction);

    disposeSplash(splash);

    mainFrame.setVisible(true);

    time = System.currentTimeMillis() - time;
    LOG.info("Start in " + time + " ms");

    // do not show start dialog if we start from server
    if (Globals.getServerUrl() == null) {
        showStartDialog(true);
        showSurveyDialog();
    } else {
        new NextReportsServerRequest();
    }
}