Author: scabanovich
Date: 2008-04-07 10:36:31 -0400 (Mon, 07 Apr 2008)
New Revision: 7382
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectPresentation.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementPresentationManager.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/resources/meta/base.meta
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementObjectImpl.java
Log:
JBIDE-1998
Modified: trunk/common/plugins/org.jboss.tools.common.model/resources/meta/base.meta
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/resources/meta/base.meta 2008-04-07
13:56:47 UTC (rev 7381)
+++ trunk/common/plugins/org.jboss.tools.common.model/resources/meta/base.meta 2008-04-07
14:36:31 UTC (rev 7382)
@@ -4,6 +4,7 @@
<XModelEntityGroup>
<VERSION MODULE="Model" VERSION="1.0"/>
<MAPPINGS>
+ <MAPPING name="AnyElementPresentation"/>
<MAPPING name="AttributeEditor">
<PAIR name="*"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="AccessibleJava"
value="org.jboss.tools.common.model.ui.attribute.editor.JavaEclipseChoicerFieldEditor"/>
@@ -12,6 +13,7 @@
<PAIR name="CLASSPATH"
value="org.jboss.tools.common.model.ui.attribute.editor.NoteEditor"/>
<PAIR name="CheckBox"
value="org.jboss.tools.common.model.ui.attribute.editor.CheckBoxEditor"/>
<PAIR name="Color"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
+ <PAIR name="CommonFileSystem"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="FileChooser"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="FolderChooser"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="Imports"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
@@ -32,7 +34,6 @@
<PAIR name="NoteHTML"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="Parameters"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="Properties"
value="org.jboss.tools.common.model.ui.attribute.editor.PropertyEditor"/>
- <PAIR name="CommonFileSystem"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="RemoteParams"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="Text"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
<PAIR name="TreeChooser"
value="org.jboss.tools.common.model.ui.attribute.editor.StringEditor"/>
@@ -327,25 +328,18 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="element" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="tag" xmlname="tag">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="attributes" xmlname="attributes">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="text">
- <Constraint/>
<Editor name="Note"/>
</XModelAttribute>
- <XModelAttribute PROPERTIES="id=true;generate=true" name="_id_"
visibility="false">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute PROPERTIES="id=true;generate=true" name="_id_"
visibility="false"/>
</XModelAttributes>
<XActionItem kind="list">
<XActionItem kind="list" name="CreateActions">
@@ -397,25 +391,16 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="element" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="tag" xmlname="tag">
<Constraint loader="XMLName"/>
- <Editor/>
</XModelAttribute>
- <XModelAttribute name="text">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute name="text"/>
<XModelAttribute name="name">
<Constraint loader="XMLName"/>
- <Editor/>
</XModelAttribute>
- <XModelAttribute name="value">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute name="value"/>
</XModelAttributes>
<XActionItem kind="list">
<XActionItem kind="list" name="EditActions">
@@ -436,7 +421,6 @@
<XEntityRenderer/>
<XModelAttributes>
<XModelAttribute default="Eclipse Workspace" name="name"
xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
</XModelAttributes>
@@ -458,17 +442,12 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="root" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="Root" name="name"
visibility="false" xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
- <XModelAttribute default="Root" name="project name"
visibility="false">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute default="Root" name="project name"
visibility="false"/>
</XModelAttributes>
<XActionItem kind="list">
<XActionItem
@@ -490,17 +469,12 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="root" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="Root" name="name"
visibility="false" xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
- <XModelAttribute default="Root" name="project name"
visibility="false">
- <Constraint/>
- <Editor/>
- </XModelAttribute>
+ <XModelAttribute default="Root" name="project name"
visibility="false"/>
</XModelAttributes>
<XActionItem kind="list"/>
<XDependencies/>
@@ -515,11 +489,9 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="root" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="ExtraRoot" name="name"
visibility="false" xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
</XModelAttributes>
@@ -536,7 +508,6 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="util" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="name">
@@ -573,7 +544,6 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="util" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="redhat project" visibility="false">
@@ -601,16 +571,13 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="project" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute name="name" xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
</XModelAttributes>
- <XActionItem kind="list">
- </XActionItem>
+ <XActionItem kind="list"/>
<XDependencies/>
</XModelEntity>
<XModelEntity
@@ -627,11 +594,9 @@
</XEntityRenderer>
<XModelAttributes>
<XModelAttribute default="partition" loader="ElementType"
name="element type">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="Workspaces" name="name"
visibility="false" xmlname="NAME">
- <Constraint/>
<Editor name="Uneditable"/>
</XModelAttribute>
<XModelAttribute default="yes" name="open workspace"
xmlname="OPEN">
@@ -642,8 +607,7 @@
<Editor name="Uneditable"/>
</XModelAttribute>
</XModelAttributes>
- <XActionItem kind="list">
- </XActionItem>
+ <XActionItem kind="list"/>
<XDependencies/>
</XModelEntity>
</XModelEntityGroup>
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectPresentation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectPresentation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelObjectPresentation.java 2008-04-07
14:36:31 UTC (rev 7382)
@@ -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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface XModelObjectPresentation {
+
+ public String getValue(XModelObject object);
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementObjectImpl.java 2008-04-07
13:56:47 UTC (rev 7381)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementObjectImpl.java 2008-04-07
14:36:31 UTC (rev 7382)
@@ -19,7 +19,8 @@
public static char SEPARATOR = ';';
public String getPresentationString() {
- return "" + get("tag");
+ String value = AnyElementPresentationManager.instance.getValue(this);
+ return value != null ? value : "" + get("tag");
}
public String name() {
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementPresentationManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementPresentationManager.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/AnyElementPresentationManager.java 2008-04-07
14:36:31 UTC (rev 7382)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.common.meta.XMapping;
+import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectPresentation;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.ModelFeatureFactory;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class AnyElementPresentationManager implements XModelObjectPresentation {
+ static AnyElementPresentationManager instance = new AnyElementPresentationManager();
+
+ /**
+ * tag name to class name
+ */
+ Map<String, String> tags = new HashMap<String, String>();
+
+ /**
+ * class name to instance
+ */
+ Map<String,XModelObjectPresentation> instances = new HashMap<String,
XModelObjectPresentation>();
+
+ public AnyElementPresentationManager() {
+ init();
+ }
+
+ public String getValue(XModelObject object) {
+ String tag = object.get("tag");
+ if(tag == null) return null;
+ String classname = tags.get(tag);
+ if(classname == null) return null;
+ XModelObjectPresentation p = instances.get(classname);
+ if(p == null) {
+ try {
+ p =
(XModelObjectPresentation)ModelFeatureFactory.getInstance().createFeatureInstance(classname);
+ } catch (ClassCastException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ if(p == null) {
+ tags.remove(tag);
+ } else {
+ instances.put(classname, p);
+ }
+ }
+ return p == null ? null : p.getValue(object);
+ }
+
+ private void init() {
+ XMapping m =
XModelMetaDataImpl.getInstance().getMapping("AnyElementPresentation");
+ if(m == null) return;
+ String[] ks = m.getKeys();
+ for (int i = 0; i < ks.length; i++) {
+ String cn = m.getValue(ks[i]);
+ String[] qs = ks[i].split(",");
+ for (int j = 0; j < qs.length; j++) {
+ tags.put(qs[j], cn);
+ }
+ }
+ }
+}