<!doctype html public "-//w3c//dtd html 4.0//en"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | |
<title>Eclipse Workbench Extension Point: Element Factories</title> | |
</head> | |
<body link="#0000FF" vlink="#800080"> | |
<center> | |
<h1> | |
Element Factories</h1></center> | |
<b><i>Identifier: </i></b>org.eclipse.ui.elementFactories | |
<p><b><i>Description: </i></b>This extension point is used to add element | |
factories to the workbench. An element factory is used to recreate | |
<tt>IAdaptable | |
</tt>objects which are persisted during workbench shutdown. | |
<p>As an example, the element factory is used to persist editor input. | |
The input for an editor must implement <tt>org.eclipse.ui.IEditorInput</tt>. | |
The lifecycle of an <tt>IEditorInput </tt>within an editor has a number | |
of phases. | |
<ol> | |
<li> | |
The initial input for an editor is passed in during editor creation.</li> | |
<li> | |
On shutdown the workbench state is captured. In this process the | |
workbench will create a memento for each open editor and its input. | |
The input is saved as a two part memento containing a factory ID and any | |
primitive data required to recreate the element on startup. For more | |
information see the documentation on <tt>org.eclipse.ui.IPersistableElement</tt>.</li> | |
<li> | |
On startup the workbench state is read and the editors from the previous | |
session are recreated. In this process the workbench will recreate | |
the input element for each open editor. To do this it will map the | |
original factory ID for the input element to a concrete factory class defined | |
in the registry. If a mapping exists, and the factory class is valid, | |
an instance of the factory class is created. Then the workbench asks | |
the factory to recreate the original element from the remaining primitive | |
data within the memento. The resulting <tt>IAdaptable</tt> is cast | |
to an <tt>IEditorInput</tt> and passed to the new editor.</li> | |
</ol> | |
<b><i>Configuration Markup:</i></b> | |
<p><tt> <!ELEMENT factory EMPTY></tt> | |
<br><tt> <!ATTLIST factory</tt> | |
<br><tt> id CDATA | |
#REQUIRED</tt> | |
<br><tt> class | |
CDATA #REQUIRED</tt> | |
<br><tt> ></tt> | |
<ul> | |
<li> | |
<b>id</b> - a unique name that will be used to identify this factory.</li> | |
<li> | |
<b>class</b> - a fully qualified name of a class that implements | |
<tt>org.eclipse.ui.IElementFactory</tt>.</li> | |
</ul> | |
<b><i>Examples:</i></b> | |
<p>The following is an example of an element factory extension: | |
<p><tt> <extension</tt> | |
<br><tt> point = "org.eclipse.ui.elementFactories"></tt> | |
<br><tt> <factory</tt> | |
<br><tt> id | |
="com.xyz.ElementFactory"</tt> | |
<br><tt> class="com.xyz.ElementFactory"></tt> | |
<br><tt> </factory></tt> | |
<br><tt> </extension></tt> | |
<p><b><i>API Information: </i></b>The value of the <tt>class</tt> attribute | |
must be a fully qualified name of a class that implements <tt>org.eclipse.ui.IElementFactory</tt>. | |
An instance of this class must create an <tt>IAdaptable</tt> object from | |
a workbench memento. | |
<p><b><i>Supplied Implementation: </i></b>The workbench provides an <tt>IResource</tt> | |
factory. Additional factories should be added to recreate other <tt>IAdaptable</tt> | |
types commonly found in other object models, such as the Java model. | |
<p><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation and others 2000, 2002." BORDER=0></a> | |
</body> | |
</html> |