Search in sources :

Example 81 with AbstractAction

use of javax.swing.AbstractAction in project knime-core by knime.

the class ScatterPlotter method getShowAllAction.

/**
 * The <code>ScatterPlotter</code> adds the posssibility to show, fade or
 * hide unhilited dots and this is the show all action. The hide flag is
 * administered in the <code>ScatterPlotter</code>, since hidden points
 * are not passed to the
 * {@link org.knime.base.node.viz.plotter.scatter
 * .ScatterPlotterDrawingPane},
 * the fade flag is administered in the
 * {@link org.knime.base.node.viz.plotter.scatter
 * .ScatterPlotterDrawingPane},
 * since the dots are painted but with a different (faded) color.
 *
 * @return the menu item for show all.
 */
public Action getShowAllAction() {
    Action show = new AbstractAction(AbstractPlotter.SHOW_ALL) {

        /**
         * {@inheritDoc}
         */
        @Override
        public void actionPerformed(final ActionEvent e) {
            m_hide = false;
            if (getDrawingPane() instanceof ScatterPlotterDrawingPane) {
                getScatterPlotterDrawingPane().setFadeUnhilited(false);
            }
            updatePaintModel();
        }
    };
    return show;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 82 with AbstractAction

use of javax.swing.AbstractAction in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method editInPlace.

private void editInPlace(final LargeShape selectedShape) {
    if (shapePanel.getComponentCount() > 0) {
        // remove if there's one already present
        // this is the only component that may exist in this panel
        shapePanel.remove(0);
    }
    Rectangle labelOutline = selectedShape.getLabelOutline();
    Font font = selectedShape.getLabelFont();
    // Add press 'Enter' action, 'Escape' action, editor gets focus and mouse 'Exit' parent action
    final JTextField jTextField = new JTextField(selectedShape.getFullName());
    jTextField.setFont(font);
    jTextField.selectAll();
    jTextField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                String name = jTextField.getText();
                // Type specific edit actions
                if (selectedShape instanceof MolecularTypeLargeShape) {
                    ((MolecularTypeLargeShape) selectedShape).getMolecularType().setName(name);
                } else if (selectedShape instanceof MolecularComponentLargeShape) {
                    ((MolecularComponentLargeShape) selectedShape).getMolecularComponent().setName(name);
                } else if (selectedShape instanceof ComponentStateLargeShape) {
                    ((ComponentStateLargeShape) selectedShape).getComponentStateDefinition().setName(name);
                }
            } catch (Exception e2) {
                e2.printStackTrace();
                DialogUtils.showErrorDialog(shapePanel, e2.getMessage());
                shapePanel.remove(0);
                updateInterface();
            }
            if (shapePanel.getComponentCount() > 0) {
                shapePanel.remove(0);
            }
        }
    });
    InputMap im = jTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap am = jTextField.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), "cancelChange");
    am.put("cancelChange", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            shapePanel.remove(0);
            updateInterface();
        }
    });
    final int MinWidth = 30;
    jTextField.setBounds(labelOutline.x, labelOutline.y, Math.max(labelOutline.width, MinWidth), labelOutline.height);
    shapePanel.add(jTextField);
    // shapePanel.validate();
    jTextField.requestFocus();
    return;
}
Also used : ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) Rectangle(java.awt.Rectangle) JTextField(javax.swing.JTextField) Font(java.awt.Font) ExpandVetoException(javax.swing.tree.ExpandVetoException) Point(java.awt.Point) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) ActionListener(java.awt.event.ActionListener) ComponentStateLargeShape(cbit.vcell.graph.MolecularComponentLargeShape.ComponentStateLargeShape) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction) MolecularComponentLargeShape(cbit.vcell.graph.MolecularComponentLargeShape)

Example 83 with AbstractAction

use of javax.swing.AbstractAction in project vcell by virtualcell.

the class SpatialProcessDisplayPanel method initialize.

private void initialize() {
    setName("SpatialProcessDisplayPanel");
    setLayout(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = new Insets(4, 4, 4, 4);
    add(new JLabel("Search "), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    add(textFieldSearch, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 50, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    add(addNewButton, gbc);
    addNewButton.setIcon(new DownArrowIcon());
    addNewButton.setHorizontalTextPosition(SwingConstants.LEFT);
    addNewButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            JPopupMenu popup = new JPopupMenu();
            JMenuItem newPointLocationMenuItem = new JMenuItem(new AbstractAction("new Point Location") {

                public void actionPerformed(ActionEvent e) {
                    createNewPointLocation();
                }
            });
            JMenuItem newPointKinematicsMenuItem = new JMenuItem(new AbstractAction("new Point Kinematics") {

                public void actionPerformed(ActionEvent e) {
                    createNewPointKinematics();
                }
            });
            JMenuItem newSurfaceKinematicsMenuItem = new JMenuItem(new AbstractAction("new Surface Kinematics") {

                public void actionPerformed(ActionEvent e) {
                    createNewSurfaceKinematics();
                }
            });
            JMenuItem newVolumeKinematicsMenuItem = new JMenuItem(new AbstractAction("new Volume Kinematics") {

                public void actionPerformed(ActionEvent e) {
                    createNewVolumeKinematics();
                }
            });
            newPointLocationMenuItem.setIcon(VCellIcons.addIcon(VCellIcons.spatialPointIcon, VCellIcons.spatialLocationIcon));
            newPointKinematicsMenuItem.setIcon(VCellIcons.addIcon(VCellIcons.spatialPointIcon, VCellIcons.spatialKinematicsIcon));
            newSurfaceKinematicsMenuItem.setIcon(VCellIcons.addIcon(VCellIcons.spatialMembraneIcon, VCellIcons.spatialKinematicsIcon));
            newVolumeKinematicsMenuItem.setIcon(VCellIcons.addIcon(VCellIcons.spatialVolumeIcon, VCellIcons.spatialKinematicsIcon));
            popup.add(newPointLocationMenuItem);
            popup.add(newPointKinematicsMenuItem);
            popup.add(newSurfaceKinematicsMenuItem);
            popup.add(newVolumeKinematicsMenuItem);
            popup.show(addNewButton, 0, addNewButton.getHeight());
        }
    });
    // for now disable 'add' button
    // addNewButton.setEnabled(false);
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(deleteButton, gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.gridwidth = 6;
    gbc.fill = GridBagConstraints.BOTH;
    add(table.getEnclosingScrollPane(), gbc);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu)

Example 84 with AbstractAction

use of javax.swing.AbstractAction in project vcell by virtualcell.

the class OverlayEditorPanelJAI method initCtrlz.

private void initCtrlz() {
    this.getActionMap().put("Undo", new AbstractAction("Undo") {

        public void actionPerformed(ActionEvent evt) {
            getUndoButton().doClick();
        }
    });
    this.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "Undo");
    this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "Undo");
    this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "Undo");
    // comp.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "Redo" );//redo, to be impl
    this.getActionMap().put("Cibele_sep", new AbstractAction("Cibele_sep") {

        public void actionPerformed(ActionEvent evt) {
            OverlayEditorPanelJAI.this.firePropertyChange(FRAP_DATA_SEPARATE_PROPERTY, null, null);
        }
    });
    this.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke('!'), "Cibele_sep");
    this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke('!'), "Cibele_sep");
    this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('!'), "Cibele_sep");
}
Also used : ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 85 with AbstractAction

use of javax.swing.AbstractAction in project vcell by virtualcell.

the class BeanUtils method addCloseWindowKeyboardAction.

public static void addCloseWindowKeyboardAction(JComponent jComponent) {
    @SuppressWarnings("serial") Action winCloseAction = new AbstractAction() {

        @Override
        public synchronized void actionPerformed(ActionEvent e) {
            Window window = null;
            if (e.getSource() != null) {
                if (e.getSource() instanceof Window) {
                    window = (Window) e.getSource();
                } else {
                    window = (Window) BeanUtils.findTypeParentOfComponent((Component) e.getSource(), Window.class);
                }
            }
            if (window != null) {
                window.dispatchEvent(new WindowEvent(window, java.awt.event.WindowEvent.WINDOW_CLOSING));
            }
        }
    };
    final String winCloseInputMapAction = "winCloseAction";
    InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    if (inputMap.get(CLOSE_WINDOW_KEY_STROKE) == null) {
        inputMap.put(CLOSE_WINDOW_KEY_STROKE, winCloseInputMapAction);
        jComponent.getActionMap().put(winCloseInputMapAction, winCloseAction);
    }
}
Also used : Window(java.awt.Window) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Aggregations

AbstractAction (javax.swing.AbstractAction)174 ActionEvent (java.awt.event.ActionEvent)162 Action (javax.swing.Action)42 InputMap (javax.swing.InputMap)34 JButton (javax.swing.JButton)33 JMenu (javax.swing.JMenu)30 JPanel (javax.swing.JPanel)30 ActionListener (java.awt.event.ActionListener)24 JMenuItem (javax.swing.JMenuItem)24 ActionMap (javax.swing.ActionMap)23 JScrollPane (javax.swing.JScrollPane)16 JPopupMenu (javax.swing.JPopupMenu)15 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 WindowEvent (java.awt.event.WindowEvent)9 JMenuBar (javax.swing.JMenuBar)9 JTextField (javax.swing.JTextField)9