Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Confused About Actions(Which to use, actions, commands, handlers, all of the above?)
icon5.gif  Confused About Actions [message #531722] Wed, 05 May 2010 18:07 Go to next message
Eclipse UserFriend
I'm still coming up to speed on Eclipse RCP development, and am working through how / when to use actions.

As an example application, I'm creating a video player view. For the simplicity of the example, when the RCP application launches, the view is already loaded, and the video file is playing as soon as the view loads.

Within the view, I've added three actions, one each to play, pause, and stop the video. I defined these within the plugin.xml file, within a "viewContribution" tag in the "org.eclipse.ui.viewActions" extension point. Each action has a 'class' attribute, which references a class implementing IViewActionDelegate. This seems to work perfectly.

Now, to teach myself a bit more about what's going on, I also created an "actionSet" within another extension point (org.eclipse.ui.actionSets), and basically redefined all of the actions from the above viewContributions, verbatim (I used the same backing classes, and just made them also implement IWorkbenchWindowActionDelegate). These also work great for controlling the video, but I have begun to run into some issues.

I am attempting to change the enabled state on the action when it is pressed, such as disabling the play button when it is pressed, and enabling the pause button when the play button is pressed. This only seems to work locally (e.g.: the view contribution action buttons only update each other, not the actionSet actions, and visa versa). Is there a better way of doing this?

This question led me to begin to research commands, handlers, and more information on actions. At this point, I just managed to get confused. From what I've read (and I may be interpreting things incorrectly), a Command doesn't really do anything, unless connected to a handler. A handler doesn't do much unless connected to a command, which makes sense. How do I invoke the command (and how, philosophically, is this different than invoking an action?)

Is there yet another way to do what I'm describing above that I haven't discovered?

Thanks in advance!
R
Re: Confused About Actions [message #531758 is a reply to message #531722] Thu, 06 May 2010 00:51 Go to previous messageGo to next message
Eclipse UserFriend
On 06/05/10 3:37 AM, Anonymous Coward wrote:
>
> This question led me to begin to research commands, handlers, and more
> information on actions. At this point, I just managed to get confused.
> From what I've read (and I may be interpreting things incorrectly), a
> Command doesn't really do anything, unless connected to a handler. A
> handler doesn't do much unless connected to a command, which makes
> sense. How do I invoke the command (and how, philosophically, is this
> different than invoking an action?)
> Is there yet another way to do what I'm describing above that I haven't
> discovered?

http://eclipse-tips.com/tutorials/1-actions-vs-commands


- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Confused About Actions [message #531897 is a reply to message #531722] Thu, 06 May 2010 09:39 Go to previous messageGo to next message
Eclipse UserFriend
Anonymous Coward wrote:

Prakash has a nice link to commands vs actions. There's also the
standard article about actions,
http://www.eclipse.org/articles/article.php?file=Article-act ion-contribution/index.html

>
> This question led me to begin to research commands, handlers, and more
> information on actions. At this point, I just managed to get confused.
> From what I've read (and I may be interpreting things incorrectly), a
> Command doesn't really do anything, unless connected to a handler. A
> handler doesn't do much unless connected to a command, which makes
> sense. How do I invoke the command (and how, philosophically, is this
> different than invoking an action?)
> Is there yet another way to do what I'm describing above that I haven't
> discovered?


With commands there's 3 steps to making it work.

1) define the command (the abstract semantic behaviour). Cut, copy,
paste, or in your case, play, pause, stop.

2) define an appropriate handler (this is the implementation of the
behaviour). For something at the application (exit) or window (show
view) level, you can declare the handler in the plugin.xml. For
something at the view level (play) you can either declare the handler or
programmatically activate the handler from your createPartControl(*) call.

3) expose your command to the user. That means using
org.eclipse.ui.bindings to create a keybinding for it, or using
org.eclipse.ui.menus to create menu items or tool items for it.
org.eclipse.ui.menus can target the main menu bar and toolbar, as well
as the view toolbar, view dropdown menu, and registered view context menus.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Confused About Actions [message #531914 is a reply to message #531897] Thu, 06 May 2010 10:07 Go to previous message
Eclipse UserFriend
Paul and Prakash-
Thank you both for your replies, I'll get to reading, and it sounds like what I'm trying to do isn't hard at all.

Thanks again!
R
Previous Topic:How to change color of editor area
Next Topic:CNF Remove existing menu item
Goto Forum:
  


Current Time: Mon Jul 07 05:23:44 EDT 2025

Powered by FUDForum. Page generated in 0.29743 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top