Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to define custom context (org.eclipse.ui.contexts)?
How to define custom context (org.eclipse.ui.contexts)? [message #462930] Fri, 02 February 2007 14:42 Go to next message
Eclipse UserFriend
Originally posted by: Henry.Grippa.googlemail.com

Could anyone please provide an example or useful link or just briefly
explain how to define my own context for key bindings?
For example I want to define any text field or tree as a context to be
able to add any key bindings to it.

Regards,
Henry
Re: How to define custom context (org.eclipse.ui.contexts)? [message #463031 is a reply to message #462930] Mon, 05 February 2007 17:28 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Well, I am no expert, but here is what I did (following the advice of Paul Webster, whose webpage is
now part of the help docco):

a) plug into the "contexts" ext-point, with this:
<context
description="Key-binding context for Your Special Stuff"
id="com.mun.ist.special.context"
name="Special Stuff"
parentId="org.eclipse.ui.contexts.window"/>

b) plug into "commands" something like this (or choose some other menu category):
<command
categoryId="org.eclipse.ui.category.file"
description="Do your special thing, go out and download some code, e.g."
id="com.mun.ist.special.doit"
name="Do That Funky Thing"/>

c) plug into "bindings" like this (or choose some other scheme):
<key
commandId="com.mun.ist.special.doit"
contextId="com.mun.ist.special.context"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+K"/>

d) and then for each action you plug in, use the corresponding "command-id" (as in # b) as the
"definitionId" of that action.

e) If you are in an RCP, you may need to activate the context you have defined, like this: in your
WorkbenchWindowAdvisor, method preWindowOpen(), call:
final IWorkbench workbench = PlatformUI.getWorkbench();
final IContextService cs =
(IContextService) workbench.getAdapter(IContextService.class);
cs.activateContext("com.mun.ist.special.context");

I'm not sure where to do that if you are writing for Eclipse itself (plugging in to the JDT, e.g.).

HTH,
Paul
Re: How to define custom context (org.eclipse.ui.contexts)? [message #463240 is a reply to message #463031] Wed, 07 February 2007 11:19 Go to previous message
Eclipse UserFriend
Originally posted by: Henry.Grippa.googlemail.com

Thank you very much.
I have already done something like this and it works but anyway thanks
for response.

Paul Keyser wrote:
> Well, I am no expert, but here is what I did (following the advice of
> Paul Webster, whose webpage is now part of the help docco):
>
> a) plug into the "contexts" ext-point, with this:
> <context
> description="Key-binding context for Your Special Stuff"
> id="com.mun.ist.special.context"
> name="Special Stuff"
> parentId="org.eclipse.ui.contexts.window"/>
>
> b) plug into "commands" something like this (or choose some other menu
> category):
> <command
> categoryId="org.eclipse.ui.category.file"
> description="Do your special thing, go out and download
> some code, e.g."
> id="com.mun.ist.special.doit"
> name="Do That Funky Thing"/>
>
> c) plug into "bindings" like this (or choose some other scheme):
> <key
> commandId="com.mun.ist.special.doit"
> contextId="com.mun.ist.special.context"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
> sequence="M1+K"/>
>
> d) and then for each action you plug in, use the corresponding
> "command-id" (as in # b) as the "definitionId" of that action.
>
> e) If you are in an RCP, you may need to activate the context you have
> defined, like this: in your WorkbenchWindowAdvisor, method
> preWindowOpen(), call:
> final IWorkbench workbench = PlatformUI.getWorkbench();
> final IContextService cs =
> (IContextService) workbench.getAdapter(IContextService.class);
> cs.activateContext("com.mun.ist.special.context");
>
> I'm not sure where to do that if you are writing for Eclipse itself
> (plugging in to the JDT, e.g.).
>
> HTH,
> Paul
Previous Topic:actions enabled on a specific perspective ...
Next Topic:New Feature Install
Goto Forum:
  


Current Time: Thu Oct 10 17:12:21 GMT 2024

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

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

Back to the top