Example usage for javax.swing Action SHORT_DESCRIPTION

List of usage examples for javax.swing Action SHORT_DESCRIPTION

Introduction

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

Prototype

String SHORT_DESCRIPTION

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

Click Source Link

Document

The key used for storing a short String description for the action, used for tooltip text.

Usage

From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.DownloadAction.java

/**
 * Creates a new instance.//from w  w  w. j  a  v  a  2s  . c o m
 * 
 * @param model Reference to the Model. Mustn't be <code>null</code>.
 */
public DownloadAction(TreeViewer model) {
    super(model);
    name = NAME;
    putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(DESCRIPTION));
    description = (String) getValue(Action.SHORT_DESCRIPTION);
    IconManager im = IconManager.getInstance();
    putValue(Action.SMALL_ICON, im.getIcon(IconManager.DOWNLOAD));
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.TreeViewerAction.java

/**
 * Returns the name of the action.//from  ww  w.j ava  2s  . co  m
 * 
 * @return See above.
 */
public String getActionDescription() {
    if (StringUtils.isEmpty(description))
        return (String) getValue(Action.SHORT_DESCRIPTION);
    return description;
}

From source file:com.meghnasoft.async.AbstractAsynchronousAction.java

/**
 * Constructor, private.//  w  ww.  j av  a 2s.  c  o m
 *
 *
 */
private AbstractAsynchronousAction() {
    //The key used for storing a longer description for the action, could be 
    //used for context-sensitive help.
    putValue(Action.LONG_DESCRIPTION, "Starts an asynchronous task");
    //The key used for storing the name for the action, used for a menu or button.
    //static String
    putValue(Action.NAME, "Start(long)");
    //The key used for storing a short description for the action, 
    //used for tooltip text.
    putValue(Action.SHORT_DESCRIPTION, "Start");
    //Useful constants that can be used as the storage-retreival key when 
    //setting or getting one of this object's properties (text or icon)
    putValue(Action.DEFAULT, "AsynchronousAction");
}

From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java

/**
 * Initialize.//  w  w w.  j ava  2 s .com
 */
public AccountProperties() {
    this.putValue(Action.NAME, "Account Properties...");
    this.putValue(Action.LONG_DESCRIPTION, "Show the properties of an account.");
    this.putValue(Action.SHORT_DESCRIPTION, "Show the properties of an account.");
}

From source file:com.apatar.ui.Actions.java

@SuppressWarnings("serial")
private void createActions() {

    // apon// ww  w  .  j a va  2s . co m
    newWebService = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            JwsdlLocationDialog wsdlDiag = new JwsdlLocationDialog();
            wsdlDiag.setVisible(true);
        }
    };
    newWebService.putValue(Action.NAME, "New Web Service");
    newWebService.putValue(Action.SHORT_DESCRIPTION, "create a Web Service dynamic client");

    // new progect
    newPrj = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                if (!ApatarUiMain.saveProject()) {
                    return;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return;
            }
            UiUtils.clearWorkPane(workPane);
            ApplicationData.PROJECT_PATH = null;
            ApplicationData.getProject().removeAllElements();
            ApplicationData.STATUS_APPLICATION = ApplicationData.SAVED_STATUS;
            ApplicationData.DATAMAP_DATE_SETTINGS.init(ApplicationData.APLICATION_DATE_SETTINGS);
            ApatarUiMain.MAIN_FRAME.setTitle(String.format(JApatarMainUIFrame.FRAME_TITLE, ""));
        }
    };
    newPrj.putValue(Action.NAME, "New");
    newPrj.putValue(Action.SHORT_DESCRIPTION, "New");

    // opening data
    open = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                if (!ApatarUiMain.saveProject()) {
                    return;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return;
            }
            openProject(frame, workPane);
            ApplicationData.STATUS_APPLICATION = ApplicationData.SAVED_STATUS;
        }
    };
    open.putValue(Action.NAME, "Open");
    open.putValue(Action.SHORT_DESCRIPTION, "Open");

    save = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                saveProject();
                ApplicationData.STATUS_APPLICATION = ApplicationData.SAVED_STATUS;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    save.putValue(Action.NAME, "Save");
    save.putValue(Action.SHORT_DESCRIPTION, "Save");

    // saving As data
    saveAs = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                saveAs();
                ApplicationData.STATUS_APPLICATION = ApplicationData.SAVED_STATUS;
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    };
    saveAs.putValue(Action.NAME, "Save As");
    saveAs.putValue(Action.SHORT_DESCRIPTION, "Save As");

    publishToApatar = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                publishToApatar();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (HttpException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    publishToApatar.putValue(Action.NAME, "Publish to Apatar");
    publishToApatar.putValue(Action.SHORT_DESCRIPTION, "Publish to Apatar");

    runScheduling = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                String osName = System.getProperty("os.name");

                if (osName.contains("Windows")) {
                    String pathPrj = (ApplicationData.REPOSITORIES == null ? "" : ApplicationData.REPOSITORIES);
                    Runtime.getRuntime().exec(pathPrj + "scheduling.bat");
                } else {
                    Runtime.getRuntime().exec("./scheduling.bat");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    runScheduling.putValue(Action.NAME, "Scheduling");
    runScheduling.putValue(Action.SHORT_DESCRIPTION, "Scheduling");

    // exit
    exit = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApatarUiMain.exit();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    exit.putValue(Action.NAME, "Exit");
    exit.putValue(Action.SHORT_DESCRIPTION, "Exit");

    options = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            JOptionsDialog dlg = new JOptionsDialog(ApatarUiMain.MAIN_FRAME);
            dlg.setVisible(true);
        }
    };
    options.putValue(Action.NAME, "Options");
    options.putValue(Action.SHORT_DESCRIPTION, "Options");

    windowsLookAndFeel = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        }
    };
    windowsLookAndFeel.putValue(Action.NAME, "Windows");
    windowsLookAndFeel.putValue(Action.SHORT_DESCRIPTION, "Windows");

    metalLookAndFeel = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        }
    };
    metalLookAndFeel.putValue(Action.NAME, "Metal");
    metalLookAndFeel.putValue(Action.SHORT_DESCRIPTION, "Metal");

    motifLookAndFeel = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        }
    };
    motifLookAndFeel.putValue(Action.NAME, "Motif");
    motifLookAndFeel.putValue(Action.SHORT_DESCRIPTION, "Motif");

    debugOutput = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            JErrorDebugDialog dlg = new JErrorDebugDialog(ApatarUiMain.MAIN_FRAME, true,
                    JErrorDebugDialog.DEBUG_DIALOG);
            dlg.setVisible(true);
        }
    };
    debugOutput.putValue(Action.NAME, "Show Output");
    debugOutput.putValue(Action.SHORT_DESCRIPTION, "Show Debug Information");

    errorOutput = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            JErrorDebugDialog dlg = new JErrorDebugDialog(ApatarUiMain.MAIN_FRAME, true,
                    JErrorDebugDialog.ERROR_DIALOG);
            dlg.setVisible(true);
        }
    };
    errorOutput.putValue(Action.NAME, "Show Error");
    errorOutput.putValue(Action.SHORT_DESCRIPTION, "Show Error Information");

    run = new AbstractAction() { // @@ TODO Send the aptr file to Lefteri
        public void actionPerformed(ActionEvent e) {
            System.out.println("Project Path" + ApplicationData.PROJECT_PATH);
            System.out.println("Saved Status" + ApplicationData.SAVED_STATUS);

            try {
                saveProject();
                final String dir = System.getProperty("user.dir");
                System.out.println("current dir = " + dir);

                String projectPath = ApplicationData.PROJECT_PATH;
                projectPath = projectPath.replace(" ", "/ ");
                System.out.println("Project = " + projectPath);
                String jarname = "resultsDisplayWindow.jar";
                File jar = new File(jarname);
                if (jar.exists()) {

                    Process proc = Runtime.getRuntime().exec("java -jar  " + jarname + " " + projectPath);

                } else {
                    JOptionPane.showMessageDialog(ApatarUiMain.MAIN_FRAME,
                            "Unable to find executable: " + dir + "/" + jarname);
                }

                //proc.waitFor();
                // System.out.println("Process Status: "+proc.exitValue());
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            ApplicationData.STATUS_APPLICATION = ApplicationData.SAVED_STATUS;

            ApplicationData.clearLogsBeforeRun();

            // Runnable rn = new Runnable();
            // rn.Run(ApplicationData.getProject().getNodes().values(),
            // null,
            // new ProcessingProgressActions());
        }
    };

    run.putValue(Action.NAME, "Run");
    run.putValue(Action.SHORT_DESCRIPTION, "Run");

    submitBug = new AbstractAction() {

        public void actionPerformed(ActionEvent arg0) {
            JSubmitHelpDialog dlg = new JSubmitHelpDialog(ApatarUiMain.MAIN_FRAME, true);
            dlg.setVisible(true);
        }

    };
    submitBug.putValue(Action.NAME, "Submit Bug");

    featureRequest = new AbstractAction() {

        public void actionPerformed(ActionEvent arg0) {
            JFeatureRequestHelpDialog dlg = new JFeatureRequestHelpDialog(ApatarUiMain.MAIN_FRAME, true);
            dlg.setVisible(true);
        }

    };
    featureRequest.putValue(Action.NAME, "Feature Request");

    catalogOfApatars = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            Thread tr;
            try {
                tr = new OpenWebBrowser("http://www.apatarforge.org/");
                tr.start();
            } catch (ApatarException e) {
                e.printStackTrace();
            }

        }
    };
    catalogOfApatars.putValue(Action.NAME, "Catalog Of DataMaps");
    catalogOfApatars.putValue(Action.SHORT_DESCRIPTION, "Catalog Of Apatars");

    demos = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            Thread tr;
            try {
                tr = new OpenWebBrowser("http://www.apatar.com/web_demo.html");
                tr.start();
            } catch (ApatarException e) {
                e.printStackTrace();
            }

        }
    };
    demos.putValue(Action.NAME, "Demos");
    demos.putValue(Action.SHORT_DESCRIPTION, "Demos");

    forums = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            Thread tr;
            try {
                tr = new OpenWebBrowser("http://www.apatarforge.org/forums/");
                tr.start();
            } catch (ApatarException e) {
                e.printStackTrace();
            }

        }
    };
    forums.putValue(Action.NAME, "Forums");
    forums.putValue(Action.SHORT_DESCRIPTION, "Forums");

    wiki = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            Thread tr;
            try {
                tr = new OpenWebBrowser("http://www.apatarforge.org/wiki/");
                tr.start();
            } catch (ApatarException e) {
                e.printStackTrace();
            }
        }
    };
    wiki.putValue(Action.NAME, "Wiki");
    wiki.putValue(Action.SHORT_DESCRIPTION, "Wiki");

    tutorials = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            Thread tr;
            try {
                tr = new OpenWebBrowser("http://www.apatar.com/community_documentation.html");
                tr.start();
            } catch (ApatarException e) {
                e.printStackTrace();
            }
        }
    };
    tutorials.putValue(Action.NAME, "Tutorials");
    tutorials.putValue(Action.SHORT_DESCRIPTION, "Tutorials");

    about = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            JAboutDialog dlg = new JAboutDialog(ApatarUiMain.MAIN_FRAME, true);
            dlg.setVisible(true);
        }
    };
    about.putValue(Action.NAME, "About");
    about.putValue(Action.SHORT_DESCRIPTION, "About");

}

From source file:ro.nextreports.designer.querybuilder.SQLViewPanel.java

private void initUI() {
    sqlEditor = new Editor() {
        public void afterCaretMove() {
            removeHighlightErrorLine();/*from w  ww. j  av a  2  s. c om*/
        }
    };
    this.queryArea = sqlEditor.getEditorPanel().getEditorPane();
    queryArea.setText(DEFAULT_QUERY);

    errorPainter = new javax.swing.text.Highlighter.HighlightPainter() {
        @Override
        public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {
            try {
                Rectangle r = c.modelToView(c.getCaretPosition());
                g.setColor(Color.RED.brighter().brighter());
                g.fillRect(0, r.y, c.getWidth(), r.height);
            } catch (BadLocationException e) {
                // ignore
            }
        }
    };

    ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap();

    // create the toolbar
    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);

    // add cut action
    Action cutAction = actionMap.get(BaseEditorKit.cutAction);
    cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut"));
    cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut"));
    toolBar.add(cutAction);

    // add copy action
    Action copyAction = actionMap.get(BaseEditorKit.copyAction);
    copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy"));
    copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy"));
    toolBar.add(copyAction);

    // add paste action
    Action pasteAction = actionMap.get(BaseEditorKit.pasteAction);
    pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste"));
    pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste"));
    toolBar.add(pasteAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add undo action
    Action undoAction = actionMap.get(BaseEditorKit.undoAction);
    undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo"));
    undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo"));
    toolBar.add(undoAction);

    // add redo action
    Action redoAction = actionMap.get(BaseEditorKit.redoAction);
    redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo"));
    redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo"));
    toolBar.add(redoAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add find action
    Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction);
    findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find"));
    findReplaceAction.putValue(Action.SHORT_DESCRIPTION,
            I18NSupport.getString("sqleditor.findReplaceActionName"));
    toolBar.add(findReplaceAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add run action
    runAction = new SQLRunAction();
    runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run"));
    runAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")));
    runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " ("
            + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")");
    // runAction is globally registered in QueryBuilderPanel !
    toolBar.add(runAction);

    //        ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel);

    // create the table
    resultTable = new JXTable();
    resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators
    resultTable.setDefaultRenderer(Long.class, new ToStringRenderer());
    resultTable.setDefaultRenderer(Date.class, new DateRenderer());
    resultTable.setDefaultRenderer(Double.class, new DoubleRenderer());
    resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable));
    TableUtil.setRowHeader(resultTable);
    resultTable.setColumnControlVisible(true);
    //        resultTable.getTableHeader().setReorderingAllowed(false);
    resultTable.setHorizontalScrollEnabled(true);

    // highlight table
    Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE,
            ColorUtil.PANEL_BACKROUND_COLOR);
    Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter());
    Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter());
    Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter());
    resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter);
    resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR);
    resultTable.setGridColor(Color.LIGHT_GRAY);

    resultTable.setRolloverEnabled(true);
    resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.66);
    split.setOneTouchExpandable(true);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    statusPanel = new SQLStatusPanel();
    bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    split.setTopComponent(topPanel);
    split.setBottomComponent(bottomPanel);
    split.setDividerLocation(400);

    setLayout(new BorderLayout());
    this.add(split, BorderLayout.CENTER);
}

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 www  . j  av a2 s .com

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

}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the UI panel that contains the controls to filter the channel list.
 * //from w  ww  .  jav a  2  s.  c  o m
 * @return  the UI component dealing with filtering
 */
private JComponent createFilterPanel() {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new BorderLayout(5, 5));
    filterPanel.setBackground(Color.white);
    filterPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel filterIconLabel = new JLabel(DataViewer.getIcon("icons/filter.gif"));
    filterPanel.add(filterIconLabel, BorderLayout.WEST);

    filterTextField = new JTextField();
    filterTextField.setToolTipText("Enter text here to filter the channel list");
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            treeModel.setFilter(filterTextField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }
    });
    filterPanel.add(filterTextField, BorderLayout.CENTER);

    Action focusFilterAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -2443410059209958411L;

        public void actionPerformed(ActionEvent e) {
            filterTextField.requestFocusInWindow();
            filterTextField.selectAll();
        }
    };

    int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    filterTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F, modifier), "focusFilter");
    filterTextField.getActionMap().put("focusFilter", focusFilterAction);

    Action cancelFilterAction = new AbstractAction(null, DataViewer.getIcon("icons/cancel.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8913797349366699615L;

        public void actionPerformed(ActionEvent e) {
            treeModel.setFilter(null);
        }
    };
    cancelFilterAction.putValue(Action.SHORT_DESCRIPTION, "Cancel filter");

    filterTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelFilter");
    filterTextField.getActionMap().put("cancelFilter", cancelFilterAction);

    clearFilterButton = new JButton(cancelFilterAction);
    clearFilterButton.setBorderPainted(false);
    clearFilterButton.setVisible(false);
    filterPanel.add(clearFilterButton, BorderLayout.EAST);

    return filterPanel;
}

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);/*from   w  w  w .ja  v  a 2 s  .  co m*/
        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:VASSAL.launch.EditorWindow.java

protected EditorWindow() {
    setTitle("VASSAL " + getEditorType() + " Editor");
    setLayout(new BorderLayout());

    ApplicationIcons.setFor(this);

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();/*from w  ww .  jav  a 2s .  com*/
        }
    });

    toolBar.setFloatable(false);
    add(toolBar, BorderLayout.NORTH);

    // setup menubar and actions
    final MenuManager mm = MenuManager.getInstance();
    final MenuBarProxy mb = mm.getMenuBarProxyFor(this);

    // file menu
    if (SystemUtils.IS_OS_MAC_OSX) {
        mm.addToSection("Editor.File", mm.addKey("Editor.save"));
        mm.addToSection("Editor.File", mm.addKey("Editor.save_as"));
    } else {
        final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file"));

        // FIMXE: setting nmemonic from first letter could cause collisions in
        // some languages
        fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0));

        fileMenu.add(mm.addKey("Editor.save"));
        fileMenu.add(mm.addKey("Editor.save_as"));
        fileMenu.addSeparator();
        fileMenu.add(mm.addKey("General.quit"));
        mb.add(fileMenu);
    }

    // edit menu
    final MenuProxy editMenu = new MenuProxy(Resources.getString("General.edit"));
    editMenu.setMnemonic(Resources.getString("General.edit.shortcut").charAt(0));

    editMenu.add(mm.addKey("Editor.cut"));
    editMenu.add(mm.addKey("Editor.copy"));
    editMenu.add(mm.addKey("Editor.paste"));
    editMenu.add(mm.addKey("Editor.move"));
    editMenu.addSeparator();
    editMenu.add(mm.addKey("Editor.ModuleEditor.properties"));
    editMenu.add(mm.addKey("Editor.ModuleEditor.translate"));

    // tools menu
    final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools"));
    toolsMenu.setMnemonic(Resources.getString("General.tools.shortcut").charAt(0));

    toolsMenu.add(mm.addKey("create_module_updater"));
    toolsMenu.add(mm.addKey("Editor.ModuleEditor.update_saved"));

    if (SystemUtils.IS_OS_MAC_OSX) {
        mm.addToSection("Editor.MenuBar", editMenu);
        mm.addToSection("Editor.MenuBar", toolsMenu);
    } else {
        mb.add(editMenu);
        mb.add(toolsMenu);
    }

    // help menu
    if (SystemUtils.IS_OS_MAC_OSX) {
        mm.addToSection("Documentation.VASSAL", mm.addKey("Editor.ModuleEditor.reference_manual"));
    } else {
        final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help"));

        // FIMXE: setting nmemonic from first letter could cause collisions in
        // some languages
        helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0));

        helpMenu.add(mm.addKey("General.help"));
        helpMenu.add(mm.addKey("Editor.ModuleEditor.reference_manual"));
        helpMenu.addSeparator();
        helpMenu.add(mm.addKey("AboutScreen.about_vassal"));
        mb.add(helpMenu);
    }

    final int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();

    saveAction = new SaveAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            save();
            treeStateChanged(false);
        }
    };

    saveAction.setEnabled(false);
    saveAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, mask));
    mm.addAction("Editor.save", saveAction);
    toolBar.add(saveAction);

    saveAsAction = new SaveAsAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            saveAs();
            treeStateChanged(false);
        }
    };

    saveAsAction.setEnabled(false);
    saveAsAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, mask));
    mm.addAction("Editor.save_as", saveAsAction);
    toolBar.add(saveAsAction);

    mm.addAction("General.quit", new ShutDownAction());
    // FXIME: mnemonics should be language-dependant
    //    mm.getAction("General.quit").setMnemonic('Q');

    createUpdater = new AbstractAction("Create " + getEditorType() + " updater") {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            new ModuleUpdaterDialog(EditorWindow.this).setVisible(true);
        }
    };
    createUpdater.setEnabled(false);
    mm.addAction("create_module_updater", createUpdater);

    URL url = null;
    try {
        url = new File(Documentation.getDocumentationBaseDir(), "README.html").toURI().toURL();
    } catch (MalformedURLException e) {
        ErrorDialog.bug(e);
    }
    mm.addAction("General.help", new ShowHelpAction(url, null));

    url = null;
    try {
        File dir = VASSAL.build.module.Documentation.getDocumentationBaseDir();
        dir = new File(dir, "ReferenceManual/index.htm"); //$NON-NLS-1$
        url = URLUtils.toURL(dir);
    } catch (MalformedURLException e) {
        ErrorDialog.bug(e);
    }

    final Action helpAction = new ShowHelpAction(url, helpWindow.getClass().getResource("/images/Help16.gif")); //$NON-NLS-1$
    helpAction.putValue(Action.SHORT_DESCRIPTION, Resources.getString("Editor.ModuleEditor.reference_manual")); //$NON-NLS-1$

    mm.addAction("Editor.ModuleEditor.reference_manual", helpAction);
    toolBar.add(helpAction);

    mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this));

    setJMenuBar(mm.getMenuBarFor(this));

    // the presence of the panel prevents a NullPointerException on packing
    final JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(250, 400));

    scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    add(scrollPane, BorderLayout.CENTER);
    pack();
}