...
Method | Description |
---|---|
getId() | Unique ID |
getUI() | Return the Composite panel |
getDisplayName(Locale l) | Localized name |
getPerspectiveIcon() | Icon to be showed in the toolbar |
setActive(boolean active) | Notification when active state changes |
getOverlays() | Return a list of XulOverlays to apply when your perspective is activated |
getEventHandlers() | Return a list of XulEventHandlers to be added to Spoon |
addPerspectiveListener(...listener) | Allows outside code to register to for activation events for this perspective |
getActiveMeta() | Return the active EngineMeta in the case of perspectives with save-able content |
Code Block | ||
---|---|---|
| ||
public class HelloWorldSwtPerspective implements SpoonPerspective {
private Composite comp;
private static HelloWorldSwtPerspective instance = new HelloWorldSwtPerspective();
private HelloWorldSwtPerspective(){
createUI();
}
private void createUI(){
comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lbl = new Label(comp, SWT.CENTER);
lbl.setLayoutData(new GridData(GridData.FILL_BOTH));
lbl.setText("This perspective has added two menu-items to the Spoon menu-system. One is under " +
"Tools->\"Spoon Plugin Example\", the other is only visible when the perspective is active: " +
"Edit->\"Perspective Only Action\"");
}
public static HelloWorldSwtPerspective getInstance(){
return instance;
}
public void setActive(boolean b) {
}
public List<XulOverlay> getOverlays() {
return Collections.singletonList((XulOverlay) new DefaultXulOverlay("org/pentaho/di/plugins/examples/helloworld/res/spoon_perspective_overlay.xul"));
}
public List<XulEventHandler> getEventHandlers() {
return Collections.singletonList((XulEventHandler) new HelloWorldPerspectiveHandler());
}
public void addPerspectiveListener(SpoonPerspectiveListener spoonPerspectiveListener) {
}
public String getId() {
return "helloWorld";
}
// Whatever you pass out will be reparented. Don't construct the UI in this method as it may be called more than once.
public Composite getUI() {
return comp;
}
public String getDisplayName(Locale locale) {
return "Spoon Example";
}
public InputStream getPerspectiveIcon() {
ClassLoader loader = getClass().getClassLoader();
return loader.getResourceAsStream("org/pentaho/di/plugins/examples/helloworld/res/blueprint.png");
}
/**
* This perspective is not Document based, therefore there is no EngineMeta to save/open.
*/
public EngineMetaInterface getActiveMeta() {
return null;
}
}
|