TWiki> Public Web>DpHipe>DpHipePerspectives (revision 4)EditAttach

Creating a Perspective

If you think that a set of (new) views should be presented in convenient way, you can do so by creating a new perspective. Such a perspective defines how these views are layed out in tabs and split panes. This section briefly explains how to contribute a new perspective.

Basic Steps

HIPE Perspective menu
The aim is that your contribution is automatically picked up by the infrastructure, such that your perspective is added to the perspective menu, as shown in the picture on the right.

To make this happen, you will have to:

  • Implement the interface.
  • Register your implementation to the herschel.ia.core.ExtensionRegistry in the

For you convenience an abstract implementation exists (; it allows you to concentrate on implementing one method only:

    public abstract class AbstractPerspective implements Perspective {
	public abstract SitePart doLayout(SitePartBuilder builder);

Construction items

SiteParts are the building blocks of a perspective. We distinct the following flavors:
  • ViewPart - normal views
  • EditorArea - the editor area
  • SplitPart - two windows with a movable split
  • TabPart - n windows organized into tabs

Access to the views, editor area or creation of the tab and split layout containers are all through the SitePartBuilder:

public interface SitePartBuilder {
    ViewPartManager getViewManager();    
    TabbedPart buildTabs(SitePart... parts);
    SplitPart buildSplit(float split, boolean horizontal, SitePart lhs, SitePart rhs);    


The above is explained by an example in which we are going to create a perspective with a familiar layout and register it to HIPE.


The implementation below reflects a classic JIDE layout. My JIDE implementation

public final class MyJidePerspective extends AbstractPerspective {

    public SitePart doLayout(SitePartBuilder builder) {
        // get pointers to the views and editor area
	ViewPartManager vm = builder.getViewManager();

	SitePart editors = vm.getEditor();
	SitePart console = vm.getViewByTitle("Console");
	SitePart history = vm.getViewByTitle("History");

	// actual layout:
	boolean vert = false;
	boolean hori = true;

        SitePart bottom = builder.buildSplit(0.7f, hori, console, history);
	SitePart window = builder.buildSplit(0.7f, vert, editors, bottom);

	return window;


The above code is divided into three stages:

  • Getting hold of the views you are interested in. This is done by asking the builder for the view manager. Then you grab existing views either by title or by a view's unique identifier.
  • Creation of split panes that hold the views. First we create the bottom part (console and history), and then split the window into a top part (being the editor area) and the bottom part we just created.
  • The last part is returning the created site part.


The following snippet, could then go into your

# import
from herschel.ia.core import ExtensionRegistry, Extension

# registry
REGISTRY.register(PERSPECTIVE, Extension(
         "site.perspective.myjide",                   # a unique ID
         "", # the above implementation
         "My JIDE",                                   # how it should be called in the menu
         None                                         # possible icon (none here)

# cleanup

Edit | Attach | Watch | Print version | History: r21 | r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2008-01-15 - JorgoBakker
This site is powered by the TWiki collaboration platform Powered by Perl