blob: f234e1d89c3ae418e4d65d37ddbcfc7d94cbeef7 [file] [log] [blame]
jpasch947e2ec2011-12-27 15:25:37 +01001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
6<title>Diagram</title>
7<link href="..\book.css" rel="stylesheet" type="text/css">
8<link href="..\code.css" rel="stylesheet" type="text/css">
9</head>
10
11<body>
12
13<h1>Diagram</h1>
14<p>For the creation of an editor, it is necessary to implement a <b>diagram type
15agent</b>. This diagram type agent consists of a <b>diagram type provider</b> and
16a <b>feature provider</b>. The minimum implementation of the diagram type provider
17is described in this chapter.</p>
18<h2>Create a Plug-In</h2>
19<p>Create a plug-in project for your diagram type specific graphical editor. Please
20keep in mind <b>not to use</b> the ID <i>org.eclipse.graphiti.tutorial</i>, which
21is the ID of our implementation of the tutorial. Additionally use different ID&#39;s
22for implementations of our extension points, see below.</p>
23<p>You should have references to following plug-ins: <i>org.eclipse.graphiti</i>,
24<i>org.eclipse.graphiti.ui</i>, <i>org.eclipse.graphiti.examples.common</i>, <i>
25org.eclipse.core.resources</i>, <i>org.eclipse.core.runtime</i>, <i>org.eclipse.ui.views.properties.tabbed</i>.</p>
26<p>Hint: the final version of this tutorial as it is included in the SDK download
27of Graphiti actually defines more dependencies; these are introduced in later sections
28of this tutorial. To start off with the tutorial only the above mentioned dependencies
29are required.</p>
30<h2>Create a Diagram Type Provider</h2>
31<p>A diagram type provider has to implement the interface
32<a href="../../../javadoc/org/eclipse/graphiti/dt/IDiagramTypeProvider.html">IDiagramTypeProvider</a>.
33Instead of implementing it directly it should extend one of the available base classes.
34In this example we extend the base class
35<a href="../../../javadoc/org/eclipse/graphiti/dt/AbstractDiagramTypeProvider.html">
36AbstractDiagramTypeProvider</a>.</p>
37<p>You can see the complete implementation of the diagram type provider here:</p>
38<!-- Begin code ------------------------------------------------------------------------------- -->
39<p>&nbsp;</p>
40<div class="literallayout">
41 <div class="incode">
42 <p class="code"><span class="keyword">package </span>
43 <span class="incode">org.eclipse.graphiti.examples.tutorial.diagram</span><span class="keyword">;<br>
44 <br>public class </span><span class="incode">MyTutorialDiagramTypeProvider</span><span class="keyword">
45 extends </span><span class="incode">AbstractDiagramTypeProvider {</span><span class="keyword"><br>
46 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public </span>
47 <span class="incode">MyTutorialDiagramTypeProvider() {</span><span class="keyword"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
48 super</span><span class="incode">();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
49 }<br></span><span class="keyword">}<br></span></p>
50 </div>
51</div>
52<p>&nbsp;</p>
53<!-- End code ------------------------------------------------------------------------------- -->
54<h2>Create a Diagram Type</h2>
55<p>If you create a diagram type provider for a diagram type which does not exist
56in the repository, it is necessary to provide also information about this new diagram
57type.The diagram type advertises that the containing diagram type provider understands
58the given diagram type and is suitable for editing and viewing diagrams of that
59type.</p>
60<p>The information about a diagram type must be declared in the plugin.xml.</p>
61<h2>Register the Diagram Type Provider and Diagram Type</h2>
62<p>The newly created diagram type provider and diagram type are registered through
63the extension points:</p>
64<ul>
65 <li><a href="../extension-points/diagramTypes.html">diagramTypes</a></li>
66 <li><a href="../extension-points/diagramTypeProviders.html">diagramTypeProviders</a></li>
67</ul>
68<p>The corresponding <i>plugin.xml</i> looks similar to this:</p>
69<!-- Begin code ------------------------------------------------------------------------------- -->
70<div class="literallayout">
71 <div class="incode">
72 <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>
73 <span class="string">&lt;plugin&gt;<br>&nbsp; &lt;extension<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
74 point</span>=<span class="comment">&quot;org.eclipse.graphiti.ui.diagramTypes&quot;</span><span class="string">&gt;</span><br>&nbsp;&nbsp;&nbsp;
75 <span class="string">&lt;diagramType</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
76 <span class="string">description</span>=<span class="comment">&quot;This is the
77 diagram type for my Graphiti tutorial&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
78 <span class="string">id</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
79 <span class="string">name</span>=<span class="comment">&quot;My Graphiti Tutorial
80 Diagram Type&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
81 <span class="string">type</span>=<span class="comment">&quot;mytutorial&quot;</span><span class="string">&gt;</span><br>&nbsp;&nbsp;
82 <span class="string">&nbsp;&lt;/diagramType&gt;<br>&nbsp; &lt;/extension&gt;<br><br>&nbsp;
83 &lt;extension<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point</span>=<span class="comment">&quot;org.eclipse.graphiti.ui.diagramTypeProviders</span>&quot;<span class="string">&gt;</span><br>&nbsp;&nbsp;&nbsp;
84 <span class="string">&lt;diagramTypeProvider<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
85 class</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.</span><br>&nbsp;<span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
86 MyTutorialDiagramTypeProvider&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
87 <span class="string">description</span>=<span class="comment">&quot;This is my
88 editor for the Graphiti tutorial&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
89 <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;
90 MyTutorialDiagramTypeProvider&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
91 <span class="string">name</span>=<span class="comment">&quot;My tutorial editor&quot;</span><span class="string">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
92 &lt;diagramType<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id</span>=<span class="comment">&quot;org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType&quot;</span><span class="string">&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
93 &lt;/diagramType&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/diagramTypeProvider&gt;<br>&nbsp; &lt;/extension&gt;<br>
94 &lt;/plugin&gt;</span></p>
95 <p>&nbsp;&nbsp;&nbsp;&nbsp; </p>
96 </div>
97</div>
98<p>&nbsp;</p>
99<!-- End code ------------------------------------------------------------------------------- -->
100<p>For further information to these extension points, see the extension point description
101in the Eclipse IDE.</p>
102<p>&nbsp;</p>
103
104</body>
105
106</html>