Time for action – upgrading the actions
The JFace
Action
class is used in pop-up menus using the Eclipse 2.x model, but in Eclipse 3.x and Eclipse 4.x, the separation between handlers (code that does the work) and commands (logical operations such as copy that may be processed by different handlers) allows for a more flexible system, as described in Chapter 4, Interacting with the User. The first step is to replace the actions with handlers.
- Open the
SampleView
class and go to themakeActions
method, which creates anonymous inner subclasses ofAction
with an associatedrun
method. To convert these, they will need to bestatic
inner classes, so highlight the firstnew Action
expression and navigate to the Refactor | Convert Anonymous Class to Nested… ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.