use of javax.swing.AbstractAction in project OpenNotebook by jaltekruse.
the class KeyboardShortcuts method addKeyboardShortcuts.
public static void addKeyboardShortcuts(final JPanel panel, final NotebookPanel notebookPanel) {
panel.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.singleton(KeyStroke.getKeyStroke("TAB")));
panel.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.singleton(KeyStroke.getKeyStroke("shift TAB")));
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("DELETE"), "delete");
panel.getActionMap().put("delete", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.delete();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control S"), "save");
panel.getActionMap().put("save", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.save();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control W"), "closeCurrent");
panel.getActionMap().put("closeCurrent", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.closeCurrentViewer();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control TAB"), "switchTab");
panel.getActionMap().put("switchTab", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.switchTab();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control shift TAB"), "switchTabBackwards");
panel.getActionMap().put("switchTabBackwards", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.switchTabBackward();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control O"), "open");
panel.getActionMap().put("open", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.open();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control P"), "print");
panel.getActionMap().put("print", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.print();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control C"), "copy");
panel.getActionMap().put("copy", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.copy();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control X"), "cut");
panel.getActionMap().put("cut", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.cut();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control V"), "paste");
panel.getActionMap().put("paste", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.paste();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control N"), "add page");
panel.getActionMap().put("add page", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.addPage();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control Z"), "undo");
panel.getActionMap().put("undo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.undo();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control Y"), "redo");
panel.getActionMap().put("redo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.redo();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control EQUALS"), "zoomIn");
panel.getActionMap().put("zoomIn", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.zoomIn();
}
});
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control MINUS"), "zoomOut");
panel.getActionMap().put("zoomOut", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
notebookPanel.zoomOut();
}
});
}
use of javax.swing.AbstractAction in project binnavi by google.
the class CDatabaseSettingsPanel method setupHotkeys.
/**
* Sets up the hotkeys of the panel.
*/
private void setupHotkeys() {
final InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
final ActionMap actionMap = getActionMap();
inputMap.put(HotKeys.DATABASE_SETTINGS_TEST_CONNECTION_KEY.getKeyStroke(), "TEST_CONNECTION");
actionMap.put("TEST_CONNECTION", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent event) {
if (testButton.isEnabled()) {
testConnection();
}
}
});
inputMap.put(HotKeys.DATABASE_SETTINGS_SAVE_CONNECTION_KEY.getKeyStroke(), "SAVE_CONNECTION");
actionMap.put("SAVE_CONNECTION", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent event) {
saveConnection();
}
});
}
use of javax.swing.AbstractAction in project binnavi by google.
the class TypeEditorMouseHandler method createNodeClickedMenu.
private JPopupMenu createNodeClickedMenu(final TreeNode clickedNode) {
final JPopupMenu popupMenu = new JPopupMenu();
if (clickedNode instanceof TypeMemberTreeNode) {
final TypeMember selectedMember = ((TypeMemberTreeNode) clickedNode).getTypeMember();
final AbstractAction editMemberAction = new EditMemberAction(owner, typeManager, selectedMember);
final AbstractAction insertAction = new InsertMemberAction(owner, typeManager, selectedMember);
if (tree.getSelectionCount() > 1) {
editMemberAction.setEnabled(false);
insertAction.setEnabled(false);
}
if (selectedMember.getParentType() != null && selectedMember.getParentType().getCategory() == BaseTypeCategory.STRUCT) {
popupMenu.add(new AppendMemberAction(owner, typeManager, selectedMember.getParentType()));
popupMenu.add(insertAction);
}
popupMenu.add(editMemberAction);
popupMenu.add(new DeleteMemberAction(owner, typeManager, typeEditor));
} else if (clickedNode instanceof BaseTypeTreeNode) {
final BaseType selectedType = ((BaseTypeTreeNode) clickedNode).getBaseType();
final AbstractAction editAction = new EditTypeAction(owner, typeManager, selectedType);
final AbstractAction appendAction = new AppendMemberAction(owner, typeManager, selectedType);
if (tree.getSelectionCount() > 1) {
editAction.setEnabled(false);
appendAction.setEnabled(false);
} else if (selectedType.getCategory() != BaseTypeCategory.STRUCT) {
appendAction.setEnabled(false);
}
popupMenu.add(editAction);
popupMenu.add(appendAction);
popupMenu.add(new DeleteTypeAction(owner, typeManager, typeEditor));
}
return popupMenu;
}
use of javax.swing.AbstractAction in project binnavi by google.
the class CGraphHotkeys method registerHotKeys.
/**
* Register the default hotkeys of a graph view.
*
* @param parent Parent window used for dialogs.
* @param panel The panel where the view is shown.
* @param debuggerProvider Provides the debugger used by some hotkeys.
* @param searchField The search field that is shown in the graph panel.
* @param addressField The address field that is shown in the graph panel.
*/
public static void registerHotKeys(final JFrame parent, final CGraphPanel panel, final IFrontEndDebuggerProvider debuggerProvider, final CGraphSearchField searchField, final CGotoAddressField addressField) {
Preconditions.checkNotNull(parent, "IE01606: Parent argument can not be null");
Preconditions.checkNotNull(panel, "IE01607: Panel argument can not be null");
Preconditions.checkNotNull(searchField, "IE01608: Search field argument can not be null");
Preconditions.checkNotNull(addressField, "IE01609: Address field argument can not be null");
final InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
final ActionMap actionMap = panel.getActionMap();
inputMap.put(HotKeys.GRAPH_GOTO_ADDRESS_FIELD_KEY.getKeyStroke(), "GOTO_ADDRESS_FIELD");
actionMap.put("GOTO_ADDRESS_FIELD", new AbstractAction() {
/**
* Used for serialization.
*/
private static final long serialVersionUID = -8994014581850287793L;
@Override
public void actionPerformed(final ActionEvent event) {
addressField.requestFocusInWindow();
}
});
inputMap.put(HotKeys.GRAPH_SHOW_HOTKEYS_ACCELERATOR_KEY.getKeyStroke(), "SHOW_HOTKEYS");
actionMap.put("SHOW_HOTKEYS", new CShowHotkeysAction(parent));
registerSearchKeys(panel.getModel().getGraph().getView(), searchField, inputMap, actionMap);
registerDebuggerKeys(panel.getModel().getParent(), panel.getModel().getGraph(), debuggerProvider, inputMap, actionMap);
}
use of javax.swing.AbstractAction in project EnrichmentMapApp by BaderLab.
the class LegendPanelMediator method showCreationParamsDialog.
@SuppressWarnings("serial")
private void showCreationParamsDialog() {
JDialog d = new JDialog(dialog, "EnrichmentMap Creation Parameters", ModalityType.APPLICATION_MODAL);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setMinimumSize(new Dimension(420, 260));
d.setPreferredSize(new Dimension(580, 460));
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
d.dispose();
}
});
JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton);
d.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
CyNetworkView netView = legendPanelProvider.get().getOptions().getNetworkView();
if (netView != null) {
EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
CreationParametersPanel paramsPanel = new CreationParametersPanel(map);
d.getContentPane().add(paramsPanel, BorderLayout.CENTER);
}
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(d.getRootPane(), null, closeButton.getAction());
d.getRootPane().setDefaultButton(closeButton);
d.setLocationRelativeTo(dialog);
d.pack();
d.setVisible(true);
}
Aggregations