Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Technology Project and PMC » Can one retrieve the keyboard shortcut bindings through the API?
Can one retrieve the keyboard shortcut bindings through the API? [message #72475] Sat, 10 June 2006 05:26 Go to next message
Eclipse User
Originally posted by: pschlesi.NOSPAM.uci.edu

Hi all.

I'd like to be able to retrieve the Eclipse keyboard shortcut bindings -
the 178 or so keyboard shortcuts listed when you hit Ctrl-Shift-L twice
in a row. Is there any way to do that? Or do I have to manually retype
them?

Your help is much appreciated. Thank you in advance.

- Phil
Re: Can one retrieve the keyboard shortcut bindings through the API? [message #72567 is a reply to message #72475] Sun, 11 June 2006 21:18 Go to previous messageGo to next message
Eclipse User
Originally posted by: pschlesi.NOSPAM.uci.edu

Philip Schlesinger wrote:
> Hi all.
>
> I'd like to be able to retrieve the Eclipse keyboard shortcut bindings -
> the 178 or so keyboard shortcuts listed when you hit Ctrl-Shift-L twice
> in a row. Is there any way to do that? Or do I have to manually retype
> them?
>
> Your help is much appreciated. Thank you in advance.
>
> - Phil

Found it (this might come out a bit messy):

IBindingService bindingService = (IBindingService)
PlatformUI.getWorkbench().getAdapter(IBindingService.class);

bindingService.readRegistryAndPreferences( (ICommandService)
PlatformUI.getWorkbench().getAdapter(ICommandService.class) );

Binding[] bindingList = bindingService.getBindings();

PrintWriter out;

try {
out = new PrintWriter( new BufferedWriter( new FileWriter("c:/foo2.out")
) );

out.write(
" Trigger\tcontext\tlocale\tplatform\tscheme\ttype\tclass\tpar ameterized\n "
);

for (int i = 0; i < bindingList.length; ++i) {

out.write(bindingList[i].getTriggerSequence().toString());
out.write("\t" + bindingList[i].getContextId());
out.write("\t" + bindingList[i].getLocale());
out.write("\t" + bindingList[i].getPlatform());
out.write("\t" + bindingList[i].getSchemeId());
out.write("\t" + bindingList[i].getType());
out.write("\t" + bindingList[i].getClass().toString());
if (bindingList[i].getParameterizedCommand() != null)
out.write( "\t" +
bindingList[i].getParameterizedCommand().getCommand().getId( ) );
else
out.write("\t" + bindingList[i].getParameterizedCommand());
/* necessary because some ParameterizedCommands are just null, so will
get a NullPointerException in those cases if one tries the command for
the "true" value */

out.write("\n");

} // end for

out.close();

} catch (IOException e) {
e.printStackTrace();
}
Re: Can one retrieve the keyboard shortcut bindings through the API? [message #72602 is a reply to message #72567] Mon, 12 June 2006 13:34 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Philip Schlesinger wrote:
> IBindingService bindingService = (IBindingService)
> PlatformUI.getWorkbench().getAdapter(IBindingService.class);
>
> bindingService.readRegistryAndPreferences( (ICommandService)
> PlatformUI.getWorkbench().getAdapter(ICommandService.class) );

Just a note that the above line will reset all of your keybindings ...
and shouldn't really be necessary, since the IBindingService you get
from the workbench should be the global binding service and already have
the keybindings set correctly.

>
> Binding[] bindingList = bindingService.getBindings();

Other than that, good use of the IBindingService.

Later,
PW


Re: Can one retrieve the keyboard shortcut bindings through the API? [message #600714 is a reply to message #72475] Sun, 11 June 2006 21:18 Go to previous message
Philip Schlesinger is currently offline Philip Schlesinger
Messages: 7
Registered: July 2009
Junior Member
Philip Schlesinger wrote:
> Hi all.
>
> I'd like to be able to retrieve the Eclipse keyboard shortcut bindings -
> the 178 or so keyboard shortcuts listed when you hit Ctrl-Shift-L twice
> in a row. Is there any way to do that? Or do I have to manually retype
> them?
>
> Your help is much appreciated. Thank you in advance.
>
> - Phil

Found it (this might come out a bit messy):

IBindingService bindingService = (IBindingService)
PlatformUI.getWorkbench().getAdapter(IBindingService.class);

bindingService.readRegistryAndPreferences( (ICommandService)
PlatformUI.getWorkbench().getAdapter(ICommandService.class) );

Binding[] bindingList = bindingService.getBindings();

PrintWriter out;

try {
out = new PrintWriter( new BufferedWriter( new FileWriter("c:/foo2.out")
) );

out.write(
" Trigger\tcontext\tlocale\tplatform\tscheme\ttype\tclass\tpar ameterized\n "
);

for (int i = 0; i < bindingList.length; ++i) {

out.write(bindingList[i].getTriggerSequence().toString());
out.write("\t" + bindingList[i].getContextId());
out.write("\t" + bindingList[i].getLocale());
out.write("\t" + bindingList[i].getPlatform());
out.write("\t" + bindingList[i].getSchemeId());
out.write("\t" + bindingList[i].getType());
out.write("\t" + bindingList[i].getClass().toString());
if (bindingList[i].getParameterizedCommand() != null)
out.write( "\t" +
bindingList[i].getParameterizedCommand().getCommand().getId( ) );
else
out.write("\t" + bindingList[i].getParameterizedCommand());
/* necessary because some ParameterizedCommands are just null, so will
get a NullPointerException in those cases if one tries the command for
the "true" value */

out.write("\n");

} // end for

out.close();

} catch (IOException e) {
e.printStackTrace();
}
Re: Can one retrieve the keyboard shortcut bindings through the API? [message #600728 is a reply to message #72567] Mon, 12 June 2006 13:34 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Philip Schlesinger wrote:
> IBindingService bindingService = (IBindingService)
> PlatformUI.getWorkbench().getAdapter(IBindingService.class);
>
> bindingService.readRegistryAndPreferences( (ICommandService)
> PlatformUI.getWorkbench().getAdapter(ICommandService.class) );

Just a note that the above line will reset all of your keybindings ...
and shouldn't really be necessary, since the IBindingService you get
from the workbench should be the global binding service and already have
the keybindings set correctly.

>
> Binding[] bindingList = bindingService.getBindings();

Other than that, good use of the IBindingService.

Later,
PW


Previous Topic:RAP+RSP+Wicket
Next Topic:RAP & Thin-client UIs
Goto Forum:
  


Current Time: Thu Oct 30 15:28:14 GMT 2014

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

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