org.openide.util.actions
Class CookieAction

java.lang.Object
  |
  +--org.openide.util.SharedClassObject
        |
        +--org.openide.util.actions.SystemAction
              |
              +--org.openide.util.actions.CallableSystemAction
                    |
                    +--org.openide.util.actions.NodeAction
                          |
                          +--org.openide.util.actions.CookieAction
All Implemented Interfaces:
Action, ActionListener, EventListener, Externalizable, Presenter, Presenter.Menu, Presenter.Popup, Presenter.Toolbar, Serializable
Direct Known Subclasses:
CustomizeBeanAction, EditAction, ExecuteAction, OpenAction, PrintAction, ReorderAction, SaveAction, ViewAction

public abstract class CookieAction
extends NodeAction

An action dependent on the cookies of the selected nodes.

See Also:
Serialized Form

Inner classes inherited from class org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Field Summary
static int MODE_ALL
          Action will be enabled if there are one or more selected nodes and all of them support the given cookies.
static int MODE_ANY
          Action will be enabled if there are one or more selected nodes and any of them (one, all, or some) support the given cookies.
static int MODE_EXACTLY_ONE
          Action will be enabled if there is exactly one selected node and it supports the given cookies.
static int MODE_ONE
          Action will be enabled if there are one or more selected nodes and there is exactly one node which supports the given cookies.
static int MODE_SOME
          Action will be enabled if there are several selected nodes and some of them (at least one, but not all) support the given cookies.
 
Fields inherited from class org.openide.util.actions.SystemAction
PROP_ENABLED, PROP_ICON
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
CookieAction()
           
 
Method Summary
protected  void addNotify()
          Notify subclasses that the first listener has been added to this action.
protected abstract  Class[] cookieClasses()
          Get the cookies that this action requires.
protected  boolean enable(Node[] activatedNodes)
          Test for enablement based on the cookies of selected nodes.
protected  void initialize()
          Initialize the action.
protected abstract  int mode()
          Get the mode of the action, i.e. how strict it should be about cookie support.
protected  void removeNotify()
          Notify subclasses that the last listener has been removed from this action.
 
Methods inherited from class org.openide.util.actions.NodeAction
actionPerformed, getActivatedNodes, isEnabled, performAction, performAction, surviveFocusChange
 
Methods inherited from class org.openide.util.actions.CallableSystemAction
getMenuPresenter, getPopupPresenter, getToolbarPresenter
 
Methods inherited from class org.openide.util.actions.SystemAction
clearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, linkActions, putValue, setEnabled, setIcon
 
Methods inherited from class org.openide.util.SharedClassObject
addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removePropertyChangeListener, writeExternal, writeReplace
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

MODE_ONE

public static final int MODE_ONE
Action will be enabled if there are one or more selected nodes and there is exactly one node which supports the given cookies.

MODE_SOME

public static final int MODE_SOME
Action will be enabled if there are several selected nodes and some of them (at least one, but not all) support the given cookies.

MODE_ALL

public static final int MODE_ALL
Action will be enabled if there are one or more selected nodes and all of them support the given cookies.

MODE_EXACTLY_ONE

public static final int MODE_EXACTLY_ONE
Action will be enabled if there is exactly one selected node and it supports the given cookies.

MODE_ANY

public static final int MODE_ANY
Action will be enabled if there are one or more selected nodes and any of them (one, all, or some) support the given cookies.
Constructor Detail

CookieAction

public CookieAction()
Method Detail

mode

protected abstract int mode()
Get the mode of the action, i.e. how strict it should be about cookie support.
Returns:
the mode of the action. Possible values are disjunctions of the MODE_XXX constants.

cookieClasses

protected abstract Class[] cookieClasses()
Get the cookies that this action requires. The cookies are disjunctive, i.e. a node must support AT LEAST ONE of the cookies specified by this method.
Returns:
a list of cookies

initialize

protected void initialize()
Description copied from class: SystemAction
Initialize the action. The default implementation just enabled it.
Overrides:
initialize in class NodeAction

addNotify

protected void addNotify()
Description copied from class: SharedClassObject
Notify subclasses that the first listener has been added to this action. The default implementation does nothing.
Overrides:
addNotify in class NodeAction

removeNotify

protected void removeNotify()
Description copied from class: SharedClassObject
Notify subclasses that the last listener has been removed from this action. The default implementation does nothing.
Overrides:
removeNotify in class NodeAction

enable

protected boolean enable(Node[] activatedNodes)
Test for enablement based on the cookies of selected nodes. Generally subclasses should not override this except for strange purposes, and then only calling the super method and adding a check. Just use cookieClasses() and mode() to specify the enablement logic.
Overrides:
enable in class NodeAction
Parameters:
activatedNodes - the set of activated nodes
Returns:
true to enable


Built on February 22 2001.  |  Portions Copyright 1997-2000 Sun Microsystems, Inc. All rights reserved.