Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338431

Summary: Problem with fragment contribution since 4.1 m5
Product: [Eclipse Project] e4 Reporter: Holger Sachse <hasachse>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: pwebster, tom.schindl
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Small fragment example none

Description Holger Sachse CLA 2011-02-28 11:17:07 EST
Created attachment 189960 [details]
Small fragment example

I have since e4.1m5 a strange behavior with menu and toolbar contributions via a fragment plug-in.

Adapting Tom's tutorial to the changes since m5 contribution works. Loading the versioned projects from a subversion repository into another workspace (only e4 projects) the menu/ toolbar entry does not show up.

Even worse creating an e4 project via the wizard and adding a simple view and adding a fragment project with only one handler does not work. I followed Tom's and Lars' instructions mentioned in their tutorials.

Has anybody a clue where to start searching what I may do wrong?

the two projects are in the attached file.
Comment 1 Thomas Schindl CLA 2011-02-28 11:50:56 EST
For me they work in an inner eclipse like a charme. First they've not worked either but then I checked my run-configuration and i missed including the contribution plugin to the launch. 

Is it possible that your problem too? 

Beside that there's one other strange thing happing which is that I get the following exception when hitting a the "Say Hello"-Button (Paul any idea where this is coming from?):

!ENTRY org.eclipse.e4.ui.workbench 1 0 2011-02-28 17:49:19.437
!MESSAGE Start building UI
org.eclipse.core.commands.common.NotDefinedException: Cannot get the parent identifier from an undefined context. org.eclipse.ui.contexts.dialog
	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.Arrays.mergeSort(Arrays.java:1270)
	at java.util.Arrays.sort(Arrays.java:1210)
	at java.util.Collections.sort(Collections.java:159)
	at org.eclipse.e4.ui.bindings.internal.ContextSet.<init>(ContextSet.java:76)
	at org.eclipse.e4.ui.bindings.internal.BindingTableManager.createContextSet(BindingTableManager.java:56)
	at org.eclipse.e4.ui.bindings.internal.BindingServiceImpl.setContextIds(BindingServiceImpl.java:202)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:75)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:88)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:326)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:343)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.activate(EclipseContext.java:596)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener$2.run(ShellActivationListener.java:120)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:117)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1072)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1435)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1439)
	at org.eclipse.swt.widgets.Shell.windowDidBecomeKey(Shell.java:2057)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5438)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:213)
	at org.eclipse.swt.widgets.Widget.becomeKeyWindow(Widget.java:358)
	at org.eclipse.swt.widgets.Shell.becomeKeyWindow(Shell.java:494)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5262)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSWindow.makeKeyAndOrderFront(NSWindow.java:194)
	at org.eclipse.swt.widgets.Shell.makeKeyAndOrderFront(Shell.java:1235)
	at org.eclipse.swt.widgets.Shell.setWindowVisible(Shell.java:1904)
	at org.eclipse.swt.widgets.Shell.open(Shell.java:1313)
	at org.eclipse.jface.window.Window.open(Window.java:797)
	at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:334)
	at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:364)
	at org.eclipse.jface.dialogs.MessageDialog.openInformation(MessageDialog.java:446)
	at de.sachsefamily.learnapp.contribution.handler.HelloHandler.run(HelloHandler.java:13)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:207)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:123)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:122)
	at org.eclipse.e4.ui.workbench.renderers.swt.ToolItemRenderer$8.widgetSelected(ToolItemRenderer.java:415)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4054)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1435)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1443)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1255)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3900)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3541)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:842)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:758)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:134)
	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:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 2 Thomas Schindl CLA 2011-02-28 11:59:42 EST
I've talked to Paul and you should not rename the binding contexts but leave the default ids in else you'll get into trouble e.g. when a Dialog is opened.
Comment 3 Holger Sachse CLA 2011-02-28 13:08:09 EST
(In reply to comment #2)
> I've talked to Paul and you should not rename the binding contexts but leave
> the default ids in else you'll get into trouble e.g. when a Dialog is opened.

I understand your comment about the binding context but it did not work without it either. Or has a fragment to contribute to each element in the master model?
Comment 4 Thomas Schindl CLA 2011-02-28 13:11:18 EST
Like I said - your fragment and master works perfectly in my e4 dev (current CVS-HEAD) install (please note the model *can't* run in a m5 install because the model has changed since m5 was released!)
Comment 5 Holger Sachse CLA 2011-02-28 13:15:24 EST
(In reply to comment #1)
Does this mean that the contribution plug-in has to be in the dependencies of
the master?

If yes then a big advantage of e3 is lost in e4! My undertanding about e3 was
until now that the master does not need to know about the contributing plug-in!
Comment 6 Holger Sachse CLA 2011-02-28 13:18:50 EST
(In reply to comment #4)
This confuses me. The two plug-in's are build up in an m5 env and not moved from m4 forward. Reading your words it is even more confusing for me that it works in m4.

I am lost, but may be it is to late for today to understand it.
Comment 7 Thomas Schindl CLA 2011-02-28 14:04:27 EST
(In reply to comment #5)
> (In reply to comment #1)
> Does this mean that the contribution plug-in has to be in the dependencies of
> the master?
> 
> If yes then a big advantage of e3 is lost in e4! My undertanding about e3 was
> until now that the master does not need to know about the contributing plug-in!

No. The master does not need to know about the fragment! The fragment is the replacement for all extension points you used in e3. 

You should notice that master has no dependency on contribution but it has to be in the launch config!
Comment 8 Thomas Schindl CLA 2011-02-28 14:10:41 EST
(In reply to comment #6)
> (In reply to comment #4)
> This confuses me. The two plug-in's are build up in an m5 env and not moved
> from m4 forward. Reading your words it is even more confusing for me that it
> works in m4.
> 
> I am lost, but may be it is to late for today to understand it.

Looking at the e4xmi this is NOT the case because you are using the new Binding-Without-String refs and the m5 release has not had those because we introduced them in bug 320171!

I'm closing this as worksforme because you code is working perfectly in the latest I-Builds. If you have an e4xmi-Files created pre bug 320171 you have to update it to use the NEW Binding-Objects else it won't load in M6!
Comment 9 Holger Sachse CLA 2011-02-28 16:39:26 EST
(In reply to comment #8)
OK got it and it works fine now. Thank you for your support.