Where to action registry code from GEF redbook [message #234269] |
Fri, 18 May 2007 21:55  |
Eclipse User |
|
|
|
Originally posted by: mlevison.gmail.com
In the EMF/GEF redbook there is some sample code that demonstrates
installing zoom menu and tool bar items. Unfortunately I can't get to
work as advertised.
The first problem is where to put the code discussed in Example 4-6
which is similar to this code:
ZoomManager zoomManager = getZoomManager();
IAction zoomIn = new ZoomInAction(zoomManager);
IAction zoomOut = new ZoomOutAction(zoomManager);
ActionRegistry actionRegistry = getActionRegistry();
actionRegistry.registerAction(zoomIn);
actionRegistry.registerAction(zoomOut);
The redbook says put it inside the editor part - but gives not hint as
to which method. If I put it inside the init method - I get a null
pointer exception as I try to access as I attempt
ScalableFreeFormEdit.getZoomManager() - presumably because my
RootEditPart is ready yet. If do it inside the configureGraphicalViewer
I get in trouble with my contributeMenu code in the actionBarContribiutor:
public void contributeToMenu(IMenuManager menuManager) {
super.contributeToMenu(menuManager);
System.out.println("contributeToMenu");
// add a "View" menu after "Edit"
MenuManager viewMenu = new MenuManager("View");
viewMenu.add(getAction(GEFActionConstants.ZOOM_IN));
viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT));
}
In this case the exception occurs because the action has been registered
and so getAction returns null.
So clearly there is a better place to register the actions within the
EditPart - I just can't figure it out.
One last detail - before I tried to add the menu items I just tried to
add the ZoomComboContributionItem to either the coolbar or toolbar as below:
public void contributeToCoolBar(ICoolBarManager coolBarManager) {
super.contributeToCoolBar(coolBarManager);
System.out.println("contributeToCoolBar");
coolBarManager.add(new Separator());
coolBarManager.add(new ZoomComboContributionItem(getPage()));
}
and nothing appeared in the application's toolbar.
Is there an up to date working set of example code that demos adding
zoom items to the menu and coolbar via an ActionBarContributor? If not
would someone be prepare to spend an hour or two on the phone on
Tuesday? If you did then I would delighted to write and publish an fresh
example. (Heck if you're in the Ottawa area - lets do this over coffee)
Tired and confused in Ottawa.
Mark Levison
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10259 seconds