/*** Finds an action that we should delegate to * @return the action or null */ private Action findAction() { Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet(); if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for (ActionMap map : c) { Action action = map.get(key); if (action != null) { return action; } } } return null; }
/** Perform the action. Tries the performer and then scans the ActionMap * of selected topcomponent. */ public void actionPerformed(final ActionEvent ev) { // First try global context action. final Action action = GlobalManager.getDefault().findGlobalAction(getActionMapKey(), getSurviveFocusChange()); if (action != null) { if (action.isEnabled()) { action.actionPerformed(ev); } else { Toolkit.getDefaultToolkit().beep(); } return; } final Object ap = getActionPerformer(); if (ap != null) { org.openide.util.actions.ActionInvoker.invokeAction( this, ev, asynchronous(), new Runnable() { public void run() { if (ap == getActionPerformer()) { getActionPerformer().performAction(CallbackSystemAction.this); } } } ); return; } Toolkit.getDefaultToolkit().beep(); }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled() { Action action = GlobalManager.getDefault().findGlobalAction( getActionMapKey(), getSurviveFocusChange() ); if (action != null) { setEnabled(action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if ((l == null) || (l.get() != this)) { l = new ActionDelegateListener(this, action); putProperty(LISTENER, l); } else { l.attach(action); } } } else { if (getActionPerformer() != null) { // we have performer setEnabled(true); } else { setEnabled(false); } clearListener(); } }
/*** Finds an action that we should delegate to * @return the action or null */ private Action findAction() { Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet(); if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for (ActionMap map : c) { Action action = map.get(key); if (action != null) { return action; } } } return null; }
/** Perform the action. Tries the performer and then scans the ActionMap * of selected topcomponent. */ public void actionPerformed(final ActionEvent ev) { // First try global context action. final Action action = GlobalManager.getDefault().findGlobalAction(getActionMapKey(), getSurviveFocusChange()); if (action != null) { if (action.isEnabled()) { action.actionPerformed(ev); } else { Utilities.disabledActionBeep(); } return; } final Object ap = getActionPerformer(); if (ap != null) { org.openide.util.actions.ActionInvoker.invokeAction( this, ev, asynchronous(), new Runnable() { public void run() { if (ap == getActionPerformer()) { getActionPerformer().performAction(CallbackSystemAction.this); } } } ); return; } Utilities.disabledActionBeep(); }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled() { Action action = GlobalManager.getDefault().findGlobalAction( getActionMapKey(), getSurviveFocusChange() ); if (action != null) { setEnabled(action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if ((l == null) || (l.get() != this)) { l = new ActionDelegateListener(this, action); putProperty(LISTENER, l); } else { l.attach(action); } } } else { if (getActionPerformer() != null) { // we have performer setEnabled(true); } else { setEnabled(false); } clearListener(); } }
/*** Finds an action that we should delegate to * @return the action or null */ private Action findAction() { Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet(); if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for (ActionMap map : c) { Action action = map.get(key); if (action != null) { return action; } } } return null; }
/*** Finds an action that we should delegate to * @return the action or null */ private javax.swing.Action findAction () { java.util.Collection c = result != null ? result.allInstances() : java.util.Collections.EMPTY_LIST; if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for(Iterator it = c.iterator(); it.hasNext(); ) { javax.swing.ActionMap map = (javax.swing.ActionMap)it.next(); javax.swing.Action action = map.get (key); if(action != null) { return action; } } } return null; }
/*** Finds an action that we should delegate to * @return the action or null */ private javax.swing.Action findAction () { java.util.Collection c = result != null ? result.allInstances() : java.util.Collections.EMPTY_LIST; if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for(Iterator it = c.iterator(); it.hasNext(); ) { javax.swing.ActionMap map = (javax.swing.ActionMap)it.next(); javax.swing.Action action = map.get (key); if(action != null) { return action; } } } return null; }
/*** Finds an action that we should delegate to * @return the action or null */ private Action findAction() { Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet(); if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for (ActionMap map : c) { Action action = map.get(key); if (action != null) { return action; } } } return null; }
@Override public void ancestorAdded(AncestorEvent ae) { TopComponent tc = findTC(ae.getComponent()); if(tc != null) { ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); sfa = actionMap.get(a.getActionMapKey()); actionMap.put(a.getActionMapKey(), new FindAction()); } } @Override
@Override public void ancestorRemoved(AncestorEvent ae) { TopComponent tc = findTC(ae.getComponent()); if(tc != null && sfa != null) { ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); actionMap.put(a.getActionMapKey(), sfa); sfa = null; } } @Override
/** Finds global context action (the one from activated component). * @return action for key of activated component or null */ private javax.swing.Action findGlobalContextAction () { ActionMap map = GlobalManager.getDefault ().getActionMap (); if (map != null) { Object key = getActionMapKey(); return map.get (key); } return null; }
/** Finds global context action (the one from activated component). * @return action for key of activated component or null */ private javax.swing.Action findGlobalContextAction () { ActionMap map = GlobalManager.getDefault ().getActionMap (); if (map != null) { Object key = getActionMapKey(); return map.get (key); } return null; }
private void updateFind(boolean enabled, final FindPerformer performer) { CallbackSystemAction globalFindAction = (CallbackSystemAction) SystemAction.get(FindAction.class); Object findActionKey = globalFindAction.getActionMapKey(); if (enabled) { getActionMap().put(findActionKey, new AbstractAction() { public void actionPerformed(ActionEvent e) { performer.performFind(); } }); } else { getActionMap().remove(findActionKey); } }
private void updateFind(boolean enabled, final SnapshotResultsWindow.FindPerformer performer) { CallbackSystemAction globalFindAction = (CallbackSystemAction) SystemAction.get(FindAction.class); Object findActionKey = globalFindAction.getActionMapKey(); if (enabled) { getActionMap().put(findActionKey, new AbstractAction() { public void actionPerformed(ActionEvent e) { performer.performFind(); } }); } else { getActionMap().remove(findActionKey); } } }
private FindSupport(TopComponent tc) { this.tc = tc; bar = new FindBar(this); ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); actionMap.put(a.getActionMapKey(), new FindAction(true)); actionMap.put(FIND_NEXT_ACTION, new FindAction(true)); actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false)); // Hack ensuring the same shortcuts as editor JEditorPane pane = new JEditorPane(); for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N Object name = action.getValue(Action.NAME); if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) { reuseShortcut(action); } } // PENDING the colors below should not be hardcoded highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66)); highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227)); pattern = Pattern.compile("$^"); // NOI18N }
private WidgetAction createActionMap() { ActionMap actionMap = refPageFlowView.get().getActionMap(); CallbackSystemAction a = (CallbackSystemAction) SystemAction.get(DeleteAction.class); actionMap.put(a.getActionMapKey(), new PageFlowDeleteAction(this)); //Temporary workaround ISSUE# 107506 return new MyActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap()); //return ActionFactory.createActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap()); }
@Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { boolean ret = super.processKeyBinding(ks, e, condition, pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled() { Action action = GlobalManager.getDefault().findGlobalAction( getActionMapKey(), getSurviveFocusChange() ); if (action != null) { setEnabled(action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if ((l == null) || (l.get() != this)) { l = new ActionDelegateListener(this, action); putProperty(LISTENER, l); } else { l.attach(action); } } } else { if (getActionPerformer() != null) { // we have performer setEnabled(true); } else { setEnabled(false); } clearListener(); } }