Package projectviewer.action

Creating custom actions.

See:
          Description

Class Summary
Action An action defines an action to be taken when the user presses some menu item in the tree's context menu.
ActionSeparator Small hack to enable a separator to be shown when some other action is also shown.
AddProjectAction Action that when executed creates a new project.
ArchiveAction Opens the search dialog for the selected directory/project.
CollapseAllAction Expands all nodes of the current tree.
EditGroupAction Action that when executed creates a new group or edits an existing one.
EditProjectAction Action that when executed edits an existing project.
ExpandAllAction Expands all nodes of the current tree.
FileImportAction Action that when executed imports files into a node.
LaunchBrowserAction Opens the selected file in the configured web-browser.
LaunchBrowserAction.Helper Class to hold references to classes that may not be available, so this class can behave well when called from a BeanShell script.
MoveNodeAction Action to move a project or group into another group.
NewFileAction Action that when executed creates a new file under the current node.
NodePropertiesAction Shows a dialog with properties for the selected node.
NodeRemoverAction Action that when executed removes nodes from the trees.
NodeRenamerAction Action for renaming files, directories and projects.
OpenCloseAllProjectFilesAction Action that when executed opens/closes all project files.
OpenParentGroupAction Action that when executed closes the current project.
OpenSelectedAction Opens all selected file nodes.
OpenWithAppAction Opens a file with a registered application, using PV-specified or desktop-configured file associations.
OpenWithEncodingAction Opens a node in jEdit using a specific character encoding.
ReimportAction Removes all the files below the root from a project, and then calls the initial project importer.
SearchAction Opens the search dialog for the selected directory/project.
SearchAction.NodeFileSet Implements a SearchFileSet representing files that are children of a given node and its children.
SetActiveAction Action that when executed opens the project pointed by the selected node.
UpAction A tree action that moves the selection up.
UpdateVCSStatusAction Action that causes the current version control system to update the status of the node.
 

Package projectviewer.action Description

Creating custom actions.

ProjectViewer allows other plugin developers too interact with the file trees by creating custom actions to be executed on the nodes. The actions are made available on the tree's context menu.

Creating a new action is very simple:

The menu item show in the context menu is provided by the getMenuItem() of the Action class. Subclasses are welcome to override this method to provide other kinds of menu items (a sub-menu, for example).

Before showing the menu item in the context menu, ProjectViewer will call the prepareForNode() method in all actions registered in the context menu. This allows each action to decide if it should be shown for the given node and what message to show, for example.

Another important thing to notice in the prepareForNode() method is that the actions should check is the node is of a certain type, and not if the node is not of a certain type. For example, use "node.isFile()" and not "!node.isDirectory()". This ensures that the action will not do anything wrong if a different node type is added in the future to PV, or if another plugin adds a custom node type to PV.

It's important to notice that the instance created by jEdit's ServiceManager is not the instance used by the viewer instances. Those instances are used as prototypes, and the viewers use clone() to get instances for the specific viewer. After the cloning, the setViewer() method is called, so the actions have a reference to the viewers where they are being used. This also means that you should not use the constructor of your Action implementation to instantiate GUI components. Instantiations of GUI components should be done lazily in the getMenuItem() method. The default implementation already does this, so you should only worry about this if you are overriding one of these methods.