RetargetAction key binding only works when subclassing? [message #436021] |
Tue, 30 August 2005 02:30 |
J Messages: 7 Registered: July 2009 |
Junior Member |
|
|
Hi,
I have some RetargetAction objects that are added to an RCP
application's menu bar. My key bindings for the RetargetAction objects
do not work with code such as this, in my ActionBarAdvisor subclass:
private RetargetAction retAction;
....
protected void makeActions(final IWorkbenchWindow window) {
retAction = new RetargetAction("com.ex.retAction", "R&et");
retAction.setToolTipText("Ret");
window.getPartService().addPartListener(retAction);
register(retAction);
}
However, if I make it an anonymous subclass and add some initialization,
it works fine:
private RetargetAction retAction;
....
protected void makeActions(final IWorkbenchWindow window) {
retAction = new RetargetAction("com.ex.retAction", "R&et") {
{setActionDefinitionId("com.ex.retAction");
setId("com.ex.retAction");}
};
retAction.setToolTipText("Ret");
window.getPartService().addPartListener(retAction);
register(retAction);
}
I'm concerned about this because the doc for RetargetAction states it
should not be subclassed, and, well, I don't understand why passing the
action ID to the RetargetAction constructor isn't enough.
My plugin.xml looks like this:
<plugin>
<extension point="org.eclipse.ui.commands">
<category name="My Category"
description="My Category commands"
id="com.ex.commands"/>
<command id="com.ex.retAction"
name="Ret"
categoryId="com.ex.commands"/>
</extension>
<extension point="org.eclipse.ui.bindings">
<scheme id="com.ex.keyConfiguration"
name="My Category Key Configuration"/>
<key sequence="Ctrl+G"
commandId="com.ex.retAction"
schemeId="com.ex.keyConfiguration">
</key>
</extension>
</plugin>
Is this normal for RetargetActions?
Thanks
|
|
|
Re: RetargetAction key binding only works when subclassing? [message #436058 is a reply to message #436021] |
Tue, 30 August 2005 14:56 |
J Messages: 7 Registered: July 2009 |
Junior Member |
|
|
Ok, I realized that the subclassing was sort of dumb and definitely
unnecessary - if I do the setActionDefinitionId() call after creating
the RetargetAction, things work fine. However, now I'm confused as to
the difference between the definition ID and the plain action ID. Why,
when I'm passing the action ID to the constructor, do I need to specify
the action definition ID separately?
Unfortunately the javadocs don't give much information on the difference
between these two fields..
Thanks
J wrote:
> Hi,
> I have some RetargetAction objects that are added to an RCP
> application's menu bar. My key bindings for the RetargetAction objects
> do not work with code such as this, in my ActionBarAdvisor subclass:
>
> private RetargetAction retAction;
> ...
> protected void makeActions(final IWorkbenchWindow window) {
> retAction = new RetargetAction("com.ex.retAction", "R&et");
> retAction.setToolTipText("Ret");
> window.getPartService().addPartListener(retAction);
> register(retAction);
> }
>
> However, if I make it an anonymous subclass and add some initialization,
> it works fine:
>
> private RetargetAction retAction;
> ...
> protected void makeActions(final IWorkbenchWindow window) {
> retAction = new RetargetAction("com.ex.retAction", "R&et") {
> {setActionDefinitionId("com.ex.retAction");
> setId("com.ex.retAction");}
> };
> retAction.setToolTipText("Ret");
> window.getPartService().addPartListener(retAction);
> register(retAction);
> }
>
> I'm concerned about this because the doc for RetargetAction states it
> should not be subclassed, and, well, I don't understand why passing the
> action ID to the RetargetAction constructor isn't enough.
>
> My plugin.xml looks like this:
>
> <plugin>
> <extension point="org.eclipse.ui.commands">
> <category name="My Category"
> description="My Category commands"
> id="com.ex.commands"/>
> <command id="com.ex.retAction"
> name="Ret"
> categoryId="com.ex.commands"/>
> </extension>
> <extension point="org.eclipse.ui.bindings">
> <scheme id="com.ex.keyConfiguration"
> name="My Category Key Configuration"/>
> <key sequence="Ctrl+G"
> commandId="com.ex.retAction"
> schemeId="com.ex.keyConfiguration">
> </key>
> </extension>
> </plugin>
>
> Is this normal for RetargetActions?
> Thanks
|
|
|
Re: RetargetAction key binding only works when subclassing? [message #436109 is a reply to message #436058] |
Wed, 31 August 2005 08:01 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
J wrote:
> Ok, I realized that the subclassing was sort of dumb and definitely
> unnecessary - if I do the setActionDefinitionId() call after creating
> the RetargetAction, things work fine. However, now I'm confused as to
> the difference between the definition ID and the plain action ID.
> Why, when I'm passing the action ID to the constructor, do I need to
> specify the action definition ID separately?
In short: the action definition ID is the ID of the command where the
action ID is the concrete action that performs that command: there might
be different action implementations (e.g. one for each view) for a
given command.
HTH
Dani
>
> Unfortunately the javadocs don't give much information on the
> difference between these two fields..
>
> Thanks
>
> J wrote:
>
>> Hi,
>> I have some RetargetAction objects that are added to an RCP
>> application's menu bar. My key bindings for the RetargetAction
>> objects do not work with code such as this, in my ActionBarAdvisor
>> subclass:
>>
>> private RetargetAction retAction;
>> ...
>> protected void makeActions(final IWorkbenchWindow window) {
>> retAction = new RetargetAction("com.ex.retAction", "R&et");
>> retAction.setToolTipText("Ret");
>> window.getPartService().addPartListener(retAction);
>> register(retAction);
>> }
>>
>> However, if I make it an anonymous subclass and add some
>> initialization, it works fine:
>>
>> private RetargetAction retAction;
>> ...
>> protected void makeActions(final IWorkbenchWindow window) {
>> retAction = new RetargetAction("com.ex.retAction", "R&et") {
>> {setActionDefinitionId("com.ex.retAction");
>> setId("com.ex.retAction");}
>> };
>> retAction.setToolTipText("Ret");
>> window.getPartService().addPartListener(retAction);
>> register(retAction);
>> }
>>
>> I'm concerned about this because the doc for RetargetAction states it
>> should not be subclassed, and, well, I don't understand why passing
>> the action ID to the RetargetAction constructor isn't enough.
>>
>> My plugin.xml looks like this:
>>
>> <plugin>
>> <extension point="org.eclipse.ui.commands">
>> <category name="My Category"
>> description="My Category commands"
>> id="com.ex.commands"/>
>> <command id="com.ex.retAction"
>> name="Ret"
>> categoryId="com.ex.commands"/>
>> </extension>
>> <extension point="org.eclipse.ui.bindings">
>> <scheme id="com.ex.keyConfiguration"
>> name="My Category Key Configuration"/>
>> <key sequence="Ctrl+G"
>> commandId="com.ex.retAction"
>> schemeId="com.ex.keyConfiguration">
>> </key>
>> </extension>
>> </plugin>
>>
>> Is this normal for RetargetActions?
>> Thanks
>
|
|
|
Powered by
FUDForum. Page generated in 0.03906 seconds