Tags:
create new tag
view all tags

PDF Version Portrait Landscape

Help 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 view

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


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:

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(ViewPart part) method.
  • In principle only one instance of a view should exist.
  • The ID returned by your implementation must be unique

Example

Implementation

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;
	makeActions();
    }

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

Registry

The following snippet registers the above view within your package's init.py:

REGISTRY.register(VIEWABLE, Extension(
                 "site.view.myview",
                 "resides.in.java.package.MyView",
                 "My View",
                 "resides/in/java/package/myview.gif"))

See also the Extension Registry documentation for more details.

Adding features

Triggering events

Your viewable may want to trigger site events which might be interesting to other views. The ViewPart interface that is passed on through the init method gives you the means of triggering site events:
    private void someMethod() {
        :
        getPart().getEventHandler().trigger(aSiteEvent)
        :
    }

Receiving events

Your viewable may want to listen to site events produced by other views. For that you have to implement the SiteEventListener interface and inform the event handler that you are interested in one or more event types, for instance:
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;
       :
   }

}


blog comments powered by Disqus
Edit | Attach | Watch | Print version | History: r19 < r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r19 - 2014-02-18 - AlvarGarcia
 
This site is powered by the TWiki collaboration platform Powered by Perl