Author: scabanovich
Date: 2007-07-03 13:47:09 -0400 (Tue, 03 Jul 2007)
New Revision: 2271
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
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
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
Log:
EXIN-217 Preparation to collecting all changed declarations before merging them to model.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -20,10 +20,8 @@
/**
* @author Viacheslav Kabanovich
*/
-public class SeamAnnotatedFactory implements ISeamAnnotatedFactory {
+public class SeamAnnotatedFactory extends SeamFactory implements ISeamAnnotatedFactory {
IMethod javaSource = null;
- String name = null;
- ScopeType scopeType = ScopeType.UNSPECIFIED;
public IMethod getSourceMethod() {
return javaSource;
@@ -33,22 +31,6 @@
this.javaSource = method;
}
- public String getName() {
- return name;
- }
-
- public ScopeType getScope() {
- return scopeType;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setScope(ScopeType type) {
- this.scopeType = type;
- }
-
public IMember getSourceMember() {
return javaSource;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -193,5 +193,17 @@
public Set<ISeamXmlComponentDeclaration> getXmlDeclarations() {
return xmlDeclarations;
}
+
+ public void addDeclaration(ISeamComponentDeclaration declaration) {
+ if(allDeclarations.contains(declaration)) return;
+ allDeclarations.add(declaration);
+ if(declaration instanceof ISeamJavaComponentDeclaration) {
+ javaDeclarations.add((ISeamJavaComponentDeclaration)declaration);
+ } else if(declaration instanceof ISeamXmlComponentDeclaration) {
+ xmlDeclarations.add((ISeamXmlComponentDeclaration)xmlDeclarations);
+ } else if(declaration instanceof ISeamPropertiesDeclaration) {
+ propertyDeclarations.add((ISeamPropertiesDeclaration)declaration);
+ }
+ }
}
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-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -1,5 +1,6 @@
package org.jboss.tools.seam.internal.core;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
@@ -21,5 +22,19 @@
source = path;
}
+ public int getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+ public IResource getResource() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getStartPosition() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -0,0 +1,26 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.jboss.tools.seam.core.ISeamFactory;
+import org.jboss.tools.seam.core.ScopeType;
+
+public class SeamFactory implements ISeamFactory {
+ String name = null;
+ ScopeType scopeType = ScopeType.UNSPECIFIED;
+
+ public String getName() {
+ return name;
+ }
+
+ public ScopeType getScope() {
+ return scopeType;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setScope(ScopeType type) {
+ this.scopeType = type;
+ }
+
+}
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-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -3,10 +3,12 @@
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IType;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
-import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
import org.jboss.tools.seam.core.ISeamComponentMethod;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
@@ -19,10 +21,16 @@
protected ScopeType scopeType = ScopeType.UNSPECIFIED;
protected boolean stateful = false;
protected boolean entity = false;
+
+ protected IType type;
protected Set<IBijectedAttribute> bijectedAttributes = new
HashSet<IBijectedAttribute>();
protected Set<ISeamComponentMethod> componentMethods = new
HashSet<ISeamComponentMethod>();
protected Set<IRole> roles = new HashSet<IRole>();
+
+ public void setType(IType type) {
+ this.type = type;
+ }
public String getClassName() {
return className;
@@ -115,4 +123,8 @@
this.entity = entity;
}
+ public IMember getSourceMember() {
+ return type;
+ }
+
}
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-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -10,19 +10,22 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamFactory;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamContextVariable;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
/**
@@ -30,9 +33,11 @@
*/
public class SeamProject implements ISeamProject {
IProject project;
- Set<SeamComponent> allComponents = new HashSet<SeamComponent>();
+ Map<String, SeamComponent> allComponents = new HashMap<String,
SeamComponent>();
protected Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
Set<ISeamContextVariable> allVariables = new
HashSet<ISeamContextVariable>();
+
+ Map<String, SeamJavaComponentDeclaration> javaDeclarations = new
HashMap<String, SeamJavaComponentDeclaration>();
public SeamProject() {}
@@ -65,13 +70,13 @@
protected void store() {
}
-// public ISeamComponent getComponentByName(String name) {
-// return components.get(name);
-// }
+ public ISeamComponent getComponentByName(String name) {
+ return allComponents.get(name);
+ }
public Set<ISeamComponent> getComponents() {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- result.addAll(allComponents);
+ result.addAll(allComponents.values());
return result;
}
@@ -83,21 +88,48 @@
public void registerComponents(SeamComponentDeclaration[] list, IPath source) {
pathRemoved(source);
if(list == null) return;
- //TODO
+
for (int i = 0; i < list.length; i++) {
list[i].setSourcePath(source);
-
- //TODO !!!
-// allComponents.add(list[i]);
+ String name = list[i].getName();
+ SeamComponent c = getComponent(name);
+ if(c == null) {
+ c = newComponent(name);
+ allComponents.put(name, c);
+ }
+ c.addDeclaration(list[i]);
+ if(list[i] instanceof ISeamJavaComponentDeclaration) {
+ javaDeclarations.put(c.getClassName(), (SeamJavaComponentDeclaration)list[i]);
+ Set<ISeamComponent> cs = getComponentsByClass(c.getClassName());
+ for (ISeamComponent ci: cs) {
+ if(ci == c) continue;
+ SeamComponent cii = (SeamComponent)ci;
+ cii.addDeclaration(list[i]);
+ }
+ } else if(list[i] instanceof ISeamXmlComponentDeclaration) {
+ ISeamXmlComponentDeclaration xml = (ISeamXmlComponentDeclaration)list[i];
+ String className = xml.getClassName();
+ SeamJavaComponentDeclaration j = javaDeclarations.get(className);
+ if(j != null) c.addDeclaration(j);
+ }
}
}
/**
* Package local method called by builder.
+ * @param component
* @param source
+ */
+ public void registerFactories(ISeamFactory[] list, IPath source) {
+
+ }
+
+ /**
+ * Package local method called by builder.
+ * @param source
*/
public void pathRemoved(IPath source) {
- Iterator<SeamComponent> iterator = allComponents.iterator();
+ Iterator<SeamComponent> iterator = allComponents.values().iterator();
while(iterator.hasNext()) {
ISeamComponent c = iterator.next();
Iterator<ISeamComponentDeclaration> ds = c.getAllDeclarations().iterator();
@@ -111,13 +143,11 @@
}
}
+ //deprecated
public Set<ISeamComponent> getComponentsByName(String name) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for(SeamComponent component: allComponents) {
- if(name.equals(component.getName())) {
- result.add(component);
- }
- }
+ ISeamComponent c = getComponentByName(name);
+ if(c != null) result.add(c);
return result;
}
@@ -126,7 +156,7 @@
*/
public Set<ISeamComponent> getComponentsByClass(String className) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for(SeamComponent component: allComponents) {
+ for(SeamComponent component: allComponents.values()) {
if(className.equals(component.getClassName())) {
result.add(component);
}
@@ -139,7 +169,7 @@
*/
public Set<ISeamComponent> getComponentsByScope(ScopeType type) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
- for(SeamComponent component: allComponents) {
+ for(SeamComponent component: allComponents.values()) {
if(type.equals(component.getScope())) {
result.add(component);
}
@@ -151,7 +181,7 @@
* @see
org.jboss.tools.seam.core.ISeamProject#addComponent(org.jboss.tools.seam.core.ISeamComponent)
*/
public void addComponent(ISeamComponent component) {
- allComponents.add((SeamComponent)component);
+ allComponents.put(component.getName(), (SeamComponent)component);
}
/**
@@ -229,5 +259,15 @@
public void removeFactory(ISeamFactory factory) {
allFactories.remove(factory);
}
+
+ SeamComponent getComponent(String name) {
+ return allComponents.get(name);
+ }
+
+ SeamComponent newComponent(String name) {
+ SeamComponent c = new SeamComponent();
+ c.setName(name);
+ return c;
+ }
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-03
17:17:00 UTC (rev 2270)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-03
17:47:09 UTC (rev 2271)
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IResource;
import org.jboss.tools.seam.core.ISeamPropertiesDeclaration;
import org.jboss.tools.seam.core.ISeamProperty;