Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2010-01-19 19:36:17 +0000
committerbvosburgh2010-01-19 19:36:17 +0000
commit62085289e47c5915e30047daeb594ccb4a7135c5 (patch)
tree15e671e5bd8938396c7512384a9ed3620502cc65 /jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
parent04d8fcd7a4df6c52abeecb2066633d4565c7f04b (diff)
downloadwebtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.tar.gz
webtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.tar.xz
webtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.zip
[233567] rework sync between resource model and AST
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java40
1 files changed, 23 insertions, 17 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
index e22a024bfc..e600666f3e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
import org.eclipse.jpt.core.resource.java.DiscriminatorType;
@@ -43,7 +43,7 @@ public final class SourceDiscriminatorColumnAnnotation
public SourceDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, Type type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
- this.discriminatorTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, DISCRIMINATOR_TYPE_ADAPTER);
+ this.discriminatorTypeAdapter = new MemberAnnotationElementAdapter<String>(type, DISCRIMINATOR_TYPE_ADAPTER);
this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.DISCRIMINATOR_COLUMN__LENGTH);
this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter);
}
@@ -60,10 +60,10 @@ public final class SourceDiscriminatorColumnAnnotation
}
@Override
- public void update(CompilationUnit astRoot) {
- super.update(astRoot);
- this.setLength(this.buildLength(astRoot));
- this.setDiscriminatorType(this.buildDiscriminatorType(astRoot));
+ public void synchronizeWith(CompilationUnit astRoot) {
+ super.synchronizeWith(astRoot);
+ this.syncLength(this.buildLength(astRoot));
+ this.syncDiscriminatorType(this.buildDiscriminatorType(astRoot));
}
@@ -88,13 +88,16 @@ public final class SourceDiscriminatorColumnAnnotation
}
public void setDiscriminatorType(DiscriminatorType discriminatorType) {
- if (this.attributeValueHasNotChanged(this.discriminatorType, discriminatorType)) {
- return;
+ if (this.attributeValueHasChanged(this.discriminatorType, discriminatorType)) {
+ this.discriminatorType = discriminatorType;
+ this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType));
}
+ }
+
+ private void syncDiscriminatorType(DiscriminatorType astDiscriminatorType) {
DiscriminatorType old = this.discriminatorType;
- this.discriminatorType = discriminatorType;
- this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType));
- this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType);
+ this.discriminatorType = astDiscriminatorType;
+ this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, astDiscriminatorType);
}
private DiscriminatorType buildDiscriminatorType(CompilationUnit astRoot) {
@@ -107,13 +110,16 @@ public final class SourceDiscriminatorColumnAnnotation
}
public void setLength(Integer length) {
- if (this.attributeValueHasNotChanged(this.length, length)) {
- return;
+ if (this.attributeValueHasChanged(this.length, length)) {
+ this.length = length;
+ this.lengthAdapter.setValue(length);
}
+ }
+
+ private void syncLength(Integer astLength) {
Integer old = this.length;
- this.length = length;
- this.lengthAdapter.setValue(length);
- this.firePropertyChanged(LENGTH_PROPERTY, old, length);
+ this.length = astLength;
+ this.firePropertyChanged(LENGTH_PROPERTY, old, astLength);
}
private Integer buildLength(CompilationUnit astRoot) {

Back to the top