Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] action contribution

How do I register an action contributed by an editor action bar contributor
for dynamic key binding?

Besides the above, what do you recommend for contributing actions in
general? This covers menu bar contribution, retargeting, key binding
participation, and accelerator specification:

Currently, when putting place holders (RetargetActions) into menus, they
can be linked to concrete actions. For that, the concrete action must be
registered as global action handler under the place holder's action id. The
action id identifies the particular action instance representing the place
holder. Any action that should participate in dynamic key binding must be
registered with the key binding service under an action definition id. The
action definition id defines an abstract action type such as Save or
Rename.

As a plug-in developer, I tend to register all my actions with the key
binding service in order to achieve customizability. Thus, my actions get
set an action definition id. Also, I tend to register them as global action
handlers as I want to decouple decisions about my menu bar structure from
the implementations of my parts. For that I have to know the action id of
the place holder. As I know the action definition id anyway, this usually
leads to a design where the action id of all place holders is the same as
their action definition id. Action definition ids appear in the action
declaration part of the plugin.xml files. This sustains  the decoupling.

Based on this scheme, it seems useful to free client code from the need to
know about the intrinsics of retargeting and dynamic key binding. It would
suffice if the client registers its actions with its part site. The part
site would then set the action as global action handler and register it
with the key binding service. As a side effect the workbench could change
related code without affecting clients.

Actions can be put into the menu bar via code (such as the editor action
bar contributor) or XML. Using XML the actions seem to automatically be
registered with the key binding service. In the first case, the
registration must be done in code. What's the general scheme to do this?
(See my first question.) Is XML or code the recommended way in respect to
decoupling, maintenance, and scalability? It seems to me that focussing on
XML would simplify things.

Most property files contain the action name and the default accelerator.
Typically, the accelerator is also specified in at least one  key binding
in the plugin.xml. Can I remove the accelerator specification from my
property files?

Kai



Back to the top