Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Multiple Key Bindings to Single Action
Multiple Key Bindings to Single Action [message #481994] Tue, 25 August 2009 02:18 Go to next message
Seth is currently offline SethFriend
Messages: 10
Registered: July 2009
Junior Member
I'm attempting to get multiple key bindings be redirected to once class
which will call the appropriate method for each key binding. My key
binding class is

public class KeyAction extends LispAction{

public void run(IAction action) {
// TODO Auto-generated method stub


}


}
where lispaction extends Action and implements IEditorActionDelegate.

Then, the xml i try to use is below.
I'm trying to use a parameter for each keybinding and somehow i'll get it
in the run method above. If only i can figure out how that parameter thing
works, everything will be fine. I would like to ask if I'm approaching this
the correct way. Any help would be appreciated
Thanks!



<extension
point="org.eclipse.ui.bindings">
<key
commandId="jasko.tim.lisp.paredit.KeyAction"
contextId="jasko.tim.lisp.context1"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="Alt+0">
<parameter
id="org.eclipse.ui.views.showView.viewId"
value="test"/>

</key>
</extension>


<extension point="org.eclipse.ui.editorActions">
<editorContribution
targetID="jasko.tim.lisp.editors.LispEditor"
id="jasko.tim.lisp.paredit">
<action
class="jasko.tim.lisp.paredit.KeyAction"
definitionId="jasko.tim.lisp.paredit.KeyAction"
id="jasko.tim.lisp.paredit.KeyAction"
label="Paredit KeyAction">
</action>
</editorContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
categoryId="jasko.tim.lisp.category1"
id="jasko.tim.lisp.paredit.KeyAction"
name="Paredit KeyAction">
</command>
</extension>
Re: Multiple Key Bindings to Single Action [message #482195 is a reply to message #481994] Tue, 25 August 2009 16:40 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You need a command definition in org.eclipse.ui.commands that has a commandParameter element in it (or you can't create the parameterized command using org.eclipse.ui.bindings or org.eclipse.ui.menus).

Also, use a handler (subclass org.eclipse.core.commands.AbstractHandler) instead of an action, handlers work with commands (actions not so much).

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/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Multiple Key Bindings to Single Action [message #482509 is a reply to message #482195] Wed, 26 August 2009 20:22 Go to previous message
Seth is currently offline SethFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks! That did the trick,
Previous Topic:Could not save master table to file
Next Topic:Setting Cursor Position in TextEditor
Goto Forum:
  


Current Time: Tue Apr 16 09:37:20 GMT 2024

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

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

Back to the top