Author: scabanovich
Date: 2007-07-13 05:58:31 -0400 (Fri, 13 Jul 2007)
New Revision: 2424
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IValueInfo.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLValueInfo.java
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/SeamAnnotatedFactory.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/SeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 Added IValueInfo and implemented for components.xml source
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IValueInfo.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IValueInfo.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IValueInfo.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -0,0 +1,38 @@
+ /*******************************************************************************
+ * 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;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface IValueInfo {
+
+ /**
+ * Returns string value
+ * @return
+ */
+ public String getValue();
+
+ /**
+ * Returns start position of value or, when value is implied,
+ * position of object that could contains that value.
+ * @return
+ */
+ public int getStartPosition();
+
+ /**
+ * Returns length of value or, when value is implied,
+ * that of object that could contains that value.
+ * @return
+ */
+ public int getLength();
+
+}
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -14,14 +14,12 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
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;
-import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -32,7 +30,7 @@
protected ScopeType scopeType;
protected String scope;
- protected Map<String,ValueInfo> attributes = new HashMap<String,
ValueInfo>();
+ protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
public String getName() {
return name;
@@ -99,12 +97,12 @@
return s1 == null ? s2 == null : s1.equals(s2);
}
- public void setName(ValueInfo value) {
+ public void setName(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.NAME, value);
name = value == null ? null : value.getValue();
}
- public void setScope(ValueInfo value) {
+ public void setScope(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
setScopeAsString(value == null ? null : value.getValue());
}
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -16,8 +16,8 @@
import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
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.event.Change;
-import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -56,7 +56,7 @@
* invoke getLocationFor("name");
*/
public ISeamTextSourceReference getLocationFor(String path) {
- final ValueInfo valueInfo = attributes.get(path);
+ final IValueInfo valueInfo = attributes.get(path);
ISeamTextSourceReference reference = new ISeamTextSourceReference() {
public int getLength() {
return valueInfo != null ? valueInfo.getLength() : 0;
@@ -69,7 +69,7 @@
return reference;
}
- public void setAutoCreate(ValueInfo value) {
+ public void setAutoCreate(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.AUTO_CREATE, value);
setAutoCreate(value != null && "true".equals(value.getValue()));
}
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -15,14 +15,13 @@
import java.util.Map;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.jboss.tools.seam.core.IOpenableElement;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
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;
-import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -36,7 +35,7 @@
*/
protected String name;
- protected Map<String,ValueInfo> attributes = new HashMap<String,
ValueInfo>();
+ protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
public String getName() {
return name;
@@ -100,7 +99,7 @@
* invoke getLocationFor("name");
*/
public ISeamTextSourceReference getLocationFor(String path) {
- final ValueInfo valueInfo = attributes.get(path);
+ final IValueInfo valueInfo = attributes.get(path);
ISeamTextSourceReference reference = new ISeamTextSourceReference() {
public int getLength() {
return valueInfo != null ? valueInfo.getLength() : 0;
@@ -113,7 +112,7 @@
return reference;
}
- public void setName(ValueInfo value) {
+ public void setName(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.NAME, value);
name = value == null ? null : value.getValue();
}
@@ -122,4 +121,4 @@
}
-}
\ No newline at end of file
+}
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -16,12 +16,12 @@
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
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.SeamComponentMethodType;
import org.jboss.tools.seam.core.SeamComponentPrecedenceType;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.Change;
-import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
public class SeamJavaComponentDeclaration extends SeamComponentDeclaration
implements ISeamJavaComponentDeclaration {
@@ -316,12 +316,12 @@
this.precedence = precedence;
}
- public void setScope(ValueInfo value) {
+ public void setScope(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
setScope(value == null ? null : value.getValue());
}
- public void setPrecedence(ValueInfo value) {
+ public void setPrecedence(IValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.PRECEDENCE, value);
try {
setPrecedence(value == null ? 0 : Integer.parseInt(value.getValue()));
@@ -331,12 +331,12 @@
}
}
- public void setEntity(ValueInfo value) {
+ public void setEntity(IValueInfo value) {
attributes.put("entity", value);
setEntity(value != null && "true".equals(value.getValue()));
}
- public void setStateful(ValueInfo value) {
+ public void setStateful(IValueInfo value) {
attributes.put("stateful", value);
setStateful(value != null && "true".equals(value.getValue()));
}
@@ -349,4 +349,5 @@
SeamCorePlugin.getPluginLog().logError(e);
}
}
+
}
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -702,6 +702,7 @@
}
} else {
IResource variableResource = variable.getResource();
+ if(variableResource == null) continue;
if(path.equals(variableResource.getFullPath())) {
result.add(variable);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -3,6 +3,7 @@
import java.util.List;
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;
@@ -61,26 +62,56 @@
this.className = className;
}
+ public void setClassName(IValueInfo value) {
+ attributes.put(INSTALLED, value);
+ setInstalled(value == null ? null : value.getValue());
+ }
+
public void setAutoCreate(String autoCreate) {
this.autoCreate = autoCreate;
}
+ public void setAutoCreate(IValueInfo value) {
+ attributes.put(AUTO_CREATE, value);
+ setAutoCreate(value == null ? null : value.getValue());
+ }
+
public void setInstalled(String installed) {
this.installed = installed;
}
+ public void setInstalled(IValueInfo value) {
+ attributes.put(INSTALLED, value);
+ setInstalled(value == null ? null : value.getValue());
+ }
+
public void setJndiName(String jndiName) {
this.jndiName = jndiName;
}
+ public void setJndiName(IValueInfo value) {
+ attributes.put(JNDI_NAME, value);
+ setJndiName(value == null ? null : value.getValue());
+ }
+
public void setPrecedence(String precedence) {
this.precedence = precedence;
}
+ public void setPrecedence(IValueInfo value) {
+ attributes.put(PRECEDENCE, value);
+ setPrecedence(value == null ? null : value.getValue());
+ }
+
public void setScope(String scope) {
this.scope = scope;
}
+ public void setScope(IValueInfo value) {
+ attributes.put(SCOPE, value);
+ setScope(value == null ? null : value.getValue());
+ }
+
/**
* 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/SeamXmlFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -13,6 +13,7 @@
import java.util.List;
import org.jboss.tools.seam.core.ISeamXmlFactory;
+import org.jboss.tools.seam.core.IValueInfo;
import org.jboss.tools.seam.core.event.Change;
/**
@@ -34,9 +35,19 @@
this.method = method;
}
+ public void setMethod(IValueInfo value) {
+ attributes.put("method", value);
+ setMethod(value == null ? null : value.getValue());
+ }
+
public void setValue(String value) {
this.value = value;
}
+
+ public void setValue(IValueInfo value) {
+ attributes.put("value", value);
+ setValue(value == null ? null : value.getValue());
+ }
public List<Change> merge(SeamObject s) {
List<Change> changes = super.merge(s);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -366,4 +366,4 @@
return true;
}
-}
\ No newline at end of file
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java 2007-07-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -9,8 +9,9 @@
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.StringLiteral;
+import org.jboss.tools.seam.core.IValueInfo;
-public class ValueInfo {
+public class ValueInfo implements IValueInfo {
String value;
int valueStartPosition;
int valueLength;
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-13
08:47:45 UTC (rev 2423)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -97,13 +97,13 @@
component.setSourcePath(source);
component.setId(os[i]);
- component.setName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.NAME));
- component.setClassName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.CLASS));
- component.setScope(os[i].getAttributeValue(ISeamXmlComponentDeclaration.SCOPE));
- component.setPrecedence(os[i].getAttributeValue(ISeamXmlComponentDeclaration.PRECEDENCE));
- component.setInstalled(os[i].getAttributeValue(ISeamXmlComponentDeclaration.INSTALLED));
- component.setAutoCreate(os[i].getAttributeValue(ISeamXmlComponentDeclaration.AUTO_CREATE));
- component.setJndiName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.JNDI_NAME));
+ component.setName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.NAME));
+ component.setClassName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.CLASS));
+ component.setScope(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.SCOPE));
+ component.setPrecedence(new XMLValueInfo(os[i],
ISeamXmlComponentDeclaration.PRECEDENCE));
+ component.setInstalled(new XMLValueInfo(os[i],
ISeamXmlComponentDeclaration.INSTALLED));
+ component.setAutoCreate(new XMLValueInfo(os[i],
ISeamXmlComponentDeclaration.AUTO_CREATE));
+ component.setJndiName(new XMLValueInfo(os[i],
ISeamXmlComponentDeclaration.JNDI_NAME));
XAttribute[] attributes = componentEntity.getAttributes();
for (int ia = 0; ia < attributes.length; ia++) {
@@ -152,10 +152,10 @@
SeamXmlFactory factory = new SeamXmlFactory();
factory.setId(os[i]);
factory.setSourcePath(source);
- factory.setName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.NAME));
- factory.setScopeAsString(os[i].getAttributeValue(ISeamXmlComponentDeclaration.SCOPE));
- factory.setValue(os[i].getAttributeValue("value"));
- factory.setMethod(os[i].getAttributeValue("method"));
+ factory.setName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.NAME));
+ factory.setScope(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.SCOPE));
+ factory.setValue(new XMLValueInfo(os[i], "value"));
+ factory.setMethod(new XMLValueInfo(os[i], "method"));
ds.getFactories().add(factory);
//TODO assign positioning attributes to created ISeamProperty object
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLValueInfo.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLValueInfo.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLValueInfo.java 2007-07-13
09:58:31 UTC (rev 2424)
@@ -0,0 +1,54 @@
+ /*******************************************************************************
+ * 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.internal.core.scanner.xml;
+
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.PositionHolder;
+import org.jboss.tools.seam.core.IValueInfo;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class XMLValueInfo implements IValueInfo {
+ XModelObject object;
+ String attribute;
+
+ PositionHolder h = null;
+
+ public XMLValueInfo(XModelObject object, String attribute) {
+ this.object = object;
+ this.attribute = attribute;
+ }
+
+ public int getLength() {
+ getPositionHolder();
+ int length = h.getEnd() - h.getStart();
+ return length < 0 ? 0 : length;
+ }
+
+ public int getStartPosition() {
+ getPositionHolder();
+ return h.getStart();
+ }
+
+ public String getValue() {
+ return object.getAttributeValue(attribute);
+ }
+
+ PositionHolder getPositionHolder() {
+ if(h == null) {
+ h = PositionHolder.getPosition(object, attribute);
+ }
+ h.update();
+ return h;
+ }
+
+}