Did you spot something wrong or missing on this page? If you have an account on this TWiki, you can fix it yourself by editing the page. If you don't have an account, you can leave a message at the bottom of the page to tell us about it. Thank you in advance!
Creating a Perspective
If you think that a set of (new) views should be presented in standard layout, you can do so by creating a new perspective. Such a perspective defines
how these views are laid out in tabs and split panes. This section briefly explains how to contribute a new perspective.
See also the overview page.
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:
The above is explained by an example in which we are going to create a simple perspective with just three views. Next we are going to register it to HIPE.
Implementation
The implementation below is made of three views: Editor, Console and History.
public final class MySimplePerspective extends AbstractPerspective {
@Override
public SitePart doLayout(SitePartBuilder builder) {
// get pointers to the views and editor area
ViewPartManager vm = builder.getViewManager();
SitePart editors = vm.getEditorArea();
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.
Registry
The following snippet, could then go into your __init__.py:
REGISTRY.register(PERSPECTIVE, Extension(
"site.perspective.mysimple", # a unique ID
"resides.in.java.package.MySimplePerspective", # the above implementation
"My Simple", # how it should be called in the menu
None # possible icon (none here)
))