blob: 1d7f9d9e48e07d8f525e0da1c4ce2abbb7e1b566 [file] [log] [blame]
<!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.&nbsp; 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.&nbsp;
The input for an editor must implement <tt>org.eclipse.ui.IEditorInput</tt>.&nbsp;
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.&nbsp; In this process the
workbench will create a memento for each open editor and its input.&nbsp;
The input is saved as a two part memento containing a factory ID and any
primitive data required to recreate the element on startup.&nbsp; 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.&nbsp; In this process the workbench will recreate
the input element for each open editor.&nbsp; To do this it will map the
original factory ID for the input element to a concrete factory class defined
in the registry.&nbsp; If a mapping exists, and the factory class is valid,
an instance of the factory class is created.&nbsp; Then the workbench asks
the factory to recreate the original element from the remaining primitive
data within the memento.&nbsp; The resulting <tt>IAdaptable</tt> is cast
to an <tt>IEditorInput</tt> and passed to the new editor.</li>
</ol>
&nbsp;<b><i>Configuration Markup:</i></b>
<p><tt>&nbsp;&nbsp; &lt;!ELEMENT factory EMPTY></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST factory</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp; CDATA
#REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<ul>
<li>
<b>id</b> - a unique name that will be used to identify this factory.</li>
<li>
<b>class</b>&nbsp; - 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>&nbsp;&nbsp; &lt;extension</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point = "org.eclipse.ui.elementFactories"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;factory</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id
="com.xyz.ElementFactory"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class="com.xyz.ElementFactory"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/factory></tt>
<br><tt>&nbsp;&nbsp;&nbsp; &lt;/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.&nbsp; 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>