Author: scabanovich
Date: 2007-07-16 11:16:18 -0400 (Mon, 16 Jul 2007)
New Revision: 2445
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
EXIN-217 Merge of variables improved
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-16
14:20:43 UTC (rev 2444)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-16
15:16:18 UTC (rev 2445)
@@ -13,10 +13,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.jboss.tools.seam.core.IOpenableElement;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.IValueInfo;
@@ -118,6 +120,10 @@
name = value == null ? null : value.getValue();
}
+ public Set<ISeamContextVariable> getDeclaredVariables() {
+ return null;
+ }
+
public void open() {
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-16
14:20:43 UTC (rev 2444)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-16
15:16:18 UTC (rev 2445)
@@ -13,6 +13,7 @@
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponentMethod;
+import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
@@ -343,6 +344,15 @@
setStateful(value != null && "true".equals(value.getValue()));
}
+ public Set<ISeamContextVariable> getDeclaredVariables() {
+ Set<ISeamContextVariable> set = new HashSet<ISeamContextVariable>();
+ set.addAll(roles);
+ for (IBijectedAttribute a : bijectedAttributes) {
+ if(a.isContextVariable()) set.add(a);
+ }
+ return set;
+ }
+
public void open() {
if(type == null) return;
try {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-16
14:20:43 UTC (rev 2444)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-16
15:16:18 UTC (rev 2445)
@@ -30,7 +30,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.tools.common.xml.XMLUtilities;
-import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamContextVariable;
@@ -270,8 +269,24 @@
String oldClassName = c == null ? null : c.getClassName();
if(current != null) {
+ Set<ISeamContextVariable> oldVariables = current.getDeclaredVariables();
List<Change> changes = current.merge(loaded);
if(changes != null && changes.size() > 0) {
+
+ Set<ISeamContextVariable> newVariables = current.getDeclaredVariables();
+ if(oldVariables != null && newVariables != null) {
+ for (ISeamContextVariable v : oldVariables) {
+ if(!newVariables.contains(v)) {
+ allVariables.remove(v);
+ }
+ }
+ for (ISeamContextVariable v : newVariables) {
+ if(!oldVariables.contains(v)) {
+ allVariables.add(v);
+ }
+ }
+ }
+
Change cc = new Change(c, null, null, null);
cc.addChildren(changes);
List<Change> cchanges = Change.addChange(null, cc);
@@ -310,11 +325,7 @@
if(loaded instanceof ISeamJavaComponentDeclaration) {
SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)loaded;
javaDeclarations.put(jd.getClassName(), jd);
- Set<IBijectedAttribute> as = jd.getBijectedAttributes();
- for (IBijectedAttribute a : as) {
- if(a.isContextVariable()) allVariables.add(a);
- }
- allVariables.addAll(jd.getRoles());
+ allVariables.addAll(jd.getDeclaredVariables());
Set<ISeamComponent> cs = getComponentsByClass(jd.getClassName());
for (ISeamComponent ci: cs) {
if(ci == c) continue;
@@ -405,11 +416,10 @@
if(ds[i].source.equals(source)) {
c.removeDeclaration(ds[i]);
if(ds[i] instanceof ISeamJavaComponentDeclaration) {
- ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)ds[i];
+ SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)ds[i];
String className = jd.getClassName();
javaDeclarations.remove(className);
- allVariables.removeAll(jd.getBijectedAttributes());
- allVariables.removeAll(jd.getRoles());
+ allVariables.removeAll(jd.getDeclaredVariables());
}
changes = Change.addChange(changes, new Change(c, null, ds[i], null));
}
@@ -450,13 +460,12 @@
Collection<ISeamComponentDeclaration> declarations = removed.values();
for (ISeamComponentDeclaration declaration: declarations) {
if(declaration instanceof ISeamJavaComponentDeclaration) {
- ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
+ SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)declaration;
String className = jd.getClassName();
if(javaDeclarations.get(className) == jd) {
javaDeclarations.remove(className);
}
- allVariables.removeAll(jd.getRoles());
- allVariables.removeAll(jd.getBijectedAttributes());
+ allVariables.removeAll(jd.getDeclaredVariables());
}
}