Package projectviewer.vpt

Creating custom nodes.

See:
          Description

Interface Summary
IconComposer.VCProvider Version control plugins that want to provide file status info to PV should implement this interface.
 

Class Summary
IconComposer Create decorated icons for VPT nodes
VFSFile Models a file accessed using jEdit's VFS.
VPTCellRenderer Used by the jTree to underline the file name when it's opened.
VPTCompactModel A tree model that compress the view by displaying packed directories.
VPTCompactModel.CompactDirectoryNode  
VPTContextMenu A handler for context menu requests on the tree, providing node-sensitive functionality.
VPTDirectory Models a directory that is part of a project.
VPTFile Models a file that is part of a project.
VPTFileListModel A tree model that represents all files in a project without any relationship to the nodes they are a child of.
VPTFilterData  
VPTFilteredModel A tree model that compress the view by displaying packed directories.
VPTGroup A VPTGroup is a container for groups and projects.
VPTNode Node implementation for the Virtual Project Tree.
VPTProject Models a project.
VPTRoot The root of the tree.
VPTSelectionListener Listens to the project JTree and responds to file selections.
VPTWorkingFileListModel A tree model that shows all files currently opened in jEdit in a flat list.
 

Package projectviewer.vpt Description

Creating custom nodes.

It's possible to create new kinds of nodes to be inserted into a project. Although not tested, all the necessary functionality is available. To create a new kind of node, the following steps need to be taken:

These steps should be enough to create a new kind of node and make it be automatically persisted by the ProjectViewer plugin with the corresponding project. You may want to provide other actions to be executed on the given node (by creating more Action subclasses), or implement the open() method of the node to specify an action to be executed when the node receives a double click on the tree. When implementing open(), make sure to make the close(), canOpen() and isOpened() methods consistent with your implementation.

Implementing new nodes should be considered highly experimental, so bear that in mind when going through this path.

Registering a NodeHandler with the ProjectViewer plugin

There are two methods of registering node handlers with the PV plugin. The first one is to call the registerHandler(NodeHandler) method of the ProjectPersistenceManager class. The second one uses a jEdit 4.2-style API for registering the handler. Just declare a property named plugin.projectviewer.class name.context-menu-actions and provide a comma-separated list of class names that should be registered. The classes must extend the NodeHandler class.

Registering custom node handlers has one shortcoming: when your plugin is unloaded, the classes won't be able to be garbage collected. This happens because there's no safe way to remove the custom nodes that have been added to the project and wait for the plugin to be activated again to create a new version of that node with the new instance of the Class. So, the ProjectViewer plugin will keep a reference to the custom node's class and to the node handler's class so that it is possible to persist that node when the project is saved.

If you develop custom nodes, you should keep this in mind to make sure that this does not affect the newly loaded instance of your plugin. Declaring ProjectViewer as an optional dependency for your plugin should fix this issue, since it will make jEdit reload ProjectViewer when your plugin is reloaded.