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:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java

private void init() {
    setLayout(new BorderLayout());

    contentPanel = new TierDataLayoutPanel();

    dateField = createDateField();//w  w w .  j a  va  2s.  co  m
    dateField.getTextField().setColumns(10);
    dateField.setBackground(Color.white);

    mediaLocationField = new MediaSelectionField(getEditor().getProject());
    mediaLocationField.setEditor(getEditor());
    mediaLocationField.getTextField().setColumns(10);
    mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener);

    participantTable = new JXTable();
    participantTable.setVisibleRowCount(3);

    ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable);
    ActionMap participantTableActionMap = new ActionMap();

    ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL);
    final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant");
    deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant");
    deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon);
    participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction);
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT");
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT");

    removeParticipantButton = new JButton(deleteAction);

    participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap);
    participantTable.setActionMap(participantTableActionMap);

    addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this));
    addParticipantButton.setFocusable(false);

    ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL);
    final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant");
    editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant...");
    editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant...");
    editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon);
    editParticipantButton = new JButton(editParticipantAct);
    editParticipantButton.setFocusable(false);

    final CellConstraints cc = new CellConstraints();
    FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow");
    JPanel participantPanel = new JPanel(participantLayout);
    participantPanel.setBackground(Color.white);
    participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2));
    participantPanel.add(addParticipantButton, cc.xy(2, 1));
    participantPanel.add(editParticipantButton, cc.xy(3, 1));
    participantPanel.add(removeParticipantButton, cc.xy(4, 2));
    participantTable.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) {
                editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit"));
            }
        }

    });

    languageField = new LanguageField();
    languageField.getDocument().addDocumentListener(languageFieldListener);

    int rowIdx = 0;
    final JLabel dateLbl = new JLabel("Session Date");
    dateLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel mediaLbl = new JLabel("Media");
    mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel partLbl = new JLabel("Participants");
    partLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel langLbl = new JLabel("Language");
    langLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    add(new JScrollPane(contentPanel), BorderLayout.CENTER);

    update();
}

From source file:org.apache.jmeter.gui.action.Save.java

@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
    HashTree subTree = null;//from  ww w.java2s  .c o  m
    boolean fullSave = false; // are we saving the whole tree?
    if (!commands.contains(e.getActionCommand())) {
        throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_AS)) {
        JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
        if (nodes.length > 1) {
            JMeterUtils.reportErrorToUser(JMeterUtils.getResString("save_as_error"), // $NON-NLS-1$
                    JMeterUtils.getResString("save_as")); // $NON-NLS-1$
            return;
        }
        subTree = GuiPackage.getInstance().getCurrentSubTree();
    } else if (e.getActionCommand().equals(ActionNames.SAVE_AS_TEST_FRAGMENT)) {
        JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
        if (checkAcceptableForTestFragment(nodes)) {
            subTree = GuiPackage.getInstance().getCurrentSubTree();
            // Create Test Fragment node
            TestElement element = GuiPackage.getInstance()
                    .createTestElement(TestFragmentControllerGui.class.getName());
            HashTree hashTree = new ListedHashTree();
            HashTree tfTree = hashTree.add(new JMeterTreeNode(element, null));
            for (JMeterTreeNode node : nodes) {
                // Clone deeply current node
                TreeCloner cloner = new TreeCloner(false);
                GuiPackage.getInstance().getTreeModel().getCurrentSubTree(node).traverse(cloner);
                // Add clone to tfTree
                tfTree.add(cloner.getClonedTree());
            }

            subTree = hashTree;

        } else {
            JMeterUtils.reportErrorToUser(JMeterUtils.getResString("save_as_test_fragment_error"), // $NON-NLS-1$
                    JMeterUtils.getResString("save_as_test_fragment")); // $NON-NLS-1$
            return;
        }
    } else {
        fullSave = true;
        HashTree testPlan = GuiPackage.getInstance().getTreeModel().getTestPlan();
        // If saveWorkBench 
        if (isWorkbenchSaveable()) {
            HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
            testPlan.add(workbench);
        }
        subTree = testPlan;
    }

    String updateFile = GuiPackage.getInstance().getTestPlanFile();
    if (!ActionNames.SAVE.equals(e.getActionCommand()) || updateFile == null) {
        JFileChooser chooser = FileDialoger.promptToSaveFile(updateFile == null
                ? GuiPackage.getInstance().getTreeListener().getCurrentNode().getName() + JMX_FILE_EXTENSION
                : updateFile);
        if (chooser == null) {
            return;
        }
        updateFile = chooser.getSelectedFile().getAbsolutePath();
        // Make sure the file ends with proper extension
        if (FilenameUtils.getExtension(updateFile).isEmpty()) {
            updateFile = updateFile + JMX_FILE_EXTENSION;
        }
        // Check if the user is trying to save to an existing file
        File f = new File(updateFile);
        if (f.exists()) {
            int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
                    JMeterUtils.getResString("save_overwrite_existing_file"), // $NON-NLS-1$
                    JMeterUtils.getResString("save?"), // $NON-NLS-1$
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.NO_OPTION) {
                return; // Do not save, user does not want to overwrite
            }
        }

        if (!e.getActionCommand().equals(ActionNames.SAVE_AS)) {
            GuiPackage.getInstance().setTestPlanFile(updateFile);
        }
    }

    // backup existing file according to jmeter/user.properties settings
    List<File> expiredBackupFiles = EMPTY_FILE_LIST;
    File fileToBackup = new File(updateFile);
    try {
        expiredBackupFiles = createBackupFile(fileToBackup);
    } catch (Exception ex) {
        log.error("Failed to create a backup for " + fileToBackup.getName(), ex); //$NON-NLS-1$
    }

    try {
        convertSubTree(subTree);
    } catch (Exception err) {
        log.warn("Error converting subtree " + err);
    }

    FileOutputStream ostream = null;
    try {
        ostream = new FileOutputStream(updateFile);
        SaveService.saveTree(subTree, ostream);
        if (fullSave) { // Only update the stored copy of the tree for a full save
            subTree = GuiPackage.getInstance().getTreeModel().getTestPlan(); // refetch, because convertSubTree affects it
            if (isWorkbenchSaveable()) {
                HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
                subTree.add(workbench);
            }
            ActionRouter.getInstance()
                    .doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));
        }

        // delete expired backups : here everything went right so we can
        // proceed to deletion
        for (File expiredBackupFile : expiredBackupFiles) {
            try {
                FileUtils.deleteQuietly(expiredBackupFile);
            } catch (Exception ex) {
                log.warn("Failed to delete backup file " + expiredBackupFile.getName()); //$NON-NLS-1$
            }
        }
    } catch (Throwable ex) {
        log.error("Error saving tree:", ex);
        if (ex instanceof Error) {
            throw (Error) ex;
        }
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        throw new IllegalUserActionException("Couldn't save test plan to file: " + updateFile, ex);
    } finally {
        JOrphanUtils.closeQuietly(ostream);
    }
    GuiPackage.getInstance().updateCurrentGui();
}

From source file:org.wings.SAbstractButton.java

public void fireFinalEvents() {
    requestFocus();//from w ww .  j a  va  2  s.c o  m
    super.fireFinalEvents();
    fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getActionCommand()));
    if (buttonGroup != null)
        buttonGroup.fireDelayedFinalEvents();
}

From source file:com.funambol.admin.module.panels.DefaultSyncSourceConfigPanel.java

/**
 * Creates the panel//from   w  w  w. j  a va  2  s.c o  m
 */
private void init() {

    this.setLayout(null);

    titledBorder = new TitledBorder("");

    panelName.setFont(GuiFactory.titlePanelFont);
    panelName.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_EDIT) + " " + sourceTypeDescription);
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_Y = 30;

    sourceUriLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_URI) + ": ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    nameLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_NAME) + ": ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    infoTypesLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_SUPPORTED_TYPES) + ": ");
    infoTypesLabel.setFont(defaultFont);
    infoTypesLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    infoTypesValue.setFont(defaultFont);
    infoTypesValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    infoVersionsLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_SUPPORTED_VERSIONS) + ": ");
    infoVersionsLabel.setFont(defaultFont);
    infoVersionsLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    infoVersionsValue.setFont(defaultFont);
    infoVersionsValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    int x = LABEL_X;

    encryption.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_ENCRYPTION));
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });
    y += GAP_Y; // New line

    encoding.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_ENCODING));
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);
    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_ADD));
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    DefaultSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            DefaultSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    DefaultSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            DefaultSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(infoTypesLabel, null);
    this.add(infoTypesValue, null);
    this.add(infoVersionsLabel, null);
    this.add(infoVersionsValue, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}

From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java

@Override
public void mouseClicked(final MouseEvent event) {

    // Let the parent handle the event (selection etc.)
    super.mouseClicked(event);

    if (event.getX() < 70) { // User clicked on Y-axis
        if (event.getClickCount() == 2) { // Reset zoom on Y-axis
            XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
            Number maximum = DatasetUtilities.findMaximumRangeValue(data);
            getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
        } else if (event.getClickCount() == 1) {
            // Auto range on Y-axis
            getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
            getXYPlot().getRangeAxis().setAutoRange(true);
        }/*from ww  w .j  a  v  a 2s.co m*/
    } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41
            && event.getClickCount() == 2) {
        // Reset zoom on X-axis
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        restoreAutoDomainBounds();
    } else if (event.getClickCount() == 2) {
        visualizer.actionPerformed(
                new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
    }
}

From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java

@Override
public void mouseClicked(final MouseEvent event) {

    // Let the parent handle the event (selection etc.)
    super.mouseClicked(event);

    if (event.getX() < 70) { // User clicked on Y-axis
        if (event.getClickCount() == 2) { // Reset zoom on Y-axis
            XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
            Number maximum = DatasetUtils.findMaximumRangeValue(data);
            getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
        } else if (event.getClickCount() == 1) {
            // Auto range on Y-axis
            getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
            getXYPlot().getRangeAxis().setAutoRange(true);
        }//from   ww w. jav a  2 s .  c o m
    } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41
            && event.getClickCount() == 2) {
        // Reset zoom on X-axis
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        restoreAutoDomainBounds();
    } else if (event.getClickCount() == 2) {
        visualizer.actionPerformed(
                new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
    }
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

public void setChart(JFreeChart chart) {
    this.jFreeChart = chart;
    recalcScrollBar(jFreeChart.getPlot());
    if (chartPanel != null) {
        remove(chartPanel);//w ww .  j av  a2  s.  c  o m
    }
    this.chartPanel = new ChartPanel(jFreeChart);
    jFreeChart.addChangeListener(this);

    // enable zoom
    actionPerformed(new ActionEvent(this, 0, ACTION_CHART_ZOOM_BOX));

    // MouseListeners for pan function
    this.chartPanel.addMouseListener(this);
    this.chartPanel.addMouseMotionListener(this);

    // remove popup menu to allow panning
    // with right mouse pressed
    this.chartPanel.setPopupMenu(null);

    XYPlot vvPlot = (XYPlot) chart.getXYPlot();
    ValueAxis axis = vvPlot.getRangeAxis();
    yMax = axis.getMaximumAxisValue();
    yMin = axis.getMinimumAxisValue();

    add(chartPanel, BorderLayout.CENTER);

}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeChooserDialog.java

public TvShowEpisodeChooserDialog(TvShowEpisode ep, MediaScraper mediaScraper) {
    super(BUNDLE.getString("tvshowepisode.choose"), "episodeChooser"); //$NON-NLS-1$
    setBounds(5, 5, 600, 400);//w ww  . j  a  v  a  2s. com

    this.episode = ep;
    this.mediaScraper = mediaScraper;
    this.metadata = new MediaEpisode(mediaScraper.getId());
    episodeEventList = new ObservableElementList<>(
            GlazedLists.threadSafeList(new BasicEventList<TvShowEpisodeChooserModel>()),
            GlazedLists.beanConnector(TvShowEpisodeChooserModel.class));
    sortedEpisodes = new SortedList<>(GlazedListsSwing.swingThreadProxyList(episodeEventList),
            new EpisodeComparator());

    getContentPane().setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("590px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:37px"),
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    {
        JSplitPane splitPane = new JSplitPane();
        getContentPane().add(splitPane, "2, 2, fill, fill");

        JPanel panelLeft = new JPanel();
        panelLeft.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        textField = EnhancedTextField.createSearchTextField();
        panelLeft.add(textField, "2, 2, fill, default");
        textField.setColumns(10);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setMinimumSize(new Dimension(200, 23));
        panelLeft.add(scrollPane, "2, 4, fill, fill");
        splitPane.setLeftComponent(panelLeft);

        MatcherEditor<TvShowEpisodeChooserModel> textMatcherEditor = new TextComponentMatcherEditor<>(textField,
                new TvShowEpisodeChooserModelFilterator());
        FilterList<TvShowEpisodeChooserModel> textFilteredEpisodes = new FilterList<>(sortedEpisodes,
                textMatcherEditor);
        AdvancedTableModel<TvShowEpisodeChooserModel> episodeTableModel = GlazedListsSwing
                .eventTableModelWithThreadProxyList(textFilteredEpisodes, new EpisodeTableFormat());
        DefaultEventSelectionModel<TvShowEpisodeChooserModel> selectionModel = new DefaultEventSelectionModel<>(
                textFilteredEpisodes);
        selectedEpisodes = selectionModel.getSelected();

        selectionModel.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                    return;
                }
                // display first selected episode
                if (!selectedEpisodes.isEmpty()) {
                    TvShowEpisodeChooserModel episode = selectedEpisodes.get(0);
                    taPlot.setText(episode.getOverview());
                } else {
                    taPlot.setText("");
                }
                taPlot.setCaretPosition(0);
            }
        });

        table = new JTable(episodeTableModel);
        table.setSelectionModel(selectionModel);
        scrollPane.setViewportView(table);

        JPanel panelRight = new JPanel();
        panelRight.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, }));
        JScrollPane scrollPane_1 = new JScrollPane();
        panelRight.add(scrollPane_1, "2, 2, fill, fill");
        splitPane.setRightComponent(panelRight);

        taPlot = new JTextArea();
        taPlot.setEditable(false);
        taPlot.setWrapStyleWord(true);
        taPlot.setLineWrap(true);
        scrollPane_1.setViewportView(taPlot);
        splitPane.setDividerLocation(300);

    }
    JPanel bottomPanel = new JPanel();
    getContentPane().add(bottomPanel, "2, 4, fill, top");

    bottomPanel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"),
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JPanel buttonPane = new JPanel();
    bottomPanel.add(buttonPane, "5, 2, fill, fill");
    EqualsLayout layout = new EqualsLayout(5);
    layout.setMinWidth(100);
    buttonPane.setLayout(layout);
    final JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
    okButton.setToolTipText(BUNDLE.getString("tvshow.change"));
    okButton.setIcon(IconManager.APPLY);
    buttonPane.add(okButton);
    okButton.setActionCommand("OK");
    okButton.addActionListener(this);

    JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
    cancelButton.setToolTipText(BUNDLE.getString("edit.discard"));
    cancelButton.setIcon(IconManager.CANCEL);
    buttonPane.add(cancelButton);
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);

    // column widths
    table.getColumnModel().getColumn(0).setMaxWidth(50);
    table.getColumnModel().getColumn(1).setMaxWidth(50);

    SearchTask task = new SearchTask();
    task.execute();

    MouseListener mouseListener = new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2 && !e.isConsumed() && e.getButton() == MouseEvent.BUTTON1) {
                actionPerformed(new ActionEvent(okButton, ActionEvent.ACTION_PERFORMED, "OK"));
            }
        }

    };
    table.addMouseListener(mouseListener);
}

From source file:org.kepler.gui.popups.LibraryPopupListener.java

/** Handle a double-click action. */
private void handleDoubleClickOutsideKar(TreePath selPath, MouseEvent event) {
    Object ob = selPath.getLastPathComponent();

    if (ob instanceof EntityLibrary) {
        return;//from www  .  j a  va 2 s  .com
    } else {

        int liid = LibraryManager.getLiidFor((ComponentEntity) ob);
        LibItem li = null;
        try {
            li = LibraryManager.getInstance().getPopulatedLibItem(liid);
        } catch (SQLException e) {
            MessageHandler.error("Error accessinc library item.", e);
            return;
        }

        // open it if it's a MoML
        String filePath = li.getAttributeValue(LibIndex.ATT_XMLFILE);
        if (filePath != null) {
            Component component = _aptree.getParentComponent();
            while (component != null && !(component instanceof TableauFrame)) {
                component = component.getParent();
            }
            if (component == null) {
                MessageHandler.error("Could not find TableauFrame.");
                return;
            }
            Configuration configuration = ((TableauFrame) component).getConfiguration();
            try {
                URL url = new File(filePath).toURI().toURL();
                configuration.openModel(url, url, url.toExternalForm());
            } catch (Exception e) {
                MessageHandler.error("Error opening " + filePath, e);
            }

            // if we successfully opened a file, update the history menu and
            // set the last directory.

            // update the history menu
            if (component instanceof KeplerGraphFrame) {
                try {
                    ((KeplerGraphFrame) component).updateHistory(filePath);
                } catch (IOException exception) {
                    MessageHandler.error("Unable to update history menu.", exception);
                }
            }
            if (component instanceof BasicGraphFrame) {
                ((BasicGraphFrame) component).setLastDirectory(new File(filePath).getParentFile());
            }

        } else if (li.getLsid() != null) {
            // if it has an lsid, show the documentation
            Component component = _aptree.getParentComponent();
            while (component != null && !(component instanceof PtolemyFrame)) {
                component = component.getParent();
            }
            if (component == null) {
                MessageHandler.error("Could not find TableauFrame.");
                return;
            }
            ShowDocumentationAction action = new ShowDocumentationAction(selPath, _aptree.getParentComponent());
            action.setLsidToView(li.getLsid());
            action.setPtolemyFrame((PtolemyFrame) component);

            action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_FIRST, "open"));
        }
    }
}

From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationVisualizer.java

/**
 * Visualize just the events specified/*from   w w  w  .  ja  va2 s  . com*/
 * TODO: fold parts of this in with the no-arg visualizeQuantEvents
 * @param quantEvents
 * @throws IOException
 * @return the list of QuantEvents in the order in which they were written to the file(s)
 */
public List<QuantEvent> visualizeQuantEvents(List<QuantEvent> quantEvents, boolean saveInProteinDirs)
        throws IOException {
    if (outHtmlFile == null)
        outHtmlFile = new File(outDir, "quantitation.html");
    if (outTsvFile == null)
        outTsvFile = new File(outDir, "quantitation.tsv");
    tsvFileAlreadyExists = outTsvFile.exists();
    if (writeHTMLAndText) {
        outHtmlPW = new PrintWriter(outHtmlFile);
        outTsvPW = new PrintWriter(new FileOutputStream(outTsvFile, appendTsvOutput));

        //if we're appending, don't write header.  Cheating by writing it to a fake file
        PrintWriter conditionalTsvPW = outTsvPW;
        if (appendTsvOutput && tsvFileAlreadyExists)
            conditionalTsvPW = new PrintWriter(
                    TempFileManager.createTempFile("fake_file", "fake_file_for_quantvisualizer"));

        QuantEvent.writeHeader(outHtmlPW, conditionalTsvPW, showProteinColumn, show3DPlots);
        _log.debug("Wrote header to HTML file " + outHtmlFile.getAbsolutePath() + " and tsv file "
                + outTsvFile.getAbsolutePath());
        TempFileManager.deleteTempFiles("fake_file_for_quantvisualizer");
    }
    if (outTurkFile != null) {
        outTurkPW = new PrintWriter(outTurkFile);
        outTurkPW.println(TurkUtilities.createTurkHITFileHeaderLine());
        outTurkPW.flush();
    }

    //map from fraction name to list of events in that fraction
    Map<String, List<QuantEvent>> fractionEventMap = new HashMap<String, List<QuantEvent>>();

    for (QuantEvent quantEvent : quantEvents) {
        List<QuantEvent> eventList = fractionEventMap.get(quantEvent.getFraction());
        if (eventList == null) {
            eventList = new ArrayList<QuantEvent>();
            fractionEventMap.put(quantEvent.getFraction(), eventList);
        }
        eventList.add(quantEvent);

    }
    //sort events by scan within fractions, to keep recently-used scans in cache
    Comparator<QuantEvent> scanAscComp = new QuantEvent.ScanAscComparator();
    for (List<QuantEvent> eventList : fractionEventMap.values())
        Collections.sort(eventList, scanAscComp);
    int numEventsProcessed = 0;

    //listeners that want to be updated when we finish an event
    ActionListener[] progressListeners = dummyProgressButton.getActionListeners();

    List<QuantEvent> resortedEvents = new ArrayList<QuantEvent>();
    for (String fraction : fractionEventMap.keySet()) {
        File mzXmlFile = CommandLineModuleUtilities.findFileWithPrefix(fraction + ".", mzXmlDir, "mzXML");
        MSRun run = MSRun.load(mzXmlFile.getAbsolutePath());

        for (QuantEvent quantEvent : fractionEventMap.get(fraction)) {
            resortedEvents.add(quantEvent);
            File outDirThisEvent = outDir;
            if (saveInProteinDirs && shouldCreateCharts) {
                String protein = quantEvent.getProtein();
                outDirThisEvent = new File(outDir, protein);
                outDirThisEvent.mkdir();
            }
            handleEvent(run, outDirThisEvent, quantEvent.getProtein(), fraction, quantEvent);
            numEventsProcessed++;

            if (progressListeners != null) {
                ActionEvent event = new ActionEvent(dummyProgressButton, 0, "" + numEventsProcessed);
                for (ActionListener listener : progressListeners)
                    listener.actionPerformed(event);
            }
        }
    }

    if (writeHTMLAndText) {
        QuantEvent.writeFooterAndClose(outHtmlPW, outTsvPW);
        ApplicationContext.infoMessage("Saved HTML file " + outHtmlFile.getAbsolutePath());
        ApplicationContext.infoMessage("Saved TSV file " + outTsvFile.getAbsolutePath());
    }
    if (outTurkFile != null) {
        try {
            outTurkPW.close();
        } catch (Exception e) {
        }
    }

    return resortedEvents;
}