blob: eff9bcc3c8ad72e662e6ae58b1f7c579cdde05d6 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>Diagram</title>
<link href="..\book.css" rel="stylesheet" type="text/css">
<link href="..\code.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Diagram</h1>
<p>For the creation of an editor, it is necessary to implement a <b>diagram type
agent</b>. This diagram type agent consists of a <b>diagram type provider</b> and
a <b>feature provider</b>. The minimum implementation of the diagram type provider
is described in this chapter.</p>
<h2>Create a Plug-In</h2>
<p>Create a plug-in project for your diagram type specific graphical editor. Please
keep in mind <b>not to use</b> the ID <i>org.eclipse.graphiti.tutorial</i>, which
is the ID of our implementation of the tutorial. Additionally use different ID&#39;s
for implementations of our extension points, see below.</p>
<p>You should have references to following plug-ins: <i>org.eclipse.graphiti</i>,
<i>org.eclipse.graphiti.ui</i>, <i>org.eclipse.graphiti.examples.common</i>, <i>
org.eclipse.core.resources</i>, <i>org.eclipse.core.runtime</i>, <i>org.eclipse.ui.views.properties.tabbed</i>.</p>
<p>Hint: the final version of this tutorial as it is included in the SDK download
of Graphiti actually defines more dependencies; these are introduced in later sections
of this tutorial. To start off with the tutorial only the above mentioned dependencies
are required.</p>
<h2>Create a Diagram Type Provider</h2>
<p>A diagram type provider has to implement the interface
<a href="../../../javadoc/org/eclipse/graphiti/dt/IDiagramTypeProvider.html">IDiagramTypeProvider</a>.
Instead of implementing it directly it should extend one of the available base classes.
In this example we extend the base class
<a href="../../../javadoc/org/eclipse/graphiti/dt/AbstractDiagramTypeProvider.html">
AbstractDiagramTypeProvider</a>.</p>
<p>You can see the complete implementation of the diagram type provider here:</p>
<!-- Begin code ------------------------------------------------------------------------------- -->
<p>&nbsp;</p>
<div class="literallayout">
<div class="incode">
<p class="code"><span class="keyword">package </span>
<span class="incode">org.eclipse.graphiti.examples.tutorial.diagram</span><span class="keyword">;<br>
<br>public class </span><span class="incode">MyTutorialDiagramTypeProvider</span><span class="keyword">
extends </span><span class="incode">AbstractDiagramTypeProvider {</span><span class="keyword"><br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public </span>
<span class="incode">MyTutorialDiagramTypeProvider() {</span><span class="keyword"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
super</span><span class="incode">();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<br></span><span class="keyword">}<br></span></p>
</div>
</div>
<p>&nbsp;</p>
<!-- End code ------------------------------------------------------------------------------- -->
<h2>Create a Diagram Type</h2>
<p>If you create a diagram type provider for a diagram type which does not exist
in the repository, it is necessary to provide also information about this new diagram
type.The diagram type advertises that the containing diagram type provider understands
the given diagram type and is suitable for editing and viewing diagrams of that
type.</p>
<p>The information about a diagram type must be declared in the plugin.xml.</p>
<h2>Register the Diagram Type Provider and Diagram Type</h2>
<p>The newly created diagram type provider and diagram type are registered through
the extension points:</p>
<ul>
<li><a href="../extension-points/diagramTypes.html">diagramTypes</a></li>
<li><a href="../extension-points/diagramTypeProviders.html">diagramTypeProviders</a></li>
</ul>
<p>The corresponding <i>plugin.xml</i> looks similar to this:</p>
<!-- Begin code ------------------------------------------------------------------------------- -->
<div class="literallayout">
<div class="incode">
<p class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;?eclipse version=&quot;3.0&quot;?&gt;<br><span class="string">&lt;plugin&gt;<br>&nbsp; &lt;extension<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
point</span>=<span class="comment">&quot;org.eclipse.graphiti.ui.diagramTypes&quot;</span><span class="string">&gt;</span><br>&nbsp;&nbsp;&nbsp;
<span class="string">&lt;diagramType</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">description</span>=<span class="comment">&quot;This is the
diagram type for my Graphiti tutorial&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">id</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">name</span>=<span class="comment">&quot;My Graphiti Tutorial
Diagram Type&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">type</span>=<span class="comment">&quot;mytutorial&quot;<span class="string">&gt;</span><br>&nbsp;&nbsp;&nbsp;
<span class="string">&lt;/diagramType&gt;<br>&nbsp; &lt;/extension&gt;<br><br>&nbsp;
&lt;extension<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point</span>=<span class="comment">&quot;org.eclipse.graphiti.ui.diagramTypeProviders&quot;</span><span class="string">&gt;</span><br>&nbsp;&nbsp;&nbsp;
<span class="string">&lt;diagramTypeProvider<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
class</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.<br>&nbsp;</span></span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span class="comment">MyTutorialDiagramTypeProvider&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">description</span>=<span class="comment">&quot;This is my
editor for the Graphiti tutorial&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">id</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
MyTutorialDiagramTypeProvider&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="string">name</span>=<span class="comment">&quot;My tutorial editor&quot;</span><span class="string">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;diagramType<br>&nbsp;&nbsp;&nbsp; &lt;/diagramTypeProvider&gt;<br>&nbsp; &lt;/extension&gt;<br>
&lt;/plugin&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<!-- End code ------------------------------------------------------------------------------- -->
<p>For further information to these extension points, see the extension point description
in the Eclipse IDE.</p>
<p>&nbsp;</p>
</body>
</html>