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:
start()
method of your EditPlugin implementation.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
{@link projectviewer.vpt.VPTNode#open() 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.
There are two methods of registering node handlers with the PV plugin. The first one is to call the {@link projectviewer.persist.ProjectPersistenceManager#registerHandler(NodeHandler) 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.