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!

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) {
            @Override
	    public void actionPerformed(ActionEvent e) {
		_button.setText("Cleared");
	    }
	};

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.

Menus

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);

Toolbars

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);

Note that these instructions assume that the action belongs to a View, so that you can use the ViewPart of the View to access the ActionBars. If an action is not associated to any View, then you should introduce an ActionMaker for the action. For an example, see herschel.ia.gui.apps.views.status.StopActionMaker.

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:

	this.addMouseListener(getPart().getMouseListener()); 	 

Drag & drop

HIPE supports drag & drop of selections.

A component that wants to enable it must implement the DnDSelection interface and register itself:

	SelectionTransferHandler.register(this);  // this is the Component being built

The selection type returned by getSelectionType() specifies the kind of selections that can be handled: variables, files...


blog comments powered by Disqus
Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2014-02-19 - AlvarGarcia
 
This site is powered by the TWiki collaboration platform Powered by Perl