by bgruenba » Tue Jan 06, 2009 12:38 pm
Is this your own code or the book's version of the code? I ran into a similar problem working through the Commands section in Chapter 6 of the third edition of the book. I specifically mention that because it is different in the first and second editions. Here is what I wrote in an e-mail on this:
I have been working through the section on Commands in chapter 6 and I spent quite a lot of time trying to figure out why I could not get my command to work as expected after adding the handler as described in section 6.3.1. I made use of the “click on the class:” method as described in the paragraph. When I tried to run the example I got a message “The chosen operation is not enabled.” I looked at the sample code for the Commands section and found the difference.
When you generate the class using the method discussed in the text of the book, the class is generated to implement org.eclipse.core.commands.IHandler. Several additional methods are generated for you. The example that is available on-line extends org.eclipse.core.commands.AbstractHandler which obviously includes behavior for the standard behavior. I changed my own code to follow this and it executes just fine.
regards,
Bruce Gruenbaum