Adding Components to existing Views

The contents of certain views can be extended by developers, such as the Outline View and the Editor Area. Both are examples of the system reacting on a data selection made by the user.

Here we explain how you can contribute to the outline view and the editor area.


Outline View

Whenever the user selects a session variable in the VariablesView, a SelectionEvent is sent around.
The OutlineView is listening to such an event and it tries to find the appropriate component that can show the outline information of that variable.

The contract for outline components is:

The recommended way of implementing OutlineComponent is by extending ObjectOutline, which provides a table with basic information about the variable.
Methods getExtraTableInfo() and getExtraComponent() may be overriden as needed for providing extra information about your type.

An example:

Suppose you would like to create an outline for FineTime variables and you would like to show the contents in the outline view whenever a session variable of that type is selected by the user.

Component Implementation

In this example, we simply add an entry to the ObjectOutline with the contents of the FineTime.

public class FineTimeOutline extends ObjectOutline {

    @Override
    protected Object[][] getExtraTableInfo() {
        Object time = getSelection().getValue();
        return new Object[][] { { "time", time.toString() } };
    }
}

Component Registry

The following snippet, could then go into your __init__.py:

# Register to the variable outline factory
REGISTRY.register(COMPONENT,Extension(
                 "My FineTime Outline",
                 "resides.in.java.package.FineTimeOutline",
                 "factory.outline.variable",
                 "herschel.share.fltdyn.time.FineTime"))

See also the Extension Registry documentation for more details.

Source Code of Basic implementations

The ia_gui_apps contains some basic implementations for OutlineComponents:

Tip, idea If you have a sub-class of e.g. a product, you can also create a dedicated OutlineComponent for that sub-class, which will be picked up instead of the default ProductOutline.

Editor Area

The above showed an example of extending the outline view by adding an OutlineComponent. Similarly, you can contribute by developing a specific EditorComponent.

Editor components are editors (optionally read-only) of data contents of a specific variable that is selected within in the HIPE session.
They are triggered by double-clicking on a variable, or through the open with menu. Editor components are opened in the editor area.

The contract for editor components is:

Simple Example Code

import herschel.ia.gui.kernel.parts.AbstractVariableEditorComponent;

/**
 * Editor component for SomeType.
 */
public class SomeEditorComponent extends AbstractVariableEditorComponent<SomeType> {

    public Icon getComponentIcon() {
	return ...;
    }

    @Override
    protected Class<SomeType> getVariableType() {
	return SomeType.class;
    }

    @Override
    protected boolean makeEditorContent() {
        String name = getKey();
        SomeType value = getValue();
        JComponent content = ...;    // build the content with the provided value
        add(content);
        return true;
    }
}

Source Code of Basic implementations

The ia_gui_apps contains some basic implementations for EditorComponents:

Your Explorer Implementation

You may have created an implementation of the former Explorer interface which is used by the dataset inspector (and is registered within that inspector).

If you do not expect that your explorer needs to talk to other parts within the HIPE application, you can simply extend AbstractExplorerComponent:

public class ArrayDataComponent extends AbstractExplorerComponent<ArrayData> {
    private static final Icon ICON = ...

    public ArrayDataComponent() {
	super(ICON);
    }   

    @Override
    protected Class<ArrayData> getVariableType() {
	return ArrayData.class;
    }
}

That's it. Your explorer would be picked up for showing the values it is registered to manage (see next section).

Component Registry

Editor components need to be registered for telling the types they are interested in. This is to be done within your __init__.py:

# Register to the editor component factory
REGISTRY.register(COMPONENT,Extension(
                 "Some editor",
                 "herschel.your.module.views.SomeEditorComponent",
                 "factory.editor.variable",
                 "herschel.your.module.SomeType"))


This topic: Public > DpHipe > DpHipeComponents
Topic revision: r10 - 2009-12-02 - DavideRizzo
 
This site is powered by the TWiki collaboration platform Powered by Perl