- <extension point="org.eclipse.ui.contexts">
- <context description="allow refresh via f5" id="com.iwaysoftware.explorer.refresh" <br=""> name="refresh" parentId="org.eclipse.ui.contexts.window">
- </context>
- </extension>
Once correct context is defined, it needs to be activated. For example, in view:
- View.createPartControl(Composite parent) {
- ...
- ...
- IContextService contextService = (IContextService) getSite().getService(IContextService.class);
- contextService.activateContext("com.iwaysoftware.explorer.refresh");
- }
Then the usual, command is created that is tied to a handler that extends AbstractHandler, command is tied to a binding, and the binding is in turn uses earlier created custom context.
- <extension point="org.eclipse.ui.commands">
- <command categoryid="org.eclipse.debug.ui.category.run" <br=""></command> defaultHandler="com.iwaysoftware.explorer.handler.RefreshHandler" id="com.iwaysoftware.explorer.refreshCommand"
- name="Refresh">
- </extension>
- <extension point="org.eclipse.ui.bindings">
- <key commandid="com.iwaysoftware.explorer.refreshCommand" <br=""> sequence="F5" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- contextId="com.iwaysoftware.explorer.refresh" />
- </key></extension>
- <extension point="org.eclipse.ui.contexts">
- <context description="allow refresh via F5" id="com.iwaysoftware.explorer.refresh" <br=""> name="refresh" parentId="org.eclipse.ui.contexts.window">
- </context>
- </extension>
No comments:
Post a Comment