Define Key Binding in Fragment [message #1709136] |
Thu, 24 September 2015 08:09  |
Eclipse User |
|
|
|
Hi,
I am trying to define a key binding for an e4 fragment. I tried to add the following model fragment:
Element ID=org.eclipse.e4.ide.application
Featurename=bindingContexts
But unfortunately this produces an exception at application start. If I add the binding context as a child to a binding context of the application plug-in, it works.
What could I be doing wrong? Here is the stack trace:
org.eclipse.core.commands.common.NotDefinedException: Cannot get the parent identifier from an undefined context. my-application.bindingcontext.myKeyBindings
at org.eclipse.core.commands.contexts.Context.getParentId(Context.java:201)
at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.getLevel(ContextSet.java:48)
at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:37)
at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:1)
at java.util.TimSort.countRunAndMakeAscending(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at org.eclipse.e4.ui.bindings.internal.ContextSet.<init>(ContextSet.java:76)
at org.eclipse.e4.ui.bindings.internal.BindingTableManager.createContextSet(BindingTableManager.java:90)
at org.eclipse.e4.ui.bindings.internal.BindingTableManager.addTable(BindingTableManager.java:50)
at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.defineBindingTable(BindingProcessingAddon.java:165)
at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.defineBindingTables(BindingProcessingAddon.java:151)
at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.init(BindingProcessingAddon.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:267)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:186)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:49)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:276)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:144)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
|
|
|
|
|
|
Re: Define Key Binding in Fragment [message #1760498 is a reply to message #1739479] |
Thu, 27 April 2017 13:54  |
Eclipse User |
|
|
|
Here are the steps I took to solve this problem:
First, in the Application.e4xmi file, add a Binding Context as a Subcontext to one of the predefined Binding Contexts. (I created a Subcontext of org.eclipse.ui.context.window (In Windows))
Then, do the following in the fragment.e4xmi file:
- Add a model fragment with Extended Element ID == <Subcontext ID from Application.e4xmi> and Feature Name == children
- Under this children model fragment, create a Binding Context
- Add a model fragment with Extended Element ID == org.eclipse.e4.ide.application and Feature Name == bindingTables
- Under this bindingTables model fragment, create a Binding Table with the Binding Context ID created in the children model fragment
- Under this Binding Table, add key bindings
Lastly, in the part descriptor of the fragment.e4xmi file, add the Binding Context from the children model fragment to the Binding Contexts list.
|
|
|
Powered by
FUDForum. Page generated in 0.25967 seconds