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:fr.eurecom.hybris.demogui.HybrisDemoGui.java

public void actionPerformed(ActionEvent e) {

    String cmd = e.getActionCommand();
    if (cmd.equals("Get")) {

        if (lstHybris.getSelectedIndex() >= 0) {
            try {
                System.out.println("Retrieving " + lstHybris.getSelectedValue() + "...");
                byte[] retrieved = cm.hybris.get(lstHybris.getSelectedValue());
                if (retrieved != null) {
                    JFileChooser fc = new JFileChooser(
                            System.getProperty("user.home") + File.separator + "Desktop");
                    fc.setSelectedFile(new File("RETRIEVED_" + lstHybris.getSelectedValue()));
                    int returnVal = fc.showSaveDialog(frame);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File file = fc.getSelectedFile();
                        FileUtils.writeByteArrayToFile(file, retrieved);
                        System.out.println("Saved: " + file.getName() + ".");
                    }/* ww w. j a v a2s . co m*/
                } else
                    JOptionPane.showMessageDialog(frame, "Hybris could not download the file.", "Error",
                            JOptionPane.ERROR_MESSAGE);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

    }
    if (cmd.equals("Put")) {

        JFileChooser fc = new JFileChooser(System.getProperty("user.home") + File.separator + "Desktop");
        int returnVal = fc.showOpenDialog(frame);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            System.out.println("Putting: " + file.getName() + ".");
            byte[] array;
            try {
                array = FileUtils.readFileToByteArray(file);
                new Thread(cm.new BackgroundWorker(OperationType.PUT, ClientType.HYBRIS, file.getName(), array))
                        .start();
            } catch (Exception e1) {
                e1.printStackTrace();
            }

        }

    }
    if (cmd.equals("Delete")) {

        if (lstHybris.getSelectedIndex() >= 0) {
            new Thread(cm.new BackgroundWorker(OperationType.DELETE, ClientType.HYBRIS,
                    lstHybris.getSelectedValue(), null)).start();
            System.out.println("Removed " + lstHybris.getSelectedValue() + " from Hybris.");
        }
    }
}

From source file:ca.sfu.federation.viewer.propertysheet.LinePropertySheet.java

private void jtfNameActionListener(java.awt.event.ActionEvent evt) {
    String command = evt.getActionCommand();
    logger.log(Level.INFO, "ComponentSheet jtfNameActionListener fired {0}", command);
    try {/*  w ww.  j a v  a 2s  .  co m*/
        BeanProxy proxy = new BeanProxy(this.target);
        proxy.set("name", evt.getActionCommand());
    } catch (Exception ex) {
        String stack = ExceptionUtils.getFullStackTrace(ex);
        logger.log(Level.WARNING, "{0}", stack);
    }
}

From source file:ca.sfu.federation.viewer.propertysheet.LinePropertySheet.java

private void jtfDescriptionActionListener(java.awt.event.ActionEvent evt) {
    String command = evt.getActionCommand();
    logger.log(Level.INFO, "ComponentSheet jtfDescriptionActionListener fired {0}", command);
    try {/* w w w .  j a va 2s  .  c om*/
        BeanProxy proxy = new BeanProxy(this.target);
        proxy.set("description", evt.getActionCommand());
    } catch (Exception ex) {
        String stack = ExceptionUtils.getFullStackTrace(ex);
        logger.log(Level.WARNING, "{0}", stack);
    }

}

From source file:fi.elfcloud.client.dialog.UploadDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(TransferFrame.CANCEL_ACTION)) {
        autoClose = false;/* w  w w. ja  v  a2s  .  com*/
        task.cancel(true);
        taskOutput.append(Messages.getString("UploadDialog.task_cancelled")); //$NON-NLS-1$
    }
}

From source file:latexstudio.editor.DropboxRevisionsTopComponent.java

public void updateRevisionsList(String path) {
    DbxClient client = DbxUtil.getDbxClient();
    List<DbxEntry.File> entries = null;

    if (path != null) {
        try {/*ww w.j  av a 2 s  .c o  m*/
            entries = client.getRevisions(path);
        } catch (DbxException ex) {
            DbxUtil.showDbxAccessDeniedPrompt();
        }
    }

    dlm.clear();
    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == REVIEW_COLUMN;
        }
    };
    model.addColumn(REVISION_COLUMN_NAME);
    model.addColumn(MODIFIED_COLUMN_NAME);
    model.addColumn(FILE_SIZE_COLUMN_NAME);
    model.addColumn(REVIEW_COLUMN_NAME);

    if (entries != null && entries.size() > 0) {
        for (DbxEntry.File dbxEntry : entries) {
            dlm.addElement(new DbxEntryRevision(dbxEntry));
            model.addRow(new Object[] { dbxEntry.rev, dbxEntry.lastModified, dbxEntry.humanSize,
                    REVIEW_BUTTON_LABEL });
        }
    }

    Action showVersion = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Resolving which row has been double-clicked
            JTable table = (JTable) e.getSource();
            int row = Integer.valueOf(e.getActionCommand());
            // Finding revision using information from the clicked row
            String revisionNumber = table.getValueAt(row, REVISION_COLUMN).toString();
            loadRevision(revisionNumber);
        }
    };

    jTable1.setModel(model);
    ButtonColumn buttonColumn = new ButtonColumn(jTable1, showVersion, REVIEW_COLUMN);
    buttonColumn.setMnemonic(KeyEvent.VK_D);
}

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(Constants.ACTION_CHANGE_USERACCOUNTS)) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                reload();//from  w  ww.j a  v a 2  s  .  c om
            }
        });
        t.setPriority(Thread.NORM_PRIORITY);
        t.start();
    }
}

From source file:ca.sfu.federation.viewer.propertysheet.PointPropertySheet.java

private void jtfZActionListener(java.awt.event.ActionEvent evt) {
    String command = evt.getActionCommand();
    logger.log(Level.INFO, "ComponentSheet jtfZActionListener fired {0}", command);
    try {//from   w  w  w . j a va2s  . c  o  m
        BeanProxy proxy = new BeanProxy(this.target);
        proxy.set("Z", evt.getActionCommand());
    } catch (Exception ex) {
        String stack = ExceptionUtils.getFullStackTrace(ex);
        logger.log(Level.WARNING, "{0}", stack);
    }
}

From source file:org.jfree.chart.demo.CompassDemo.java

/**
 * Handles an action event./*from  www  .j a  v a 2  s. c  om*/
 *
 * @param e  the event.
 */
void pick2PointerActionPerformed(final ActionEvent e) {
    if (CompassDemo.DEBUG) {
        System.out.println("compassDemo:pick2PointActionPerformed " + e.getActionCommand() + ",");
    }
    this.compassPlot.setSeriesNeedle(1, this.pick2Pointer.getSelectedIndex());
    this.compassPlot.setSeriesPaint(1, Color.red);
    this.compassPlot.setSeriesOutlinePaint(1, Color.red);
}

From source file:ca.sfu.federation.viewer.propertysheet.PointPropertySheet.java

private void jtfYActionListener(java.awt.event.ActionEvent evt) {
    String command = evt.getActionCommand();
    logger.log(Level.INFO, "ComponentSheet jtfYActionListener fired {0}", command);
    try {/*  w ww  . j  ava 2  s  .c om*/
        BeanProxy proxy = new BeanProxy(this.target);
        proxy.set("Y", evt.getActionCommand());
    } catch (Exception ex) {
        String stack = ExceptionUtils.getFullStackTrace(ex);
        logger.log(Level.WARNING, "{0}", stack);
    }

}

From source file:ca.sfu.federation.viewer.propertysheet.PointPropertySheet.java

private void jtfXActionListener(java.awt.event.ActionEvent evt) {
    String command = evt.getActionCommand();
    logger.log(Level.INFO, "ComponentSheet jtfXActionListener fired {0}", command);
    try {//from  ww  w .j av  a  2s. co m
        BeanProxy proxy = new BeanProxy(this.target);
        proxy.set("X", evt.getActionCommand());
    } catch (Exception ex) {
        String stack = ExceptionUtils.getFullStackTrace(ex);
        logger.log(Level.WARNING, "{0}", stack);
    }

}