站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ContextAwareAction (Utilities API) - NetBeans API Javadoc (Current Development Version)

org.openide.util 7.9.0 1

org.openide.util
Interface ContextAwareAction

All Superinterfaces:
Action, ActionListener, EventListener
All Known Implementing Classes:
CallbackSystemAction

public interface ContextAwareAction
extends Action

Interface to be implemented by an action whose behavior is dependent on some context. The action created by createContextAwareInstance(org.openide.util.Lookup) is bound to the provided context: Action.isEnabled(), ActionListener.actionPerformed(java.awt.event.ActionEvent), etc. may be specific to that context.

For example, the action representing a context menu item will usually implement this interface. When the actual context menu is created, rather than making a presenter for the generic action, the menu will contain a presenter for the context-aware instance. The context will then be taken from the GUI environment where the context menu was shown; for example it may be a TopComponent's context, often taken from an activated node selection. The context action might be enabled only if a certain "cookie" is present in that selection. When invoked, the action need not search for an object to act on, since it can use the context.

Since:
3.29
See Also:
Utilities.actionsToPopup(javax.swing.Action[], org.openide.util.Lookup)

Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Method Summary
 Action createContextAwareInstance(Lookup actionContext)
          Creates action instance for provided context.
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Method Detail

createContextAwareInstance

Action createContextAwareInstance(Lookup actionContext)
Creates action instance for provided context.

Parameters:
actionContext - an arbitrary context (e.g. "cookies" from a node selection)
Returns:
a transient action whose behavior applies only to that context

org.openide.util 7.9.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.