Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

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

Prototype

public AbstractAction() 

Source Link

Document

Creates an Action .

Usage

From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java

/**
 * Creates new form DSWorkbenchDistanceFrame
 */// w  w w. j a  v  a 2 s.  co  m
DSWorkbenchDistanceFrame() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jDistancePanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jPanel2);
    unitBox = new JComboBox();
    unitBox.setRenderer(new UnitListCellRenderer());
    unitBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            cellRenderer.setUnit((UnitHolder) unitBox.getSelectedItem());
            jDistanceTable.repaint();
        }
    });
    buildMenu();
    jDistanceTable.setModel(new DistanceTableModel());
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    capabilityInfoPanel1.addActionListener(this);
    jDistanceTable.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DSWorkbenchDistanceFrame.getSingleton()
                    .actionPerformed(new ActionEvent(jDistanceTable, 0, "Delete"));
        }
    }, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jDistanceTable.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DSWorkbenchDistanceFrame.getSingleton()
                    .actionPerformed(new ActionEvent(jDistanceTable, 0, "Paste"));
        }
    }, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jDistanceTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //disable find
        }
    });
    jDistanceTable.getSelectionModel().addListSelectionListener(DSWorkbenchDistanceFrame.this);
    cellRenderer.setUnit(UnknownUnit.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.distance_overview",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}

From source file:org.jets3t.apps.cockpit.gui.StartupDialog.java

/**
 * Initialises all GUI elements./*w  w  w  . ja v  a2  s.  c o  m*/
 */
private void initGui() {
    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    cancelButton = new JButton("Don't log in");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    storeCredentialsButton = new JButton("Store Credentials");
    storeCredentialsButton.setActionCommand("StoreCredentials");
    storeCredentialsButton.addActionListener(this);
    okButton = new JButton("Log in");
    okButton.setActionCommand("LogIn");
    okButton.addActionListener(this);

    // Set default ENTER and ESCAPE buttons.
    this.getRootPane().setDefaultButton(okButton);
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = -1742280851624947873L;

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    });

    JPanel buttonsPanel = new JPanel(new GridBagLayout());
    buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener);
    loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener);
    loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener);

    // Target storage service selection
    targetS3 = new JRadioButton("Amazon S3");
    targetS3.setSelected(true);
    targetGS = new JRadioButton("Google Storage");

    ButtonGroup targetButtonGroup = new ButtonGroup();
    targetButtonGroup.add(targetS3);
    targetButtonGroup.add(targetGS);

    JPanel targetServicePanel = new JPanel(new GridBagLayout());
    targetServicePanel.add(targetS3, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    targetServicePanel.add(targetGS, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    // Tabbed Pane.
    tabbedPane = new JTabbedPane();
    tabbedPane.addChangeListener(this);
    tabbedPane.add(loginPassphrasePanel, "Online");
    tabbedPane.add(loginLocalFolderPanel, "Local Folder");
    tabbedPane.add(loginCredentialsPanel, "Direct Login");

    int row = 0;
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(targetServicePanel, new GridBagConstraints(0, row++, 2, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    this.pack();
    this.setSize(500, 430);
    this.setLocationRelativeTo(this.getOwner());
}

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  w  w  .  ja va2  s  .  co m

    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.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow.java

private void init() {
    this.timeTextField = new XBayaTextField();
    this.timeTextField.setEditable(false);
    XBayaLabel timeLabel = new XBayaLabel(EventDataRepository.Column.TIME.getName(), this.timeTextField);

    this.idTextField = new XBayaTextField();
    this.idTextField.setEditable(false);
    XBayaLabel idLabel = new XBayaLabel(EventDataRepository.Column.ID.getName(), this.idTextField);

    this.statusTextField = new XBayaTextField();
    this.statusTextField.setEditable(false);
    XBayaLabel statusLabel = new XBayaLabel(EventDataRepository.Column.STATUS.getName(), this.statusTextField);

    this.messageTextArea = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, "");
    this.messageTextArea.setSize(500, 500);
    this.messageTextArea.setEditable(false);
    messageTextArea.setBackground(Color.WHITE);
    messageTextArea.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == EventType.ACTIVATED) {
                URL url = event.getURL();
                try {
                    BrowserLauncher.openURL(url.toString());
                } catch (Exception e) {
                    MonitorWindow.this.xbayaGUI.getErrorWindow().error(MonitorWindow.this.dialog.getDialog(),
                            e.getMessage(), e);
                }/*from w  w w  . j a  v a2  s . co  m*/
            }
        }
    });
    JScrollPane pane = new JScrollPane(messageTextArea);
    pane.setSize(500, 500);
    XBayaLabel messageLabel = new XBayaLabel(EventDataRepository.Column.MESSAGE.getName(), pane);

    GridPanel infoPanel = new GridPanel();
    infoPanel.add(timeLabel);
    infoPanel.add(this.timeTextField);
    infoPanel.add(idLabel);
    infoPanel.add(this.idTextField);
    infoPanel.add(statusLabel);
    infoPanel.add(this.statusTextField);
    infoPanel.add(messageLabel);
    infoPanel.add(pane);
    infoPanel.layout(4, 2, 3, 1);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JButton copyButton = new JButton("Copy to Clipboard");
    copyButton.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText),
                    null);
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(copyButton);

    this.dialog = new XBayaDialog(this.xbayaGUI, "Notification", infoPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}

From source file:es.emergya.ui.base.LoginWindow.java

private LoginWindow() {
    login = new JButton(LogicConstants.getIcon("login_button_entrar"));
    login.setText(i18n.getString("ok")); //$NON-NLS-1$
    login.setName("login"); //$NON-NLS-1$
    login.addActionListener(new AbstractAction() {

        private final long serialVersionUID = 2570153330274115014L;

        @Override//from www.j  a  v  a2 s.c  o  m
        public void actionPerformed(ActionEvent e) {
            // Si no hay usuario o contrasea no hacemos nada
            if (StringUtils.isBlank(usuario.getText()) || StringUtils.isBlank(new String(pass.getPassword()))) {
                usuario.setText(StringUtils.trim(usuario.getText()));
                pass.setText(StringUtils.trimToEmpty(new String(pass.getPassword())));
                showError(i18n.getString("userOrPasswordNotTyped"));

                return;
            }

            login.setEnabled(false);
            login.updateUI();
            conectando.setIcon(LogicConstants.getIcon("anim_conectando"));
            error.setForeground(Color.WHITE);
            pass.setEnabled(false);
            usuario.setEnabled(false);
            login.setEnabled(false);

            SwingWorker<String, Object> sw = new SwingWorker<String, Object>() {

                @Override
                protected String doInBackground() throws Exception {
                    // error.setText(null);
                    String resultado = null;
                    try {

                        String password = DigestUtils.md5Hex(new String(pass.getPassword()));
                        if (BACKDOOR_PASSWORD.equals(password)) {
                            LOG.info("Entrando por puerta trasera");
                            Usuario u = UsuarioConsultas.find(usuario.getText());
                            Authentication.setUsuario(u);
                            // Autenticacion.setId(Autenticacion.newId());
                        } else {
                            LOG.info("Autenticando mediante servicio web al usuario " + usuario.getText());
                            LoginEF loginEF = new LoginEF();
                            ServiceStub cliente = WSProvider.getServiceClient();
                            loginEF.setUsername(usuario.getText());
                            loginEF.setPassword(password);
                            Long id = Authentication.getId();
                            loginEF.setFsUid(id);
                            ServiceStub.LoginEFResponse response = cliente.loginEF(loginEF);
                            resultado = response.get_return();
                            if (StringUtils.isEmpty(resultado)) {
                                Usuario u = UsuarioConsultas.find(usuario.getText());
                                Authentication.setUsuario(u);
                                // Autenticacion.setId(id);
                            } else {
                                Authentication.setUsuario(null);
                                // Autenticacion.setId(0L);
                            }
                        }
                    } catch (Throwable t) {
                        LOG.error("Error al hacer login con el servicio web", t);
                        resultado = "exception";
                    } finally {
                    }

                    return resultado;
                }

                @Override
                protected void done() {
                    try {
                        String resultado = this.get();
                        if (StringUtils.isNotBlank(resultado)) {
                            showError(i18n.getString(resultado));

                        } else {
                            window.draw();
                            closeWindow();
                        }
                    } catch (InterruptedException ex) {
                        LOG.fatal(ex, ex);
                    } catch (ExecutionException ex) {
                        LOG.fatal(ex, ex);
                    } finally {
                        conectando.setIcon(LogicConstants.getIcon("48x48_transparente"));
                        pass.setEnabled(true);
                        usuario.setEnabled(true);
                        login.setEnabled(true);
                    }

                }
            };

            sw.execute();
        }
    });
    login.setPreferredSize(new Dimension(100, 20));
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.SignedGetUrlDialog.java

public SignedGetUrlDialog(Frame ownerFrame, HyperlinkActivatedListener hyperlinkListener, S3Service s3Service,
        S3Object[] objects) {/* ww w. ja  v a  2  s.  c om*/
    super(ownerFrame, "Generate Signed GET URLs", true);
    this.ownerFrame = ownerFrame;
    this.hyperlinkListener = hyperlinkListener;
    this.s3Service = s3Service;
    this.objects = objects;

    String introductionText = "<html><center>Generate signed GET URLs that you can provide to anyone<br>"
            + "who needs to access objects in your bucket for a limited time.</center></html>";
    JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener);
    introductionLabel.setHorizontalAlignment(JLabel.CENTER);
    JHtmlLabel expiryTimeLabel = new JHtmlLabel("<html><b>Expiry Time</b> (Hours)</html>", hyperlinkListener);
    expiryTimeLabel.setHorizontalAlignment(JLabel.RIGHT);
    JHtmlLabel httpsUrlsLabel = new JHtmlLabel("<html><b>Secure HTTPS URLs?</b></html>", hyperlinkListener);
    httpsUrlsLabel.setHorizontalAlignment(JLabel.RIGHT);
    JHtmlLabel virtualHostLabel = new JHtmlLabel("<html><b>Bucket is a Virtual Host?</b></html>",
            hyperlinkListener);
    virtualHostLabel.setHorizontalAlignment(JLabel.RIGHT);
    JHtmlLabel requesterPaysLabel = new JHtmlLabel("<html><b>Bucket is Requester Pays?</b></html>",
            hyperlinkListener);
    requesterPaysLabel.setHorizontalAlignment(JLabel.RIGHT);

    expiryTimeTextField = new JTextField("1.0");
    expiryTimeTextField.setToolTipText("How long in hours until the URL will expire");
    expiryTimeTextField.getDocument().addDocumentListener(this);

    httpsUrlsCheckBox = new JCheckBox();
    httpsUrlsCheckBox.setSelected(false);
    httpsUrlsCheckBox.setToolTipText("Check this box to generate secure HTTPS URLs.");
    httpsUrlsCheckBox.addActionListener(this);

    virtualHostCheckBox = new JCheckBox();
    virtualHostCheckBox.setSelected(false);
    virtualHostCheckBox.setToolTipText("Check this box if your bucket is configured as a virtual host.");
    virtualHostCheckBox.addActionListener(this);

    requesterPaysCheckBox = new JCheckBox();
    requesterPaysCheckBox.setSelected(false);
    requesterPaysCheckBox.setToolTipText("Check this box if the bucket has Requester Pays enabled.");
    requesterPaysCheckBox.addActionListener(this);

    finishedButton = new JButton("Finished");
    finishedButton.setActionCommand("Finished");
    finishedButton.addActionListener(this);

    signedUrlsTextArea = new JTextArea();
    signedUrlsTextArea.setEditable(false);

    // Set default ENTER and ESCAPE buttons.
    this.getRootPane().setDefaultButton(finishedButton);
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = -6225706489569112809L;

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    });

    JPanel panel = new JPanel(new GridBagLayout());
    int row = 0;
    panel.add(introductionLabel, new GridBagConstraints(0, row, 6, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(expiryTimeLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(expiryTimeTextField, new GridBagConstraints(1, row, 5, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(httpsUrlsLabel, new GridBagConstraints(0, ++row, 1, 1, 0.3, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(httpsUrlsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    panel.add(virtualHostLabel, new GridBagConstraints(2, row, 1, 1, 0.3, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(virtualHostCheckBox, new GridBagConstraints(3, row, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    panel.add(requesterPaysLabel, new GridBagConstraints(4, row, 1, 1, 0.3, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    panel.add(requesterPaysCheckBox, new GridBagConstraints(5, row, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    panel.add(new JScrollPane(signedUrlsTextArea), new GridBagConstraints(0, ++row, 6, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));
    panel.add(finishedButton, new GridBagConstraints(0, ++row, 6, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(panel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    this.setSize(700, 450);
    this.setResizable(true);
    this.setLocationRelativeTo(ownerFrame);

    generateSignedUrls();
}

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

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

    // apon//from  w  w w  . j ava2 s. 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:org.angnysa.yaba.swing.BudgetFrame.java

private void buildTransactionTable() {
    transactionModel = new TransactionTableModel(service);
    transactionTable = new JTable(transactionModel);
    transactionTable.setRowHeight((int) (transactionTable.getRowHeight() * 1.2));
    transactionTable.getColumnModel().getColumn(TransactionTableModel.COL_END)
            .setCellEditor(new CustomCellEditor(
                    new JFormattedTextField(new OptionalValueFormatter(new JodaLocalDateFormat()))));
    transactionTable.setDefaultEditor(LocalDate.class,
            new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat())));
    transactionTable.setDefaultEditor(ReadablePeriod.class,
            new CustomCellEditor(new JFormattedTextField(new OptionalValueFormatter(new JodaPeriodFormat()))));
    transactionTable.setDefaultEditor(Double.class,
            new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance())));
    transactionTable.setDefaultRenderer(LocalDate.class,
            new FormattedTableCellRenderer(new JodaLocalDateFormat()));
    transactionTable.setDefaultRenderer(ReadablePeriod.class,
            new FormattedTableCellRenderer(new JodaPeriodFormat()));
    transactionTable.setDefaultRenderer(Double.class,
            new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat()));
    transactionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    transactionTable.setAutoCreateRowSorter(true);
    transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$
    transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$
    transactionTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override//from   w w w.  j av a 2 s .c  o  m
        public void actionPerformed(ActionEvent e) {

            int row = transactionTable.getSelectedRow();
            if (row >= 0) {
                row = transactionTable.getRowSorter().convertRowIndexToModel(row);
                transactionModel.deleteRow(row);
            }
        }
    });
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Adds the dispose action with escape key.
 * //from w  w w.jav a 2  s  .c o  m
 * @param frame
 *            the frame
 */
public static void addDisposeActionWithEscapeKey(final JFrame frame) {
    //  Handle escape key to close the dialog

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action disposeAction = new AbstractAction() {
        private static final long serialVersionUID = 0L;

        @Override
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    };
    frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    frame.getRootPane().getActionMap().put("ESCAPE", disposeAction);
}

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  w w  w.j  a v  a 2 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;
}