Example usage for java.awt.event ActionEvent ActionEvent

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

Introduction

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

Prototype

public ActionEvent(Object source, int id, String command) 

Source Link

Document

Constructs an ActionEvent object.

Usage

From source file:de.juwimm.cms.Main.java

private void showToolPanel(boolean withSelection, ActionEvent e) throws Exception {
    if (Constants.CMS_CLIENT_VIEW != Constants.CLIENT_VIEW_CONTENT) {
        panRibbon.setView(true);//from  ww w . ja  va  2s. c  o  m
        try {
            panTool = PanTool.getInstance();
            panTool.reload(withSelection, e.getSource());
        } catch (UserHasNoUnitsException ex) {
            JOptionPane.showMessageDialog(UIConstants.getMainFrame(), ex.getMessage(),
                    rb.getString("msgbox.title.loginFailed"), JOptionPane.ERROR_MESSAGE);
            ActionHub.fireActionPerformed(
                    new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_LOGOFF));
            return;
        } catch (NullPointerException npe) {
            panTool.setTreeToEmpty();
            JOptionPane.showMessageDialog(UIConstants.getMainFrame(), rb.getString("exception.SiteIsEmpty"),
                    rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE);
        }
        setCenterPanel(panTool);
    }
}

From source file:com.alvermont.terraj.planet.ui.MainFrame.java

/**
 * Set up our list model from the projection list
 *//*from  w w  w  .  j a v a2  s .  c o  m*/
protected void setListModel() {
    final DefaultComboBoxModel<Projector> dcm = new DefaultComboBoxModel<>();

    for (Projector p : projManager.getProjections()) {
        dcm.addElement(p);
    }

    projComboBox.setModel(dcm);

    // make the first one selected
    dcm.setSelectedItem(dcm.getElementAt(0));

    // TODO: do this properly
    projComboBoxActionPerformed(new ActionEvent(this, 0, "Hack"));
}

From source file:DragPictureDemo2.java

public void actionPerformed(ActionEvent e) {
    if (focusOwner == null)
        return;//from   w w w  .  ja v  a 2 s.c om
    String action = (String) e.getActionCommand();
    Action a = focusOwner.getActionMap().get(action);
    if (a != null) {
        a.actionPerformed(new ActionEvent(focusOwner, ActionEvent.ACTION_PERFORMED, null));
    }
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep1(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"),
            localeDelegate.getMessage("dbtransfer.import.step1.2",
                    "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus."));

    final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei"));

    utils.initJPanel(step,/*from ww  w .  ja  v a 2  s.c o  m*/
            new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
                    TableLayout.FILL },
            new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL });

    final JButton btnBrowse = new JButton("...");
    //final JProgressBar progressBar = new JProgressBar(0, 230);
    final JCheckBox chbxImportAsNuclon = new JCheckBox(
            localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon"));
    chbxImportAsNuclon.setEnabled(false);
    final JEditorPane editWarnings = new JEditorPane();
    editWarnings.setContentType("text/html");
    editWarnings.setEditable(false);
    editWarnings.setBackground(Color.WHITE);

    final JScrollPane scrollWarn = new JScrollPane(editWarnings);
    scrollWarn.setPreferredSize(new Dimension(680, 250));
    scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    scrollWarn.getVerticalScrollBar().setUnitIncrement(20);
    scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent);
    scrollPrev.setPreferredSize(new Dimension(680, 250));
    scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    scrollPrev.getVerticalScrollBar().setUnitIncrement(20);
    scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JPanel jpnPreview = new JPanel(new BorderLayout());
    jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH);
    jpnPreview.add(scrollPrev, BorderLayout.CENTER);
    jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH);
    jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jpnPreview.setBackground(Color.WHITE);
    jpnPreviewHeader.setBackground(Color.WHITE);
    jpnPreviewContent.setBackground(Color.WHITE);
    jpnPreviewFooter.setBackground(Color.WHITE);

    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"),
            scrollWarn);
    final String sDefaultPreparePreviewTabText = localeDelegate
            .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen");
    tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview);

    final JLabel lbNewUser = new JLabel();

    step.add(lbFile, "0,0");
    step.add(tfTransferFile, "1,0");
    step.add(btnBrowse, "2,0");
    step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1");
    step.add(lbNewUser, "0,2,3,2");
    step.add(tabbedPane, "0,3,3,3");

    tfTransferFile.setEditable(false);

    final ActionListener prepareImportAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE);

            Thread t = new Thread() {
                @Override
                public void run() {
                    step.setComplete(false);
                    boolean blnTransferWithWarnings = false;
                    //progressBar.setValue(0);
                    //progressBar.setVisible(true);
                    try {
                        String fileName = tfTransferFile.getText();
                        if (StringUtils.isNullOrEmpty(fileName)) {
                            return;
                        }
                        File f = new File(fileName);
                        long size = f.length();

                        final InputStream fin = new BufferedInputStream(new FileInputStream(f));
                        final byte[] transferFile;
                        try {
                            transferFile = utils.getBytes(fin, (int) size);
                        } finally {
                            fin.close();
                        }

                        resetStep2();
                        importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon,
                                transferFile);
                        chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions()
                                .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED));

                        step.setComplete(!importTransferObject.result.hasCriticals());

                        if (!importTransferObject.result.hasCriticals()
                                && !importTransferObject.result.hasWarnings()) {
                            editWarnings.setText(localeDelegate.getMessage(
                                    "configuration.transfer.prepare.no.warnings", "Keine Warnungen"));
                        } else {
                            editWarnings.setText("<html><body><font color=\"#800000\">"
                                    + importTransferObject.result.getCriticals() + "</font>"
                                    + (importTransferObject.result.hasCriticals() ? "<br />" : "")
                                    + importTransferObject.result.getWarnings() + "</body></html>");
                        }

                        int iPreviewSize = importTransferObject.getPreviewParts().size();
                        blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts());
                        tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText
                                + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")"));
                        lbNewUser.setText(
                                "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine"
                                        : importTransferObject.getNewUserCount()));
                    } catch (Exception e) {
                        //                              progressBar.setVisible(false);
                        Errors.getInstance().showExceptionDialog(ifrm, e);
                    } finally {
                        btnBrowse.setEnabled(true);
                        //                              progressBar.setVisible(false);
                        ifrm.unlockLayer();
                    }
                    if (blnTransferWithWarnings) {
                        JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage(
                                "dbtransfer.import.step1.19",
                                "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!",
                                "Warning", JOptionPane.WARNING_MESSAGE));
                    }
                }

            };

            t.start();
        }
    };
    final ActionListener browseAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            final JFileChooser filechooser = utils.getFileChooser(
                    localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"),
                    ".nuclet");
            final int iBtn = filechooser.showOpenDialog(ifrm);

            if (iBtn == JFileChooser.APPROVE_OPTION) {

                final File file = filechooser.getSelectedFile();
                if (file != null) {
                    tfTransferFile.setText("");
                    btnBrowse.setEnabled(false);
                    //progressBar.setVisible(true);

                    String fileName = file.getPath();
                    if (StringUtils.isNullOrEmpty(fileName)) {
                        return;
                    }

                    tfTransferFile.setText(fileName);

                    prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
                }
            }
        }
    };
    final ActionListener importAsNuclonAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            isNuclon = chbxImportAsNuclon.isSelected();
            prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
        }
    };
    btnBrowse.addActionListener(browseAction);
    chbxImportAsNuclon.addActionListener(importAsNuclonAction);

    //      progressBar.setVisible(false);

    return step;
}

From source file:de.juwimm.cms.Main.java

public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {//from   ww w  .  j  a v a 2  s. c o m
        if (action.equals(Constants.ACTION_EXIT)) {
            if (ActionHub.fireExitPerformed(new ExitEvent())) {
                comm.getDbHelper().shutdown();
                System.exit(0);
            }
        } else if (action.equals(Constants.ACTION_LOGIN)) {
            this.setLayout(new BorderLayout());
            Constants.CMS_CLIENT_VIEW = -1;
            setCenterPanel(PanInitView.getInstance());

            if (panStatusbar == null) {
                panStatusbar = new PanStatusbar();
                UIConstants.setStatusLine(panStatusbar);
                ActionHub.addActionListener(panStatusbar);
            }

            if (panRibbon == null) {
                panRibbon = new PanRibbon(comm);
                ActionHub.addActionListener(panRibbon);
            }
            this.getContentPane().add(panRibbon, BorderLayout.NORTH);
            ActionHub.fireActionPerformed(
                    new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_VIEW_EDITOR));

            //      this.getJMenuBar().setVisible(true);
            //      this.getContentPane().add(panToolbar, BorderLayout.NORTH);
            this.getContentPane().add(panStatusbar, BorderLayout.SOUTH);

            this.getRootPane().setDoubleBuffered(true);
            this.getRootPane().validate();
            this.getRootPane().repaint();
        } else if (action.equals(Constants.ACTION_LOGOFF)) {
            if (ActionHub.fireExitPerformed(new ExitEvent())) {
                comm.setLoggedIn(false);
                Application.initializeContext();
                panLogin = new PanLogin();
                panRoot = null;
                panAdmin = null;
                panRibbon = null;
                this.getContentPane().removeAll();
                //this.getJMenuBar().setVisible(false);
                comm.getDbHelper().autoEmptyCache();
                PanContentView.getInstance().unloadAll();
                setCenterPanel(panLogin);
                Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN;
                this.validate();
                this.getContentPane().validate();
                this.getContentPane().repaint();
                this.repaint();
                panLogin.init();
            }
        } else if (action.equals(Constants.ACTION_VIEW_EDITOR)) {
            showToolPanel(false, e);
            panTool = PanTool.getInstance();
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        } else if (action.equals(Constants.ACTION_VIEW_EDITOR_WITH_SELECTION)) {
            showToolPanel(true, e);
            panTool = PanTool.getInstance();
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        } else if (action.equals(Constants.ACTION_VIEW_ADMIN) || action.equals(Constants.ACTION_VIEW_ROOT)) {
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_ADMIN;
            showAdminPanel();
            panStatusbar.setCountVisible(false);
        } else if (action.equals(Constants.ACTION_CHANGE_PASSWORD)) {
            showChangePasswordDialog();
        } else if (action.equals(Constants.ACTION_SHOW_TASK)) {
            showTaskPanel();
            panStatusbar.setCountVisible(false);
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_TASK;
        } else if (action.equals(Constants.ACTION_SHOW_CONTENT)) {
            Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT;
        }
    } catch (Exception exe) {
        log.error("Error in actionPerformed", exe);
    } finally {
        this.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionReport(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) {
    OpenReportAction openAction = new OpenReportAction();
    openAction.setReportName(selectedNode.getDBObject().getName());
    openAction.setReportPath(selectedNode.getDBObject().getAbsolutePath());

    if (e.getClickCount() == 2) {
        if (pressed) {
            openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), ""));
        }// w  w  w.ja v a 2s .  c o  m
    } else {
        JPopupMenu popupMenu = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(openAction);
        popupMenu.add(menuItem);

        DeleteReportAction deleteAction = new DeleteReportAction(instance, selectedNode);
        JMenuItem menuItem2 = new JMenuItem(deleteAction);
        popupMenu.add(menuItem2);

        RenameReportAction renameAction = new RenameReportAction(instance, selectedNode);
        JMenuItem menuItem3 = new JMenuItem(renameAction);
        popupMenu.add(menuItem3);

        ExportReportAction exportAction = new ExportReportAction(instance, selectedNode);
        JMenuItem menuItem4 = new JMenuItem(exportAction);
        popupMenu.add(menuItem4);

        Report report = FormLoader.getInstance().load(selectedNode.getDBObject().getAbsolutePath(), false);
        JMenu runMenu = new JMenu(I18NSupport.getString("export"));
        Globals.setTreeReportAbsolutePath(selectedNode.getDBObject().getAbsolutePath());
        runMenu.add(new JMenuItem(new ExportToHtmlAction(report)));
        runMenu.add(new JMenuItem(new ExportToExcelAction(report)));
        runMenu.add(new JMenuItem(new ExportToPdfAction(report)));
        runMenu.add(new JMenuItem(new ExportToDocxAction(report)));
        runMenu.add(new JMenuItem(new ExportToRtfAction(report)));
        runMenu.add(new JMenuItem(new ExportToCsvAction(report)));
        runMenu.add(new JMenuItem(new ExportToTsvAction(report)));
        runMenu.add(new JMenuItem(new ExportToXmlAction(report)));
        runMenu.add(new JMenuItem(new ExportToTxtAction(report)));
        popupMenu.add(runMenu);

        PublishReportAction publishAction = new PublishReportAction(
                selectedNode.getDBObject().getAbsolutePath());
        JMenuItem menuItem5 = new JMenuItem(publishAction);
        popupMenu.add(menuItem5);

        JMenuItem menuItem6 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem6);

        JMenuItem menuItem7 = new JMenuItem(new AddToFavoritesAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem7);

        popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
    }
}

From source file:com.projity.pm.graphic.frames.DocumentFrame.java

public void doCut() {
    SpreadSheet ss = getActiveSpreadSheet();
    if (ss != null)
        ss.prepareAction(MenuActionConstants.ACTION_CUT).actionPerformed(new ActionEvent(ss, 0, null));
    //NodeListTransferHandler.getCutAction(ss).actionPerformed(new ActionEvent(this,0,null));
    //ss.executeAction(SpreadSheet.CUT);
}

From source file:com.projity.pm.graphic.frames.DocumentFrame.java

public void doCopy() {
    SpreadSheet ss = getActiveSpreadSheet();
    if (ss != null)
        ss.prepareAction(MenuActionConstants.ACTION_COPY).actionPerformed(new ActionEvent(ss, 0, null));
    //NodeListTransferHandler.getCopyAction(ss).actionPerformed(new ActionEvent(this,0,null));
    //ss.executeAction(SpreadSheet.COPY);
}

From source file:com.projity.pm.graphic.frames.DocumentFrame.java

public void doPaste() {
    SpreadSheet ss = getActiveSpreadSheet();
    if (ss != null)
        ss.prepareAction(MenuActionConstants.ACTION_PASTE).actionPerformed(new ActionEvent(ss, 0, null));
    //NodeListTransferHandler.getPasteAction(ss).actionPerformed(new ActionEvent(this,0,null));
    //ss.executeAction(SpreadSheet.PASTE);
}

From source file:org.apache.jmeter.visualizers.RespTimeGraphVisualizer.java

@Override
public void actionPerformed(ActionEvent event) {
    boolean forceReloadData = false;
    final Object eventSource = event.getSource();
    if (eventSource == displayButton) {
        actionMakeGraph();/*from  w  w  w  .  ja v  a 2 s  .c o m*/
    } else if (eventSource == saveGraph) {
        saveGraphToFile = true;
        try {
            ActionRouter.getInstance().getAction(ActionNames.SAVE_GRAPHICS, SaveGraphics.class.getName())
                    .doAction(new ActionEvent(this, event.getID(), ActionNames.SAVE_GRAPHICS));
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    } else if (eventSource == syncWithName) {
        graphTitle.setText(namePanel.getName());
    } else if (eventSource == dynamicGraphSize) {
        enableDynamicGraph(dynamicGraphSize.isSelected());
    } else if (eventSource == samplerSelection) {
        enableSamplerSelection(samplerSelection.isSelected());
        if (!samplerSelection.isSelected()) {
            // Force reload data
            forceReloadData = true;
        }
    }
    // Not 'else if' because forceReloadData 
    if (eventSource == applyFilterBtn || eventSource == intervalButton || forceReloadData) {
        if (eventSource == intervalButton) {
            intervalValue = Integer.parseInt(intervalField.getText());
        }
        if (eventSource == applyFilterBtn && samplerSelection.isSelected()
                && samplerMatchLabel.getText() != null && samplerMatchLabel.getText().length() > 0) {
            pattern = createPattern(samplerMatchLabel.getText());
        } else if (forceReloadData) {
            pattern = null;
            matcher = null;
        }
        if (getFile() != null && getFile().length() > 0) {
            // Reload data from file
            clearData();
            FilePanel filePanel = (FilePanel) getFilePanel();
            filePanel.actionPerformed(event);
        } else {
            // Reload data form internal list of results
            synchronized (lockInterval) {
                if (internalList.size() >= 2) {
                    List<RespTimeGraphDataBean> tempList = new ArrayList<>();
                    tempList.addAll(internalList);
                    this.clearData();
                    for (RespTimeGraphDataBean data : tempList) {
                        SampleResult sr = new SampleResult(data.getStartTime(), data.getTime());
                        sr.setSampleLabel(data.getSamplerLabel());
                        this.add(sr);
                    }
                }
            }
        }
    }
}