Author: scabanovich
Date: 2007-12-17 09:28:38 -0500 (Mon, 17 Dec 2007)
New Revision: 5331
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/DefaultEntityRecognizer.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableContainerLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java
Log:
JBIDE-1498
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -22,6 +22,9 @@
public static String WORKSPACE_OLD_REF = "%" + WORKSPACE_OLD + "%";
public static String MODEL_VERSION = "version";
+
+ public static String XMODEL_ENTITY_ATTR = "model-entity";
+ public static String XMODEL_ENTITY_ATTR_OLD = "ENTITY";
private XModelConstants() {}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -27,7 +27,7 @@
public class XModelObjectImpl implements XModelObject, Serializable, Cloneable {
private static final long serialVersionUID = 3860648580262144825L;
- protected static final String ENTITY = "ENTITY";
+// protected static final String ENTITY = XModelConstants.XMODEL_ENTITY_ATTR;
private XModel model = null;
private XModelEntity entity = null;
private XModelObjectImpl parent = null;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/DefaultEntityRecognizer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/DefaultEntityRecognizer.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/DefaultEntityRecognizer.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -12,6 +12,7 @@
import java.io.*;
import org.w3c.dom.*;
+import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.loaders.*;
import org.jboss.tools.common.model.util.XMLUtil;
@@ -22,8 +23,14 @@
public String getEntityName(String ext, String body) {
if(body == null) return null;
Element e = XMLUtil.getElement(new StringReader(body));
- if(e == null || !XMLUtil.hasAttribute(e, "ENTITY")) return null;
- return e.getAttribute("ENTITY");
+ if(e == null) return null;
+ if(XMLUtil.hasAttribute(e, XModelConstants.XMODEL_ENTITY_ATTR)) {
+ return e.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR);
+ }
+ if(XMLUtil.hasAttribute(e, XModelConstants.XMODEL_ENTITY_ATTR_OLD)) {
+ return e.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR_OLD);
+ }
+ return null;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableContainerLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableContainerLoader.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableContainerLoader.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -12,6 +12,7 @@
import org.w3c.dom.*;
import org.jboss.tools.common.model.options.*;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
//import com.elt.model.viewedit.impl.flow.*;
import org.jboss.tools.common.model.*;
@@ -22,7 +23,7 @@
public void loadChild(Element element, SharableElement sharable, String scopename) {
SharableContainerImpl container = (SharableContainerImpl)sharable;
XModelObject o = container.getChildForScope(scopename);
- String en = element.getAttribute("ENTITY");
+ String en = XModelObjectLoaderUtil.getModelEntityAttribute(element);
if(!o.getModelEntity().getName().equals(en)) return;
//// if(o instanceof FlowClassTemplateImpl) {
//// new ClassLoader_Impl().loadClass(element, (Class_)o);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -13,6 +13,7 @@
import java.util.*;
import org.w3c.dom.*;
import org.jboss.tools.common.meta.*;
+import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.options.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -54,7 +55,8 @@
}
public void loadChild(Element element, SharableElement sharable, String scopename) {
- String en = element.getAttribute("ENTITY");
+ String en = XModelObjectLoaderUtil.getModelEntityAttribute(element);
+ if(en == null) return;
XModelEntity ent = sharable.getModel().getMetaData().getEntity(en);
if(ent == null) return;
boolean hasName = (ent.getAttribute("name") != null);
@@ -96,7 +98,7 @@
public void saveAttributes(Element element, SharableElement sharable, String
scopename) {
XModelEntity entity = sharable.getModelEntity();
- element.setAttribute("ENTITY", entity.getName());
+ element.setAttribute(XModelConstants.XMODEL_ENTITY_ATTR, entity.getName());
XAttribute[] as = sharable.getModelEntity().getAttributes();
element.setAttribute(SCOPE, reduceScopeName(scopename, sharable.getScope()));
for (int i = 0; i < as.length; i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java 2007-12-17
14:24:02 UTC (rev 5330)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectLoaderUtil.java 2007-12-17
14:28:38 UTC (rev 5331)
@@ -39,6 +39,7 @@
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.ServiceDialog;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.filesystems.XFileObject;
@@ -150,7 +151,10 @@
protected Set<String> getAllowedAttributes(XModelEntity entity) {
if(entity.getChild("AnyElement") != null) return null;
Set<String> attributes = new HashSet<String>();
- if(saveentity) attributes.add("ENTITY");
+ if(saveentity) {
+ attributes.add(XModelConstants.XMODEL_ENTITY_ATTR);
+ attributes.add(XModelConstants.XMODEL_ENTITY_ATTR_OLD);
+ }
XAttribute[] as = entity.getAttributes();
for (int i = 0; i < as.length; i++) {
String xml = as[i].getXMLName();
@@ -322,9 +326,19 @@
}
}
+ public static String getModelEntityAttribute(Element element) {
+ if(XMLUtil.hasAttribute(element, XModelConstants.XMODEL_ENTITY_ATTR)) {
+ return element.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR);
+ }
+ if(XMLUtil.hasAttribute(element, XModelConstants.XMODEL_ENTITY_ATTR_OLD)) {
+ return element.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR_OLD);
+ }
+ return null;
+ }
+
protected String getChildEntity(XModelEntity entity, Element e) {
- String en = e.getAttribute("ENTITY");
- if(en.length() == 0) {
+ String en = getModelEntityAttribute(e);
+ if(en == null || en.length() == 0) {
String n = e.getNodeName();
if(namespaceMapping != null) {
n = namespaceMapping.convertToDefault(n);
@@ -338,7 +352,9 @@
}
protected boolean acceptElement(Element e, String entity) {
- return !saveentity || entity.equals(e.getAttribute("ENTITY"));
+ return !saveentity ||
+ (entity.equals(e.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR))
+ || entity.equals(e.getAttribute(XModelConstants.XMODEL_ENTITY_ATTR_OLD)));
}
public static XModelObject createValidObject(XModel model, String entityname) {
@@ -404,8 +420,9 @@
public void saveAttributes(Element element, XModelObject o) {
XModelEntity entity = o.getModelEntity();
XAttribute[] as = entity.getAttributes();
- if (saveentity)
- element.setAttribute("ENTITY", entity.getName());
+ if (saveentity) {
+ element.setAttribute(XModelConstants.XMODEL_ENTITY_ATTR, entity.getName());
+ }
for (int i = 0; i < as.length; i++) {
if (as[i].isFake()) continue;
String xmlname = as[i].getXMLName();
@@ -479,7 +496,7 @@
public XModelObject parse(XModel model, Reader reader) {
Element element = XMLUtil.getElement(reader);
if(element == null) return null;
- String entity = element.getAttribute("ENTITY");
+ String entity = getModelEntityAttribute(element);
XModelObject o = model.createModelObject(entity, null);
load(element, o);
return o;