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;
}
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;
}
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);
}
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");
}
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);
}
}
Aggregations