action = action == null ? aMap.get(DefaultEditorKit.deletePrevCharAction) : null; aMap.remove(DefaultEditorKit.deletePrevCharAction); aMap = aMap.getParent(); } while (aMap != null); aMap = getActionMap();
public ActionMap getParent() { return delegate == null ? null : delegate.getParent (); }
public ActionMap getParent() { return delegate == null ? null : delegate.getParent (); }
/** * Removes the specified action map from the specified component. * * @param c * Component. * @param map * Action map to remove. */ void removeUIActionMap(JComponent c, ActionMap map) { ActionMap im = null; ActionMap parent = c.getActionMap(); while (parent != null) { if (parent == map) { if (im == null) { c.setActionMap(map.getParent()); } else { im.setParent(map.getParent()); } break; } im = parent; parent = parent.getParent(); } } }
/** * All of the {@code @ProxyActions} recursively defined by this * {@code ApplicationActionMap} and its parent ancestors. * <p> * Returns a read-only list of the {@code @ProxyActions} defined * by this {@code ApplicationActionMap's} {@code actionClass} * and, recursively, by this {@code ApplicationActionMap's} parent. * If there are no proxyActions, an empty list is returned. * * @return a list of all the proxyActions for this {@code ApplicationActionMap} */ public List<ApplicationAction> getProxyActions() { // TBD: proxyActions that shadow should be merged ArrayList<ApplicationAction> allProxyActions = new ArrayList<ApplicationAction>(proxyActions); ActionMap parent = getParent(); while (parent != null) { if (parent instanceof ApplicationActionMap) { allProxyActions.addAll(((ApplicationActionMap) parent).proxyActions); } parent = parent.getParent(); } return Collections.unmodifiableList(allProxyActions); }
/** * All of the {@code @ProxyActions} recursively defined by this * {@code ApplicationActionMap} and its parent ancestors. * <p> * Returns a read-only list of the {@code @ProxyActions} defined * by this {@code ApplicationActionMap's} {@code actionClass} * and, recursively, by this {@code ApplicationActionMap's} parent. * If there are no proxyActions, an empty list is returned. * * @return a list of all the proxyActions for this {@code ApplicationActionMap} */ public List<ApplicationAction> getProxyActions() { // TBD: proxyActions that shadow should be merged ArrayList<ApplicationAction> allProxyActions = new ArrayList<ApplicationAction>(proxyActions); ActionMap parent = getParent(); while(parent != null) { if (parent instanceof ApplicationActionMap) { allProxyActions.addAll(((ApplicationActionMap)parent).proxyActions); } parent = parent.getParent(); } return Collections.unmodifiableList(allProxyActions); }
private static void removeRecursively(ActionMap map, Object key) { map.remove(key); ActionMap parent = map.getParent(); if (parent != null) { removeRecursively(parent, key); } }
private void removeWindowsF10() { InputMap imap = menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); Object action = imap.get(KeyStroke.getKeyStroke("F10")); if (log.isInfoEnabled()) log.info("Removing the F10 key from the menuBar's InputMap; it did " + (action == null ? "not" : "") + " exist"); ActionMap amap = menuBar.getActionMap(); amap.getParent().remove(action); }
private void invokeTextAction(JTextComponent text, String actionName) { ActionMap actionMap = text.getActionMap().getParent(); long eventTime = EventQueue.getMostRecentEventTime(); int eventMods = getCurrentEventModifiers(); ActionEvent actionEvent = new ActionEvent(text, ActionEvent.ACTION_PERFORMED, actionName, eventTime, eventMods); actionMap.get(actionName).actionPerformed(actionEvent); }
// "early" in the app instantiate a textField JTextField text = new JTextField(); ActionMap map = text.getActionMap(); // get a reference to the default binding final Action notify = map.get(JTextField.notifyAction); while (map.getParent() != null) { // walk up the parent chain to reach the top-most shared ancestor map = map.getParent(); } // custom notify action TextAction tab = new TextAction(JTextField.notifyAction) { @Override public void actionPerformed(ActionEvent e) { // delegate to default if enabled if (notify.isEnabled()) { notify.actionPerformed(e); } // trigger a focus transfer getTextComponent(e).transferFocus(); } }; // replace default with augmented custom action map.put(JTextField.notifyAction, tab);
private ActionMap getMapForKey(ActionMap am, String key) { if(am == null) return null; if(am != null && am.keys() != null) { Object[] keys = am.keys(); // for(int i = 0; i < keys.length; i++) { // System.out.println(keys[i] + " -> " + am.get(keys[i])); // } for(int i = 0; i < keys.length; i++) { if(key.equals(keys[i])) return am; } } return getMapForKey(am.getParent(), key); }
private void invokeTextAction(JTextComponent text, String actionName) { ActionMap actionMap = text.getActionMap().getParent(); long eventTime = EventQueue.getMostRecentEventTime(); int eventMods = getCurrentEventModifiers(); ActionEvent actionEvent = new ActionEvent(text, ActionEvent.ACTION_PERFORMED, actionName, eventTime, eventMods); actionMap.get(actionName).actionPerformed(actionEvent); }
/** */ private void unblockMnemonics() { assert rootPane != null; if (actionMappingInfo == null) { /* blockMnemonics() did not pass */ return; } assert actionMappingInfo.length == mnemonicBlocked.length; final JComponent[] comps = mnemonicBlocked; for (int i = 0; i < comps.length; i++) { ActionMappingInfo mappingInfo = actionMappingInfo[i]; if (mappingInfo != null) { comps[i].getActionMap().put( mappingInfo.actionKey, mappingInfo.inProximateActionMap ? mappingInfo.originalAction : (Action) null); } else if (comps[i] instanceof JLabel) { comps[i].setActionMap(comps[i].getActionMap().getParent()); } } }
private static void adaptActionMap(AttributeTable table) { InputMap ancestorInputMap = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke f2 = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); InputMap focusedComponentInputMap = table.getInputMap(JTable.WHEN_FOCUSED); final Object editKey = ancestorInputMap.get(f2); focusedComponentInputMap.put(enter, editKey); final ActionMap actionMap = table.getActionMap(); if(defaultParentActionMap == null || defaultParentActionMap != actionMap.getParent()) { defaultParentActionMap = actionMap.getParent(); newDefaultParentActionMap = new ActionMap() { @Override public Action get(Object key) { if(editingActions.contains(key)) return null; else return super.get(key); } }; newDefaultParentActionMap.setParent(defaultParentActionMap); EditCellAction action = new EditCellAction(); newDefaultParentActionMap.put(editKey, action); } actionMap.setParent(newDefaultParentActionMap); }
private JSplitPane createSplitPane(Component lower) { JSplitPane pane = new JSplitPane(); if (firstSplit == null) { firstSplit = Boolean.TRUE; } else { firstSplit = Boolean.FALSE; } pane.setRightComponent(lower); pane.setOrientation(JSplitPane.VERTICAL_SPLIT); pane.setContinuousLayout(true); pane.setResizeWeight(1); pane.setDividerLocation(0.80f); pane.setBorder(BorderFactory.createEmptyBorder()); //Do not install our custom split pane UI on Nimbus L&F if (!"Nimbus".equals(UIManager.getLookAndFeel().getID())) { pane.setUI(PropUtils.createSplitPaneUI()); } // #52188: default F6 behaviour doesn't make to much sense in NB // property sheet and blocks NetBeans default F6 pane.getActionMap().getParent().remove("toggleFocus"); if( PropUtils.isAqua ) { pane.setBackground( UIManager.getColor("NbExplorerView.background") ); //NOI18N } return pane; }
/** * Adds the specified action map to the specified component. * * @param c * Component. * @param map * Action map to add. */ void addUIActionMap(JComponent c, ActionMap map) { ActionMap lastNonUI = null; ActionMap parent = c.getActionMap(); while (parent != null && !(parent instanceof UIResource)) { lastNonUI = parent; parent = parent.getParent(); } if (lastNonUI == null) { c.setActionMap(map); } else { lastNonUI.setParent(map); } map.setParent(parent); }
public static void setAsBrightnessDialog( final BigDataViewer bdv ) { final InputActionBindings inputActionBindings = bdv.getViewerFrame().getKeybindings(); final ActionMap am = inputActionBindings.getConcatenatedActionMap(); //final ToggleDialogAction tda = (ToggleDialogAction)am.getParent().get( BigDataViewerActions.BRIGHTNESS_SETTINGS ); // the old one am.getParent().put( BigDataViewerActions.BRIGHTNESS_SETTINGS, new ToggleDialogActionBrightness( BigDataViewerActions.BRIGHTNESS_SETTINGS, new ScrollableBrightnessDialog( bdv.getViewerFrame(), bdv.getSetupAssignments() ) ) ); }
public JSplitPane buildUtilityAndDocumentSplitPane(boolean embeddableComponent) { JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitpane.setOneTouchExpandable(false); splitpane.setDividerSize(8); splitpane.setContinuousLayout(true); // set the utility pane the left of the split pane splitpane.setLeftComponent(buildUtilityTabbedPane()); // set the viewController embeddable flag. DocumentViewController viewController = viewerController.getDocumentViewController(); // will add key event listeners viewerController.setIsEmbeddedComponent(embeddableComponent); // remove F6 focus management key from the splitpane splitpane.getActionMap().getParent().remove("toggleFocus"); // add the viewControllers doc view container to the split pain splitpane.setRightComponent(viewController.getViewContainer()); // apply previously set divider location, default is -1 int dividerLocation = PropertiesManager.checkAndStoreIntegerProperty( propertiesManager, PropertiesManager.PROPERTY_DIVIDER_LOCATION, 260); splitpane.setDividerLocation(dividerLocation); // Add the split pan component to the view controller so that it can // manipulate the divider via the controller, hide, show, etc. for // utility pane. if (viewerController != null) viewerController.setUtilityAndDocumentSplitPane(splitpane); return splitpane; }