DSF Filesystem Browser Example

Goals

This example demonstrates an implementation of a viewer model with a layout node that has itself as a child.  Such layout nodes are needed to represents elements which themselves have a natural tree structures.  This example uses filesystem folders as the tree-structured data, which is retrieved directly from the java.io.File class.  This example also demonstrates a viewer model implementation which does not retrieve data using DSF services and associated data model interfaces. 

Design

Model Adapter Hookup
A flexible-hierarchy tree viewer {@link org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer} is created within a model dialog.  Corresponding {@link FileBrowserModelAdapter} and {@link FileBrowserVMProvider} classes are instanciated, and the root element object created by FileBrowserVMProvider is set as input to the tree viewer.  From there FileBrowserModelAdapter is returned as the {@link IElementContentProvier} and {@link IModelProxyFactory} for all elements in the tree.

Layout Nodes
There are three layout nodes:

Both FilesystemRootsLayoutNode and FileLayoutNode create elements of the same type: {@link FileVMContext}.  Additionally, when populating elements in the tree, the FileLayoutNode requires that a FileVMContext element be the parent element in order to be able to retrieve its children. 

Event Handling/Generating Model Deltas
The view model responds to events generated by a text box in the dialog, where the user can type in a filesystem path.  If the entered path resolves to a file on the filesystem, the view model generates a delta to select and reveal the given file in the tree.  The two file layout nodes handle generating the delta in different ways:

How to use

  1. Make sure that the DSF examples menu is visible in the perspective
  2. Open the dialog by selecting DSF Examples->Open File Browser Dialog menu item.
  3. Expand the items in the tree to see filesystem contents.
  4. Select elements in the tree, to fill in text box with selected file's path.
  5. Type in a file path in text box and have the tree expand to the specified element.