Monday, June 25, 2007

ToolBar paths and Archimedes news

The end of the semester is always a disaster. Tons of things to do and not enough time.
For once I don't have tons of tests, the only hard work is to maintain the job, the work on Archimedes, the studies and the corrections going.

Anyway, enough complaining.
I got some news about Archimedes:
This release is coming to an end but I am proud to say that most of the work that should have been done is complete. There are a few details missing but those are mostly related to difficulties we are finding with RCP.
Both the import and the export feature that will become the save and open one are finished, all that is left to do is to integrate this with the platform so that the users can enjoy all the flexibility of Eclipse's wizards.

Also, Mariana is now responsible for releasing updates for the old 0.17.x version and get our bug fixes and new features ported to that platform until the RCP one is not perfect. I wish her luck and hope to see a lot of report from you guys when she does.

Most of the reported bugs have been correct so far and I even learned how to organize the action icons on the toolbar. This means that, from now on, Archimedes' toolbar will be a bit more organized than it was before.

Since I found absolutely NO documentation about this, I wanted to write a little bit about how to make it work. It is quite simple but worth saying.

Mainly, when you extend org.eclipse.ui.actionSet and create an action, you can add two attributes: menubarPath and toolbarPath. The first one is quite decently documented so you can find several tutorial that will explain you that you should add some MenuManagers in your ApplicationActionBarAdvisor and then refer to the paths you set on those managers to decide where the actions should appear.

Regarding the latter, you will find almost nothing. I've search a lot and very little is published to explain you one very tiny and simple thing: It works EXACTLY the same way. May sound stupid for me to say it like that but if you have no documentation or example, this may not be evident because when you create ToolBarManagers, you cannot add slots within those to specify boxes where the actions should appear. However, you must pretend that you did. In most cases, this will mean that you will simply copy paste whatever you did on the menubarPath to the toolbarPath.

I am pasting a simplified version of the fillMenuBar method and the fillCoolBar one as well as a couple of plugins that add actions to those slots.

protected void fillCoolBar (ICoolBarManager coolBar) {
  IToolBarManager fileBar = new ToolBarManager(coolBar.getStyle());
  coolBar.add(new ToolBarContributionItem(fileBar, "file"));


protected void fillMenuBar (IMenuManager menuBar) {
  MenuManager fileMng = new MenuManager("File", "file");
  fileMng.add(new GroupMarker("start"));
  fileMng.add(new Separator());
  fileMng.add(new GroupMarker("end"));

With those method set up, you can add plugins (or just your RCP application xml descriptor) that use those paths:

<actionSet description="The action set containing some file actions."
  id="" label="File Action Set"
    <action icon="icons/my_icon.png" style="push"
      label="My Action" tooltip="An example action"

If you just add a couple more of those plugins, you will see that all the actions will be grouped both on the menu and on the toolbar.

And that's about it for now. Have fun guys.

No comments: