Thursday, June 22, 2006

What can the Command framework do for you?

In 3.2 much more of the eclipse action infrastructure has moved onto the command framework. It is based on 4 extension points.

org.eclipse.ui.commands and the ICommandService create the abstract user command (like COPY). org.eclipse.ui.handlers and the IHandlerService allow plugins and interested parts to provide an implementation for the COPY command.

org.eclipse.ui.bindings can map key sequences to commands, and IBindingService can programmatically review those keybindings. org.eclipse.ui.contexts and the IContextService can activate contexts, which can be used to scope the keybindings.

The IBindingService can be used to programmatically add new keybindings ... but not easily. There was some example code and discussion on the newsgroup:

Re: Action accelerators

In 3.2 there is still no replacement for placing the command in a menu or toolbar. <actions/> (which should always be linked to commands, BTW) are still used, and the work is done in 4 extension points. org.eclipse.ui.actionSets, org.eclipse.ui.editorActions, org.eclipse.ui.viewActions, and org.eclipse.ui.popupMenus.

Providing this replacement will be part of the command framework work for 3.3.

I'm still wondering if this information should be captured on a wiki for updating (until it can make it into the 3.3 documentation), or just left floating around the newsgroups ...