Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Command handler and shotcuts
Command handler and shotcuts [message #465610] Tue, 03 April 2007 07:23 Go to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

Hi everybody,

The simplest way to explain my question is to show a sample.

A) In my RCP application i declare a global cut action:

/*ActionBarAdvisor#makeActions*/
cutAction = ActionFactory.CUT.create(window);
register(cutAction);

/*ActionBarAdvisor#fillMenuBar*/
....
editMenuManager.add(cutAction);
....

B) In a view part i hook a handler to this global action :

myCut = new MyCutAction();
getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.CUT.getId(),
myCut);

C) Next the myCut action is added to the context menu of the view

menuManager.add(myCut);


D) In the plugin.xml the Ctrl+X key sequence is associated to the cut
command.
And it works fine, when i type Ctrl+X the cut command is executed.

The problem is that the key sequence does not appear in the context menu
right to the action label e.g 'Cut Ctrl+C'.
In the edit menu (containing the global action) the key sequence appears.

How can i fix that?

I have a solution, but i don't know if it's the right way.
In the view context menu, instead of adding the myCut action i do the
following :
menuManager.add(ActionFactory.CUT.create(window));
which creates a new cut global cut action .


valere.
Thanks for the help.
Re: Command handler and shotcuts [message #465722 is a reply to message #465610] Tue, 03 April 2007 18:51 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

valere fedronic wrote:
> B) In a view part i hook a handler to this global action :
>
> myCut = new MyCutAction();
> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.CUT.getId(),
> myCut);

Does MyCutAction return the correct action definition id for the cut
command?

PW


Re: Command handler and shotcuts [message #465731 is a reply to message #465722] Wed, 04 April 2007 07:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

Thanks for the answer.

> Does MyCutAction return the correct action definition id for the cut
> command?

No, it wasn't, but i change it :
myCut.setActionDefinitionId(ActionFactory.CUT.getId());

And the shortcut sequence is still not displayed.

I noticed that the key bindings are not displayed in the navigator and
marker view context menus but it works in the package view, i'm going to
take a look.

Thx,
valere.

valere.

Paul Webster wrote:
> valere fedronic wrote:
>> B) In a view part i hook a handler to this global action :
>>
>> myCut = new MyCutAction();
>> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.CUT.getId(),
>> myCut);
>
> Does MyCutAction return the correct action definition id for the cut
> command?
>
> PW
Re: Command handler and shotcuts [message #465743 is a reply to message #465731] Wed, 04 April 2007 13:27 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

valere fedronic wrote:
> Thanks for the answer.
>
> > Does MyCutAction return the correct action definition id for the cut
> > command?
>
> No, it wasn't, but i change it :
> myCut.setActionDefinitionId(ActionFactory.CUT.getId());
>
> And the shortcut sequence is still not displayed.
>

That's the action ID, not the command definition id. the command id
looks something like org.eclipse.ui.file.cut

PW


Re: Command handler and shotcuts [message #465748 is a reply to message #465743] Wed, 04 April 2007 13:49 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Paul Webster wrote:
>
> That's the action ID, not the command definition id. the command id
> looks something like org.eclipse.ui.file.cut
>

Ooops, org.eclipse.ui.edit.cut
PW


Re: Command handler and shotcuts [message #465776 is a reply to message #465748] Thu, 05 April 2007 07:27 Go to previous message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

It works!
( with "org.eclipse.ui.edit.cut").

Thanks again,
valere.

Paul Webster wrote:
> Paul Webster wrote:
>>
>> That's the action ID, not the command definition id. the command id
>> looks something like org.eclipse.ui.file.cut
>>
>
> Ooops, org.eclipse.ui.edit.cut
> PW
Previous Topic:Dynamic Help in RCP
Next Topic:How to add my own selection to the selectionstack?
Goto Forum:
  


Current Time: Sat Apr 27 00:42:18 GMT 2024

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

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

Back to the top