blob: 48389db0d2004992a52014316ccae53c8ee682af [file] [log] [blame]
<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 bgcolor="white" lang="DE" link="blue" style="margin-bottom: 12.0pt" vlink="purple">
<div class="WordSection1">
<div>
<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<span lang="EN-GB">
</span><span class="code1"><span lang="EN-US" style="color: black">
<a href="../../../javadoc/org/eclipse/graphiti/dt/IDiagramTypeProvider.html">
IDiagramTypeProvider</a></span></span>. Instead of implementing it directly
it should extend one of the available base classes. In this example we extend
the base class<span lang="EN-GB"> </span><span class="code1">
<span lang="EN-US" style="color: black">
<a href="../../../javadoc/org/eclipse/graphiti/dt/AbstractDiagramTypeProvider.html">
AbstractDiagramTypeProvider</a>.</span></span></p>
<p>You can see the complete implementation of the diagram type provider
here:</p>
<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>
<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.<span lang="EN-GB"> </span>
<span lang="EN-US" style="color: black">The diagram type</span><span lang="EN-US">
advertises that the containing diagram type provider understands the given
diagram type and is suitable for editing and viewing diagrams of that type.</span></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><span lang="EN-GB">The newly created diagram type provider and diagram
type are registered through the extension points:</span></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>
<div class="literallayout">
<div class="incode">
<p class="code"><span lang="EN-US">&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><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 lang="EN-US"><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></span></p>
<p><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
</div>
</div>
<p>&nbsp;<span lang="EN-US">For further information to these extension points,
see the extension point description in the Eclipse IDE.</span></p>
</div>
</div>
</body>
</html>