Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We will first provide an overview of the main features of the navigation tree; we will then provide a set of #examples examples to show how plugins interact with the navigation tree.

...

The following examples show how to interact with the navigation tree; the code provided in each of them can be compiled in run within JAS3.

Adding and removing FTreeNodes

To add a node to the FTree it is necessary to send an FTreeNodeAddedNotification to the tree specifying the type of the node and its location within the tree (optionally it is possible to provide the object contained in the node). The path can either be a String in the standard unix notation (directories separated by "/") or an FTreePath. The type defines the behavior of the node; two default type are provided: FTreeLeafNode for leaves in the tree, and FTreeFolderNode for folders.

...

To remove an FTreeNode from the tree use an FTreeNodeRemovedNotification as shown in the following code.

Adding nodes on two navigation trees

As mentioned earlier the tree provider allows the user to create new navigation tree; the following code shows how to create two navigation trees adding nodes to them.

Create adapter to define double click on tree node

In the above examples the nodes added on the tree had very little functionality. The code in this example shows how to create an adapter to add the double click action to the leaf nodes. In the example we create a new node adapter by extending the DefaultFTreeNodeAdapter, the default implementation of the FTreeNodeAdapter, overwriting its doubleClick method. When double clicking on the nodes created when running the example an empty editor window will appear whose title is the node's name.

Adding a new sorting algorithm

In the following code a new sorting algorithm is added to the JAS3 lookup table. Running the example a few nodes will be added to the JAS3 navigation tree. By right clicking on the "sortable nodes" folder and selecting the Sorting... menu item you will notice the presence of the algorithm we just added: "Name-length". It sorts nodes based on the length of their name. To achieve this all we had to do was to implement the FTreeNodeSorter interface and register an instance with the lookup table.