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

Bug 338859

Summary: exception right-clicking attribute in JPA structure view
Product: [WebTools] Dali JPA Tools Reporter: Karen Butzke <karenfbutzke>
Component: Diagram EditorAssignee: Krum Bakalsky <krum.bakalsky>
Status: RESOLVED FIXED QA Contact: Stefan Dimov <stefan.dimov>
Severity: normal    
Priority: P3 CC: bakalsky, cbridgha, david_williams, nan.n.li, neil.hauge, paul.fullbright
Version: 3.0Flags: david_williams: pmc_approved+
stefan.dimov: pmc_approved? (raghunathan.srinivasan)
stefan.dimov: pmc_approved? (naci.dai)
stefan.dimov: pmc_approved? (deboer)
stefan.dimov: pmc_approved? (neil.hauge)
stefan.dimov: pmc_approved? (kaloyan)
cbridgha: pmc_approved+
stefan.dimov: review+
neil.hauge: review+
Target Milestone: 3.0 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch proposal
none
Fixing the IndexOutOfBounds exception neil.hauge: iplog+

Description Karen Butzke CLA 2011-03-03 16:33:19 EST
I get this exception in the error log when right-clicking on an attribute in the JPA structure view. It appears to be related to the Open Diagram action.

org.eclipse.core.runtime.CoreException: No property tester contributes a property org.eclipse.wst.common.project.facet.core.projectFacet to type class org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.JavaEclipseLinkPersistentAttribute
	at org.eclipse.core.internal.expressions.TypeExtensionManager.getProperty(TypeExtensionManager.java:123)
	at org.eclipse.core.internal.expressions.TestExpression.evaluate(TestExpression.java:96)
Comment 1 Nan Li CLA 2011-03-11 11:27:57 EST
I get the similar exception in the error log when right-clicking on JPA Content in the Project Explorer.

org.eclipse.core.runtime.CoreException: No property tester contributes a property org.eclipse.wst.common.project.facet.core.projectFacet to type class org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode
	at org.eclipse.core.internal.expressions.TypeExtensionManager.getProperty(TypeExtensionManager.java:123)
	at org.eclipse.core.internal.expressions.TestExpression.evaluate(TestExpression.java:96)
Comment 2 Neil Hauge CLA 2011-03-14 10:22:37 EDT
Stefan...Is the "Open Diagram" menu item supposed to be included in every right-click context menu for Dali content?  I'm not sure this question is related to this bug, but just curios as to the intention of where this menu item is placed.
Comment 3 Stefan Dimov CLA 2011-04-28 04:30:42 EDT
(In reply to comment #2)
> Stefan...Is the "Open Diagram" menu item supposed to be included in every
> right-click context menu for Dali content?  I'm not sure this question is
> related to this bug, but just curios as to the intention of where this menu
> item is placed.

Yes, it's being propagated to all the subnodes of 'JPA Content' node. Do you think it's ok?
Comment 4 Neil Hauge CLA 2011-05-02 11:07:35 EDT
I didn't notice this bug was targeted to 3.1.  This really should be fixed for Indigo.  This is a common action that will result in exceptions in the error log which should be avoided if at all possible for a release.

As for the location, I'm not sure if this item should be in the Structure View tree.  I think of this area being more task focused to the current editor, and not a place to switch editors.  What do others think?
Comment 5 Stefan Dimov CLA 2011-05-03 04:48:43 EDT
Yes, we should certainly fix this for Indigo (along with other bugs, which I will retarget shortly). As for the location I'm also not sure ...
Comment 6 Krum Bakalsky CLA 2011-05-05 03:37:04 EDT
Created attachment 194796 [details]
Patch proposal
Comment 7 Krum Bakalsky CLA 2011-05-05 03:37:39 EDT
We have found the problem and are proposing a patch. The issue was related to the changes in the package name of some Dali classes: in particular org.eclipse.jpt.jpa.core.JpaNode, which, together with another minor problem, was causing that JPA Diagram's property tester was not applied.
Comment 8 Stefan Dimov CLA 2011-05-05 09:22:14 EDT
The patch works fine except for a specific scenario:

1. Double click on an entity in order to see it in the JPA structure view
2. Right click on the entity in the JPA structure view

You get:
----------------------------------------------
java.lang.ArrayIndexOutOfBoundsException: 1
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.propertytester.JpaProjectFacetVersionPropertyTester.test(JpaProjectFacetVersionPropertyTester.java:21)
	at org.eclipse.core.internal.expressions.Property.test(Property.java:58)
	at org.eclipse.core.internal.expressions.TestExpression.evaluate(TestExpression.java:99)
	at org.eclipse.core.internal.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:53)
	at org.eclipse.core.internal.expressions.EnablementExpression.evaluate(EnablementExpression.java:53)
	at org.eclipse.ui.internal.ObjectActionContributor$ObjectContribution.isApplicableTo(ObjectActionContributor.java:374)
	at org.eclipse.ui.internal.ObjectActionContributor.isApplicableTo(ObjectActionContributor.java:242)
	at org.eclipse.ui.internal.ObjectContributorManager.isApplicabl
....
-----------------------------------------------

Please, see into it ...
Comment 9 Krum Bakalsky CLA 2011-05-09 04:47:37 EDT
Created attachment 195046 [details]
Fixing the IndexOutOfBounds exception

Thanks Stefan, for pointing this out. I have proposed another patch (the JUnit tests are OK). Could you please take a look at it ?
Comment 10 Stefan Dimov CLA 2011-05-10 06:32:01 EDT
This bug is a regression. Every (first) time the user tries to open the diagram she can't do it and gets an exception.

The workaround is just to retry opening the diagram, but it's annoying.

The fix was tested manually. 

The change is very small - in plugin.xml and in JpaProjectFacetVersionPropertyTester. It concerns project facet testing. I (as a component lead) have reviewed the fix. The risk is low.
Comment 11 David Williams CLA 2011-05-10 09:32:34 EDT
Excellent. Obviously important to fix for Indigo, fix looks simple, and safe. 

Thanks for fixing ... and finding!
Comment 12 Chuck Bridgham CLA 2011-05-10 10:20:25 EDT
Fix looks good - thanks
Comment 13 Stefan Dimov CLA 2011-05-11 11:44:01 EDT
Committed and released ...