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:de.tor.tribes.ui.views.DSWorkbenchAttackFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    AttackTableTab activeTab = getActiveTab();
    int idx = jAttackTabPane.getSelectedIndex();
    if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("TimeChange")) {
            activeTab.fireChangeTimeEvent();
        } else if (e.getActionCommand().equals("UnitChange")) {
            activeTab.fireChangeUnitEvent();
        } else if (e.getActionCommand().equals("Recolor")) {
            activeTab.updateSortHighlighter();
        } else if (e.getActionCommand().equals("ExportScript")) {
            activeTab.fireExportScriptEvent();
        } else if (e.getActionCommand().equals("Copy")) {
            activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("BBCopy")) {
            activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.CLIPBOARD_BB);
        } else if (e.getActionCommand().equals("Cut")) {
            activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD);
            jAttackTabPane.setSelectedIndex(idx);
        } else if (e.getActionCommand().equals("Paste")) {
            activeTab.transferSelection(AttackTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD);
            jAttackTabPane.setSelectedIndex(idx);
        } else if (e.getActionCommand().equals("Delete")) {
            activeTab.deleteSelection(true);
        } else if (e.getActionCommand().equals("Find")) {
            BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
            Graphics g = back.getGraphics();
            g.setColor(new Color(120, 120, 120, 120));
            g.fillRect(0, 0, back.getWidth(), back.getHeight());
            g.setColor(new Color(120, 120, 120));
            g.drawLine(0, 0, 3, 3);/*from ww  w  .  j a v  a 2 s.  c o  m*/
            g.dispose();
            TexturePaint paint = new TexturePaint(back,
                    new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));

            jxSearchPane.setBackgroundPainter(new MattePainter(paint));
            DefaultListModel model = new DefaultListModel();

            for (int i = 0; i < activeTab.getAttackTable().getColumnCount(); i++) {
                TableColumnExt col = activeTab.getAttackTable().getColumnExt(i);
                if (col.isVisible()) {
                    if (!col.getTitle().equals("Einheit") && !col.getTitle().equals("Typ")
                            && !col.getTitle().equals("Sonstiges") && !col.getTitle().equals("Abschickzeit")
                            && !col.getTitle().equals("Ankunftzeit") && !col.getTitle().equals("Verbleibend")) {
                        model.addElement(col.getTitle());
                    }
                }
            }
            jXColumnList.setModel(model);
            jXColumnList.setSelectedIndex(0);
            jxSearchPane.setVisible(true);
        }
    }
}

From source file:ucar.unidata.idv.control.chart.ChartManager.java

/**
 * show dialog for chart//from   w  w w . ja  va  2  s .c  o  m
 *
 * @param chartHolder chart
 */
protected void showPropertiesDialog(final ChartHolder chartHolder) {
    List comps = new ArrayList();
    getPropertiesComponents(chartHolder, comps);
    GuiUtils.tmpInsets = GuiUtils.INSETS_5;
    JComponent contents = GuiUtils.doLayout(comps, 2, GuiUtils.WT_NY, GuiUtils.WT_N);
    final JDialog propertiesDialog = GuiUtils.createDialog(chartHolder.getName() + " Properties", true);

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            String cmd = ae.getActionCommand();
            if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_APPLY)) {
                if (!applyProperties(chartHolder)) {
                    return;
                }
                updateThumb(true);
            }
            if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_CANCEL)) {
                propertiesDialog.dispose();
            }
        }
    };
    JPanel buttons = GuiUtils.makeButtons(listener,
            new String[] { GuiUtils.CMD_APPLY, GuiUtils.CMD_OK, GuiUtils.CMD_CANCEL });

    contents = GuiUtils.centerBottom(contents, buttons);
    contents = GuiUtils.inset(contents, 5);
    propertiesDialog.getContentPane().add(GuiUtils.top(contents));
    propertiesDialog.pack();

    propertiesDialog.setLocation(200, 200);
    propertiesDialog.setVisible(true);
}

From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java

/**
 * Reacts to the "save data" check box.// w  ww.  ja v  a 2  s .  c  o  m
 */
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();

    if (command.equals(SAVE_DATA)) {
        if (saveDataCheckBox.isSelected()) {
            // they want to save data, so open a data file
            createFileWriter();
        } else {
            // They don't want to save data anymore, so close the file.
            // The synchronized keyword prevents accidental access elsewhere
            // in the code while the file is being closed. Otherwise, other
            // code might try to write to the file while it is being closed.
            synchronized (this) {
                if (fileWriter != null) {
                    fileWriter.close();
                    fileWriter = null;
                }
            }
        }
    } else if (command.equals(PLOT_ZERO_STATE)) {
        if (priceList != null && plotZeroStateCheckBox.isSelected()) {
            // they want the zero state to be plotted
            plotZeroState = true;
            priceList.addFirst((new Point2D.Double(0, marketValue[0])));
        } else {
            // they don't want the zero state to be plotted
            plotZeroState = false;
            if (priceList.size() > 0) {
                priceList.removeFirst();
            }
        }

        plotData();
    }
}

From source file:com._17od.upm.gui.MainWindow.java

public void actionPerformed(ActionEvent event) {

    try {//from w ww  . j av a 2 s  .  co  m
        if (event.getActionCommand() == MainWindow.NEW_DATABASE_TXT) {
            dbActions.newDatabase();
        } else if (event.getActionCommand() == MainWindow.OPEN_DATABASE_TXT) {
            dbActions.openDatabase();
        } else if (event.getActionCommand() == MainWindow.OPEN_DATABASE_FROM_URL_TXT) {
            dbActions.openDatabaseFromURL();
        } else if (event.getActionCommand() == MainWindow.SYNC_DATABASE_TXT) {
            dbActions.syncWithRemoteDatabase();
        } else if (event.getActionCommand() == MainWindow.ADD_ACCOUNT_TXT) {
            dbActions.reloadDatabaseBefore(new AddAccountAction());
        } else if (event.getActionCommand() == MainWindow.EDIT_ACCOUNT_TXT) {
            String selectedAccName = (String) this.accountsListview.getSelectedValue();
            dbActions.reloadDatabaseBefore(new EditAccountAction(selectedAccName));
        } else if (event.getActionCommand() == MainWindow.DELETE_ACCOUNT_TXT) {
            dbActions.reloadDatabaseBefore(new DeleteAccountAction());
        } else if (event.getActionCommand() == MainWindow.VIEW_ACCOUNT_TXT) {
            dbActions.viewAccount();
        } else if (event.getActionCommand() == MainWindow.OPTIONS_TXT) {
            dbActions.options();
        } else if (event.getActionCommand() == MainWindow.ABOUT_TXT) {
            dbActions.showAbout();
        } else if (event.getActionCommand() == MainWindow.RESET_SEARCH_TXT) {
            dbActions.resetSearch();
        } else if (event.getActionCommand() == MainWindow.CHANGE_MASTER_PASSWORD_TXT) {
            dbActions.reloadDatabaseBefore(new ChangeMasterPasswordAction());
        } else if (event.getActionCommand() == MainWindow.DATABASE_PROPERTIES_TXT) {
            dbActions.reloadDatabaseBefore(new ShowDatabasePropertiesAction());
        } else if (event.getActionCommand() == MainWindow.EXIT_TXT) {
            dbActions.exitApplication();
        } else if (event.getActionCommand() == MainWindow.EXPORT_TXT) {
            dbActions.export();
        } else if (event.getActionCommand() == MainWindow.IMPORT_TXT) {
            dbActions.reloadDatabaseBefore(new ImportAccountsAction());
        }
    } catch (Exception e) {
        dbActions.errorHandler(e);
    }
}

From source file:ffx.ui.KeywordPanel.java

/**
 * Handles input from KeywordPanel ToolBar buttons.
 *
 * {@inheritDoc}/*from w  w  w  .ja v a 2s .  co m*/
 */
@Override
public void actionPerformed(ActionEvent evt) {
    String arg = evt.getActionCommand();
    switch (arg) {
    case "Open...":
        keyOpen();
        break;
    case "Close":
        keyClose();
        break;
    case "Save":
        keySave(currentKeyFile);
        break;
    case "Save As...":
        keySaveAs();
        break;
    case "Description":
        JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();
        setDivider(box.isSelected());
        break;
    }
    if (evt.getSource() instanceof JComboBox) {
        loadKeywordGroup();
    }
}

From source file:com.funambol.foundation.admin.FileDataObjectSyncSourceConfigPanel.java

/**
 * Create the panel//www  .j ava  2  s .co m
 */

private void init() {
    // set layout
    this.setLayout(null);

    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit File Data Object SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(14, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(14, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    storageProviderLabel.setText("Storage type:");
    storageProviderLabel.setFont(defaultFont);
    storageProviderLabel.setBounds(new Rectangle(14, y, 150, 18));
    //list of supported storage providers
    String[] providers = new String[] { PROVIDER_FILESYSTEM, PROVIDER_S3 };
    storageProviderValue = new JComboBox(providers);
    storageProviderValue.addActionListener(jcloudsProviderValueActionListener);
    storageProviderValue.setFont(defaultFont);
    storageProviderValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageContainerNameLabel.setText("Provider container name:");
    storageContainerNameLabel.setFont(defaultFont);
    storageContainerNameLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageContainerNameValue.setFont(defaultFont);
    storageContainerNameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageIdentityLabel.setText("Provider identity:");
    storageIdentityLabel.setFont(defaultFont);
    storageIdentityLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageIdentityValue.setFont(defaultFont);
    storageIdentityValue.setBounds(new Rectangle(170, y, 350, 18));

    //storage provider identity and storageFilesystemRootPathLabel aren't
    //showed together, so leaving the y coordinate equals the panel has a better
    //aspect for different storage types
    //y += dy;

    //    storageFilesystemRootPathLabel.setText("Local path for filesystem provider:");
    storageFilesystemRootPathLabel.setFont(defaultFont);
    storageFilesystemRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageFilesystemRootPathValue.setFont(defaultFont);
    storageFilesystemRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageCredentialLabel.setText("Provider credential:");
    storageCredentialLabel.setFont(defaultFont);
    storageCredentialLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageCredentialValue.setFont(defaultFont);
    storageCredentialValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    localRootPathLabel.setText("Root local path for temp files: ");
    localRootPathLabel.setFont(defaultFont);
    localRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    localRootPathValue.setFont(defaultFont);
    localRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    quotaLabel.setText("Quota: ");
    quotaLabel.setFont(defaultFont);
    quotaLabel.setBounds(new Rectangle(14, y, 150, 18));
    model = new RolesTableModel();
    quotaTable = new JTable(model);
    quotaTable.setFont(defaultFont);
    quotaTable.setShowGrid(true);
    quotaTable.setAutoscrolls(true);
    quotaTable.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    //add the table into a JScrollPanel, otherwise no columns headers and border
    //will be show
    JScrollPane scrollpane = new JScrollPane(quotaTable);
    scrollpane.setBounds(new Rectangle(170, y, 350, 110));
    quotaTable.setPreferredScrollableViewportSize(new Dimension(350, 110));

    y += dy + 75;
    notaLabel.setText(
            "<html>Please enter the number followed by 'M' if it is 'MegaBytes', or 'G' if it is 'GigaBytes'<BR>Example: '100 M' stands for 100 MegaBytes, '2 G' stands for 2 GigaBytes</html>");
    notaLabel.setFont(defaultFont);
    notaLabel.setBounds(new Rectangle(170, y, 350, 54));

    //button separed from other controls, and the height of the table
    y += dy + 36;

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(170, y, 70, 25);

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this,
                                    ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this,
                                    ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // add all components to the panel
    this.add(panelName, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(storageProviderLabel, null);
    this.add(storageProviderValue, null);
    this.add(storageContainerNameLabel, null);
    this.add(storageContainerNameValue, null);
    this.add(storageIdentityLabel, null);
    this.add(storageIdentityValue, null);
    this.add(storageCredentialLabel, null);
    this.add(storageCredentialValue, null);
    this.add(storageFilesystemRootPathLabel, null);
    this.add(storageFilesystemRootPathValue, null);
    this.add(localRootPathLabel, null);
    this.add(localRootPathValue, null);
    this.add(quotaLabel, null);
    this.add(scrollpane, null);
    this.add(notaLabel, null);
    this.add(confirmButton, null);
}

From source file:com.dfki.av.sudplan.ui.MainFrame.java

private void miOpenDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miOpenDataActionPerformed
    try {/* w  w  w.  j  a  va 2  s .com*/
        String cmd = evt.getActionCommand();
        final JFileChooser fc = new JFileChooser();

        FileFilter fileFilter;
        // Set file filter..
        if (cmd.equalsIgnoreCase(miOpenKMLFile.getActionCommand())) {
            fileFilter = new FileNameExtensionFilter("KML/KMZ File", "kml", "kmz");
        } else if (cmd.equalsIgnoreCase(miAddGeoTiff.getActionCommand())) {
            fileFilter = new FileNameExtensionFilter("GeoTiff File ( *.tif, *.tiff)", "tif", "tiff");
        } else if (cmd.equalsIgnoreCase(miAddShape.getActionCommand())) {
            fileFilter = new FileNameExtensionFilter("ESRI Shapefile (*.shp)", "shp", "SHP");
        } else if (cmd.equalsIgnoreCase(miAddShapeZip.getActionCommand())) {
            fileFilter = new FileNameExtensionFilter("ESRI Shapefile ZIP (*.zip)", "zip", "ZIP");
        } else {
            log.warn("No valid action command.");
            fileFilter = null;
        }
        fc.setFileFilter(fileFilter);

        // Set latest working directory...
        XMLConfiguration xmlConfig = Configuration.getXMLConfiguration();
        String path = xmlConfig.getString("sudplan3D.working.dir");
        File dir;
        if (path != null) {
            dir = new File(path);
            if (dir.exists()) {
                fc.setCurrentDirectory(dir);
            }
        }

        // Show dialog...
        int ret = fc.showOpenDialog(this);

        // Save currently selected working directory...
        dir = fc.getCurrentDirectory();
        path = dir.getAbsolutePath();
        xmlConfig.setProperty("sudplan3D.working.dir", path);

        if (ret != JFileChooser.APPROVE_OPTION) {
            return;
        }

        if (cmd.equalsIgnoreCase(miOpenKMLFile.getActionCommand())) {
            wwPanel.addKMLLayer(fc.getSelectedFile());
        } else if (cmd.equalsIgnoreCase(miAddGeoTiff.getActionCommand())) {
            wwPanel.addGeoTiffLayer(fc.getSelectedFile());
        } else if (cmd.equalsIgnoreCase(miAddShape.getActionCommand())
                || cmd.equalsIgnoreCase(miAddShapeZip.getActionCommand())) {
            IVisAlgorithm algo = VisAlgorithmFactory.newInstance(VisPointCloud.class.getName());
            if (algo != null) {
                wwPanel.addLayer(fc.getSelectedFile(), algo, null);
            } else {
                log.error("VisAlgorithm {} not supported.", VisPointCloud.class.getName());
                JOptionPane.showMessageDialog(this, "Algorithm not supported.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else {
            log.warn("No valid action command.");
        }
    } catch (Exception ex) {
        log.error(ex.toString());
        JOptionPane.showMessageDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

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

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("BBCopy")) {
        transferBBCodeToClipboard();//from   www .ja v  a2  s . co m
    } else if (e.getActionCommand().equals("Delete")) {
        removeMonitoredElements();
    }
}

From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java

/**
 * Handles action events generated by the popup menu.
 *
 * @param event  the event.//from  ww  w. j ava2s  .  c o  m
 */
public void actionPerformed(ActionEvent event) {

    String command = event.getActionCommand();

    if (command.equals(SAVE_COMMAND)) {
        try {
            doSaveAs();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (command.equals(PRINT_COMMAND)) {
        createChartPrintJob();
    }

    else if (command.equals(NEW_CLASS_COMMAND)) {
        // Definicion de nueba clase
        newRoiChart();
        if (gestorRois != null) {
            gestorRois.addNewRoiEntry(activeROI);
        }
        updateList();

    }

}