Author: dgeraskov
Date: 2011-09-12 06:25:46 -0400 (Mon, 12 Sep 2011)
New Revision: 34625
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-9687
Workaround for Dali bug which fixes class cast exception
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -43,6 +43,7 @@
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -411,6 +412,23 @@
private static IndexedDeclarationAnnotationAdapter
buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter
hibernateGenericGeneratorsAdapter) {
return new NestedIndexedDeclarationAnnotationAdapter(hibernateGenericGeneratorsAdapter,
index, Hibernate.GENERIC_GENERATOR);
}
+
+ /*
+ * This is a workaround fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=357224
+ * The exception occurs due to wrong cast in SourceAnnotation
+ * The method should be removed after the bug fix.
+ */
+ public void convertToStandAlone() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ this.storeOn(map);
+ this.removeAnnotation(); // this annotation has already been removed from the model
+ this.daa = new SimpleDeclarationAnnotationAdapter(this.getAnnotationName());
+ this.annotationAdapter = new ElementAnnotationAdapter(this.annotatedElement,
this.daa);
+ this.rebuildAdapters();
+ ((JavaResourceAnnotatedElement)this.parent).addStandAloneAnnotation((NestableAnnotation)
this);
+ this.newAnnotation();
+ this.restoreFrom(map);
+ }
public static class GenericGeneratorAnnotationDefinition implements
AnnotationDefinition
{
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+import java.util.HashMap;
import java.util.ListIterator;
import java.util.Map;
@@ -33,7 +34,9 @@
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.NestableQueryHintAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.CacheModeType;
@@ -773,6 +776,23 @@
public void toString(StringBuilder sb) {
sb.append(this.name);
}
+
+ /*
+ * This is a workaround fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=357224
+ * The exception occurs due to wrong cast in SourceAnnotation
+ * The method should be removed after the bug fix.
+ */
+ public void convertToStandAlone() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ this.storeOn(map);
+ this.removeAnnotation(); // this annotation has already been removed from the model
+ this.daa = new SimpleDeclarationAnnotationAdapter(this.getAnnotationName());
+ this.annotationAdapter = new ElementAnnotationAdapter(this.annotatedElement,
this.daa);
+ this.rebuildAdapters();
+ ((JavaResourceAnnotatedElement)this.parent).addStandAloneAnnotation((NestableAnnotation)
this);
+ this.newAnnotation();
+ this.restoreFrom(map);
+ }
// ********** static methods **********
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+import java.util.HashMap;
import java.util.ListIterator;
import java.util.Map;
@@ -31,7 +32,9 @@
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.NestableQueryHintAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.CacheModeType;
@@ -610,6 +613,23 @@
public void toString(StringBuilder sb) {
sb.append(this.name);
}
+
+ /*
+ * This is a workaround fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=357224
+ * The exception occurs due to wrong cast in SourceAnnotation
+ * The method should be removed after the bug fix.
+ */
+ public void convertToStandAlone() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ this.storeOn(map);
+ this.removeAnnotation(); // this annotation has already been removed from the model
+ this.daa = new SimpleDeclarationAnnotationAdapter(this.getAnnotationName());
+ this.annotationAdapter = new ElementAnnotationAdapter(this.annotatedElement,
this.daa);
+ this.rebuildAdapters();
+ ((JavaResourceAnnotatedElement)this.parent).addStandAloneAnnotation((NestableAnnotation)
this);
+ this.newAnnotation();
+ this.restoreFrom(map);
+ }
// ********** static methods **********
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -118,7 +118,7 @@
}
private GenericGeneratorAnnotation buildGenericGenerator(int index) {
- return GenericGeneratorAnnotationImpl.createNestedGenericGenerator(this,
this.annotatedElement, index, this.daa);
+ return GenericGeneratorAnnotationImpl.createNestedGenericGenerator(this.parent,
this.annotatedElement, index, this.daa);
}
public GenericGeneratorAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex)
{
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -32,7 +32,6 @@
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -45,6 +44,7 @@
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -454,9 +454,21 @@
return this.buildStringElementAdapter(this.defForTypeDeclarationAdapter);
}
-
- private static DeclarationAnnotationElementAdapter<String>
buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String
elementName, ExpressionConverter<String> converter) {
- return new
ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter,
elementName, converter);
+ /*
+ * This is a workaround fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=357224
+ * The exception occurs due to wrong cast in SourceAnnotation
+ * The method should be removed after the bug fix.
+ */
+ public void convertToStandAlone() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ this.storeOn(map);
+ this.removeAnnotation(); // this annotation has already been removed from the model
+ this.daa = new SimpleDeclarationAnnotationAdapter(this.getAnnotationName());
+ this.annotationAdapter = new ElementAnnotationAdapter(this.annotatedElement,
this.daa);
+ this.rebuildAdapters();
+ ((JavaResourceAnnotatedElement)this.parent).addStandAloneAnnotation((NestableAnnotation)
this);
+ this.newAnnotation();
+ this.restoreFrom(map);
}
public static class TypeDefAnnotationDefinition implements AnnotationDefinition
Modified:
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
===================================================================
---
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-09-12
10:16:40 UTC (rev 34624)
+++
branches/jbosstools-3.3.0.M3/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-09-12
10:25:46 UTC (rev 34625)
@@ -118,7 +118,7 @@
}
private TypeDefAnnotation buildTypeDef(int index) {
- return TypeDefAnnotationImpl.createNestedTypeDef(this, this.annotatedElement, index,
this.daa);
+ return TypeDefAnnotationImpl.createNestedTypeDef(this.parent, this.annotatedElement,
index, this.daa);
}
public TypeDefAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) {