blob: c18cf1acafa395dbdfc9820c09b7ad3156d116a3 [file] [log] [blame]
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.wst.common.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.wst.common.core" id="uiContextSensitiveClass" name="UI Context Sensitive Class"/>
</appinfo>
<documentation>
Components are often designed in such a way that the &quot;Headless&quot; or non-graphical portions are separate from the Graphical User Interface (GUI) portions. Sometimes this is done to follow good design principles, other times there is a specific use case for doing so. When plugins follow this practice because they must vary their behavior based on whether they are running in a headless environment or a graphical environment, they often need to choose the correct implementation of a particular type. The org.eclipse.wst.common.core.uiContextSensitiveClass extension point provided by the WST component solves exactly this problem.
&lt;p&gt;
To use the extension point, you must provide two extensions that are linked by a key. The key is a unique String-based value that you will later use to instanitate your class.
&lt;p&gt;
The first usage of the extension specifies your key, and the Headless context, and the class that should be instantiated for this (key, context) pair. This means in the headless environment this class will be instantiated when requested.
&lt;p&gt;
The second extension specifies the UI context and the same key, but a different implementation designed for graphical environments. This means in the UI environment this other class will be instantiated when requested.
&lt;p&gt;
The actual request is done in your code via:
&lt;pre&gt;
IMyInterface instance = (IMyInterface) UIContextDetermination.createInstance(&quot;myKey&quot;);
&lt;/pre&gt;
where &lt;code&gt;&quot;myKey&quot;&lt;/code&gt; is the key used on both extensions. It will then choose either the UI or the Headless extension depending upon the context.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="uiContextSensitiveClass" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="uiContextSensitiveClass">
<annotation>
<documentation>
An extension point that defines an instance of a class and its appropriate context (UI or Headless)
</documentation>
</annotation>
<complexType>
<attribute name="key" type="string" use="required">
<annotation>
<documentation>
The key that should be used to create an instance of the Context Sensitive super class/interface.
</documentation>
</annotation>
</attribute>
<attribute name="className" type="string" use="required">
<annotation>
<documentation>
A concrete implementation for either a UI or Headless context.
</documentation>
</annotation>
</attribute>
<attribute name="context" use="required">
<annotation>
<documentation>
One of &quot;UI&quot; or &quot;Headless&quot; This is case-sensitive. It must match exactly as shown here.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="UI">
</enumeration>
<enumeration value="Headless">
</enumeration>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="apiInfo"/>
</appinfo>
<documentation>
See &lt;code&gt;org.eclipse.wst.common.core.util.UIContextDetermination&lt;/code&gt;
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
6.0
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
Usage for the UI context:
&lt;pre&gt;
&lt;extension
id=&quot;context.Sensitive.Class.workingCopyManager&quot;
name=&quot;Working Copy Manager - UI Context Class&quot;
point=&quot;org.eclipse.wst.common.core.ContextSensitiveClass&quot;&gt;
&lt;uiContextSensitiveClass
context=&quot;UI&quot;
key=&quot;workingCopyManager&quot;
className=&quot;com.ibm.wtp.common.ui.WTPUIWorkingCopyManager&quot;/&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;br&gt;
Usage for the Headless context:
&lt;pre&gt;
&lt;extension
id=&quot;context.Sensitive.Class.workingCopyManager&quot;
name=&quot;Working Copy Manager - Headless Context Class&quot;
point=&quot;org.eclipse.wst.common.core.ContextSensitiveClass&quot;&gt;
&lt;uiContextSensitiveClass
context=&quot;Headless&quot;
key=&quot;workingCopyManager&quot;
className=&quot;com.ibm.wtp.common.ui.WTPHeadlessWorkingCopyManager&quot;/&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;br&gt;
And finally the retrieval of the class for the current context:
&lt;pre&gt;
IWorkingCopyManager manager = (IWorkingCopyManager) UIContextDetermination.createInstance(&quot;workingCopyManager&quot;);
&lt;/pre&gt;
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="copyright"/>
</appinfo>
<documentation>
Copyright (c) IBM 2003.
</documentation>
</annotation>
</schema>