org.jlense.uiworks.perspectives

Perspectives 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.

The platform itself defines one perspective, the Outlook perspective. The Outlook perspective is implemented by the org.jlense.uiworks.internal.OutlookPerspective class. Other platform plug-ins may define additional perspectives although currently none of the JLense plugins do. Your plug-in can define its own perspective by contributing to the org.jlense.uiworks.perspectives extension point.

The specification of the perspective in the plugin.xml is straightforward. The following markup is used by the workbench in defining its own outlook perspective.

<extension point="org.jlense.uiworks.perspectives">
    <!--
    The main UIWorks perspective that displays the Outlook shortcuts
    view on the left and a content area on the right.
    -->
   <perspective
         name="Outlook"
         icon="icons/perspective.gif"
         class="org.jlense.uiworks.internal.OutlookPerspective"
         id="org.jlense.uiworks.OutlookPerspective" />

    <!--
    The main perspective for windows used to host wizards.
    The workbench windows that are opened by the rdefault UIWorks 'New' and 'Open'
    actions are examples of wizards windows.
    -->
   <perspective
         name="Wizard"
         icon="icons/perspective.gif"
         class="org.jlense.uiworks.internal.WizardPerspective"
         id="org.jlense.uiworks.WizardPerspective" />

</extension>

A plug-in must supply an id and name for the perspective, along with the name of the class that implements the perspective. The perspective class should implement IPerspectiveFactory.

We can see from the markup that the real work must be happening 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 layout

One 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.

The Outlook Perspective

The default JLense workbench is configured with a single perspective called the Outlook perspective. The outlook perspective is divided into two folders. The Outlook Shortcuts view is added to the folder on the left. View shortcut perspective extentions (defined in a later section) are added to the shortcut view. Whenever the resulting shortcut is selected the associated view is displayed in the right side folder.