projectviewer.action
Class Action

java.lang.Object
  extended byprojectviewer.action.Action
All Implemented Interfaces:
java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
ActionSeparator, ArchiveAction, CollapseAllAction, EditGroupAction, EditProjectAction, ExpandAllAction, FileImportAction, LaunchBrowserAction, MoveNodeAction, NodeRemoverAction, NodeRenamerAction, OldStyleAddFileAction, OpenWithAppAction, OpenWithEncodingAction, ReimportAction, SearchAction, UpAction, VFSFileImportAction

public abstract class Action
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Cloneable

An action defines an action to be taken when the user presses some menu item in the tree's context menu or a button on the toolbar.

Version:
$Id: Action.java 7185 2006-10-07 19:14:01Z ezust $
Author:
Marcelo Vanzin

Field Summary
protected  java.lang.String action
           
protected  javax.swing.JComponent cmItem
           
protected  org.gjt.sp.jedit.gui.RolloverButton tbButton
           
protected  ProjectViewer viewer
           
 
Constructor Summary
protected Action()
          Creates a regular action.
protected Action(java.lang.String action)
          Creates an action tied to an action name.
 
Method Summary
 java.lang.Object clone()
          Clones the current action, returning a copy of it.
 org.gjt.sp.jedit.gui.RolloverButton getButton()
          Returns the toolbar button that triggers this action.
 javax.swing.Icon getIcon()
          Returns the icon to be shown on the toolbar button.
 javax.swing.JComponent getMenuItem()
          Returns the menu item that triggers this action.
abstract  java.lang.String getText()
          Returns a String that will be shown as the text of the menu item or the tooltip of the toolbar button.
 void prepareForNode(VPTNode node)
          When a node is selected (for the toolbar button) or when the context menu is shown (for the menu item), this method is called and the selected node is passed, so the action can choose whether the action will be available or not for that node.
 void setViewer(ProjectViewer viewer)
          Sets the viewer where this action is being used.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

viewer

protected ProjectViewer viewer

tbButton

protected org.gjt.sp.jedit.gui.RolloverButton tbButton

cmItem

protected javax.swing.JComponent cmItem

action

protected java.lang.String action
Constructor Detail

Action

protected Action()
Creates a regular action.


Action

protected Action(java.lang.String action)
Creates an action tied to an action name. If the action name is not null, the default menu item created will be a jEdit EnhancedMenuItem tied to the action name; this will allow the item to show the currently assigned shortcut of the action, if any. The action listeners are removed from the menu item so that only the actionPerformed() method on this instance is called, avoiding using the jEdit action mechanism for this instance.

Method Detail

getText

public abstract java.lang.String getText()
Returns a String that will be shown as the text of the menu item or the tooltip of the toolbar button.


prepareForNode

public void prepareForNode(VPTNode node)
When a node is selected (for the toolbar button) or when the context menu is shown (for the menu item), this method is called and the selected node is passed, so the action can choose whether the action will be available or not for that node. A common action would be disable the button or hide the menu item.

By default, does nothing.

Parameters:
node - The selected node, or "null" if multiple nodes are selected.

getIcon

public javax.swing.Icon getIcon()
Returns the icon to be shown on the toolbar button. The default implementation returns "null" so that actions that will only be used in the context menu don't need to implement this.


getMenuItem

public javax.swing.JComponent getMenuItem()
Returns the menu item that triggers this action. This returns a JComponent, which makes it possible to add virtually anything to the menu. For example, it's possible to return a sub-menu instead of a simple menu item. The default implementation returns a menu item, which is stored in the "cmItem" variable.


getButton

public org.gjt.sp.jedit.gui.RolloverButton getButton()
Returns the toolbar button that triggers this action.


clone

public java.lang.Object clone()
Clones the current action, returning a copy of it.


setViewer

public void setViewer(ProjectViewer viewer)
Sets the viewer where this action is being used.