Difference: DpHipeViews (1 vs. 2)

Revision 22008-01-14 - JorgoBakker

Line: 1 to 1

Creating a View

Line: 12 to 12


 \ No newline at end of file

Basic Steps

HIPE View menu

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

To make this happen, you will have to:

  • Implement the herschel.ia.core.parts.Viewable interface by extended a JComponent implementation.
  • Register your implementation to the herschel.ia.core.ExtensionRegistry in the __init__.py

The Viewable interface is a light-weight interface that provides the contents of a View. Your implementation should take the following into account:

  • The implementation must be an extension of a swing component
  • The implementation requires a default, but light-weight constructor. Actual construction of a popup menu, a view menu, or a tool bar or contributions to the main tool bar or main menu (or combinations of them) should be done in the init method.
  • In principle only one instance of a view should exist.
  • The ID returned by your implementation must be unique



public class MyView extends SomeSwingComponent implements Viewable {
    private ViewPart _part;

    // Viewable implementation
    public MyView() {}
    public void   dispose()  {}
    public Icon   getIcon()  { return getPart().getIcon(); }
    public String getId()    { return getPart().getId();   }
    public String getTitle() { 	return getPart().getTitle(); }
    public void   init(ViewPart part) {
	_part = part;

    // private stuff
    private ViewPart getPart() { return _part; }
    private void makeActions() {
	// create tool bars, menus and other stuff


The following snippet registers the above view within your package __init__.py:

# import and short-cuts
from herschel.ia.core import ExtensionRegistry, Extension

# registry
REGISTRY.register(VIEWABLE, Extension(
         "site.view.myview",                  # a unique ID, could be the same as ...
         "resides.in.java.package.MyView",    # the class holding the implementation
         "My View",                           # how it should be called in the menu
         "resides/in/java/package/myview.gif" # resource of possible icon (can be None)

# cleanup

Adding features

Trigger events

Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.core.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events:
    private void somemethod() {

Receiving events

Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.core.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.:
public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener {
    public void init(ViewPart part) {
        part.getEventHandler().addEventListener(SelectionEvent.class, this);

   public void selectionChanged(SiteEvent event) {
       // we *know* that we only receive a SelectionEvent, so:
       SelectionEvent selection=(SelectionEvent)event;


Menus and toolbars


<-- Author: JorgoBakker -->

META FILEATTACHMENT attachment="hipe-menu-view.jpg" attr="h" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" stream="hipe-menu-view.jpg" user="Main.JorgoBakker" version="1"

Revision 12008-01-14 - JorgoBakker

Line: 1 to 1

Creating a View

<-- summary -->
You can develop new views and add them to the work-bench of HIPE. This section briefly explains how to do this.


This site is powered by the TWiki collaboration platform Powered by Perl