Example usage for java.awt.event ActionEvent getActionCommand

List of usage examples for java.awt.event ActionEvent getActionCommand

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getActionCommand.

Prototype

public String getActionCommand() 

Source Link

Document

Returns the command string associated with this action.

Usage

From source file:com.floreantpos.main.SetUpWindow.java

public void actionPerformed(ActionEvent e) {
    try {//www . j a va2  s  .c  om
        String command = e.getActionCommand();

        Database selectedDb = (Database) databaseCombo.getSelectedItem();

        final String providerName = selectedDb.getProviderName();
        final String databaseURL = tfServerAddress.getText();
        final String databasePort = tfServerPort.getText();
        final String databaseName = tfDatabaseName.getText();
        final String user = tfUserName.getText();
        final String pass = new String(tfPassword.getPassword());

        final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName);
        final String hibernateDialect = selectedDb.getHibernateDialect();
        final String driverClass = selectedDb.getHibernateConnectionDriverClass();

        if (CANCEL.equalsIgnoreCase(command)) {
            System.exit(1);
            return;
        }

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (TEST.equalsIgnoreCase(command)) {
            try {
                DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass);
            } catch (DatabaseConnectionException e1) {
                JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$
                return;
            }
            connectionSuccess = true;
            JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$
            return;
        }
        saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass,
                connectionString, hibernateDialect);
        if (CREATE_SAMPLE_DATA.equals(command)) {
            DataImportAction
                    .importMenuItems(DatabaseUtil.class.getResourceAsStream("/floreantpos-menu-items.xml")); //$NON-NLS-1$
        } else if (CREATE_DATABASE.equals(command)) {
            int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            if (i != JOptionPane.YES_OPTION) {
                return;
            }

            i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$
                    Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
            boolean generateSampleData = false;
            if (i == JOptionPane.YES_OPTION)
                generateSampleData = true;

            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort,
                    databaseName);
            boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect,
                    driverClass, user, pass, generateSampleData);

            if (databaseCreated) {
                JOptionPane.showMessageDialog(SetUpWindow.this,
                        Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$
                                Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$
                connectionSuccess = true;
            } else {
                JOptionPane.showMessageDialog(SetUpWindow.this,
                        Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$
            }
        } else if (SAVE.equalsIgnoreCase(command)) {
            Integer terminalId = tfTerminalNumber.getInteger();
            Integer defaultPassLen = tfSecretKeyLength.getInteger();
            Integer autoLogOffTime = tfLogoffTime.getInteger();
            Boolean isLogOff = chkAutoLogoff.isSelected();
            Double scaleFactor = tfScaleFactor.getDouble();

            TerminalConfig.setTerminalId(terminalId);
            TerminalConfig.setDefaultPassLen(defaultPassLen);
            TerminalConfig.setScreenScaleFactor(scaleFactor);
            TerminalConfig.setAutoLogoffEnable(isLogOff);
            TerminalConfig.setAutoLogoffTime(autoLogOffTime <= 0 ? 10 : autoLogOffTime);
            try {
                DatabaseUtil.initialize();
                saveConfigData();
            } catch (Exception ex) {
                int i = JOptionPane.showConfirmDialog(this, "Connection Failed. Do you want to save?", //$NON-NLS-1$
                        "Connection status!", JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
                if (i == JOptionPane.YES_OPTION) {
                    System.exit(1);
                }
            }
        }
    } catch (Exception e2) {
        PosLog.error(getClass(), e2);
        POSMessageDialog.showMessage(this, e2.getMessage());
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.doctype.ferramentaDoctype.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        salvaAlteracoes.salvar();/*from  ww w .ja  va2s  . c  o  m*/
    } else if (cmd == "Abrir") {
        abrirActionPerformed(null);
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "AbrirURL") {
        openUrl();
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Desfazer") {
        textAreaSourceCode.undo();
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();
    }

}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

/**
 * Returns the 'Add child' action./*www.j  a  va  2 s .c om*/
 *
 * @return the action
 */
@SuppressWarnings("serial")
private Action getAddChildAction() {
    if (addChildAction == null) {
        String actionCommand = bundle.getString(ADD_CHILD_NODE_KEY);
        String actionKey = bundle.getString(ADD_CHILD_NODE_KEY + ".action");
        addChildAction = new AbstractAction(actionCommand, Icons.ADD) {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("actionPerformed(): action = " + e.getActionCommand());
                if (checkAction()) {
                    model.addNode(StringUtils.removeEnd(nodes[0].getPath(), "/") + "/" + childName,
                            childText.getBytes());
                }
                childName = childText = "";
            }

            private boolean checkAction() {
                JDialog dlg = createAddChildDialog();

                dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                dlg.setSize(800, 600);
                dlg.setLocationRelativeTo(null);
                dlg.setVisible(true);

                boolean nameIsEmpty = childName == null || childName.isEmpty();
                boolean dataIsEmpty = childText == null;
                return !nameIsEmpty && !dataIsEmpty;
            }
        };
        addChildAction.putValue(Action.ACTION_COMMAND_KEY, actionKey);
    }
    return this.addChildAction;
}

From source file:net.sf.maltcms.chromaui.project.spi.wizard.DBProjectVisualPanel1.java

private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    String command = evt.getActionCommand();
    if ("BROWSE".equals(command)) {
        FileChooserBuilder fcb = new FileChooserBuilder(DBProjectVisualPanel1.class);
        fcb.setTitle("Select Project Location");
        fcb.setDirectoriesOnly(true);//from  w ww . j  a v  a 2 s.com
        String path = this.projectLocationTextField.getText();
        JFileChooser jfc = fcb.createFileChooser();
        if (path.length() > 0) {
            File f = new File(path);
            if (f.exists()) {
                jfc.setSelectedFile(f);
            }
        }
        if (JFileChooser.APPROVE_OPTION == jfc.showOpenDialog(this)) {
            File projectDir = jfc.getSelectedFile();
            projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
        }
        firePropertyChange("VALIDATE", null, null);
    }

}

From source file:PlayerOfMedia.java

/***************************************************************************
 * React to menu selections (quit or open) or one of the the buttons on the
 * dialog boxes./*from w  ww  .  j  a v a2  s  . com*/
 **************************************************************************/
public void actionPerformed(ActionEvent e) {

    if (e.getSource() instanceof MenuItem) {
        //////////////////////////////////////////////////
        // Quit and free up any player acquired resources.
        //////////////////////////////////////////////////
        if (e.getActionCommand().equalsIgnoreCase("QUIT")) {
            if (player != null) {
                player.stop();
                player.close();
            }
            System.exit(0);
        }
        /////////////////////////////////////////////////////////
        // User to open/play media. Show the selection dialog box.
        /////////////////////////////////////////////////////////
        else if (e.getActionCommand().equalsIgnoreCase("OPEN")) {
            selectionDialog.show();
        }
    }
    //////////////////////
    // One of the Buttons.
    //////////////////////
    else {
        /////////////////////////////////////////////////////////////
        // User to browse the local file system. Popup a file dialog.
        /////////////////////////////////////////////////////////////
        if (e.getSource() == choose) {
            FileDialog choice = new FileDialog(this, "Media File Choice", FileDialog.LOAD);
            if (lastDirectory != null)
                choice.setDirectory(lastDirectory);
            choice.show();
            String selection = choice.getFile();
            if (selection != null) {
                lastDirectory = choice.getDirectory();
                mediaName.setText("file://" + choice.getDirectory() + selection);
            }
        }
        ///////////////////////////////////////////////
        // User chooses to cancel opening of new media.
        ///////////////////////////////////////////////
        else if (e.getSource() == cancel) {
            selectionDialog.hide();
        }
        ///////////////////////////////////////////////////////
        // User has selected the name of the media. Attempt to
        // create a Player.
        ///////////////////////////////////////////////////////
        else if (e.getSource() == open) {
            selectionDialog.hide();
            createAPlayer(mediaName.getText());
        }
        ////////////////////////////////////////////
        // User has seen error message. Now hide it.
        ////////////////////////////////////////////
        else if (e.getSource() == ok)
            errorDialog.hide();
    }
}

From source file:TexCoordTest.java

public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("EYE_LINEAR") != false)
        m_TexGen.setGenMode(TexCoordGeneration.EYE_LINEAR);

    else if (event.getActionCommand().equals("OBJECT_LINEAR") != false)
        m_TexGen.setGenMode(TexCoordGeneration.OBJECT_LINEAR);

    else if (event.getActionCommand().equals("SPHERE_MAP") != false)
        m_TexGen.setGenMode(TexCoordGeneration.SPHERE_MAP);

    else if (event.getActionCommand().equals("Rotate") != false)
        m_RotationInterpolator.setEnable(!m_RotationInterpolator.getEnable());

    else if (event.getActionCommand().equals("Translate") != false)
        m_PositionInterpolator.setEnable(!m_PositionInterpolator.getEnable());

    // apply any changes to the TexCoordGeneration and copy into the
    // appearance
    TexCoordGeneration texCoordGeneration = new TexCoordGeneration();
    texCoordGeneration = (TexCoordGeneration) m_TexGen.cloneNodeComponent(true);
    m_Appearance.setTexCoordGeneration(texCoordGeneration);
}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

/**
 * Returns the 'Update' action./*from ww w. ja  v a 2s.c  o  m*/
 *
 * @return the action
 */
@SuppressWarnings("serial")
private Action getUpdateAction() {
    if (updateAction == null) {
        String actionCommand = bundle.getString(UPDATE_NODE_KEY);
        String actionKey = bundle.getString(UPDATE_NODE_KEY + ".action");
        updateAction = new AbstractAction(actionCommand, Icons.UPDATE) {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("actionPerformed(): action = " + e.getActionCommand());
                if (checkAction()) {
                    model.updateData(nodes[0].getPath(), taUpdate.getText().getBytes(getCharset()));
                }
            }

            private boolean checkAction() {
                // No node or several nodes selected
                if (nodes == null || nodes.length > 1) {
                    return false;
                }
                // No parent
                if (nodes == null || nodes.length != 1) {
                    JOptionPane.showMessageDialog(JZVNodePanel.this,
                            bundle.getString("dlg.error.updateWithoutParent"),
                            bundle.getString("dlg.error.title"), JOptionPane.ERROR_MESSAGE);
                    return false;
                }

                return (JOptionPane.showConfirmDialog(JZVNodePanel.this,
                        bundle.getString("dlg.confirm.update")) == JOptionPane.YES_OPTION);
            }
        };
        updateAction.putValue(Action.ACTION_COMMAND_KEY, actionKey);
    }
    return updateAction;
}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

/**
 * Returns the 'Delete node(s)' action./*  www  .j ava 2 s . c o  m*/
 * <p>
 * The action is created and mapped to the [Delete] key stroke
 * </p>
 *
 * @return the action
 */
@SuppressWarnings("serial")
private Action getDeleteAction() {
    if (this.deleteAction == null) {
        String actionCommand = bundle.getString(DELETE_NODE_KEY);
        String actionKey = bundle.getString(DELETE_NODE_KEY + ".action");
        this.deleteAction = new AbstractAction(actionCommand, Icons.DELETE) {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("actionPerformed(): action = " + e.getActionCommand());
                if (checkAction()) {
                    // Checks if several nodes will be deleted
                    if (nodes.length > 1) {
                        model.deleteNodes(nodes);
                    } else {
                        model.deleteNode(nodes[0]);
                    }
                }
            }

            private boolean checkAction() {
                // No node selected
                if (nodes == null) {
                    JOptionPane.showMessageDialog(JZVNodePanel.this,
                            bundle.getString("dlg.error.deleteWithoutSelection"),
                            bundle.getString("dlg.error.title"), JOptionPane.ERROR_MESSAGE);
                    return false;
                }
                return (JOptionPane.showConfirmDialog(JZVNodePanel.this,
                        bundle.getString("dlg.confirm.update")) == JOptionPane.YES_OPTION);
            }
        };
        this.deleteAction.putValue(Action.ACTION_COMMAND_KEY, actionKey);

        this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), actionKey);
        this.getActionMap().put(actionKey, this.deleteAction);
    }
    return this.deleteAction;
}

From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals(SHOW_ERROR_COMMAND)) {
        modifyBaseError();/*from  ww w .j  av  a  2  s  .  c om*/
    } else if (command.equals(CHANGE_CURVE_COMMAND)) {
        if (isPropertiesChanged) {
            updateChart(chart);
        }
        currentSeriesKey = (String) seriesCombo.getSelectedItem();
        for (int i = 0; i < chart.getXYPlot().getDatasetCount(); i++) {
            XYDataset dataset = chart.getXYPlot().getDataset(i);
            if (dataset != null && dataset instanceof IDataset && dataset.getSeriesCount() > 0) {
                int indexOfKey = dataset.indexOf(currentSeriesKey);
                if (indexOfKey >= 0) {
                    currentDataset = (IDataset) dataset;
                    currentSeriesIndex = indexOfKey;
                    initialise(currentDataset, currentSeriesIndex);
                    isPropertiesChanged = false;
                    break;
                }
            }
        }
    } else if (command.equals(CURVE_COLOR_COMMAND)) {
        modifyCurvePaint();
    } else if (command.equals(CURVE_STROCK_COMMAND)) {
        modifyCurveStroke();
    } else if (command.equals(SHOW_MARKER_COMMAND)) {
        modifyMarkerVisible();
    } else if (command.equals(MARKER_SHAPE_COMMAND)) {
        modifyMarkerShape();
    } else if (command.equals(MARKER_FILLED_COMMAND)) {
        modifyMarkerFilled();
    } else if (command.equals(CURVE_VISIBLE_COMMAND)) {
        modifyCurveVisibility();
    } else {
        super.actionPerformed(event);
    }
    isPropertiesChanged = true;
}

From source file:regresiones.EstadisticaDescriptiva.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Exportar a PDF")) {
        try {/*from   w w  w  . ja v  a2  s  .co  m*/
            String nombrePDF = JOptionPane.showInputDialog("Escribe el nombre del PDF (sin extension)");
            String[] datosVariables = { MAXIMO + "", MINIMO + "", RANGO + "", INTERVALOS + "", AMPLITUD + "",
                    RANGOAMPLIADO + "", DIFERENCIARANGOS + "", LIPI + "", LSUI + "", DM + "", VARIANZA + "",
                    DE + "", MEDIA + "", MEDIANA + "", MODA + "" };
            PDFdescriptiva.crearPDF("Estadistica descriptiva", formato(tablaCompleta), nombrePDF, N,
                    datosVariables);

            JOptionPane.showMessageDialog(jtable, "Se creo el PDF");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(RegresionMultiple.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DocumentException ex) {
            Logger.getLogger(EstadisticaDescriptiva.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}