Author: koen.aers(a)jboss.com
Date: 2009-04-29 18:07:49 -0400 (Wed, 29 Apr 2009)
New Revision: 14968
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/schema/elements.exsd
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
Log:
- support creation of DefaultWrapper in ElementRegistry
- type of element wrapper is now optional
Modified: trunk/flow/plugins/org.jboss.tools.flow.common/schema/elements.exsd
===================================================================
--- trunk/flow/plugins/org.jboss.tools.flow.common/schema/elements.exsd 2009-04-29
19:42:03 UTC (rev 14967)
+++ trunk/flow/plugins/org.jboss.tools.flow.common/schema/elements.exsd 2009-04-29
22:07:49 UTC (rev 14968)
@@ -2,9 +2,9 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jboss.tools.flow.common"
xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.jboss.tools.flow.common"
id="elements" name="Flow Language Elements"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point provides a way to contribute language elements to a target
flow language.
</documentation>
@@ -12,9 +12,9 @@
<element name="extension">
<annotation>
- <appinfo>
+ <appInfo>
<meta.element />
- </appinfo>
+ </appInfo>
</annotation>
<complexType>
<sequence>
@@ -39,9 +39,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -49,7 +49,7 @@
<element name="element">
<complexType>
- <choice>
+ <choice minOccurs="0" maxOccurs="1">
<element ref="flow"/>
<element ref="container"/>
<element ref="node"/>
@@ -67,9 +67,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="language" type="string"
use="required">
@@ -91,9 +91,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="resource"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -106,9 +106,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsElementStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -124,9 +124,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="acceptsOutgoingConnectionStrategy"
type="string">
@@ -134,9 +134,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -149,9 +149,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsElementStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="acceptsIncomingConnectionStrategy"
type="string">
@@ -159,9 +159,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="acceptsOutgoingConnectionStrategy"
type="string">
@@ -169,9 +169,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -192,9 +192,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.figure.ElementFigure"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="color" type="string">
@@ -209,9 +209,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="resource"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -227,36 +227,36 @@
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiinfo"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java 2009-04-29
19:42:03 UTC (rev 14967)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java 2009-04-29
22:07:49 UTC (rev 14968)
@@ -21,6 +21,7 @@
import org.jboss.tools.flow.common.wrapper.DefaultFlowWrapper;
import org.jboss.tools.flow.common.wrapper.DefaultLabelWrapper;
import org.jboss.tools.flow.common.wrapper.DefaultNodeWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultWrapper;
import org.jboss.tools.flow.common.wrapper.Wrapper;
public class ElementRegistry {
@@ -41,7 +42,10 @@
private static Wrapper createWrapper(IConfigurationElement configurationElement)
throws CoreException {
IConfigurationElement[] children = configurationElement.getChildren();
- if (children.length != 1) return null;
+ if (children.length > 1) return null;
+ if (children.length == 0) {
+ return createDefault(configurationElement);
+ }
String type = children[0].getName();
if ("flow".equals(type)) {
return createFlow(configurationElement);
@@ -56,6 +60,20 @@
}
}
+ private static Wrapper createDefault(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Element)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Element instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Element)element).setMetaData("configurationElement",
configurationElement);
+ DefaultWrapper result = new DefaultWrapper();
+ result.setElement((Element)element);
+ return result;
+ }
+
private static Wrapper createConnection(IConfigurationElement configurationElement)
throws CoreException {
Object element = configurationElement.createExecutableExtension("class");