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… menu.In the Convert Anonymous Class to Nested dialog that appears, ensure that public and static are selected, and give it the name
HandlerOne
:Do the same steps for the other two actions, calling them
HandlerTwo
andDoubleClick
.To fix the compile...