TWiki> Public Web>DpHipe>DpHipeViews (revision 6)EditAttach

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:

  • Implement the Viewable interface by sub-classing any %JCOMPONENT% implementation.
  • Register your implementation to the Extension Registry in the file of your sub-system.

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



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's

REGISTRY.register(VIEWABLE, Extension(
         "My View",

See also the Extension Registry documentation for more details.

Example: Add a TableDataset viewer to Hipe (using TablePlotter as an example)

# Create a Component class for the view, for example, TablePlotterComponent and overrde makeEditorContent method

package herschel.ia.gui.explorer.table;

import java.awt.BorderLayout;

import herschel.ia.dataset.gui.Explorer;
import herschel.ia.gui.apps.components.editor.AbstractExplorerComponent;
import herschel.ia.gui.kernel.util.IconLoader;

import javax.swing.Icon;
import javax.swing.JComponent;

public class TablePlotterComponent extends AbstractExplorerComponent {
    private static final long serialVersionUID = 1L;
    private static final Icon ICON = IconLoader.getKernelIcon("data/ImageDataset.gif");

    public TablePlotterComponent() {
    protected boolean makeEditorContent() {
	Object o = getSelection().getValue();
	Explorer explorer = new TablePlotter();
	JComponent component = explorer.getComponent();
	add(component, BorderLayout.CENTER);
        return true;
#Register the viewer (TablePlotter in file)
import herschel
# --- End required code
from herschel.ia.gui.kernel import ExtensionRegistry, Extension

print 'reading'

        "TableDataset viewer",


#Create file if it is not exist in its parent directory (explorer, for example)

Imports all ia sub packages either using "from pck.all import *"  or "from pck import *"
import herschel

Adding features

Trigger 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() {

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, 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


Edit | Attach | Watch | Print version | History: r19 | r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r6 - 2008-03-28 - LijunZhang
This site is powered by the TWiki collaboration platform Powered by Perl