Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Key Bindings for Actions does
Key Bindings for Actions does [message #482330] Wed, 26 August 2009 09:48 Go to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
Hello!

I tried to associate a key binding to an action in my RCP application. I
followed the steps on the following two sites:

But what should I say, it simply doesn't work. I know that this
statement isn't very helpful, but i have absolutely no idea what the
problem might be.

So i tried to add such an key bound action to a brand new Sample RCP
(The one with a single View). I used the standard "about" action for
convenience, added it to the main menu and created a key binding. With
the same result: The Action is shown in the Menu and can be clicked, but
when i press the associated keys, nothing happens.

The code i changed from the standard template can be found below... Does
anybody have an idea?

Thanks, Ralf

PS: I use Eclipse 3.5 on Ubuntu Linux 9.04

#### ApplicationActionBarAdvisor ####

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

private IWorkbenchAction exitAction;
private IWorkbenchAction aboutAction;

public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(final IWorkbenchWindow window) {

aboutAction = ActionFactory.ABOUT.create(window);
aboutAction.setActionDefinitionId("aboutCommand");
register(aboutAction);
exitAction = ActionFactory.QUIT.create(window);
register(exitAction);
}

protected void fillMenuBar(IMenuManager menuBar) {
MenuManager fileMenu = new MenuManager("&File",
IWorkbenchActionConstants.M_FILE);
menuBar.add(fileMenu);
fileMenu.add(aboutAction);
fileMenu.add(exitAction);
}

}


### plugin.xml ###
<extension
point="org.eclipse.ui.commands">
<command
id="aboutCommand"
name="About">
</command>
</extension>
<extension
id="custom-bindings"
point="org.eclipse.ui.bindings">
<key
commandId="aboutCommand"
contextId="org.eclipse.ui.contexts.dialogAndWindow"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M2+M3+J">
</key>
</extension>
Re: Key Bindings for Actions does [message #482331 is a reply to message #482330] Wed, 26 August 2009 09:50 Go to previous messageGo to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
oh, I forgot to insert the two links to the faq... sorry.

http://wiki.eclipse.org/FAQ_How_do_I_make_key_bindings_work_ in_an_RCP_application%3F
http://wiki.eclipse.org/FAQ_How_do_I_provide_a_keyboard_shor tcut_for_my_action%3F


Ralf Grossklaus wrote:
> Hello!
>
> I tried to associate a key binding to an action in my RCP application. I
> followed the steps on the following two sites:
>
> But what should I say, it simply doesn't work. I know that this
> statement isn't very helpful, but i have absolutely no idea what the
> problem might be.
>
> So i tried to add such an key bound action to a brand new Sample RCP
> (The one with a single View). I used the standard "about" action for
> convenience, added it to the main menu and created a key binding. With
> the same result: The Action is shown in the Menu and can be clicked, but
> when i press the associated keys, nothing happens.
>
> The code i changed from the standard template can be found below... Does
> anybody have an idea?
>
> Thanks, Ralf
>
> PS: I use Eclipse 3.5 on Ubuntu Linux 9.04
>
> #### ApplicationActionBarAdvisor ####
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IWorkbenchAction exitAction;
> private IWorkbenchAction aboutAction;
>
> public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
> super(configurer);
> }
>
> protected void makeActions(final IWorkbenchWindow window) {
>
> aboutAction = ActionFactory.ABOUT.create(window);
> aboutAction.setActionDefinitionId("aboutCommand");
> register(aboutAction);
> exitAction = ActionFactory.QUIT.create(window);
> register(exitAction);
> }
>
> protected void fillMenuBar(IMenuManager menuBar) {
> MenuManager fileMenu = new MenuManager("&File",
> IWorkbenchActionConstants.M_FILE);
> menuBar.add(fileMenu);
> fileMenu.add(aboutAction);
> fileMenu.add(exitAction);
> }
>
> }
>
>
> ### plugin.xml ###
> <extension
> point="org.eclipse.ui.commands">
> <command
> id="aboutCommand"
> name="About">
> </command>
> </extension>
> <extension
> id="custom-bindings"
> point="org.eclipse.ui.bindings">
> <key
> commandId="aboutCommand"
> contextId="org.eclipse.ui.contexts.dialogAndWindow"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
> sequence="M2+M3+J">
> </key>
> </extension>
Re: Key Bindings for Actions does [message #482497 is a reply to message #482330] Wed, 26 August 2009 19:49 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Ralf,

I know this is not directly related to your question but I suggest to
use commands instead of actions. They are much more powerful then actions.

The usage of commands is described including an example with a working
keybinding.

http://www.vogella.de/articles/EclipseCommands/article.html

Best regards, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter


Ralf Grossklaus wrote:
> Hello!
>
> I tried to associate a key binding to an action in my RCP application. I
> followed the steps on the following two sites:
>
> But what should I say, it simply doesn't work. I know that this
> statement isn't very helpful, but i have absolutely no idea what the
> problem might be.
>
> So i tried to add such an key bound action to a brand new Sample RCP
> (The one with a single View). I used the standard "about" action for
> convenience, added it to the main menu and created a key binding. With
> the same result: The Action is shown in the Menu and can be clicked, but
> when i press the associated keys, nothing happens.
>
> The code i changed from the standard template can be found below... Does
> anybody have an idea?
>
> Thanks, Ralf
>
> PS: I use Eclipse 3.5 on Ubuntu Linux 9.04
>
> #### ApplicationActionBarAdvisor ####
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IWorkbenchAction exitAction;
> private IWorkbenchAction aboutAction;
>
> public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
> super(configurer);
> }
>
> protected void makeActions(final IWorkbenchWindow window) {
>
> aboutAction = ActionFactory.ABOUT.create(window);
> aboutAction.setActionDefinitionId("aboutCommand");
> register(aboutAction);
> exitAction = ActionFactory.QUIT.create(window);
> register(exitAction);
> }
>
> protected void fillMenuBar(IMenuManager menuBar) {
> MenuManager fileMenu = new MenuManager("&File",
> IWorkbenchActionConstants.M_FILE);
> menuBar.add(fileMenu);
> fileMenu.add(aboutAction);
> fileMenu.add(exitAction);
> }
>
> }
>
>
> ### plugin.xml ###
> <extension
> point="org.eclipse.ui.commands">
> <command
> id="aboutCommand"
> name="About">
> </command>
> </extension>
> <extension
> id="custom-bindings"
> point="org.eclipse.ui.bindings">
> <key
> commandId="aboutCommand"
> contextId="org.eclipse.ui.contexts.dialogAndWindow"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
> sequence="M2+M3+J">
> </key>
> </extension>
Re: Key Bindings for Actions does [message #482501 is a reply to message #482497] Wed, 26 August 2009 20:13 Go to previous message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Lars,

thanks to your tutorials I already aware about the advantages of
commands, and I use commands where ever possible. But unfortunately in
my special case im stuck with the actions which are allready there :-(

regards, Ralf


Lars Vogel schrieb:
> Hi Ralf,
>
> I know this is not directly related to your question but I suggest to
> use commands instead of actions. They are much more powerful then actions.
>
> The usage of commands is described including an example with a working
> keybinding.
>
> http://www.vogella.de/articles/EclipseCommands/article.html
>
> Best regards, Lars
>
Re: Key Bindings for Actions does [message #600968 is a reply to message #482330] Wed, 26 August 2009 09:50 Go to previous message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
oh, I forgot to insert the two links to the faq... sorry.

http://wiki.eclipse.org/FAQ_How_do_I_make_key_bindings_work_ in_an_RCP_application%3F
http://wiki.eclipse.org/FAQ_How_do_I_provide_a_keyboard_shor tcut_for_my_action%3F


Ralf Grossklaus wrote:
> Hello!
>
> I tried to associate a key binding to an action in my RCP application. I
> followed the steps on the following two sites:
>
> But what should I say, it simply doesn't work. I know that this
> statement isn't very helpful, but i have absolutely no idea what the
> problem might be.
>
> So i tried to add such an key bound action to a brand new Sample RCP
> (The one with a single View). I used the standard "about" action for
> convenience, added it to the main menu and created a key binding. With
> the same result: The Action is shown in the Menu and can be clicked, but
> when i press the associated keys, nothing happens.
>
> The code i changed from the standard template can be found below... Does
> anybody have an idea?
>
> Thanks, Ralf
>
> PS: I use Eclipse 3.5 on Ubuntu Linux 9.04
>
> #### ApplicationActionBarAdvisor ####
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IWorkbenchAction exitAction;
> private IWorkbenchAction aboutAction;
>
> public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
> super(configurer);
> }
>
> protected void makeActions(final IWorkbenchWindow window) {
>
> aboutAction = ActionFactory.ABOUT.create(window);
> aboutAction.setActionDefinitionId("aboutCommand");
> register(aboutAction);
> exitAction = ActionFactory.QUIT.create(window);
> register(exitAction);
> }
>
> protected void fillMenuBar(IMenuManager menuBar) {
> MenuManager fileMenu = new MenuManager("&File",
> IWorkbenchActionConstants.M_FILE);
> menuBar.add(fileMenu);
> fileMenu.add(aboutAction);
> fileMenu.add(exitAction);
> }
>
> }
>
>
> ### plugin.xml ###
> <extension
> point="org.eclipse.ui.commands">
> <command
> id="aboutCommand"
> name="About">
> </command>
> </extension>
> <extension
> id="custom-bindings"
> point="org.eclipse.ui.bindings">
> <key
> commandId="aboutCommand"
> contextId="org.eclipse.ui.contexts.dialogAndWindow"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
> sequence="M2+M3+J">
> </key>
> </extension>
Re: Key Bindings for Actions does [message #600977 is a reply to message #482330] Wed, 26 August 2009 19:49 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Ralf,

I know this is not directly related to your question but I suggest to
use commands instead of actions. They are much more powerful then actions.

The usage of commands is described including an example with a working
keybinding.

http://www.vogella.de/articles/EclipseCommands/article.html

Best regards, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter


Ralf Grossklaus wrote:
> Hello!
>
> I tried to associate a key binding to an action in my RCP application. I
> followed the steps on the following two sites:
>
> But what should I say, it simply doesn't work. I know that this
> statement isn't very helpful, but i have absolutely no idea what the
> problem might be.
>
> So i tried to add such an key bound action to a brand new Sample RCP
> (The one with a single View). I used the standard "about" action for
> convenience, added it to the main menu and created a key binding. With
> the same result: The Action is shown in the Menu and can be clicked, but
> when i press the associated keys, nothing happens.
>
> The code i changed from the standard template can be found below... Does
> anybody have an idea?
>
> Thanks, Ralf
>
> PS: I use Eclipse 3.5 on Ubuntu Linux 9.04
>
> #### ApplicationActionBarAdvisor ####
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IWorkbenchAction exitAction;
> private IWorkbenchAction aboutAction;
>
> public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
> super(configurer);
> }
>
> protected void makeActions(final IWorkbenchWindow window) {
>
> aboutAction = ActionFactory.ABOUT.create(window);
> aboutAction.setActionDefinitionId("aboutCommand");
> register(aboutAction);
> exitAction = ActionFactory.QUIT.create(window);
> register(exitAction);
> }
>
> protected void fillMenuBar(IMenuManager menuBar) {
> MenuManager fileMenu = new MenuManager("&File",
> IWorkbenchActionConstants.M_FILE);
> menuBar.add(fileMenu);
> fileMenu.add(aboutAction);
> fileMenu.add(exitAction);
> }
>
> }
>
>
> ### plugin.xml ###
> <extension
> point="org.eclipse.ui.commands">
> <command
> id="aboutCommand"
> name="About">
> </command>
> </extension>
> <extension
> id="custom-bindings"
> point="org.eclipse.ui.bindings">
> <key
> commandId="aboutCommand"
> contextId="org.eclipse.ui.contexts.dialogAndWindow"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
> sequence="M2+M3+J">
> </key>
> </extension>
Re: Key Bindings for Actions does [message #600988 is a reply to message #482497] Wed, 26 August 2009 20:13 Go to previous message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Lars,

thanks to your tutorials I already aware about the advantages of
commands, and I use commands where ever possible. But unfortunately in
my special case im stuck with the actions which are allready there :-(

regards, Ralf


Lars Vogel schrieb:
> Hi Ralf,
>
> I know this is not directly related to your question but I suggest to
> use commands instead of actions. They are much more powerful then actions.
>
> The usage of commands is described including an example with a working
> keybinding.
>
> http://www.vogella.de/articles/EclipseCommands/article.html
>
> Best regards, Lars
>
Previous Topic:Headless Pde build : build All
Next Topic:PDE & Target platform behavior and discussion
Goto Forum:
  


Current Time: Thu Mar 28 23:23:09 GMT 2024

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

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

Back to the top