PerspectivesPerspectives provide an additional layer of organization inside a workbench window. A perspective defines a collection of views, a layout for the views, and the visible action sets that should be used when the user first opens the perspective. Your plug-in can define its own perspective by contributing to the org.jlense.uiworks.perspectives extension point. Once a perspective is defined views and action sets may be added to the perspective via the org.jlense.uiworks.perspectiveExtensions extension point. Plugins may even add perspective extensions to perspectives declared in other plugins. The specification of a perspective in the plugin.xml is straightforward. Most perspective declarations look almost exactly like the following definition. <extension point="org.jlense.uiworks.perspectives"> <perspective id="org.jlense.examples.helloworld" name="Hello World" class="org.jlense.uiworks.part.StandardPerspective" category="org.jlense.examples" availableAsShortcut="true" /> </extension> A plug-in must supply an id and name for the perspective, along with the name of the class that creates the perspective. The perspective class should implement the IPerspectiveFactory interface. The UIWorks provides a default perspective factory, org.jlense.uiworks.part.StandardPerspective. We can see from the markup that the real work of creating a non-trivial perspective must happen in the code. The interface for the perspective factory is straightforward. Implementors of IPerspectiveFactory are expected to configure an IPageLayout with information that describes the perspective and its perspective page layout. Workbench part layoutOne of the main jobs of an IPageLayout is to describe the placement of the views in the workbench window. Note that these layouts are different than layouts in Swing. Although IPageLayout and Swing layouts solve a similar problem (sizing and positioning widgets within a larger area), you do not have to understand Swing layouts in order to supply a perspective page layout. The perspective factory is responsible for adding additional views relative to a view. Views are added to the layout relative to (top, bottom, left, right) another part. Placeholders (empty space) can also be added for items that are not initially shown. To organize related views and reduce clutter, you can use IFolderLayout to group views into tabbed folders. Placeholders are commonly used with folder layouts. |