Example usage for javax.swing Action NAME

List of usage examples for javax.swing Action NAME

Introduction

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

Prototype

String NAME

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

Click Source Link

Document

The key used for storing the String name for the action, used for a menu or button.

Usage

From source file:net.sf.jhylafax.AbstractQueuePanel.java

public void updateLabels() {
    resetQueueTableAction.putValue(Action.NAME, i18n.tr("Reset to Defaults"));
}

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

private void initComponents() {
    JPanel container = new JPanel();
    setContentPane(container);/* ww  w . j  ava2  s.  c o m*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Please specify the desired source name for the data.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 5);
    container.add(new JLabel("Source name: "), c);

    sourceNameTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(10, 0, 10, 10);
    container.add(sourceNameTextField, c);

    importProgressBar = new JProgressBar(0, 100000);
    importProgressBar.setStringPainted(true);
    importProgressBar.setValue(0);
    importProgressBar.setVisible(false);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(importProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

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

        public void actionPerformed(ActionEvent e) {
            importData();
        }
    };
    importAction.putValue(Action.NAME, "Import");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import");
    actionMap.put("export", importAction);
    importButton = new JButton(importAction);
    getRootPane().setDefaultButton(importButton);
    panel.add(importButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 7909429022904810958L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();

    sourceNameTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

From source file:userinterface.graph.SeriesEditorDialog.java

/** Creates new form GUIConstantsPicker */
private SeriesEditorDialog(GUIPlugin plugin, JFrame parent, JPanel graph, java.util.List<SeriesKey> series) {
    super(parent, "Graph Series Editor", true);
    this.plugin = plugin;
    this.editors = new ArrayList<SeriesEditor>();

    initComponents();//from w  ww  . j ava  2 s .c om

    AbstractAction cut = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            editors.get(tabbedPane.getSelectedIndex()).cut();
        }
    };
    cut.putValue(Action.LONG_DESCRIPTION, "Cut the current selection to the clipboard");
    //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit");
    cut.putValue(Action.NAME, "Cut");
    cut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallCut.png"));
    //cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    AbstractAction copy = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            editors.get(tabbedPane.getSelectedIndex()).copy();
        }
    };
    copy.putValue(Action.LONG_DESCRIPTION, "Copies the current selection to the clipboard");
    //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit");
    copy.putValue(Action.NAME, "Copy");
    copy.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallCopy.png"));
    //copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    AbstractAction paste = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            editors.get(tabbedPane.getSelectedIndex()).paste();
        }
    };
    paste.putValue(Action.LONG_DESCRIPTION, "Pastes the clipboard to the current selection");
    //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit");
    paste.putValue(Action.NAME, "Paste");
    paste.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPaste.png"));
    //paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    AbstractAction delete = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            editors.get(tabbedPane.getSelectedIndex()).delete();
        }
    };
    delete.putValue(Action.LONG_DESCRIPTION, "Deletes the current");
    //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit");
    delete.putValue(Action.NAME, "Delete");
    delete.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png"));

    for (SeriesKey key : series) {
        SeriesSettings settings = null;
        if (graph instanceof Graph)
            settings = ((Graph) graph).getGraphSeries(key);
        if (graph instanceof Histogram)
            settings = ((Histogram) graph).getGraphSeries(key);
        if (graph instanceof Graph3D)
            settings = ((Graph3D) graph).getSeriesSettings();

        Object DataSeries = null;
        if (graph instanceof Graph)
            DataSeries = (PrismXYSeries) ((Graph) graph).getXYSeries(key);
        if (graph instanceof Histogram)
            DataSeries = ((Histogram) graph).getXYSeries(key);
        if (graph instanceof Graph3D)
            DataSeries = ((Graph3D) graph).getScatterSeries();

        SeriesEditor editor = new SeriesEditor(graph, DataSeries, settings, cut, copy, paste, delete);
        editor.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        tabbedPane.addTab(settings.getSeriesHeading(), editor);
        editors.add(editor);
    }

    this.getRootPane().setDefaultButton(okayButton);

    toolBar.add(cut);
    toolBar.add(copy);
    toolBar.add(paste);
    toolBar.add(delete);

    this.add(toolBar, BorderLayout.NORTH);

    this.cancelled = false;

    super.setBounds(new Rectangle(550, 300));
    setResizable(true);
    setLocationRelativeTo(getParent()); // centre
}

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

public RBNBConnectionDialog(JFrame owner, RBNBController rbnbController, DataPanelManager dataPanelManager) {
    super(owner, true);

    this.rbnb = rbnbController;
    this.dataPanelManager = dataPanelManager;

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setTitle("Connect to RBNB Server");

    JPanel container = new JPanel();
    setContentPane(container);/*from www. java 2 s .  c  om*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    headerLabel = new JLabel("Please specify the RBNB server connection information.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.gridwidth = 1;

    rbnbHostNameLabel = new JLabel("Host:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(10, 10, 10, 5);
    container.add(rbnbHostNameLabel, c);

    rbnbHostNameTextField = new JTextField(25);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(10, 0, 10, 10);
    container.add(rbnbHostNameTextField, c);

    rbnbPortLabel = new JLabel("Port:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(rbnbPortLabel, c);

    rbnbPortTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(0, 0, 10, 10);
    rbnbPortTextField.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent focusEvent) {
            rbnbPortTextField.setSelectionStart(0);
            rbnbPortTextField.setSelectionEnd(rbnbPortTextField.getText().length());
        }

        public void focusLost(FocusEvent focusEvent) {
        }
    });
    container.add(rbnbPortTextField, c);

    JPanel buttonPanel = new JPanel();

    Action connectAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 5814028508027064335L;

        public void actionPerformed(ActionEvent e) {
            connect();
        }
    };
    connectAction.putValue(Action.NAME, "Connect");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "connect");
    actionMap.put("connect", connectAction);
    connectButton = new JButton(connectAction);
    buttonPanel.add(connectButton);

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

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    buttonPanel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(buttonPanel, c);

    pack();
    setLocationByPlatform(true);
    setVisible(true);
}

From source file:net.sf.jabref.exporter.ExportFormats.java

/**
 * Create an AbstractAction for performing an export operation.
 *
 * @param frame/*from w  ww.  j  a v  a2 s .  c  o  m*/
 *            The JabRefFrame of this JabRef instance.
 * @param selectedOnly
 *            true indicates that only selected entries should be exported,
 *            false indicates that all entries should be exported.
 * @return The action.
 */
public static AbstractAction getExportAction(JabRefFrame frame, boolean selectedOnly) {

    class ExportAction extends MnemonicAwareAction {

        private final JabRefFrame frame;

        private final boolean selectedOnly;

        public ExportAction(JabRefFrame frame, boolean selectedOnly) {
            this.frame = frame;
            this.selectedOnly = selectedOnly;
            putValue(Action.NAME, selectedOnly ? Localization.menuTitle("Export selected entries")
                    : Localization.menuTitle("Export"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            ExportFormats.initAllExports();
            JFileChooser fc = ExportFormats
                    .createExportFileChooser(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY));
            fc.showSaveDialog(frame);
            File file = fc.getSelectedFile();
            if (file == null) {
                return;
            }
            FileFilter ff = fc.getFileFilter();
            if (ff instanceof ExportFileFilter) {

                ExportFileFilter eff = (ExportFileFilter) ff;
                String path = file.getPath();
                if (!path.endsWith(eff.getExtension())) {
                    path = path + eff.getExtension();
                }
                file = new File(path);
                if (file.exists()) {
                    // Warn that the file exists:
                    if (JOptionPane.showConfirmDialog(frame,
                            Localization.lang("'%0' exists. Overwrite file?", file.getName()),
                            Localization.lang("Export"),
                            JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) {
                        return;
                    }
                }
                final IExportFormat format = eff.getExportFormat();
                List<BibEntry> entries;
                if (selectedOnly) {
                    // Selected entries
                    entries = frame.getCurrentBasePanel().getSelectedEntries();
                } else {
                    // All entries
                    entries = frame.getCurrentBasePanel().getDatabase().getEntries();
                }

                // Set the global variable for this database's file directory before exporting,
                // so formatters can resolve linked files correctly.
                // (This is an ugly hack!)
                Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().getBibDatabaseContext()
                        .getFileDirectory();

                // Make sure we remember which filter was used, to set
                // the default for next time:
                Globals.prefs.put(JabRefPreferences.LAST_USED_EXPORT, format.getConsoleName());
                Globals.prefs.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, file.getParent());

                final File finFile = file;
                final List<BibEntry> finEntries = entries;
                AbstractWorker exportWorker = new AbstractWorker() {

                    String errorMessage;

                    @Override
                    public void run() {
                        try {
                            format.performExport(frame.getCurrentBasePanel().getBibDatabaseContext(),
                                    finFile.getPath(), frame.getCurrentBasePanel().getEncoding(), finEntries);
                        } catch (Exception ex) {
                            LOGGER.warn("Problem exporting", ex);
                            if (ex.getMessage() == null) {
                                errorMessage = ex.toString();
                            } else {
                                errorMessage = ex.getMessage();
                            }
                        }
                    }

                    @Override
                    public void update() {
                        // No error message. Report success:
                        if (errorMessage == null) {
                            frame.output(Localization.lang("%0 export successful", format.getDisplayName()));
                        }
                        // ... or show an error dialog:
                        else {
                            frame.output(Localization.lang("Could not save file.") + " - " + errorMessage);
                            // Need to warn the user that saving failed!
                            JOptionPane.showMessageDialog(frame,
                                    Localization.lang("Could not save file.") + "\n" + errorMessage,
                                    Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE);
                        }
                    }
                };

                // Run the export action in a background thread:
                exportWorker.getWorker().run();
                // Run the update method:
                exportWorker.update();
            }
        }
    }

    return new ExportAction(frame, selectedOnly);
}

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

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

    // apon/*  www  .ja  v  a  2 s  . com*/
    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:net.pandoragames.far.ui.swing.component.UndoHistoryPopupMenu.java

private void init(SwingConfig config, ComponentRepository componentRepository) {
    // COPY//from  ww  w  .  ja v a 2 s . c o  m
    JMenuItem copy = new JMenuItem(config.getLocalizer().localize("label.copy"));
    copy.setAccelerator(KeyStroke.getKeyStroke("control C"));
    copy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String selection = textComponent.getSelectedText();
            if (selection != null) {
                StringSelection textTransfer = new StringSelection(selection);
                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(textTransfer, null);
            }
        }
    });
    this.add(copy);
    // PASTE
    JMenuItem paste = new JMenuItem(config.getLocalizer().localize("label.paste"));
    paste.setAccelerator(KeyStroke.getKeyStroke("control V"));
    paste.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Transferable transfer = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);

            try {
                if (transfer != null && transfer.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                    String text = (String) transfer.getTransferData(DataFlavor.stringFlavor);
                    String selected = textComponent.getSelectedText();
                    if (selected == null) {
                        int insertAt = textComponent.getCaretPosition();
                        textComponent.getDocument().insertString(insertAt, text, null);
                    } else {
                        int start = textComponent.getSelectionStart();
                        int end = textComponent.getSelectionEnd();
                        textComponent.getDocument().remove(start, end - start);
                        textComponent.getDocument().insertString(start, text, null);
                    }
                }
            } catch (UnsupportedFlavorException e) {
                LogFactory.getLog(this.getClass()).error("UnsupportedFlavorException reading from clipboard",
                        e);
            } catch (IOException iox) {
                LogFactory.getLog(this.getClass()).error("IOException reading from clipboard", iox);
            } catch (BadLocationException blx) {
                LogFactory.getLog(this.getClass()).error("BadLocationException reading from clipboard", blx);
            }
        }
    });
    this.add(paste);
    // UNDO
    Action undoAction = textComponent.getActionMap().get(UndoHistory.ACTION_KEY_UNDO);
    if (undoAction != null) {
        undoAction.putValue(Action.NAME, config.getLocalizer().localize("label.undo"));
        this.add(undoAction);
    }
    // REDO
    Action redoAction = textComponent.getActionMap().get(UndoHistory.ACTION_KEY_REDO);
    if (redoAction != null) {
        redoAction.putValue(Action.NAME, config.getLocalizer().localize("label.redo"));
        this.add(redoAction);
    }
    // PREVIOUS
    Action prevAction = textComponent.getActionMap().get(UndoHistory.ACTION_KEY_PREVIOUS);
    if (prevAction != null) {
        prevAction.putValue(Action.NAME, config.getLocalizer().localize("label.previous"));
        this.add(prevAction);
    }
    // NEXT
    Action nextAction = textComponent.getActionMap().get(UndoHistory.ACTION_KEY_NEXT);
    if (nextAction != null) {
        nextAction.putValue(Action.NAME, config.getLocalizer().localize("label.next"));
        this.add(nextAction);
    }
}

From source file:ListCutPaste.java

/**
 * Create an Edit menu to support cut/copy/paste.
 *//* ww w  .  j a v a  2  s . c  om*/
public JMenuBar createMenuBar() {
    JMenuItem menuItem = null;
    JMenuBar menuBar = new JMenuBar();
    JMenu mainMenu = new JMenu("Edit");
    mainMenu.setMnemonic(KeyEvent.VK_E);
    TransferActionListener actionListener = new TransferActionListener();

    menuItem = new JMenuItem("Cut");
    menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    menuItem.setMnemonic(KeyEvent.VK_T);
    mainMenu.add(menuItem);

    menuItem = new JMenuItem("Copy");
    menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    menuItem.setMnemonic(KeyEvent.VK_C);
    mainMenu.add(menuItem);

    menuItem = new JMenuItem("Paste");
    menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    menuItem.setMnemonic(KeyEvent.VK_P);
    mainMenu.add(menuItem);

    menuBar.add(mainMenu);
    return menuBar;
}

From source file:captureplugin.CapturePlugin.java

public ActionMenu getContextMenuActions(final Program program) {

    final DeviceIf[] devices = mConfig.getDeviceArray();

    final Window parent = UiUtilities.getLastModalChildOf(getParentFrame());

    Action mainaction = new devplugin.ContextMenuAction();
    mainaction.putValue(Action.NAME, mLocalizer.msg("record", "record Program"));
    mainaction.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));

    ArrayList<ActionMenu> actionList = new ArrayList<ActionMenu>();

    for (final DeviceIf dev : devices) {
        Action action = new ContextMenuAction();
        action.putValue(Action.NAME, dev.getName());

        ArrayList<AbstractAction> commandList = new ArrayList<AbstractAction>();

        if (dev.isAbleToAddAndRemovePrograms()) {
            final Program test = dev.getProgramForProgramInList(program);

            if (test != null) {
                AbstractAction caction = new AbstractAction() {
                    public void actionPerformed(ActionEvent evt) {
                        dev.remove(parent, test);
                        updateMarkedPrograms();
                    }//from ww w . j a va  2  s .co  m
                };
                caction.putValue(Action.NAME, Localizer.getLocalization(Localizer.I18N_DELETE));
                commandList.add(caction);
            } else {
                AbstractAction caction = new AbstractAction() {
                    public void actionPerformed(ActionEvent evt) {
                        if (dev.add(parent, program)) {
                            dev.sendProgramsToReceiveTargets(new Program[] { program });
                        }
                        updateMarkedPrograms();
                    }
                };
                caction.putValue(Action.NAME, mLocalizer.msg("record", "record"));
                commandList.add(caction);
            }

        }

        String[] commands = dev.getAdditionalCommands();

        if (commands != null) {
            for (int y = 0; y < commands.length; y++) {

                final int num = y;

                AbstractAction caction = new AbstractAction() {

                    public void actionPerformed(ActionEvent evt) {
                        dev.executeAdditionalCommand(parent, num, program);
                    }
                };
                caction.putValue(Action.NAME, commands[y]);
                commandList.add(caction);
            }
        }

        if (!commandList.isEmpty()) {
            actionList.add(new ActionMenu(action, commandList.toArray(new Action[commandList.size()])));
        }
    }

    if (actionList.size() == 1) {
        ActionMenu menu = actionList.get(0);

        if (menu.getSubItems().length == 0) {
            return null;
        }

        if (menu.getSubItems().length == 1) {
            Action action = menu.getSubItems()[0].getAction();
            action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));
            return new ActionMenu(action);
        } else {
            mainaction.putValue(Action.NAME, menu.getTitle());
            return new ActionMenu(mainaction, menu.getSubItems());
        }

    }

    ActionMenu[] actions = new ActionMenu[actionList.size()];
    actionList.toArray(actions);

    if (actions.length == 0) {
        return null;
    }

    return new ActionMenu(mainaction, actions);
}

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);
            }// w  w w.j  a  v  a2 s .c  om
        }
    };
    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;
}