Java Code Examples for javax.swing.ActionMap#remove()

The following examples show how to use javax.swing.ActionMap#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CategoryList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initActions() {
    InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, 0, false ), "defaultAction" );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK, false ), "popup" );

    ActionMap map = getActionMap();
    map.put( "defaultAction", new DefaultAction( this ) );
    map.put( "popup", new PopupAction() );
    map.put( "selectPreviousRow", new MoveFocusAction( map.get( "selectPreviousRow" ), false ) );
    map.put( "selectNextRow", new MoveFocusAction( map.get( "selectNextRow" ), true ) );
    map.put( "selectPreviousColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectPreviousColumn" ), false ), false ) );
    map.put( "selectNextColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectNextColumn" ), true ), true ) );
    Node categoryNode = category.getLookup().lookup(org.openide.nodes.Node.class);
    if( null != categoryNode )
        map.put( "paste", new Utils.PasteItemAction( categoryNode ) );
    else
        map.remove( "paste" );
    map.put( "copy", new CutCopyAction( true ) );
    map.put( "cut", new CutCopyAction( false ) );
}
 
Example 2
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void detachSystemActionPerformer(JTextComponent c){
    if (c == null) return;

    Action action = getEditorAction(c);
    if (action == null) return;

    Action globalSystemAction = getSystemAction(c);
    if (globalSystemAction == null) return;

    if (globalSystemAction instanceof CallbackSystemAction){
        Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey();
        ActionMap am = c.getActionMap();
        if (am != null) {
            Object ea = am.get(key);
            if (action.equals(ea)) {
                am.remove(key);
            }
        }
    }                        
                        
}
 
Example 3
Source File: ProductSceneViewTopComponent.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private void updateActionMap(Selection newSelection) {
    ActionMap actionMap = getActionMap();
    actionMap.put(SelectionActions.SELECT_ALL, new SelectAllAction());
    actionMap.put(DefaultEditorKit.pasteAction, new PasteAction());
    if (!newSelection.isEmpty()) {
        actionMap.put(DefaultEditorKit.cutAction, new CutAction());
        actionMap.put(DefaultEditorKit.copyAction, new CopyAction());
        actionMap.put("delete", new DeleteAction());
        actionMap.put(SelectionActions.DESELECT_ALL, new DeselectAllAction());
    } else {
        actionMap.remove(DefaultEditorKit.cutAction);
        actionMap.remove(DefaultEditorKit.copyAction);
        actionMap.remove("delete");
        actionMap.remove(SelectionActions.DESELECT_ALL);
    }
    getDynamicContent().remove(actionMap);
    getDynamicContent().add(actionMap);
}
 
Example 4
Source File: CRegisterHotKeys.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public static <NodeType extends ZyGraphNode<?>> void register(
    final AbstractZyGraph<NodeType, ?> graph) {
  final Graph2DView view = graph.getView();

  final Graph2DViewActions actions = new Graph2DViewActions(view);
  final ActionMap amap = actions.createActionMap();
  final InputMap imap = actions.createDefaultInputMap(amap);

  view.setActionMap(amap);
  view.setInputMap(JComponent.WHEN_FOCUSED, imap);
  view.getCanvasComponent().setActionMap(amap);
  view.getCanvasComponent().setInputMap(JComponent.WHEN_FOCUSED, imap);

  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "DOWN");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UP");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "LEFT");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RIGHT");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), "+");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), "-");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0), "m");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S, 0), "s");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LESS, 0), "<");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK), "SELECT_VISIBLE_NODES");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK),
      "COPY_CONTENT_FROM_SELECTED_NODES");

  amap.remove(Graph2DViewActions.DELETE_SELECTION);
  amap.remove(Graph2DViewActions.EDIT_LABEL);

  registerActions(graph);
}
 
Example 5
Source File: CRegisterHotKeys.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public static <NodeType extends ZyGraphNode<?>> void unregisterActions(
    final AbstractZyGraph<NodeType, ?> graph) {
  final ActionMap amap1 = graph.getView().getCanvasComponent().getActionMap();
  final ActionMap amap2 = graph.getView().getActionMap();

  amap1.remove("F2");
  amap1.remove("DOWN");
  amap1.remove("UP");
  amap1.remove("LEFT");
  amap1.remove("RIGHT");
  amap1.remove("+");
  amap1.remove("-");
  amap1.remove("m");
  amap1.remove("s");
  amap1.remove("<");
  amap1.remove("SELECT_VISIBLE_NODES");
  amap1.remove("COPY_CONTENT_FROM_SELECTED_NODES");

  amap2.remove("DOWN");
  amap2.remove("UP");
  amap2.remove("LEFT");
  amap2.remove("RIGHT");
  amap2.remove("+");
  amap2.remove("-");
  amap2.remove("m");
  amap2.remove("s");
  amap2.remove("<");
  amap2.remove("SELECT_VISIBLE_NODES");
  amap2.remove("COPY_CONTENT_FROM_SELECTED_NODES");
}
 
Example 6
Source File: BEInternalFrameUI.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
protected void installKeyboardActions()
{
	super.installKeyboardActions();
	ActionMap map = SwingUtilities.getUIActionMap(frame);
	if (map != null)
	{
		// BasicInternalFrameUI creates an action with the same name, we override
		// it as Metal frames do not have system menus.
		map.remove("showSystemMenu");
	}
}
 
Example 7
Source File: BasicCalendarPaneUI.java    From microba with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void uninstallKeyboardActions() {
	InputMap input = peer
			.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	ActionMap action = peer.getActionMap();

	input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
	input.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));

	action.remove(ENTER_KEY);
	action.remove(ESCAPE_KEY);

}
 
Example 8
Source File: TextEditor.java    From groovy with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of TextEditor
 */
public TextEditor(boolean tabsAsSpaces, boolean multiLineTab, boolean unwrapped) {
    this.tabsAsSpaces = tabsAsSpaces;
    this.multiLineTab = multiLineTab;
    this.unwrapped = unwrapped;

    // remove and replace the delete action to another spot so ctrl H later
    // on is strictly for showing the find & replace dialog
    ActionMap aMap = getActionMap();
    Action action = null;
    do {
        action = action == null ? aMap.get(DefaultEditorKit.deletePrevCharAction) : null;
        aMap.remove(DefaultEditorKit.deletePrevCharAction);
        aMap = aMap.getParent();
    } while (aMap != null);
    aMap = getActionMap();
    InputMap iMap = getInputMap();
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0, false);
    iMap.put(keyStroke, "delete");
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.SHIFT_MASK, false);
    iMap.put(keyStroke, "delete");
    aMap.put("delete", action);

    // set all the actions
    action = new FindAction();
    aMap.put(FIND, action);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK, false);
    iMap.put(keyStroke, FIND);

    aMap.put(FIND_NEXT, FindReplaceUtility.FIND_ACTION);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, false);
    iMap.put(keyStroke, FIND_NEXT);

    aMap.put(FIND_PREVIOUS, FindReplaceUtility.FIND_ACTION);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK, false);
    iMap.put(keyStroke, FIND_PREVIOUS);

    action = new TabAction();
    aMap.put("TextEditor-tabAction", action);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, false);
    iMap.put(keyStroke, "TextEditor-tabAction");

    action = new ShiftTabAction();
    aMap.put("TextEditor-shiftTabAction", action);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK, false);
    iMap.put(keyStroke, "TextEditor-shiftTabAction");

    action = new ReplaceAction();
    getActionMap().put(REPLACE, action);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK, false);
    do {
        iMap.remove(keyStroke);
        iMap = iMap.getParent();
    } while (iMap != null);
    getInputMap().put(keyStroke, REPLACE);

    action = new AutoIndentAction();
    getActionMap().put(AUTO_INDENT, action);
    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    getInputMap().put(keyStroke, AUTO_INDENT);

    setAutoscrolls(true);

    defaultCaret = getCaret();
    overtypeCaret = new OvertypeCaret();
    overtypeCaret.setBlinkRate(defaultCaret.getBlinkRate());
}