Eclipse Keyword Binding Conflicts

I am expanding the eclipse platform with my own view. This view contains one action on the toolbar.

I want to create a key binding shortcut associated with Ctrl + R for these actions. To do this, I created my.context (my context extends the context of org.eclipse.ui.window), my.command, and my.command.binding extensions.

Then, when my look is created, in the createPartControl (*) method I activate my context:

IContextService contextService = (IContextService) getSite() .getService(IContextService.class); contextService.activateContext(VIEW_CONTEXT_ID); 

When my view is open in a debugging perspective, I have the following warning:

  Warning: A conflict occurred for CTRL+R: Binding(CTRL+R, ParameterizedCommand(Command(org.eclipse.debug.ui.commands.RunToLine,Run to Line, Resume and break when execution reaches the current line, Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), ActionDelegateHandlerProxy(null,org.eclipse.debug.internal.ui.actions.RetargetRunToLineAction), ,,true),null), org.eclipse.ui.defaultAcceleratorConfiguration, org.eclipse.debug.ui.debugging,,,system) Binding(CTRL+R, ParameterizedCommand(Command(RestoreAction,Restore Chart (T-Charts), Restore the initial chart display, Category(TChartsActions,T-Charts Actions,null,true), ActionHandler( com.st.tcharts.internal.actions.RestoreChartAction@1997b8a ), ,,true),null), org.eclipse.ui.defaultAcceleratorConfiguration, com.st.tcharts.ui.view,,,system) 

I am not sure to understand why I have this warning ....

Are there several active contexts at the moment?

If I change my shortcut to Ctrl + C , for example, I do not have this warning, but Ctrl + C is also attached to another command (copy) in the debugging context ... why?

I did not find clear ressources delaing about Eclipse contexts on the web ...

Thank you in advance

Mana

+4
source share
1 answer

I'm not sure why your context does not isolate your bindings from eclipse, but if CTRL+R already associated with the Run For Line command, you can simply change your handler to your own, as described in this thread :

(Example to adapt to your case)

  <handler class="test.handlers.DeleteFooHandler" commandId="org.eclipse.ui.edit.delete"> <activeWhen> <iterate ifEmpty="false" operator="and"> <instanceof value="test.model.Foo"> </instanceof> </iterate></activeWhen> </handler> 

Note: this approach also illustrates this thread :

 IHandlerService handlerService = getSite().getService(IHandlerService.class); IHandler myPaste = new org.eclipse.core.commands.AbstractHandler() { public Object execute(ExecutionEvent event) throws ExecutionException{ System.out.println("This is MyPaste"); } }; 

Now, since it does not explain why your own IContext does not deactivate Eclipse bindings, I can only find this thread , explaining when your context or is actually inactive:

If you open your own window (a dialog box or a shell), and the workplace window is inactive, your context will also not be active.
You can try setting your window wrapper to type == window, also using IContextService#registerShell(*) ..., which should leave the standard window contexts valid.
You still have to activate the context while your SW window wrapper is active (with deactivation disabled).

What the OP answered:

I got his solution by activating this context to increase the focus of the required window and disconnecting this context from the focus that was lost and deleting the same window.

Maybe this can help. In the meantime, you can look at the " Platform Command Framework " to activate the "trace parameter" and see how the binding is activated and for which command.

+2
source

Source: https://habr.com/ru/post/1286624/


All Articles