Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Commands, Actions, Handlers, and buttons
Commands, Actions, Handlers, and buttons [message #494519] Sat, 31 October 2009 00:42 Go to next message
J. Michael Dean, M.D. is currently offline J. Michael Dean, M.D.Friend
Messages: 218
Registered: July 2009
Senior Member
I have moved my actions into commands with handlers in anticipation that the
Action approach will eventually become deprecated. All is well when I am
attaching such commands to menus.

Unfortunately, I also need to have buttons and various other widgets carry
out certain actions - I would like this to be done with the same
AbstractHandlers that I have created for the menu commands.

How do I invoke the command handlers outside of menu situations?
Specifically, as the result of a button selection event?

Thanks.

- Mike
Re: Commands, Actions, Handlers, and buttons [message #494587 is a reply to message #494519] Sat, 31 October 2009 17:46 Go to previous message
J. Michael Dean, M.D. is currently offline J. Michael Dean, M.D.Friend
Messages: 218
Registered: July 2009
Senior Member
> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--B_3339834373_52278968
Content-type: text/plain;
charset="US-ASCII"
Content-transfer-encoding: 7bit

Sorry - stumbled into the answer. For others who may be confused, here is
code:

selectPatientButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
IHandlerService handlerService = (IHandlerService)
getSite().getService(IHandlerService.class);
try {

handlerService.executeCommand("edu.utah.cdmcc.commands.SelectPatient ",
null);
} catch (ExecutionException e1) {
e1.printStackTrace();
} catch (NotDefinedException e1) {
e1.printStackTrace();
} catch (NotEnabledException e1) {
e1.printStackTrace();
} catch (NotHandledException e1) {
e1.printStackTrace();
}
}
});



On 10/30/09 6:42 PM, in article C710E40C.27CCC%mdean77@comcast.net, "J
Michael Dean" <mdean77@comcast.net> wrote:

> I have moved my actions into commands with handlers in anticipation that the
> Action approach will eventually become deprecated. All is well when I am
> attaching such commands to menus.
>
> Unfortunately, I also need to have buttons and various other widgets carry
> out certain actions - I would like this to be done with the same
> AbstractHandlers that I have created for the menu commands.
>
> How do I invoke the command handlers outside of menu situations?
> Specifically, as the result of a button selection event?
>
> Thanks.
>
> - Mike
>


--B_3339834373_52278968
Content-type: text/html;
charset="US-ASCII"
Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: Commands, Actions, Handlers, and buttons</TITLE>
</HEAD>
<BODY>
<FONT FACE=3D"Calibri, Verdana, Helvetica, Arial"><SPAN STYLE=3D'font-size:11pt=
'>Sorry - stumbled into the answer. &nbsp;For others who may be confused, he=
re is code:<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;selectPatientButton.addSele=
ctionListener(new SelectionAdapter() {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pub=
lic void widgetSelected(final SelectionEvent e) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;IHandlerService handlerService =3D (IHandlerService) getS=
ite().getService(IHandlerService.class);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;try {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;handlerService.executeCommand(&=
quot;edu.utah.cdmcc.commands.SelectPatient&quot;, null);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;} catch (ExecutionException e1) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;e1.printStackTrace(); <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;} catch (NotDefinedException e1) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;e1.printStackTrace(); <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;} catch (NotEnabledException e1) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;e1.printStackTrace(); <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;} catch (NotHandledException e1) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;e1.printStackTrace(); <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <B=
R>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;}); <BR>
<BR>
<BR>
<BR>
On 10/30/09 6:42 PM, in article <a href=3D"C710E40C.27CCC%mdean77@comcast.net=
">C710E40C.27CCC%mdean77@comcast.net</a>, &quot;J Michael Dean&quot; &lt;<a =
href=3D"mdean77@comcast.net">mdean77@comcast.net</a>&gt; wrote:<BR>
<BR>
<FONT COLOR=3D"#0000FF">&gt; I have moved my actions into commands with handl=
ers in anticipation that the<BR>
&gt; Action approach will eventually become deprecated. &nbsp;All is well w=
hen I am<BR>
&gt; attaching such commands to menus.<BR>
&gt; <BR>
&gt; Unfortunately, I also need to have buttons and various other widgets c=
arry<BR>
&gt; out certain actions - I would like this to be done with the same<BR>
&gt; AbstractHandlers that I have created for the menu commands.<BR>
&gt; <BR>
&gt; How do I invoke the command handlers outside of menu situations?<BR>
&gt; Specifically, as the result of a button selection event?<BR>
&gt; <BR>
&gt; Thanks.<BR>
&gt; <BR>
&gt; - Mike<BR>
&gt; <BR>
</FONT></SPAN></FONT>
</BODY>
</HTML>


--B_3339834373_52278968--
Previous Topic:How to invoke a handler with a progress monitor?
Next Topic:How to add a combo to a view's action bar?
Goto Forum:
  


Current Time: Fri Dec 19 23:31:57 GMT 2014

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

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