Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Replacing actions with commands

You should ask these kind of questions in the Eclipse forum or Eclipse RCP (rich client platform) forum at http://www.eclipse.org/forums/



On Wed, Mar 13, 2013 at 3:54 PM, Norman Yee <normankyee@xxxxxxxxx> wrote:

I've run into a couple of problems:

- With my action delegates that implement IViewActionDelegate, the action delegates are able to store the view that is associated with the action when IViewActionDelegate.init() is called and then use the view later.  I started writing a command handler class, that implements IHandler and replaces the view action delegate, and I don't see how it can access its corresponding view.

You would make your handler active when your view is active, using the org.eclipse.ui.handlers extension point and the activeWhen core _expression_ (http://wiki.eclipse.org/Command_Core_Expressions and http://wiki.eclipse.org/Platform_Command_Framework).  Then in your handler use org.eclipse.ui.handlers.HandlerUtil.getActivePart(ExecutionEvent) to get the instance of your view that you act against.

You can also instantiate your view inside your createPartControl(*) and activate it using the org.eclipse.ui.handlers.IHandlerService.

 

- Similarly with editor actions, my action delegate implements IEditorActionDelegate and stores the editor instance.  My command handler class doesn't have access to the corresponding editor.

Same thing applies, you can make your handler active when your editor is active and extract the editor from the ExecutionEvent.

Please ask any followup questions in the forums.

PW


--
Paul Webster
Hi floor.  Make me a sammich! - GIR

Back to the top