Community
Participate
Working Groups
First a little bit background info, in Dali we have a view called the JPA Structure View. This view is much like an Outline view in that it has a tree of objects (PersistentTypes and PersistentAttributes) that correspond to the currently edited file (either an XML file or a Java file). We keep the tree's selection in sync with the position of the cursor in the active editor. Here is the problem: If I first right-click the root node of an XML file in the structure view, and then switch to a Java file and *directly* right-click the root node in the structure view without first left-clicking it, the context menu for the root node will be the one for the XML file. (And vice-versa.) Selecting the context menu will lead to class cast exception at this point. I have investigated the code by setting a breakpoint in WorkbenchSourceProvider.selectionChanged(...). It looks like the new selection is the right element and our plugin.xml looks fine so it could be that the Eclipse platform is using the wrong selection when evaluating our 'visibleWhen' XML specification. Please take bug 375741 for the reference to our plugin.xml entries, an example JPA project and more related info.
(In reply to comment #0) > First a little bit background info, in Dali we have a view called the JPA > Structure View. This view is much like an Outline view in that it has a tree > of objects (PersistentTypes and PersistentAttributes) that correspond to the > currently edited file (either an XML file or a Java file). We keep the > tree's selection in sync with the position of the cursor in the active > editor. > > Here is the problem: > > If I first right-click the root node of an XML file in the structure view, > and then switch to a Java file and *directly* right-click the root node in > the structure view without first left-clicking it, the context menu for the > root node will be the one for the XML file. (And vice-versa.) Selecting the > context menu will lead to class cast exception at this point. Please attach the .log with the CCE.
Created attachment 234353 [details] Stack Trace here it is
Created attachment 234354 [details] .log here is the .log
Your handler's @Execute method is configured to be injected by something that's not a matching class. Unfortunately it's not clear what handler class it is. Put a breakpoint on InjectionException and you'll see what instance is being injected, and the problematic field. !STACK 0 org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaPersistentType2_0 cannot be cast to org.eclipse.jpt.jpa.core.context.orm.EntityMappings at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132) at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
Created attachment 235333 [details] Step1: Right click in "Resource" perspective.
Created attachment 235334 [details] Step2: Right click in "Tasks" view
Created attachment 235335 [details] Normal context menu
I recognized the same behavior lately (in Kepler 4.3). However this is not related to custom plugins only. When I right click on the "META-INF" folder of a plugin project in the "Resource" perspective and then do a right click in the "Tasks" view, the sub menu "Plug-in Tools" gets added to the context menu of the "Tasks" view. The context menu changes depending on what was previously selected. The attachments.
It's possible we're having a race condition with the new view activation and creation of the popup menu. PW
New Gerrit change created: https://git.eclipse.org/r/44257
The issue happens because the CompatibilityPart class doesn't initialize a selection properly. It can be reproduced in the Tasks, Problems, Bookmarks, Error Log ... view. If you select an entry in a view, the issue will disappear. https://git.eclipse.org/r/#/c/44257 fixes the issue.
Gerrit change https://git.eclipse.org/r/44257 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=03e2bd3b8cee3cb343f10961091e00641a8907ae
Thanks Snjezana. I'm unable to reproduce the issue above but the patch looks correct.
(In reply to Brian de Alwis from comment #13) > Thanks Snjezana. I'm unable to reproduce the issue above but the patch > looks correct. Ah, reproduced it on a subsequent try, and patch fixes the issue.
Verified in I20150428-0800