| <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'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> </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> |
| <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"><?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.<br> </span></span><span class="comment"> |
| </span><span lang="EN-US"><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> </diagramTypeProvider><br> |
| </extension><br></plugin></span></span></p> |
| <p><span lang="EN-US"> </span></p> |
| </div> |
| </div> |
| <p> <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> |