<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.jem.util">
<annotation>
      <appInfo>
         <meta.schema plugin="org.eclipse.jem.util" 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.jem.util.uiContextSensitiveClass extension point provided by the JEM 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">
      <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="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.jem.util.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.jem.util.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="apiInfo"/>
      </appInfo>
      <documentation>
         See &lt;code&gt;org.eclipse.jem.util.UIContextDetermination&lt;/code&gt;
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="implementation"/>
      </appInfo>
      <documentation>
         
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="copyright"/>
      </appInfo>
      <documentation>
         Copyright (c) IBM 2003.
      </documentation>
   </annotation>

</schema>
