Difference: DpHipeViews (5 vs. 6)

Revision 62008-03-28 - LijunZhang

Line: 1 to 1
 
META TOPICPARENT name="DpHipe"

Creating a View

Line: 90 to 90
 
Added:
>
>

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() {
	super(ICON);
    }   
    @Override
    protected boolean makeEditorContent() {
	Object o = getSelection().getValue();
	Explorer explorer = new TablePlotter();
	explorer.setObject(o);
	JComponent component = explorer.getComponent();
	add(component, BorderLayout.CENTER);
	component.addMouseListener(getArea().getMouseListener());
        return true;
    }
}
#Register the viewer (TablePlotter in init.py file)
import herschel
herschel.recursive_module_lookup(__name__,__path__,__file__)
del(herschel)
# --- End required code
from herschel.ia.gui.kernel import ExtensionRegistry, Extension
COMPONENT=ExtensionRegistry.COMPONENT
REGISTRY=ExtensionRegistry.getInstance()

print 'reading init.py'

REGISTRY.register(COMPONENT,Extension(
        "TableDataset viewer",
        "herschel.ia.gui.explorer.table.TablePlotterComponent",
        "factory.editor.variable",
        "herschel.ia.dataset.TableDataset"));

__all__=[]

#Create all.py 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
herschel.loadpckg(globals(),
                  "herschel.ia.gui.explorer",
                  ['table'])
del(herschel)

 

Adding features

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