| <?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 "Headless" 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. |
| <p> |
| 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. |
| <p> |
| 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. |
| <p> |
| 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. |
| <p> |
| The actual request is done in your code via: |
| <pre> |
| IMyInterface instance = (IMyInterface) UIContextDetermination.createInstance("myKey"); |
| </pre> |
| where <code>"myKey"</code> 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 "UI" or "Headless" 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: |
| <pre> |
| <extension |
| id="context.Sensitive.Class.workingCopyManager" |
| name="Working Copy Manager - UI Context Class" |
| point="org.eclipse.jem.util.ContextSensitiveClass"> |
| <uiContextSensitiveClass |
| context="UI" |
| key="workingCopyManager" |
| className="com.ibm.wtp.common.ui.WTPUIWorkingCopyManager"/> |
| </extension> |
| </pre> |
| <br> |
| Usage for the Headless context: |
| <pre> |
| <extension |
| id="context.Sensitive.Class.workingCopyManager" |
| name="Working Copy Manager - Headless Context Class" |
| point="org.eclipse.jem.util.ContextSensitiveClass"> |
| <uiContextSensitiveClass |
| context="Headless" |
| key="workingCopyManager" |
| className="com.ibm.wtp.common.ui.WTPHeadlessWorkingCopyManager"/> |
| </extension> |
| </pre> |
| <br> |
| And finally the retrieval of the class for the current context: |
| |
| <pre> |
| IWorkingCopyManager manager = (IWorkingCopyManager) UIContextDetermination.createInstance("workingCopyManager"); |
| </pre> |
| |
| </documentation> |
| </annotation> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="apiInfo"/> |
| </appInfo> |
| <documentation> |
| See <code>org.eclipse.jem.util.UIContextDetermination</code> |
| </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> |