<!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'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> </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> public </span> | |
<span class="incode">MyTutorialDiagramTypeProvider() {</span><span class="keyword"><br> | |
super</span><span class="incode">();<br> | |
}<br></span><span class="keyword">}<br></span></p> | |
</div> | |
</div> | |
<p> </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"><?xml version="1.0" encoding="UTF-8"?><br><?eclipse version="3.0"?><br> | |
<span class="string"><plugin><br> <extension<br> | |
point</span>=<span class="comment">"org.eclipse.graphiti.ui.diagramTypes"</span><span class="string">></span><br> | |
<span class="string"><diagramType</span><br> | |
<span class="string">description</span>=<span class="comment">"This is the | |
diagram type for my Graphiti tutorial"</span><br> | |
<span class="string">id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType"</span><br> | |
<span class="string">name</span>=<span class="comment">"My Graphiti Tutorial | |
Diagram Type"</span><br> | |
<span class="string">type</span>=<span class="comment">"mytutorial"</span><span class="string">></span><br> | |
<span class="string"> </diagramType><br> </extension><br><br> | |
<extension<br> point</span>=<span class="comment">"org.eclipse.graphiti.ui.diagramTypeProviders</span>"<span class="string">></span><br> | |
<span class="string"><diagramTypeProvider<br> | |
class</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.</span><br> <span class="comment"> | |
MyTutorialDiagramTypeProvider"</span><br> | |
<span class="string">description</span>=<span class="comment">"This is my | |
editor for the Graphiti tutorial"</span><br> | |
<span class="string">id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.<br> | |
MyTutorialDiagramTypeProvider"</span><br> | |
<span class="string">name</span>=<span class="comment">"My tutorial editor"</span><span class="string">><br> | |
<diagramType<br> id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType"</span><span class="string">><br> | |
</diagramType><br> </diagramTypeProvider><br> </extension><br> | |
</plugin></span></p> | |
<p> </p> | |
</div> | |
</div> | |
<p> </p> | |
<!-- End code ------------------------------------------------------------------------------- --> | |
<p>For further information to these extension points, see the extension point description | |
in the Eclipse IDE.</p> | |
<p> </p> | |
</body> | |
</html> |