/** 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(); } }
/** Invoked when an action occurs. */ public void actionPerformed(final java.awt.event.ActionEvent e) { final Action a = findAction(); if (a != null) { Runnable run = new Runnable() { public void run() { a.actionPerformed(e); } }; org.openide.util.actions.ActionInvoker.invokeAction(delegate, e, delegate.asynchronous(), run); } else { // XXX #30303 if the action falls back to the old behaviour // it may not be performed in case it is in dialog and // is not transmodal. // This is just a hack, see TopComponent.processKeyBinding. Object source = e.getSource(); if ( source instanceof Component && javax.swing.SwingUtilities.getWindowAncestor((Component) source) instanceof java.awt.Dialog ) { Object value = delegate.getValue("OpenIDE-Transmodal-Action"); // NOI18N if (!Boolean.TRUE.equals(value)) { return; } } delegate.actionPerformed(e); } }
public javax.swing.JMenuItem getMenuPresenter() { if (isMethodOverridden(delegate, "getMenuPresenter")) { // NOI18N return delegate.getMenuPresenter(); } else { return org.openide.util.actions.ActionPresenterProvider.getDefault().createMenuPresenter(this); } }
/** Clears the listener. */ private void clearListener() { synchronized (LISTENER) { // remove listener on any action ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if (l != null) { l.clear(); putProperty(LISTENER, null); } } }
putProperty(PROP_ACTION_PERFORMER, performer); updateEnabled();
/** 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(); }
/*** 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; }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled () { javax.swing.Action action = findGlobalContextAction (); if(action != null) { setEnabled (action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener)getProperty(LISTENER); if (l == null) { 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 (); } }
public void run() { if (ap == getActionPerformer()) { getActionPerformer().performAction(CallbackSystemAction.this); } } }
/** Get the current action performer. * @return the current action performer, or <code>null</code> if there is currently no performer * @deprecated use TopComponent.getActionMap() as described in the javadoc */ @Deprecated public ActionPerformer getActionPerformer() { return (ActionPerformer) getProperty(PROP_ACTION_PERFORMER); }
public void focusLost(FocusEvent ev) { if (csa != null && (csa.getActionPerformer() instanceof PopupSupport)) { csa.setActionPerformer(null); } } }
delegate.doPerformAction (run); } else { && javax.swing.SwingUtilities.getWindowAncestor((Component)source) instanceof java.awt.Dialog) { Object value = delegate.getValue( "OpenIDE-Transmodal-Action"); // NOI18N if(!Boolean.TRUE.equals(value)) { delegate.actionPerformed (e);
public javax.swing.JMenuItem getPopupPresenter() { if (isMethodOverridden(delegate, "getPopupPresenter")) { // NOI18N return delegate.getPopupPresenter(); } else { return org.openide.util.actions.ActionPresenterProvider.getDefault().createPopupPresenter(this); } }
public java.awt.Component getToolbarPresenter() { if (isMethodOverridden(delegate, "getToolbarPresenter")) { // NOI18N return delegate.getToolbarPresenter(); } else { return org.openide.util.actions.ActionPresenterProvider.getDefault().createToolbarPresenter(this); } }
public Object getValue(String key) { return delegate.getValue(key); }
/** 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 = findGlobalContextAction (); if (action != null) { if (action.isEnabled()) { action.actionPerformed(ev); } else { Toolkit.getDefaultToolkit().beep(); } return; } final ActionPerformer ap = getActionPerformer (); if (ap != null) { doPerformAction(new ActionRunnable (ev) { public void run() { ap.performAction(CallbackSystemAction.this); } }); return; } Toolkit.getDefaultToolkit().beep(); }
/** 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(); }
/*** 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; }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled () { javax.swing.Action action = findGlobalContextAction (); if(action != null) { setEnabled (action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener)getProperty(LISTENER); if (l == null) { 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 (); } }
/** Clears the listener. */ private void clearListener() { synchronized (LISTENER) { // remove listener on any action ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if (l != null) { l.clear(); putProperty(LISTENER, null); } } }