A description of the Command Framework in Eclipse 4.x. Much of it remains the same; the command is still an abstraction for a semantic operation, still declared as an extension as are the handlers and menus that reference it. Expressions are still used for visibleWhen, activeWhen and enabledWhen statements.
The big difference is in the handler implementation and its supporting API:
- An @Execute annotation is used on the method to be invoked.
- Optionally, an @CanExecute annotation can be used on a method called by the framework to determine enablement.
- Most objects needed by the handler are to be injected using:
- @Inject (for service by interface)
- @Named (for variables, e.g. selection)
- @Preference (for the handler's plugin's preference store)
- An IEclipseContext is used extensively.
It's comforting that plugin.xml extensions can probably be left as they are and that only the handlers need migration. Though the injection and context use is radically different, it is also apparent it is leaner code and that, once learned, is portable to the rest of RCP development.
No comments:
Post a Comment