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 send a message to the Editorial Board to tell us about it. Thank you in advance!

Menus, toolbars, drag & drop

Menus, toolbars, pop-ups and drag & drop are supported in the HIPE interface and in the View components via the same set of interfaces.

The main contract is to implement the SiteAction interface which has an utility implementation AbstractSiteAction where the only required task is to define the actionPerformed method:

	clear = new AbstractSiteAction(SiteAction.Style.AS_PUSH, CLEAR_ACTION, "Clear", IconLibrary.DELETE) {
	    public void actionPerformed(ActionEvent e) {

Once the action is defined it is possible to associate it to a visible entry. HIPE comes with a predefined set of entries which are commonplaces for standard look and feel and similar operations. This insertion points are available via the Insert class which enumerates the allowed Extension values.

actions.insert(new Insert(Insert.Scheme.TOOLBAR, ID, Insert.Extension.RUN_ADDON), clear);

This code associates the clear action to an entry in the toolbar. More specialized examples are provided in the later paragraphs.


HIPE supports the development of menus in two areas:

  • Main menu
  • View menu

Once the action responsible for performing the code is defined, associating it with the predefined set of menus, toolbars and pop-ups just requires to get the handle to the right entity.

Each View has at its disposal an area for adding menu entries based on the general contract of the HIPE menu items.

It is possible to access the HIPE menu associated to each View via the ViewPart received at initialization time (method init of the Viewable contract for View).

	clear = // AS BEFORE

	ActionBars viewMenu = getPart().getActionBars(ID);
	viewMenu.insert(new Insert(MENU, ID, RUN_ADDON), clear);

As for the main menu, only the Editor area is allowed to redefine it. Nevertheless its internal behaviour is identical to the View one and it is described here for completeness.

The main menu entries are accessible via herschel.ia.gui.kernel.menus.Insert.MAIN, which provides the handle to the identifier used for the main toolbar and menus.

Adding a new entry to the main menu:

	ActionBars mainMenu = getPart().getActionBars(MAIN);
        mainMenu.insert(new Insert(MENU, MAIN, RUN_ADDON),run);	

Retargeting the default entries:

	mainMenu.retarget(Retarget.COPY, copy);
	mainMenu.retarget(Retarget.SAVE, save);


Developing entries for the toolbar is identical to menu development. Only the Insert specification is different

	clear = // AS BEFORE

	ActionBars menus = getPart().getActionBars(ID);
	menus.insert(new Insert(TOOLBAR, ID, RUN_ADDON), clear);

Adding entries to the main toolbar is just as easy:

	clear = // AS BEFORE

	ActionBars menus = getPart().getActionBars(MAIN);
	menus.insert(new Insert(TOOLBAR, ID, RUN_ADDON), clear);

Pop-up menus

Again, support for pop up menus is just as easy:

	clear = // AS BEFORE

	ActionBars menus = getPart().getActionBars(ID);
	menus.insert(new Insert(POPUP, ID, RUN_ADDON), clear);

An extra action is required to make your displayed compoment aware of the pop-up:


Drag & drop

HIPE uses a simplified support for drag & drop, whose main target is to be able to pass references from the Jython namespace.

A class that wants to implement the HIPE protocol must implement the DnDSelection interface and declare it to the Java TransferHandler system by registering it:

	setTransferHandler(new TransferHandler("variableSelection"));
This simple mechanism allows for receiving VariableSelection.

Please add your comments!

This topic: Public > DpHipe > DpMenusToolbarsDragDrop
Topic revision: r3 - 2011-06-24 - DavideRizzo
This site is powered by the TWiki collaboration platform Powered by Perl