Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to remove/replace the default key binding scheme
How to remove/replace the default key binding scheme [message #333038] Fri, 21 November 2008 10:14 Go to next message
Anders Baumann is currently offline Anders BaumannFriend
Messages: 55
Registered: July 2009
Member
Hi,
I hope that someone can help me? I would like to use the "Keys" preference
window in my Eclipse RCP application.

However, I don't want the default key bindings to appear in the list of
keys. Is there a way for me to remove the default scheme and only have my
own scheme appear in the "Scheme:" dropdown? Or better yet, can I remove the
default scheme and have my own scheme appear as the default scheme?

Thanks in advance,
Anders Baumann
Re: How to remove/replace the default key binding scheme [message #333069 is a reply to message #333038] Mon, 24 November 2008 13:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Anders Baumann wrote:
> Hi,
> I hope that someone can help me? I would like to use the "Keys" preference
> window in my Eclipse RCP application.
>
> However, I don't want the default key bindings to appear in the list of
> keys. Is there a way for me to remove the default scheme and only have my
> own scheme appear in the "Scheme:" dropdown? Or better yet, can I remove the
> default scheme and have my own scheme appear as the default scheme?
>

You can set your scheme as the default using the
plugin_customization.ini file. See
http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg24899.html

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: How to remove/replace the default key binding scheme [message #333089 is a reply to message #333069] Tue, 25 November 2008 12:36 Go to previous messageGo to next message
Anders Baumann is currently offline Anders BaumannFriend
Messages: 55
Registered: July 2009
Member
Hi Paul.
Thanks for your answer. It works.
However, just like Klaus Paul we would also like to hide or disable the
Default and Emacs schemes at the preferences dialog, page keys. These
schemes are not useful in our RCP application and it seems strange the
Default scheme is not our scheme. Do you know if there is already a bug
report for this issue or should I file a bug report in Bugzilla?

Best regards,
Anders



"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:ggeaus$b3b$1@build.eclipse.org...
> Anders Baumann wrote:
>> Hi,
>> I hope that someone can help me? I would like to use the "Keys"
>> preference
>> window in my Eclipse RCP application.
>>
>> However, I don't want the default key bindings to appear in the list of
>> keys. Is there a way for me to remove the default scheme and only have my
>> own scheme appear in the "Scheme:" dropdown? Or better yet, can I remove
>> the
>> default scheme and have my own scheme appear as the default scheme?
>>
>
> You can set your scheme as the default using the plugin_customization.ini
> file. See
> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg24899.html
>
> 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: How to remove/replace the default key binding scheme [message #333094 is a reply to message #333089] Tue, 25 November 2008 16:50 Go to previous messageGo to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
I think it possible. I am struggling with the same issue but have put it
temporarily aside.

The reason I think it is possible is that NewKeysPreferencePage does it.

Press Shift-Ctrl-L twice and then unbind a command then press Shift-Ctrl-l
again, you will see that the command you unbound is not in the list.

So in theory it should be possible unbind any and or all the commands you
want.

Have a look at the code I posted, it is titled "Wwitch between Groups of
Key Bindings Dynamically", I reckon I am doing something silly wrong,
maybe later I will try and tackle this again.
Re: How to remove/replace the default key binding scheme [message #333098 is a reply to message #333089] Tue, 25 November 2008 20:23 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In an RCP app you would use
http://wiki.eclipse.org/Product_Customization probably with some kind of
XSL transform to yank out the default and emacs definitions that you
don't want to see. Use it to kind of mask them out.

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: How to remove/replace the default key binding scheme [message #333133 is a reply to message #333098] Wed, 26 November 2008 18:11 Go to previous messageGo to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
Ok, I have a solution at least for my needs.

The solution below will filter all commands that are not in the category
mycategory, you can define the criteria as you need.

To test do Ctrl+Shift+L you should see only the commands you have not
filtered.

######################

IBindingService bindingService = (IBindingService) PlatformUI
getWorkbench().getAdapter(IBindingService.class);
BindingManager localChangeManager = new BindingManager(
new ContextManager(), new CommandManager());
try {

localChangeManager
.setActiveScheme(bindingService.getActiveScheme());
} catch (final NotDefinedException e) {
throw new Error(
"Error"); //$NON-NLS-1$
}

localChangeManager.setLocale(bindingService.getLocale());
localChangeManager.setPlatform(bindingService.getPlatform()) ;
localChangeManager.setBindings(bindingService.getBindings()) ;

Binding[] bindings = bindingService.getBindings();

for (Binding binding : bindings) {

if (binding.getTriggerSequence().format().equals("Ctrl+Shift+L ")) {
continue;
}
KeyBinding keyBinding = (KeyBinding) binding;
String contextId = binding.getContextId();
String schemeId = binding.getSchemeId();
KeySequence triggerSequence = keyBinding.getKeySequence();

ParameterizedCommand parameterizedCommand = binding
.getParameterizedCommand();
if (parameterizedCommand == null) {
continue;
}

Command command = parameterizedCommand.getCommand();
if (command == null) {
continue;
}
try {

if (!binding
getParameterizedCommand()
getCommand()
getCategory()
getId()
equals(
"mycategory")) {
KeyBinding deleteBinding = new KeyBinding(triggerSequence,
null, schemeId, contextId, null, null, null,
Binding.USER);
localChangeManager.addBinding(deleteBinding);

}

} catch (NotDefinedException e) {
e.printStackTrace();
}
}

try {
bindingService.savePreferences(
localChangeManager.getActiveScheme(), localChangeManager
.getBindings());
} catch (IOException e) {
e.printStackTrace();
}
Re: How to remove/replace the default key binding scheme [message #333135 is a reply to message #333133] Wed, 26 November 2008 18:13 Go to previous messageGo to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
does anyone know how I can get this to work without a dependency on
org.eclipse.ui.ide?
Re: How to remove/replace the default key binding scheme [message #333141 is a reply to message #333135] Wed, 26 November 2008 19:12 Go to previous message
Laurent Marchal is currently offline Laurent MarchalFriend
Messages: 91
Registered: July 2009
Member
Put this on top of your IApplication.start()

public Object start(IApplicationContext context) {
// set the default shortcuts
PlatformUI.getPreferenceStore().setDefault(IWorkbenchPrefere nceConstants.KEY_CONFIGURATION_ID,
"your.scheme"); //$NON-NLS-1$
// start your app
}

and you will have the default scheme set to your.

Cheers.
Laurent Marchal.



kent gibson wrote:
> does anyone know how I can get this to work without a dependency on
> org.eclipse.ui.ide?
Previous Topic:Wwitch between Groups of Key Bindings Dynamically
Next Topic:Where to put log4j.properties
Goto Forum:
  


Current Time: Tue Jul 16 10:58:07 GMT 2024

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

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

Back to the top