Author: scabanovich
Date: 2007-07-19 12:42:00 -0400 (Thu, 19 Jul 2007)
New Revision: 2528
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValue.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueList.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMap.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMapEntry.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueString.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractSeamDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueList.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMap.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMapEntry.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueString.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.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/SeamPropertiesDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 Property values implemented as objects implementing ISeamValue.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import org.jboss.tools.seam.core.event.ISeamValue;
+
/**
* A property of Seam Component defined in component.xml or seam.properties files
*/
@@ -23,11 +25,11 @@
/**
* @return value of this property
*/
- public Object getValue();
+ public ISeamValue getValue();
/**
* Sets value of this property
* @param value
*/
- public void setValue(Object value);
+ public void setValue(ISeamValue value);
}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValue.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValue.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValue.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.event;
+
+import org.jboss.tools.seam.core.ISeamElement;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamValue extends ISeamElement {
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueList.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueList.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueList.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,22 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.event;
+
+import java.util.List;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamValueList extends ISeamValue {
+
+ public List<ISeamValueString> getValues();
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMap.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMap.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMap.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,22 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.event;
+
+import java.util.List;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamValueMap extends ISeamValue {
+
+ public List<ISeamValueMapEntry> getEntries();
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMapEntry.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMapEntry.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueMapEntry.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,24 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.event;
+
+import org.jboss.tools.seam.core.ISeamElement;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamValueMapEntry extends ISeamElement {
+
+ public ISeamValueString getKey();
+
+ public ISeamValueString getValue();
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueString.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueString.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/ISeamValueString.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,22 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.event;
+
+import org.jboss.tools.seam.core.IValueInfo;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface ISeamValueString extends ISeamValue {
+
+ public IValueInfo getValue();
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -10,12 +10,9 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
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;
import org.jboss.tools.seam.core.ScopeType;
@@ -24,22 +21,11 @@
/**
* @author Viacheslav Kabanovich
*/
-public class AbstractContextVariable extends SeamObject implements ISeamContextVariable,
ISeamTextSourceReference {
+public class AbstractContextVariable extends AbstractSeamDeclaration implements
ISeamContextVariable {
- protected String name;
protected ScopeType scopeType;
protected String scope;
- protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public ScopeType getScope() {
return scopeType;
}
@@ -60,16 +46,6 @@
}
}
- public int getLength() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getStartPosition() {
- // TODO Auto-generated method stub
- return 0;
- }
-
/**
* Merges loaded data into currently used declaration.
* If changes were done returns a list of changes.
@@ -93,35 +69,6 @@
return changes;
}
- boolean stringsEqual(String s1, String s2) {
- return s1 == null ? s2 == null : s1.equals(s2);
- }
-
- /**
- * @param path
- * @return source reference for some member of declaration.
- * e.g. if you need source reference for @Name you have to
- * invoke getLocationFor("name");
- */
- public ISeamTextSourceReference getLocationFor(String path) {
- final IValueInfo valueInfo = attributes.get(path);
- ISeamTextSourceReference reference = new ISeamTextSourceReference() {
- public int getLength() {
- return valueInfo != null ? valueInfo.getLength() : 0;
- }
-
- public int getStartPosition() {
- return valueInfo != null ? valueInfo.getStartPosition() : 0;
- }
- };
- return reference;
- }
-
- public void setName(IValueInfo value) {
- attributes.put(ISeamXmlComponentDeclaration.NAME, value);
- name = value == null ? null : value.getValue();
- }
-
public void setScope(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
setScopeAsString(value == null ? null : value.getValue());
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractSeamDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractSeamDeclaration.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractSeamDeclaration.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.seam.core.IOpenableElement;
+import org.jboss.tools.seam.core.ISeamTextSourceReference;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.IValueInfo;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public abstract class AbstractSeamDeclaration extends SeamObject implements
ISeamTextSourceReference, IOpenableElement {
+ public static final String PATH_OF_NAME = "name";
+
+ protected String name;
+
+ protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
+
+ public AbstractSeamDeclaration() {}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void open() {}
+
+ public int getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getStartPosition() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * @param path
+ * @return source reference for some member of declaration.
+ * e.g. if you need source reference for @Name you have to
+ * invoke getLocationFor("name");
+ */
+ public ISeamTextSourceReference getLocationFor(String path) {
+ final IValueInfo valueInfo = attributes.get(path);
+ ISeamTextSourceReference reference = new ISeamTextSourceReference() {
+ public int getLength() {
+ return valueInfo != null ? valueInfo.getLength() : 0;
+ }
+
+ public int getStartPosition() {
+ return valueInfo != null ? valueInfo.getStartPosition() : 0;
+ }
+ };
+ return reference;
+ }
+
+ public void setName(IValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.NAME, value);
+ name = value == null ? null : value.getValue();
+ }
+
+ boolean stringsEqual(String s1, String s2) {
+ return s1 == null ? s2 == null : s1.equals(s2);
+ }
+
+}
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-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -10,58 +10,26 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
-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;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.event.Change;
/**
* @author Viacheslav Kabanovich
*/
-public abstract class SeamComponentDeclaration extends SeamObject implements
ISeamComponentDeclaration, IOpenableElement {
+public abstract class SeamComponentDeclaration extends AbstractSeamDeclaration implements
ISeamComponentDeclaration {
- public static final String PATH_OF_NAME = "name";
public static final String PATH_OF_SCOPE = "scope";
-
- /**
- * Seam component name.
- */
- protected String name;
- protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getLength() {
- // TODO Auto-generated method stub
- return 0;
- }
-
public void setResource(IResource resource) {
this.resource = resource;
}
- public int getStartPosition() {
- // TODO Auto-generated method stub
- return 0;
- }
-
public ScopeType getScope() {
return ScopeType.UNSPECIFIED;
}
@@ -91,41 +59,8 @@
return changes;
}
- boolean stringsEqual(String s1, String s2) {
- return s1 == null ? s2 == null : s1.equals(s2);
- }
-
- /**
- * @param path
- * @return source reference for some member of declaration.
- * e.g. if you need source reference for @Name you have to
- * invoke getLocationFor("name");
- */
- public ISeamTextSourceReference getLocationFor(String path) {
- final IValueInfo valueInfo = attributes.get(path);
- ISeamTextSourceReference reference = new ISeamTextSourceReference() {
- public int getLength() {
- return valueInfo != null ? valueInfo.getLength() : 0;
- }
-
- public int getStartPosition() {
- return valueInfo != null ? valueInfo.getStartPosition() : 0;
- }
- };
- return reference;
- }
-
- public void setName(IValueInfo value) {
- attributes.put(ISeamXmlComponentDeclaration.NAME, value);
- 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/SeamPropertiesDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -45,12 +45,6 @@
properties.remove(property.getName());
}
- public SeamProperty addStringProperty(String name, String value) {
- SeamProperty p = new SeamProperty(name, value);
- addProperty(p);
- return p;
- }
-
/**
* Merges loaded data into currently used declaration.
* If changes were done returns a list of changes.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -10,61 +10,24 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.core.event.ISeamValue;
-public class SeamProperty extends SeamObject implements ISeamProperty {
- protected String name;
- protected Object value;
- protected int startPosition = -1;
- protected int length = -1;
+public class SeamProperty extends AbstractSeamDeclaration implements ISeamProperty {
+ protected ISeamValue value;
public SeamProperty() {}
- public SeamProperty(String name) {
- this.name = name;
- }
-
- public SeamProperty(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public SeamProperty(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public int getStartPosition() {
- return startPosition;
- }
-
- public void setStartPosition(int v) {
- startPosition = v;
- }
-
- public int getLength() {
- return length;
- }
-
- public void setLength(int v) {
- length = v;
- }
-
- public Object getValue() {
+ public ISeamValue getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(ISeamValue value) {
this.value = value;
+ adopt((SeamObject)value);
}
public List<Change> merge(SeamObject s) {
@@ -72,16 +35,15 @@
SeamProperty d = (SeamProperty)s;
- startPosition = d.startPosition;
- length = d.length;
-
if(!stringsEqual(name, d.name)) {
changes = Change.addChange(changes, new Change(this, "name", name,
d.name));
name = d.name;
}
- if(!valuesEqual(value, d.value)) {
- changes = Change.addChange(changes, new Change(this, "value", value,
d.value));
- value = d.value;
+
+ List<Change> cs = ((SeamObject)value).merge((SeamObject)d.value);
+ if(cs != null && cs.size() > 0) {
+ Change c = new Change(this, "value", value, value);
+ c.addChildren(cs);
}
return changes;
@@ -91,35 +53,4 @@
return s1 == null ? s2 == null : s1.equals(s2);
}
- boolean valuesEqual(Object v1, Object v2) {
- if(v1 == null) return v2 == null;
- if(v2 == null) return v1 == null;
- if(v1 == v2) return true;
- if(v1 instanceof List && v2 instanceof List) {
- List<?> l1 = (List<?>)v1;
- List<?> l2 = (List<?>)v2;
- if(l1.size() != l2.size()) return false;
- for (int i = 0; i < l1.size(); i++) {
- if(!valuesEqual(l1.get(i), l2.get(i))) return false;
- }
- return true;
- } else if(v1 instanceof Map && v2 instanceof Map) {
- Map<?,?> m1 = (Map<?,?>)v1;
- Map<?,?> m2 = (Map<?,?>)v2;
- if(m1.size() != m2.size()) return false;
- Iterator<?> it = m1.keySet().iterator();
- while(it.hasNext()) {
- Object key = it.next();
- Object o1 = m1.get(key);
- Object o2 = m2.get(key);
- if(o2 == null) return false;
- if(!valuesEqual(o1, o2)) return false;
- }
- return true;
- }
- if(v1.equals(v2)) return true;
-
- return false;
- }
-
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueList.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueList.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueList.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.core.event.ISeamValueList;
+import org.jboss.tools.seam.core.event.ISeamValueString;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamValueList extends SeamObject implements ISeamValueList {
+ List<ISeamValueString> values = new ArrayList<ISeamValueString>();
+
+ public SeamValueList() {}
+
+ public List<ISeamValueString> getValues() {
+ return values;
+ }
+
+ public void addValue(SeamValueString value) {
+ values.add(value);
+ adopt(value);
+ }
+
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamValueList v = (SeamValueList)s;
+
+ //improve
+ if(values.size() != v.values.size()) {
+ changes = Change.addChange(changes, new Change(this, "value", values,
v.values));
+ }
+ values = v.values;
+ for (int i = 0; i < values.size(); i++) {
+ adopt((SeamObject)values.get(i));
+ }
+
+ return changes;
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMap.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMap.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMap.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.core.event.ISeamValueMap;
+import org.jboss.tools.seam.core.event.ISeamValueMapEntry;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamValueMap extends SeamObject implements ISeamValueMap {
+ List<ISeamValueMapEntry> entries = new ArrayList<ISeamValueMapEntry>();
+
+ public SeamValueMap() {}
+
+ public List<ISeamValueMapEntry> getEntries() {
+ return entries;
+ }
+
+ public void addEntry(SeamValueMapEntry entry) {
+ entries.add(entry);
+ adopt(entry);
+ }
+
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamValueMap v = (SeamValueMap)s;
+
+ //improve
+ if(entries.size() != v.entries.size()) {
+ changes = Change.addChange(changes, new Change(this, "value", entries,
v.entries));
+ }
+ entries = v.entries;
+ for (int i = 0; i < entries.size(); i++) {
+ adopt((SeamObject)entries.get(i));
+ }
+
+ return changes;
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMapEntry.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMapEntry.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueMapEntry.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.List;
+
+import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.core.event.ISeamValueMapEntry;
+import org.jboss.tools.seam.core.event.ISeamValueString;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamValueMapEntry extends SeamObject implements ISeamValueMapEntry {
+ SeamValueString key;
+ SeamValueString value;
+
+ public SeamValueMapEntry() {}
+
+ public ISeamValueString getKey() {
+ return key;
+ }
+
+ public ISeamValueString getValue() {
+ return value;
+ }
+
+ public void setKey(SeamValueString key) {
+ this.key = key;
+ adopt(key);
+ }
+
+ public void setValue(SeamValueString value) {
+ this.value = value;
+ adopt(value);
+ }
+
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+
+ SeamValueMapEntry e = (SeamValueMapEntry)s;
+
+ List<Change> keyChanges = key.merge(e.key);
+ if(keyChanges != null && keyChanges.size() > 0) {
+ Change keyChange = new Change(this, "key", key, key);
+ keyChange.addChildren(keyChanges);
+ changes = Change.addChange(changes, keyChange);
+ }
+
+ List<Change> valueChanges = value.merge(e.value);
+ if(valueChanges != null && valueChanges.size() > 0) {
+ Change valueChange = new Change(this, "value", value, value);
+ valueChange.addChildren(valueChanges);
+ changes = Change.addChange(changes, valueChange);
+ }
+
+ return changes;
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueString.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueString.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamValueString.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core;
+
+import java.util.List;
+
+import org.jboss.tools.seam.core.IValueInfo;
+import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.core.event.ISeamValueString;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeamValueString extends SeamObject implements ISeamValueString {
+ IValueInfo value;
+
+ public SeamValueString() {}
+
+ public IValueInfo getValue() {
+ return value;
+ }
+
+ public void setValue(IValueInfo value) {
+ this.value = value;
+ }
+
+ public List<Change> merge(SeamObject s) {
+ List<Change> changes = super.merge(s);
+ SeamValueString v = (SeamValueString)s;
+ String v1 = value.getValue();
+ String v2 = v.value.getValue();
+ if(v1 == null || !v1.equals(v2)) {
+ changes = Change.addChange(changes, new Change(this, "value", v1, v2));
+ value = v.value;
+ adopt((SeamObject)value);
+ }
+ return changes;
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -20,6 +20,8 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
+import org.jboss.tools.seam.internal.core.SeamProperty;
+import org.jboss.tools.seam.internal.core.SeamValueString;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
@@ -71,7 +73,6 @@
Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String,
SeamPropertiesDeclaration>();
for (int i = 0; i < properties.length; i++) {
String name = properties[i].getAttributeValue("name");
- String value = properties[i].getAttributeValue("value");
int q = name.lastIndexOf('.');
if(q < 0) continue;
String componentName = name.substring(0, q);
@@ -84,7 +85,14 @@
d.setName(componentName);
ds1.put(componentName, d);
}
- d.addStringProperty(propertyName, value);
+ SeamProperty p = new SeamProperty();
+ p.setId(properties[i]);
+ p.setName(new XMLValueInfo(properties[i], "name"));
+ p.setName(propertyName);
+ SeamValueString v = new SeamValueString();
+ v.setValue(new XMLValueInfo(properties[i], "value"));
+ p.setValue(v);
+ d.addProperty(p);
}
ds.getComponents().addAll(ds1.values());
return ds;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-19
15:53:48 UTC (rev 2527)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-19
16:42:00 UTC (rev 2528)
@@ -10,11 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.scanner.xml;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -29,11 +25,18 @@
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.InnerModelHelper;
import org.jboss.tools.seam.internal.core.SeamProperty;
+import org.jboss.tools.seam.internal.core.SeamValueList;
+import org.jboss.tools.seam.internal.core.SeamValueMap;
+import org.jboss.tools.seam.internal.core.SeamValueMapEntry;
+import org.jboss.tools.seam.internal.core.SeamValueString;
import org.jboss.tools.seam.internal.core.SeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamXmlFactory;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+/**
+ * @author Viacheslav Kabanovich
+ */
public class XMLScanner implements IFileScanner {
public XMLScanner() {}
@@ -80,6 +83,7 @@
}
static Set<String> COMMON_ATTRIBUTES = new HashSet<String>();
+ static Set<String> INTERNAL_ATTRIBUTES = new HashSet<String>();
static {
COMMON_ATTRIBUTES.add(ISeamXmlComponentDeclaration.NAME);
@@ -89,6 +93,10 @@
COMMON_ATTRIBUTES.add(ISeamXmlComponentDeclaration.INSTALLED);
COMMON_ATTRIBUTES.add(ISeamXmlComponentDeclaration.AUTO_CREATE);
COMMON_ATTRIBUTES.add(ISeamXmlComponentDeclaration.JNDI_NAME);
+
+ INTERNAL_ATTRIBUTES.add("NAME");
+ INTERNAL_ATTRIBUTES.add("EXTENSION");
+ INTERNAL_ATTRIBUTES.add("#comment");
}
public LoadedDeclarations parse(XModelObject o, IPath source) {
@@ -139,42 +147,72 @@
for (int ia = 0; ia < attributes.length; ia++) {
XAttribute a = attributes[ia];
String xml = a.getXMLName();
- if(xml == null) continue;
+ if(xml == null || xml.length() == 0 || "#comment".equals(xml)) continue;
if(COMMON_ATTRIBUTES.contains(xml)) continue;
- String stringValue = c.getAttributeValue(a.getName());
- component.addStringProperty(xml, stringValue);
+ if(INTERNAL_ATTRIBUTES.contains(xml)) continue;
+ if(xml.indexOf(":") >= 0) continue;
+ if(xml.startsWith("xmlns")) continue;
+
+ SeamProperty p = new SeamProperty();
+ p.setId(xml);
+ p.setName(xml);
+ SeamValueString v = new SeamValueString();
+ v.setId("value");
+ p.setValue(v);
+ v.setValue(new XMLValueInfo(c, a.getName()));
+ component.addProperty(p);
}
XModelObject[] properties = c.getChildren();
for (int j = 0; j < properties.length; j++) {
XModelEntity entity = properties[j].getModelEntity();
- String propertyName = properties[j].getAttributeValue("name");
+
+ SeamProperty p = new SeamProperty();
+ p.setId(properties[j]);
+ p.setName(new XMLValueInfo(properties[j], "name"));
+
if(entity.getAttribute("value") != null) {
//this is simple value;
- String value = properties[j].getAttributeValue("value");
- component.addStringProperty(propertyName, value);
+ SeamValueString v = new SeamValueString();
+ v.setId(properties[j]);
+ v.setValue(new XMLValueInfo(properties[j], "value"));
+ p.setValue(v);
} else {
XModelObject[] entries = properties[j].getChildren();
if(entity.getChild("SeamListEntry") != null
|| "list".equals(entity.getProperty("childrenLoader"))) {
//this is list value
- List<String> listValues = new ArrayList<String>();
+
+ SeamValueList vl = new SeamValueList();
+ vl.setId(properties[j]);
+
for (int k = 0; k < entries.length; k++) {
- listValues.add(entries[k].getAttributeValue("value"));
+ SeamValueString v = new SeamValueString();
+ v.setId(entries[k]);
+ v.setValue(new XMLValueInfo(entries[k], "value"));
+ vl.addValue(v);
}
- component.addProperty(new SeamProperty(propertyName, listValues));
+ p.setValue(vl);
} else {
//this is map value
- Map<String,String> mapValues = new HashMap<String, String>();
+ SeamValueMap vm = new SeamValueMap();
+ vm.setId(properties[j]);
for (int k = 0; k < entries.length; k++) {
- String entryKey = entries[k].getAttributeValue("key");
- String entryValue = entries[k].getAttributeValue("value");
- mapValues.put(entryKey, entryValue);
+ SeamValueMapEntry e = new SeamValueMapEntry();
+ e.setId(entries[k]);
+ SeamValueString key = new SeamValueString();
+ key.setId(entries[k]);
+ key.setValue(new XMLValueInfo(entries[k], "key"));
+ e.setKey(key);
+ SeamValueString value = new SeamValueString();
+ value.setId(entries[k]);
+ value.setValue(new XMLValueInfo(entries[k], "value"));
+ e.setValue(value);
+ vm.addEntry(e);
}
- component.addProperty(new SeamProperty(propertyName, mapValues));
}
+ component.addProperty(p);
}
- //TODO assign positioning attributes to created ISeamProperty object
}
ds.getComponents().add(component);