Author: dgeraskov
Date: 2011-02-16 11:00:30 -0500 (Wed, 16 Feb 2011)
New Revision: 29178
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-8436
validation and completion proposals moved to generator container
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2011-02-16
15:27:21 UTC (rev 29177)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2011-02-16
16:00:30 UTC (rev 29178)
@@ -12,7 +12,6 @@
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.BaseJoinColumn;
@@ -29,7 +28,6 @@
import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
@@ -264,17 +262,9 @@
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
super.validate(messages, reporter, astRoot);
- this.validateGenericGenerator(messages, reporter, astRoot);
this.validateForeignKey(messages, astRoot);
}
- protected void validateGenericGenerator(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
- ListIterator<JavaGenericGenerator> genericGenerators =
getGeneratorContainer().genericGenerators();
- while (genericGenerators.hasNext()) {
- genericGenerators.next().validate(messages, reporter, astRoot);
- }
- }
-
protected void validateForeignKey(List<IMessage> messages, CompilationUnit
astRoot) {
org.eclipse.jpt.db.Table table = getForeignKeyDbTable();
if (!shouldValidateAgainstDatabase() || foreignKey == null || table == null ){
@@ -297,24 +287,6 @@
messages.add(message);
}
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String>
filter,
- CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- ListIterator<JavaGenericGenerator> genericGenerators =
getGeneratorContainer().genericGenerators();
- while (genericGenerators.hasNext()) {
- result = genericGenerators.next()
- .javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
/*protected String getResourceDefaultName() {
NamingStrategy ns = getJpaProject().getNamingStrategy();
if (getJpaProject().isNamingStrategyEnabled() && ns != null){
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java 2011-02-16
15:27:21 UTC (rev 29177)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaGeneratorContainerImpl.java 2011-02-16
16:00:30 UTC (rev 29178)
@@ -15,13 +15,17 @@
import java.util.List;
import java.util.ListIterator;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaGeneratorContainer;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
@@ -148,6 +152,44 @@
addGenericGenerator(buildGenericGenerator((GenericGeneratorAnnotation)
resourceGenericGenerators.next()));
}
}
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaGeneratorContainer#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter,
org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateGenericGenerators(messages, reporter, astRoot);
+ }
+ protected void validateGenericGenerators(List<IMessage> messages, IReporter
reporter, CompilationUnit astRoot) {
+ ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
+ while (genericGenerators.hasNext()) {
+ genericGenerators.next().validate(messages, reporter, astRoot);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaGeneratorContainer#javaCompletionProposals(int,
org.eclipse.jpt.utility.Filter, org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos, Filter<String>
filter,
+ CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
+ while (genericGenerators.hasNext()) {
+ result = genericGenerators.next()
+ .javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java 2011-02-16
15:27:21 UTC (rev 29177)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMappingImpl.java 2011-02-16
16:00:30 UTC (rev 29178)
@@ -16,7 +16,6 @@
import org.eclipse.jpt.core.internal.context.java.AbstractJavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.IndexAnnotation;
/**
@@ -26,8 +25,6 @@
public class HibernateJavaIdMappingImpl extends AbstractJavaIdMapping
implements HibernateJavaIdMapping {
- protected JavaGenericGenerator genericGenerator;
-
protected JavaIndex index;
/**
@@ -75,133 +72,6 @@
return this.getColumn().getDBColumnName();
}
- protected void initializeGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource != null) {
- this.genericGenerator = buildGenericGenerator(genericGeneratorResource);
- }
- }
-
- protected GenericGeneratorAnnotation getResourceGenericGenerator() {
- return (GenericGeneratorAnnotation)
this.getResourcePersistentAttribute().getAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation
genericGeneratorResource) {
- JavaGenericGenerator generator = ((HibernateAbstractJpaFactory)
getJpaFactory()).buildJavaGenericGenerator(this);
- generator.initialize(genericGeneratorResource);
- return generator;
- }
-
- /*@SuppressWarnings("unchecked")
- public Iterator<JavaGenerator> generators() {
- return new CompositeIterator<JavaGenerator>(super.generators(),
- (getGenericGenerator() == null) ? EmptyIterator.instance()
- : new SingleElementIterator(getGenericGenerator()));
- }
-
- public JavaGenericGenerator addGenericGenerator(int index) {
- if (getGenericGenerator() != null) {
- throw new IllegalStateException("genericGenerator already exists");
//$NON-NLS-1$
- }
- this.genericGenerator =
((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(this);
- GenericGeneratorAnnotation genericGeneratorResource =
(GenericGeneratorAnnotation)getResourcePersistentAttribute()
- .addAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
- return this.genericGenerator;
- }
-
- private JavaGenericGenerator getGenericGenerator() {
- return genericGenerator;
- }
-
- private void removeGenericGenerator() {
- if (getGenericGenerator() == null) {
- throw new IllegalStateException("genericGenerator does not exist, cannot be
removed"); //$NON-NLS-1$
- }
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = null;
- this.getResourcePersistentAttribute().removeAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
- }
-
- private void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,
newGenericGenerator);
- }
-
- protected void updateGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource == null) {
- if (getGenericGenerator() != null) {
- setGenericGenerator(null);
- }
- }
- else {
- if (getGenericGenerator() == null) {
- setGenericGenerator(buildGenericGenerator(genericGeneratorResource));
- }
- else {
- getGenericGenerator().update(genericGeneratorResource);
- }
- }
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit
astRoot) {
- super.validate(messages, reporter, astRoot);
- validateGenericGenerator(messages, reporter, astRoot);
- }
-
- private void validateGenericGenerator(List<IMessage> messages, IReporter reporter,
CompilationUnit astRoot) {
- if (genericGenerator != null){
- genericGenerator.validate(messages, reporter, astRoot);
- }
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String>
filter,
- CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.getGenericGenerator() != null) {
- result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- public ListIterator<GenericGenerator> genericGenerators() {
- return genericGenerator == null ?
EmptyListIterator.<GenericGenerator>instance()
- : new SingleElementListIterator<GenericGenerator>(genericGenerator);
- }
-
- public int genericGeneratorsSize() {
- return genericGenerator == null ? 0 : 1;
- }
-
- public void moveGenericGenerator(int targetIndex, int sourceIndex) {
- throw new UnsupportedOperationException();
- }
-
- public void removeGenericGenerator(int index) {
- if (genericGeneratorsSize() < index + 1){
- throw new IndexOutOfBoundsException();
- }
- removeGenericGenerator();
- }
-
- public void removeGenericGenerator(GenericGenerator generator) {
- if (this.genericGenerator == generator){
- removeGenericGenerator();
- }
- }*/
-
// *** index
protected void initializeIndex() {