Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » binding activities to commands?
binding activities to commands? [message #309584] Wed, 01 November 2006 15:52 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
R3.1.2
WinXP

I have activities correctly bound to action-sets (and pref-pages and perspectives and views), but
attempting to bind an activity to a command fails. That is, even when the activity is disabled, the
command is still available, by pressing its short-cut (CTRL-whatever). Is there a way to accomplish
the same effect, that disabling an activity would not only hide the action-set, but also the
command-shortcut?

thanks,
Paul
Re: binding activities to commands? [message #309588 is a reply to message #309584] Wed, 01 November 2006 17:38 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
I don't know if this is the best method, but it works for me (in an RCP):

0) extend org.eclipse.ui.context to define a context for each activity for which there are
command/keybinding-pairs that need (de)activation (as my app-context is pretty simple, they are all
just children of org.eclipse.ui.contexts.window; I have no schemes);

1) write some java-code that embodies a mapping from activityID to contextID for each such pair in
your plugin.xml, and that also maps from activityID to IContextActivation;

2) make your WorkbenchWindowAdvisor implement IActivityManagerListener, and in that listener's sole
method, if theActivityManagerEvent.haveEnabledActivityIdsChanged(), let mgr =
theActivityManagerEvent.getActivityManager(), and for each activityID:

if (mgr.getEnabledActivityIds().contains(activityID)) {
_activation = getContextService().activateContext(contextID);

} else if (null != _activation) {
getContextService().deactivateContext(_activation);
}

where _activation isA IContextActivation and getContextService() lazily initalizes a static
IContextService = PlatformUI.getWorkbench().getAdapter(IContextService.class).

Is there a better way?

Paul
Re: binding activities to commands? [message #309592 is a reply to message #309584] Wed, 01 November 2006 18:39 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

AFAIK, there are 2 problems ... one, activities won't hide commands in
the keys preference page. I think there's an open bug for that.

Activities won't prevent a command from being executed. The activities
extensions are about progressive disclosure of a complex UI to users ...
it won't effect behaviour, and it won't effect keybindings.

If you really want to get rid of keybindings, I think the only way to do
it is to use the org.eclipse.ui.bindings extension point. Then you can
get rid of certain keybindings in certain contexts.

Later,
PW


Re: binding activities to commands? [message #657707 is a reply to message #309592] Thu, 03 March 2011 16:55 Go to previous message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 38
Registered: March 2011
Location: Brazil
Member
Thank you, Paul.

We were facing the same problem this week and your observations helped us.

Cheers,

Mário Marinato
from Brazil


Mário Marinato
From Brazil
Previous Topic:PerspectiveExtension and PlaceholderFolder
Next Topic:How to set the Editor size?
Goto Forum:
  


Current Time: Thu Apr 25 00:26:46 GMT 2024

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

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

Back to the top