Author: scabanovich
Date: 2008-10-31 11:09:59 -0400 (Fri, 31 Oct 2008)
New Revision: 11397
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/XModelEntity.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java
Log:
JBIDE-2969
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/XModelEntity.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/XModelEntity.java 2008-10-31
12:29:14 UTC (rev 11396)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/XModelEntity.java 2008-10-31
15:09:59 UTC (rev 11397)
@@ -15,6 +15,9 @@
import org.jboss.tools.common.model.loaders.XObjectLoader;
public interface XModelEntity extends XMetaElement, XDependencies {
+
+ public String getModule();
+
public XAttribute[] getAttributes();
public XAttribute getAttribute(String name);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-10-31
12:29:14 UTC (rev 11396)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-10-31
15:09:59 UTC (rev 11397)
@@ -15,8 +15,10 @@
import java.util.*;
import org.w3c.dom.*;
import org.jboss.tools.common.meta.XMetaElement;
+import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
+import org.jboss.tools.common.xml.XMLUtilities;
public class XMetaDataLoader implements XMetaDataConstants {
@@ -115,15 +117,22 @@
static void loadEntityGroup(XModelMetaDataImpl factory, Element g) {
// String n = g.getAttribute("NAME");
+ String module = "";
+ Element v = XMLUtilities.getUniqueChild(g, "VERSION");
+ if(v != null && v.hasAttribute("MODULE")) {
+ module = v.getAttribute("module");
+ }
loadMappings(factory, g);
factory.createIconList(getUniqueChild(g, ICONS));
loadGlobalActions(factory, g);
- loadEntities(factory, g);
+ loadEntities(factory, g, module);
}
- private static void loadEntities(XModelMetaDataImpl factory, Element element) {
+ private static void loadEntities(XModelMetaDataImpl factory, Element element, String
module) {
Element[] cs = getChildrenElements(element, XMODEL_ENTITY);
- for (int i = 0; i < cs.length; i++) factory.createEntity(cs[i]);
+ for (int i = 0; i < cs.length; i++) {
+ factory.createEntity(cs[i], module);
+ }
cs = getChildrenElements(element, XENTITY_EXTENTION);
XExtensions extensions = factory.getExtensions();
for (int i = 0; i < cs.length; i++) extensions.addExtension(cs[i]);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java 2008-10-31
12:29:14 UTC (rev 11396)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelEntityImpl.java 2008-10-31
15:09:59 UTC (rev 11397)
@@ -26,6 +26,7 @@
public class XModelEntityImpl extends XMetaElementImpl implements XModelEntity {
public static boolean hideHelp = true;
+ protected String module;
protected XChildrenImpl children = new XChildrenImpl();
protected XAttribute[] m_Attributes;
protected XActionListImpl actions = new XActionListImpl();
@@ -44,6 +45,14 @@
protected XModelEntityImpl() {}
+ public void setModule(String s) {
+ module = s;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
void setElement(Element element) {
this.element = element;
setName(element.getAttribute(NAME));
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java 2008-10-31
12:29:14 UTC (rev 11396)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XModelMetaDataImpl.java 2008-10-31
15:09:59 UTC (rev 11397)
@@ -18,6 +18,8 @@
import org.jboss.tools.common.meta.*;
import org.jboss.tools.common.meta.action.*;
import org.jboss.tools.common.meta.action.impl.*;
+import org.jboss.tools.common.meta.constraint.XAttributeConstraint;
+import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
import org.jboss.tools.common.model.icons.impl.*;
public class XModelMetaDataImpl implements XModelMetaData, XMetaDataConstants {
@@ -59,12 +61,50 @@
XModelEntity[] es = this.entities.values().toArray(new XModelEntity[0]);
for (int i = 0; i < es.length; i++) ((XModelEntityImpl)es[i]).validate();
+// makeStatistics(es);
if(reportLoadingTime) {
long dt = - t + (t = System.currentTimeMillis());
ModelPlugin.getPluginLog().logInfo("Meta model loaded in " + dt + "
ms");
}
}
+ private void makeStatistics(XModelEntity[] es) {
+ Set<String> attNames = new HashSet<String>();
+ Set<String> listValues = new HashSet<String>();
+ Set<String> actionMenuNames = new HashSet<String>();
+ int attrCount = 0;
+ for (int i = 0; i < es.length; i++) {
+ XAttribute[] as = es[i].getAttributes();
+ for (int j = 0; j < as.length; j++) {
+ if(!as[j].isVisible()) continue;
+ attrCount++;
+ attNames.add(as[j].getName());
+ XAttributeConstraint c = as[j].getConstraint();
+ if(c instanceof XAttributeConstraintAList) {
+ String[] values = ((XAttributeConstraintAList)c).getValues();
+ for (int k = 0; k < values.length; k++)
+ listValues.add(values[k]);
+ }
+ }
+
+ XActionList al = es[i].getActionList();
+ makeActionList(al, actionMenuNames);
+ }
+ System.out.println("------> Attributes=" + attNames.size() + "
(total " + attrCount + ")");
+ System.out.println("------> List values=" + listValues.size());
+ System.out.println("------> Action menu names=" +
actionMenuNames.size());
+ }
+
+ private void makeActionList(XActionList list, Set<String> actionMenuNames) {
+ XActionItem[] is = list.getActionItems();
+ for (int i = 0; i < is.length; i++) {
+ actionMenuNames.add(is[i].getName());
+ if(is[i] instanceof XActionList) {
+ makeActionList((XActionList)is[i], actionMenuNames);
+ }
+ }
+ }
+
public XIconList getIconList() {
return icons;
}
@@ -83,8 +123,9 @@
return extensions;
}
- public XModelEntity createEntity(Element element) {
+ public XModelEntity createEntity(Element element, String module) {
XModelEntityImpl entity = new XModelEntityImpl();
+ entity.setModule(module);
entity.setElement(element);
entities.put(entity.getName(), entity);
return entity;
Show replies by date