I'm struggling to build an GEF application in Eclipse. Unfortunately the documentation for GEF consists of half a dozen tutorials that were written between 2003-4. These tutorials are excellent as far as they go but don't really shed light in alot of areas. So I will use this blog posting as a way of keeping track of my questions and the answers as I stumble across them.
GEF Tutorials/Documentation
Current list. My favorites so far: A Shape Diagram Editor by Bo Majewski. The source code for this tutorial is included in the GEF Examples download (link is 3.2.2).
What's missing no tutorial/sample covers a standalone RCP/GEF application. In particular there is no information on how to integrate into the RCP commands and menu structure.
API Questions
Retarget Actions
- What is a retarget action? It appears to be a wrapper around the existing SWT actions. Retarget actions Javadocs only tell you that it "tracks the active part in the workbench". Not why this would be useful.
- Why do we need an action that is different from IAction?
- Does retarget action play nicely with 3.3 new handler code?
- Which actions need retarget actions and which don't? For example the Copy has one and Print doesn't. Why?
Integration with a plain RCP application
- Why use ActionContributor vs. adding Actions in the ActionBarAdvisor?
ActionBarContributor
- If you’re using the ActionBarContributor how do you contribute to a menu that already exists – perhaps file? In a specific place in that menu?
- When adding actions via an ActionBarContributor should you add the actions to a ‘global handler’:
• pageSite.getActionBars().setGlobalActionHandler() as per the logic editor sample **or** editor handler
• getEditorSite().getService(IHandlerService.class).
activateHandler() as per the shapes example?
Drawing
- When drawing your own figure what method should you override? paint() or paintClientArea() or paintFigure(). Finally one where I have answer (even though none of the methods provide any hints in the docs). From the Logic Designer sample code, I noticed that one that gets paintFigure() gets overridden.
- Need to turn on antialaising? Just do graphics.setAntialias(SWT.ON); If its inside paintFigure you don't need to turn it off since paint() does a graphics.restoreState(); immediately after calling paintFigure();
If you enjoyed this post, subscribe now to get free updates.