Author: DartPeng
Date: 2009-01-14 21:16:47 -0500 (Wed, 14 Jan 2009)
New Revision: 13049
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IXMLStructuredObject.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagList.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
Log:
JBIDE-3429
change the graphical model and source page text when the page was changed
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/java2xml/analyzer/Java2XMLAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -98,7 +98,7 @@
AbstractStructuredDataModel dataModel = UIUtils.findGraphModel(graph,
tag);
generateElementAttribute(graph, element, tag.getProperties());
- List children = tag.getChildren();
+ List children = tag.getXMLNodeChildren();
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
TagObject child = (TagObject) iterator.next();
element.add(generateXMLContents(graph, child));
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -710,7 +710,9 @@
}
}
} else {
- sourceModel = localJavaBeanModelWithSelector(selector, source);
+ sourceModel = (JavaBeanModel) UIUtils.localXMLNodeWithPath(
+ selector, source);// localJavaBeanModelWithSelector(selector,
+ // source);
}
if (sourceModel != null) {
MappingModel model = new MappingModel(sourceModel,
@@ -734,6 +736,37 @@
return model;
}
+ public static JavaBeanModel localJavaBeanModelWithSelectorWithoutException(
+ String selector, JavaBeanModel model) {
+ if (selector == null || model == null)
+ return null;
+ String[] selectors = selector.trim().split(SPACE_STRING);
+ if (selectors != null && selectors.length > 0) {
+ // to find the first node
+ String firstNode = selectors[0];
+ JavaBeanModel firstModel = localJavaBeanModelFromRootNode(
+ firstNode, model);
+ // first time , we search the node via context
+ if (firstModel == null) {
+ firstModel = localJavaBeanModelFromRootNode(firstNode, model
+ .getRootParent());
+ }
+ // if we can't find the node , to find it from the Root Parent node
+ if (firstModel == null) {
+ return null;
+ }
+ for (int i = 1; i < selectors.length; i++) {
+ firstModel = findTheChildJavaBeanModel(selectors[i], firstModel);
+ if (firstModel == null) {
+ return null;
+ }
+ }
+
+ return firstModel;
+ }
+ return model;
+ }
+
public static JavaBeanModel localJavaBeanModelWithSelector(String selector,
JavaBeanModel model) {
if (selector == null || model == null)
@@ -745,13 +778,13 @@
JavaBeanModel firstModel = localJavaBeanModelFromRootNode(
firstNode, model);
// first time , we search the node via context
- if(firstModel == null){
- firstModel = localJavaBeanModelFromRootNode(
- firstNode, model.getRootParent());
+ if (firstModel == null) {
+ firstModel = localJavaBeanModelFromRootNode(firstNode, model
+ .getRootParent());
}
// if we can't find the node , to find it from the Root Parent node
if (firstModel == null) {
- throw new RuntimeException("Can't find the node : " +firstNode);
+ throw new RuntimeException("Can't find the node : " + firstNode);
}
for (int i = 1; i < selectors.length; i++) {
firstModel = findTheChildJavaBeanModel(selectors[i], firstModel);
@@ -760,28 +793,58 @@
+ selectors[i] + " from parent node "
+ selectors[i - 1]);
}
-
+
return firstModel;
}
return model;
}
- public static JavaBeanModel localJavaBeanModelFromRootNode(String name,
- JavaBeanModel rootParent) {
+ private static JavaBeanModel localJavaBeanModelFromRootNode(String name,
+ JavaBeanModel rootParent, HashMap usedClassMap) {
if (name == null || rootParent == null)
return null;
if (name.equalsIgnoreCase(rootParent.getSelectorString()))
return rootParent;
-
+ usedClassMap.put(rootParent.getBeanClass(), new Object());
+ if (rootParent.isPrimitive())
+ return null;
List children = rootParent.getProperties();
+ JavaBeanModel result = null;
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
JavaBeanModel child = (JavaBeanModel) iterator.next();
- JavaBeanModel result = localJavaBeanModelFromRootNode(name, child);
- if (result != null)
- return result;
+ if (name.equalsIgnoreCase(child.getSelectorString())) {
+ result = child;
+ break;
+ }
}
- return null;
+ if (result == null) {
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ if (child.isPrimitive()) {
+ continue;
+ }
+ // to avoid the "died loop"
+ if (usedClassMap.get(child.getBeanClass()) != null) {
+ continue;
+ }
+ result = localJavaBeanModelFromRootNode(name, child,
+ usedClassMap);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return result;
+ }
+ public static JavaBeanModel localJavaBeanModelFromRootNode(String name,
+ JavaBeanModel rootParent) {
+ HashMap usedClassMap = new HashMap();
+ JavaBeanModel model = localJavaBeanModelFromRootNode(name, rootParent,
+ usedClassMap);
+ usedClassMap.clear();
+ usedClassMap = null;
+ return model;
}
protected JavaBeanModel findModelWithSelectorString(String selector,
@@ -904,7 +967,9 @@
} else {
model = new JavaBeanModel(null, rootClassName);
model.setRootClassModel(true);
- model.setError(Messages.getString("JavaBeanAnalyzer.ClassNotExist") +
rootClassName); //$NON-NLS-1$
+ model
+ .setError(Messages
+ .getString("JavaBeanAnalyzer.ClassNotExist") + rootClassName);
//$NON-NLS-1$
model.setProperties(new ArrayList());
isError = true;
}
@@ -958,8 +1023,8 @@
// "Can't load Java bean model form the config file.");
}
// if can't load the source from GraphicalInformation , return NULL
-// if (current == null && rootClassName == null)
-// return list;
+ // if (current == null && rootClassName == null)
+ // return list;
return list;
}
@@ -1280,7 +1345,8 @@
selector, listType);
if (resourceConfig != null && !resourceConfigIsUsed(resourceConfig)) {
String referenceSelector = resourceConfig.getSelector();
- JavaBeanModel model = localJavaBeanModelWithSelector(referenceSelector,
currentModel);
+ JavaBeanModel model = localJavaBeanModelWithSelector(
+ referenceSelector, currentModel);
// try to test the selector is can be loaded by classloader??
if (model == null) {
Class clazz = null;
@@ -1319,33 +1385,33 @@
} else {
selector = selector.trim();
localJavaBeanModelWithSelector(selector, currentModel);
-// String[] properties = selector.split(SPACE_STRING);
-// if (properties != null) {
-// JavaBeanModel currentParent = currentModel;
-// for (int i = 0; i < properties.length; i++) {
-// String property = properties[i].trim();
-// Class currentClazz = currentParent.getBeanClass();
-// if (currentClazz != null
-// && property.equals(currentClazz.getName())) {
-//
-// } else {
-// JavaBeanModel pm = findTheChildJavaBeanModel(property,
-// currentParent);
-// if (pm != null) {
-//
-// } else {
-// pm = new JavaBeanModel(null, property);
-// pm.setProperties(new ArrayList());
-// pm.setError(Messages
-// .getString("JavaBeanAnalyzer.DontExist")); //$NON-NLS-1$
-// currentParent.addProperty(pm);
-// }
-// currentParent = pm;
-// }
-// }
-// } else {
-// // if properties is null , how to process?
-// }
+ // String[] properties = selector.split(SPACE_STRING);
+ // if (properties != null) {
+ // JavaBeanModel currentParent = currentModel;
+ // for (int i = 0; i < properties.length; i++) {
+ // String property = properties[i].trim();
+ // Class currentClazz = currentParent.getBeanClass();
+ // if (currentClazz != null
+ // && property.equals(currentClazz.getName())) {
+ //
+ // } else {
+ // JavaBeanModel pm = findTheChildJavaBeanModel(property,
+ // currentParent);
+ // if (pm != null) {
+ //
+ // } else {
+ // pm = new JavaBeanModel(null, property);
+ // pm.setProperties(new ArrayList());
+ // pm.setError(Messages
+ // .getString("JavaBeanAnalyzer.DontExist")); //$NON-NLS-1$
+ // currentParent.addProperty(pm);
+ // }
+ // currentParent = pm;
+ // }
+ // }
+ // } else {
+ // // if properties is null , how to process?
+ // }
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -24,12 +24,13 @@
import org.jboss.tools.smooks.analyzer.IValidatable;
import org.jboss.tools.smooks.javabean.uitils.JavaPropertyUtils;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
/**
* @author Dart Peng
*
*/
-public class JavaBeanModel implements IValidatable {
+public class JavaBeanModel implements IValidatable ,IXMLStructuredObject{
private String beanClassString = null;
@@ -433,5 +434,25 @@
public void setGenericType(boolean hasGenericType) {
this.hasGenericType = hasGenericType;
}
+
+ public boolean isAttribute(){
+ return false;
+ }
+ public List<IXMLStructuredObject> getChildren() {
+ List ps = getProperties();
+ if(ps!=null){
+ return ps;
+ }
+ return null;
+ }
+
+ public Object getID() {
+ return getBeanClass();
+ }
+
+ public String getNodeName() {
+ return getSelectorString();
+ }
+
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IXMLStructuredObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IXMLStructuredObject.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IXMLStructuredObject.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui;
+
+import java.util.List;
+
+/**
+ * @author Dart
+ *
+ */
+public interface IXMLStructuredObject {
+
+ public String getNodeName();
+
+ public List<IXMLStructuredObject> getChildren();
+
+ public IXMLStructuredObject getParent();
+
+ public Object getID();
+
+ public boolean isAttribute();
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IXMLStructuredObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -36,6 +36,7 @@
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
import org.jboss.tools.smooks.ui.ViewerInitorStore;
import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
@@ -56,7 +57,6 @@
*/
public class UIUtils {
-
public static final String[] SELECTORE_SPLITER = new String[] { "\\",
//$NON-NLS-1$
"/" }; //$NON-NLS-1$
@@ -68,10 +68,13 @@
}
public static AbstractXMLObject getRootTagXMLObject(AbstractXMLObject xmlObj) {
- if(xmlObj == null) return null;
+ if (xmlObj == null)
+ return null;
AbstractXMLObject parent = xmlObj.getParent();
- if(parent == null) return null;
- if(parent instanceof TagList) return xmlObj;
+ if (parent == null)
+ return null;
+ if (parent instanceof TagList)
+ return xmlObj;
while (true) {
AbstractXMLObject p = parent.getParent();
if (p instanceof TagList)
@@ -107,9 +110,9 @@
AbstractResourceConfig resourceConfig1 = (AbstractResourceConfig) iterator
.next();
ResourceConfigType resourceConfig = null;
- if(resourceConfig1 instanceof ResourceConfigType){
- resourceConfig = (ResourceConfigType)resourceConfig1;
- }else{
+ if (resourceConfig1 instanceof ResourceConfigType) {
+ resourceConfig = (ResourceConfigType) resourceConfig1;
+ } else {
continue;
}
String selector = resourceConfig.getSelector();
@@ -529,4 +532,188 @@
viewer.setContentProvider(tprovider);
return true;
}
+
+ public static IXMLStructuredObject localXMLNodeWithNodeName(String name,
+ IXMLStructuredObject contextNode) {
+ HashMap map = new HashMap();
+ IXMLStructuredObject node = localXMLNodeWithNodeName(name, contextNode,
+ map);
+ map.clear();
+ map = null;
+ return node;
+ }
+
+ private static boolean isAttributeName(String name) {
+ if (name == null)
+ return false;
+ return name.trim().startsWith("@");
+ }
+
+ private static String getRawAttributeName(String name) {
+ if (isAttributeName(name)) {
+ return name.trim().substring(1);
+ }
+ return name;
+ }
+
+ private static IXMLStructuredObject localXMLNodeWithNodeName(String name,
+ IXMLStructuredObject contextNode, HashMap usedNodeMap) {
+ if (name == null || contextNode == null)
+ return null;
+ String nodeName = contextNode.getNodeName();
+ boolean isAttributeName = false;
+ String tempName = name;
+ if (isAttributeName(tempName)) {
+ isAttributeName = true;
+ tempName = getRawAttributeName(tempName);
+ }
+ boolean canCompare = true;
+ if (isAttributeName) {
+ if (!contextNode.isAttribute()) {
+ canCompare = false;
+ }
+ }
+
+ if (canCompare && tempName.equalsIgnoreCase(nodeName)) {
+ return contextNode;
+ }
+ usedNodeMap.put(contextNode.getID(), new Object());
+ List children = contextNode.getChildren();
+ IXMLStructuredObject result = null;
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ IXMLStructuredObject child = (IXMLStructuredObject) iterator.next();
+ if (isAttributeName) {
+ if (!child.isAttribute())
+ continue;
+ }
+ if (tempName.equalsIgnoreCase(child.getNodeName())) {
+ result = child;
+ break;
+ }
+ }
+ if (result == null) {
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ IXMLStructuredObject child = (IXMLStructuredObject) iterator
+ .next();
+ // to avoid the "died loop"
+ if (usedNodeMap.get(child.getID()) != null) {
+ continue;
+ }
+ result = localXMLNodeWithNodeName(name, child, usedNodeMap);
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static IXMLStructuredObject getRootParent(IXMLStructuredObject child) {
+ IXMLStructuredObject parent = child.getParent();
+ if (parent == null)
+ return child;
+ IXMLStructuredObject temp = parent;
+ while (temp != null) {
+ parent = temp;
+ temp = temp.getParent();
+ }
+ return parent;
+ }
+
+ public static String generatePath(IXMLStructuredObject node,
+ IXMLStructuredObject contextNode, final String sperator,
+ boolean includeContext) {
+ IXMLStructuredObject parent = node.getParent();
+ String name = node.getNodeName();
+ List<IXMLStructuredObject> nodeList = new
ArrayList<IXMLStructuredObject>();
+ if (parent == null) {
+
+ } else {
+ IXMLStructuredObject temp = parent;
+
+ }
+ if(node.isAttribute()){
+ name = "@" + name;
+ }
+ for(int i = nodeList.size() ; i > 0 ; i --){
+ IXMLStructuredObject n = nodeList.get(i);
+ name = n.getNodeName() + sperator + name;
+ }
+ return "";
+ }
+
+ public static IXMLStructuredObject getChildNodeWithName(String name,
+ IXMLStructuredObject parent) {
+ String tempName = name;
+ boolean isAttribute = false;
+ if (isAttributeName(tempName)) {
+ isAttribute = true;
+ tempName = getRawAttributeName(tempName);
+ }
+ List<IXMLStructuredObject> children = parent.getChildren();
+ if (children == null)
+ return null;
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ IXMLStructuredObject structuredObject = (IXMLStructuredObject) iterator
+ .next();
+ if (isAttribute) {
+ if (!structuredObject.isAttribute())
+ continue;
+ }
+ if (tempName.equalsIgnoreCase(structuredObject.getNodeName())) {
+ return structuredObject;
+ }
+ }
+ return null;
+ }
+
+ public static IXMLStructuredObject localXMLNodeWithPath(String path,
+ IXMLStructuredObject contextNode) {
+ return localXMLNodeWithPath(path, contextNode, null, true);
+ }
+
+ public static IXMLStructuredObject localXMLNodeWithPath(String path,
+ IXMLStructuredObject contextNode, String sperator,
+ boolean throwException) {
+ if (contextNode == null || path == null)
+ return null;
+ if (sperator == null) {
+ sperator = " ";
+ }
+ if (path != null)
+ path = path.trim();
+ String[] pathes = path.split(sperator);
+ if (pathes != null && pathes.length > 0) {
+ // to find the first node
+ // first time , we search the node via context
+ String firstNodeName = pathes[0];
+ IXMLStructuredObject firstModel = localXMLNodeWithNodeName(
+ firstNodeName, contextNode);
+
+ // if we can't find the node , to find it from the Root Parent node
+ if (firstModel == null) {
+ firstModel = localXMLNodeWithNodeName(firstNodeName,
+ getRootParent(contextNode));
+ }
+
+ if (firstModel == null) {
+ if (throwException)
+ throw new RuntimeException("Can't find the node : "
+ + firstNodeName);
+ else {
+ return null;
+ }
+ }
+ for (int i = 1; i < pathes.length; i++) {
+ firstModel = getChildNodeWithName(pathes[i], firstModel);
+ if (firstModel == null && throwException) {
+ throw new RuntimeException("Can't find the node : "
+ + pathes[i] + " from parent node " + pathes[i - 1]);
+ }
+ }
+
+ return firstModel;
+ }
+ return null;
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -15,13 +15,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
import org.jboss.tools.smooks.ui.editors.TransformDataTreeViewer;
/**
* @author Dart Peng
* @Date Jul 25, 2008
*/
-public class AbstractXMLObject implements IXMLNode{
+public class AbstractXMLObject implements IXMLNode , IXMLStructuredObject{
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
@@ -30,6 +31,10 @@
public boolean isCanEdit() {
return canEdit;
}
+
+ public boolean isAttribute(){
+ return false;
+ }
public void setCanEdit(boolean canEdit) {
this.canEdit = canEdit;
@@ -65,7 +70,7 @@
support.firePropertyChange(TransformDataTreeViewer.NODE_PROPERTY_EVENT, oldName,
this.name);
}
- public List<AbstractXMLObject> getChildren() {
+ public List<AbstractXMLObject> getXMLNodeChildren() {
return children;
}
@@ -94,6 +99,19 @@
public void removeNodePropetyChangeListener(PropertyChangeListener listener) {
support.removePropertyChangeListener(listener);
}
+
+ public List<IXMLStructuredObject> getChildren() {
+ List children = getXMLNodeChildren();
+ return children;
+ }
+
+ public Object getID() {
+ return getName();
+ }
+
+ public String getNodeName() {
+ return getName();
+ }
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagList.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagList.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagList.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
import org.jboss.tools.smooks.ui.editors.TransformDataTreeViewer;
/**
@@ -21,6 +22,8 @@
*/
public class TagList extends AbstractXMLObject {
List<TagObject> rootTagList = new ArrayList<TagObject>();
+
+ private Object id = new Object();
// public TagObject getRootTag() {
// return rootTag;
@@ -29,7 +32,31 @@
public List<TagObject> getRootTagList() {
return rootTagList;
}
+
+
+ @Override
+ public List<IXMLStructuredObject> getChildren() {
+ List tags = getRootTagList();
+ return tags;
+ }
+
+
+
+ @Override
+ public Object getID() {
+ return id;
+ }
+
+
+
+ @Override
+ public String getName() {
+ return "";
+ }
+
+
+
public void removeRootTag(TagObject rootTag){
rootTagList.remove(rootTag);
if(rootTag != null) rootTag.setParent(null);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagObject.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -14,6 +14,7 @@
import java.util.Iterator;
import java.util.List;
+import org.jboss.tools.smooks.ui.IXMLStructuredObject;
import org.jboss.tools.smooks.ui.editors.TransformDataTreeViewer;
/**
@@ -46,19 +47,29 @@
}
public void addChildTag(TagObject tag) {
- this.getChildren().add(tag);
+ this.getXMLNodeChildren().add(tag);
if (tag != null)
tag.setParent(this);
support.firePropertyChange(TransformDataTreeViewer.ADD_CHILDREN_EVENT, null, tag);
}
public void removeChildTag(TagObject tag) {
- this.getChildren().remove(tag);
+ this.getXMLNodeChildren().remove(tag);
if (tag != null)
tag.setParent(null);
support.firePropertyChange(TransformDataTreeViewer.REMOVE_CHILDREN_EVENT, tag, null);
}
+ @Override
+ public List<IXMLStructuredObject> getChildren() {
+ List all = new ArrayList();
+ List tags = this.getXMLNodeChildren();
+ List properties = this.getProperties();
+ all.addAll(properties);
+ all.addAll(tags);
+ return all;
+ }
+
public String toString() {
StringBuffer buffer = new StringBuffer(getName());
buffer.append("\n");
@@ -69,7 +80,7 @@
buffer.append("\n");
}
- List l = getChildren();
+ List l = getXMLNodeChildren();
for (Iterator iterator = l.iterator(); iterator.hasNext();) {
TagObject tag = (TagObject) iterator.next();
buffer.append("\t");
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/TagPropertyObject.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.smooks.xml.model;
+import java.util.Collections;
import java.util.List;
/**
@@ -30,6 +31,13 @@
this.value = value;
}
+
+
+ @Override
+ public boolean isAttribute() {
+ return true;
+ }
+
public String getType() {
return type;
}
@@ -39,10 +47,15 @@
}
@Override
- public List<AbstractXMLObject> getChildren() {
- return null;
+ public Object getID() {
+ return "@" + super.getID();
}
+
@Override
+ public List<AbstractXMLObject> getXMLNodeChildren() {
+ return Collections.EMPTY_LIST;
+ }
+ @Override
public void setChildren(List<AbstractXMLObject> children) {
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -54,7 +54,7 @@
if(isIgnoreNode(name, ignoreNodeNames)) return null;
if (tag == null)
return null;
- List list = tag.getChildren();
+ List list = tag.getXMLNodeChildren();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
TagObject tagc = (TagObject) iterator.next();
if (tagc.getName().equals(name))
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataContentProvider.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -38,7 +38,7 @@
List c = new ArrayList();
List pros = ((TagObject)obj).getProperties();
c.addAll(pros);
- c.addAll(((TagObject)obj).getChildren());
+ c.addAll(((TagObject)obj).getXMLNodeChildren());
return c.toArray();
}
@@ -71,7 +71,7 @@
}
if(obj instanceof TagObject){
List pros = ((TagObject)obj).getProperties();
- List c = (((TagObject)obj).getChildren());
+ List c = (((TagObject)obj).getXMLNodeChildren());
return !pros.isEmpty() || !c.isEmpty();
}
return false;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -190,7 +190,7 @@
tagPropertyObject.setCanEdit(true);
tagPropertyObject.addNodePropetyChangeListener(viewer);
}
- List list = tag.getChildren();
+ List list = tag.getXMLNodeChildren();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
if (object instanceof TagObject) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -339,8 +339,8 @@
continue;
}
String selector = resourceConfig.getSelector();
- AbstractXMLObject source = findXMLNodeWithSelector(selector,
- sourceRoot);
+ AbstractXMLObject source = (AbstractXMLObject) UIUtils.localXMLNodeWithPath(selector,
sourceRoot);
+// findXMLNodeWithSelector(selector, sourceRoot);
if (source == null) {
// TODO if can't find the root , throw exception
// MODIFY by Dart 2008.11.17
@@ -408,7 +408,7 @@
if (selector.equalsIgnoreCase(root.getName()))
return root;
if (root instanceof TagObject) {
- List<AbstractXMLObject> children = ((TagObject) root).getChildren();
+ List<AbstractXMLObject> children = ((TagObject) root).getXMLNodeChildren();
List<TagPropertyObject> properties = ((TagObject) root)
.getProperties();
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
@@ -548,14 +548,9 @@
String newSelector = processingResourceConfig.getSelector();
if (newSelector == null)
return;
- AbstractXMLObject newRoot = findXMLNodeWithSelector(newSelector,
- root);
- // find the node from the root
+ AbstractXMLObject newRoot = (AbstractXMLObject)
UIUtils.localXMLNodeWithPath(newSelector, root);
+// findXMLNodeWithSelector(newSelector,root);
if (newRoot == null) {
- newRoot = findXMLNodeWithSelector(newSelector, root, true,
- false);
- }
- if (newRoot == null) {
// TODO If can't find the element , throw exception
// MODIFY by Dart , 2008.11.07
throw new RuntimeException(
@@ -566,8 +561,7 @@
processingResourceConfig, newRoot, targetBean);
} else {
- AbstractXMLObject source = findXMLObjectWithSelectorString(
- selector, root);
+ AbstractXMLObject source = (AbstractXMLObject) UIUtils.localXMLNodeWithPath(selector,
root);
if (source == null) {
// TODO If can't find the element , throw exception
// MODIFY by Dart , 2008.11.07
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2009-01-15
02:16:32 UTC (rev 13048)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2009-01-15
02:16:47 UTC (rev 13049)
@@ -120,7 +120,7 @@
if (xmlNode instanceof TagObject) {
Element element = new DefaultElement(xmlNode.getName());
List<AbstractXMLObject> childrenList = ((TagObject) xmlNode)
- .getChildren();
+ .getXMLNodeChildren();
for (Iterator iterator = childrenList.iterator(); iterator
.hasNext();) {
AbstractXMLObject abstractXMLObject = (AbstractXMLObject) iterator
@@ -360,7 +360,7 @@
} else {
if (tagList instanceof TagObject) {
List<AbstractXMLObject> tags = ((TagObject) tagList)
- .getChildren();
+ .getXMLNodeChildren();
List<AbstractXMLObject> tempTags = new ArrayList<AbstractXMLObject>(
tags);
for (Iterator<AbstractXMLObject> iterator = tempTags.iterator(); iterator
@@ -489,7 +489,7 @@
} else {
if (node instanceof TagObject) {
List<AbstractXMLObject> children = ((TagObject) node)
- .getChildren();
+ .getXMLNodeChildren();
for (Iterator iterator = children.iterator(); iterator
.hasNext();) {
AbstractXMLObject abstractXMLObject = (AbstractXMLObject) iterator
@@ -630,7 +630,7 @@
}
if (xmlObject instanceof TagObject) {
List<AbstractXMLObject> children = ((TagObject) xmlObject)
- .getChildren();
+ .getXMLNodeChildren();
for (Iterator iterator = children.iterator(); iterator
.hasNext();) {
AbstractXMLObject abstractXMLObject = (AbstractXMLObject) iterator