org.openide.util.actions
Class ProjectSensitiveAction

java.lang.Object
  |
  +--org.openide.util.SharedClassObject
        |
        +--org.openide.util.actions.SystemAction
              |
              +--org.openide.util.actions.CallableSystemAction
                    |
                    +--org.openide.util.actions.ProjectSensitiveAction
All Implemented Interfaces:
Action, ActionListener, EventListener, Externalizable, Presenter, Presenter.Menu, Presenter.Popup, Presenter.Toolbar, Serializable
Direct Known Subclasses:
BuildProjectAction, CompileProjectAction, DebugProjectAction, ExecuteProjectAction, SaveProjectAction

public abstract class ProjectSensitiveAction
extends CallableSystemAction

Base class for all project sensitive actions. Attaches listener to changes of project desktop (TopManager.PROP_PLACES) and also to cookie changes on current project desktop. If either one is changed, the enable method is called to enable/disable the action. When enabled and invoked the method performAction (Node) is called.

See Also:
Serialized Form

Inner classes inherited from class org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
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
ProjectSensitiveAction()
           
 
Method Summary
 void actionPerformed(ActionEvent ev)
          Actually perform the action.
protected  void addNotify()
          Notify subclasses that the first listener has been added to this action.
protected abstract  boolean enable(Node project)
          Performs the action on the current project desktop node.
protected  void initialize()
          Initialize the action.
 boolean isEnabled()
          Test for enablement based on enable(org.openide.nodes.Node).
 void performAction()
          Performs the action.
protected abstract  void performAction(Node project)
          Performs the action on the current project desktop node.
protected  void removeNotify()
          Notify subclasses that the last listener has been removed from this action.
 
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
 

Constructor Detail

ProjectSensitiveAction

public ProjectSensitiveAction()
Method Detail

initialize

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

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 SharedClassObject

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 SharedClassObject

isEnabled

public boolean isEnabled()
Test for enablement based on enable(org.openide.nodes.Node). You probably ought not override this, except possibly to call the super method and add an additional check.
Overrides:
isEnabled in class SystemAction
Returns:
true to enable

actionPerformed

public void actionPerformed(ActionEvent ev)
Description copied from class: SystemAction
Actually perform the action. Specified in ActionListener.actionPerformed(java.awt.event.ActionEvent).

In some cases, the implementation may have an empty body, if the presenters handle the performing of the action in a different way than by calling this method.

When run in the normal way from the action manager (e.g. as part of a standard menu or toolbar presenter), the action body can block and take time, but needs to explicitly ask to enter the AWT event thread if doing any GUI work. See the Threading Models document in API documentation for details.

Overrides:
actionPerformed in class CallableSystemAction
Following copied from class: org.openide.util.actions.SystemAction
Parameters:
ev - the event triggering the action

performAction

public void performAction()
Performs the action. In the default implementation, calls performAction(Node). In general you need not override this.
Overrides:
performAction in class CallableSystemAction

performAction

protected abstract void performAction(Node project)
Performs the action on the current project desktop node.
Parameters:
project - desktop node

enable

protected abstract boolean enable(Node project)
Performs the action on the current project desktop node.
Parameters:
project - desktop node
Returns:
true to be enabled, false to be disabled


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.