Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » shortcut keys in context menu disappear in second occurrence
shortcut keys in context menu disappear in second occurrence [message #465807] Thu, 05 April 2007 18:08 Go to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: July 2009
Junior Member
I have shortcut keys created successfully in a context menu of an editor.
When I first bring up the context menu, I can see the shortcut keys right
beside the menuitem text, e.g. "action1 Ctrl+Shift+F", but if I leave
the current editor, and bring up another kind of editor, that is to make
the current editor to be out of focus, then come back to the previous
editor, and bring up the context menu again, the shortcut keys for
menutiems disappear, the context menu just show "action1 ". Is
this a bug in eclipse or it is something that I have not done correctly?

Below is what I did.
In plugin xml:
<extension
point="org.eclipse.ui.editors">
<editor
name="%Editor.name"
default="false"
extensions="abc"
contributorClass="...AbcActionContributor"
class="...AbcEditor"
id="...Abc"
</editor>
</extension>
<extension
point="org.eclipse.ui.contexts">
<context
name="%KeyBindings.context.esql.label"
description="%KeyBindings.context.esql.description"
parentId="org.eclipse.ui.textEditorScope"
id="com.ibm.etools.mft.esql.editor.context">
</context>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
name="%KeyBindings.label"
description="%KeyBindings.description"
id="abc.editor.category">
</category>
<command
name="%KeyBindings.command.comment.label"
description="%KeyBindings.command.comment.description"
categoryId="abc.editor.category"
id="abc.editor.comment">
</command>
</extension>
Re: shortcut keys in context menu disappear in second occurrence [message #465808 is a reply to message #465807] Thu, 05 April 2007 18:20 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: July 2009
Junior Member
Sorry I pressed the wrong button before I finished typing my previous
note. This is what I did:

In plugin xml:
<extension
point="org.eclipse.ui.editors">
<editor
name="%Editor.name"
default="false"
extensions="abc"
contributorClass="AbcActionContributor"
class="AbcEditor"
id="Abc"
</editor>
</extension>
<extension
point="org.eclipse.ui.contexts">
<context
name="%KeyBindings.context.label"
description="%KeyBindings.context.description"
parentId="org.eclipse.ui.textEditorScope"
id="abc.editor.context">
</context>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
name="%KeyBindings.label"
description="%KeyBindings.description"
id="abc.editor.category">
</category>
<command
name="%KeyBindings.command.comment.label"
description="%KeyBindings.command.comment.description"
categoryId="abc.editor.category"
id="abc.editor.action1">
</command>
</extension>

<extension
point="org.eclipse.ui.bindings">
<key
sequence="M1+M2+F"
contextId="abc.editor.context"
commandId="abc.editor.action1"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/ >
</extension>


In AbcActionContributor, when creating action1, I set
action1.setActionDefinitionId("abc.editor.action1");
action1.setId("abc.editor.action1");


In the createPartControl() of AbcEditor, I did the following:
IHandlerService keyBindings = (IHandlerService) site.getService(
IHandlerService.class );
keyBindings.activateHandler( action1.getId(), new ActionHandler( action1 )
);

IContextService contextService = (IContextService)
getSite().getService(IContextService.class);
contextService.activateContext( "abc.editor.context" );
Re: shortcut keys in context menu disappear in second occurrence [message #465811 is a reply to message #465808] Thu, 05 April 2007 19:20 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

That looks correct:
In the createPartControl() of AbcEditor, I did the following:
IHandlerService keyBindings = (IHandlerService) site.getService(
IHandlerService.class );
keyBindings.activateHandler( action1.getId(), new ActionHandler( action1
) );

IContextService contextService = (IContextService)
getSite().getService(IContextService.class);
contextService.activateContext( "abc.editor.context" );


that should activate your ActionHandler for the abc.editor.action1
command, and activate your context whenever your editor is the active
editor.

What are you using to show the label in the context menu? Are you just
adding action1 to the context menu in createPartControl(*)?

There might already be an open bug about this (sounds familiar).

PW


Re: shortcut keys in context menu disappear in second occurrence [message #465814 is a reply to message #465811] Thu, 05 April 2007 20:13 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: July 2009
Junior Member
In the constructor of action1, which is a subclass of
org.eclipse.jface.action, I just do setText() from a properties file.
Re: shortcut keys in context menu disappear in second occurrence [message #466280 is a reply to message #465814] Tue, 17 April 2007 13:19 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

I mean where do you go ....add(action1)?
PW


Previous Topic:Re: Event Handler for 'Next' button in a wizard.
Next Topic:can I add plugins to a exsit RCP application?
Goto Forum:
  


Current Time: Fri Apr 26 17:37:52 GMT 2024

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

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

Back to the top