![]() | The Java Developer's Guide to Eclipse |
In Chapter 18, Views, you learned how to create views and we have provided you with
several examples to help you understand the basics. This view is different; it
attempts to implement a tool that you may find useful when working with Eclipse. We like it
because it helps us find similar files across many folders, but
we'll let you make your own decision; and since the source for it is in
the com.ibm.jdg2e.view.files project, you can make any improvements you desire.
That said, this view still demonstrates some of the implementation strategies for views that
you should consider in your development work. These include structure, use of viewer
sorter and filter components, reuse of Eclipse actions, and the use of mutiple types of jobs
to manage content access and delivery.
You may also wish to review these other view-related example plug-ins:
These are located in the
com.ibm.jdg2e.view.simplemodel,
com.ibm.jdg2e.view.basic,
and com.ibm.jdg2e.view.marker projects, respectively.

IContainer. This includes opening the view on a working set when they are the top level
elements displayed in the Package Explorer view.While multiple view instances may not be appropriate in a single perspective, we'll show you in a minute that it can be managed. The technique to open another view instance is often useful if you use the view in two different perspectives. The second instance has its own File name criteria input field, individual control over other options, and can even manage a unique column width arrangement.
By default the view uses any currently selected resource or working set as its input and the view title changes to match. This selection triggers the process of finding the files and determining which should be displayed. While jobs are used to find and add content to the viewer, a very large resource tree can sometimes overwhelm the find and display processing. But, if you change your mind before it has finished finding all the files, the view cancels the active and waiting jobs and starts over on the new input.
The view drop down menu and action bar provide options to control view behavior.
.class files.The view displays files, but you have some control over which and what information is presented as part of the standard display. All of the points discussed below are visible in the view image shown above.

The view includes several context menu options, and as the context menu is registered with the workbench,
any other contribution that targets IResource or IFile objects will
also be shown. Sorting is also supported.
Note: The view will not react to selection when it is behind other views or not in the active perspective. This was by design as it prevents unnecessary processing. Minimizing the view is not enough, it must actually be behind another view (which may be minimized).
The File Resources View plug-in is structurally the same as the other view examples. There are just a few more viewer helpers in the form of sorters and filters.
The view has a user interface, actions in the toolbar and pull-down menu, as well as the context menu for the viewer used in the user interface. This is the limit of its function.
The plug-in manifest file defines the extension definition
for the view, the popup menu to open additional instances, the perspective extensions to add Show In Part support,
help contexts for F1 help, and a UI theme for the color customization.
The table below contains the key classes from the com.ibm.jdg2e.view.files
package that are used to implement the view part and its associated JFace viewer user interface.
| Class (All) | Description |
OpenFileView |
Used to open additional instances of the File Resources view. |
FileView |
This class implements the view's user interface and function. This includes the
NameFilter
used to determine which files are included in the display. |
FileContentProvider |
Accesses workspace resources using a
resource proxy visitor
to find files.
The visitor is run as part of a
FileFinder
job. The results of the visit are actually sent to the viewer asynchronously using an
AddToViewer
workbench job.
|
FileLabelProvider |
Create the column content for the viewer. |
Viewer Filter and Sorters |
A filter and various sorters are used to control the display. |
© Copyright International Business Machines Corporation, 2003, 2004. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.