jpasch | 947e2ec | 2011-12-27 15:25:37 +0100 | [diff] [blame^] | 1 | <!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
|
| 15 | agent</b>. This diagram type agent consists of a <b>diagram type provider</b> and
|
| 16 | a <b>feature provider</b>. The minimum implementation of the diagram type provider
|
| 17 | is 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
|
| 20 | keep in mind <b>not to use</b> the ID <i>org.eclipse.graphiti.tutorial</i>, which
|
| 21 | is the ID of our implementation of the tutorial. Additionally use different ID's
|
| 22 | for 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>
|
| 25 | org.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
|
| 27 | of Graphiti actually defines more dependencies; these are introduced in later sections
|
| 28 | of this tutorial. To start off with the tutorial only the above mentioned dependencies
|
| 29 | are 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>.
|
| 33 | Instead of implementing it directly it should extend one of the available base classes.
|
| 34 | In this example we extend the base class
|
| 35 | <a href="../../../javadoc/org/eclipse/graphiti/dt/AbstractDiagramTypeProvider.html">
|
| 36 | AbstractDiagramTypeProvider</a>.</p>
|
| 37 | <p>You can see the complete implementation of the diagram type provider here:</p>
|
| 38 | <!-- Begin code ------------------------------------------------------------------------------- -->
|
| 39 | <p> </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> public </span>
|
| 47 | <span class="incode">MyTutorialDiagramTypeProvider() {</span><span class="keyword"><br>
|
| 48 | super</span><span class="incode">();<br>
|
| 49 | }<br></span><span class="keyword">}<br></span></p>
|
| 50 | </div>
|
| 51 | </div>
|
| 52 | <p> </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
|
| 56 | in the repository, it is necessary to provide also information about this new diagram
|
| 57 | type.The diagram type advertises that the containing diagram type provider understands
|
| 58 | the given diagram type and is suitable for editing and viewing diagrams of that
|
| 59 | type.</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
|
| 63 | the 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"><?xml version="1.0" encoding="UTF-8"?><br><?eclipse version="3.0"?><br>
|
| 73 | <span class="string"><plugin><br> <extension<br>
|
| 74 | point</span>=<span class="comment">"org.eclipse.graphiti.ui.diagramTypes"</span><span class="string">></span><br>
|
| 75 | <span class="string"><diagramType</span><br>
|
| 76 | <span class="string">description</span>=<span class="comment">"This is the
|
| 77 | diagram type for my Graphiti tutorial"</span><br>
|
| 78 | <span class="string">id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType"</span><br>
|
| 79 | <span class="string">name</span>=<span class="comment">"My Graphiti Tutorial
|
| 80 | Diagram Type"</span><br>
|
| 81 | <span class="string">type</span>=<span class="comment">"mytutorial"</span><span class="string">></span><br>
|
| 82 | <span class="string"> </diagramType><br> </extension><br><br>
|
| 83 | <extension<br> point</span>=<span class="comment">"org.eclipse.graphiti.ui.diagramTypeProviders</span>"<span class="string">></span><br>
|
| 84 | <span class="string"><diagramTypeProvider<br>
|
| 85 | class</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.</span><br> <span class="comment">
|
| 86 | MyTutorialDiagramTypeProvider"</span><br>
|
| 87 | <span class="string">description</span>=<span class="comment">"This is my
|
| 88 | editor for the Graphiti tutorial"</span><br>
|
| 89 | <span class="string">id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.<br>
|
| 90 | MyTutorialDiagramTypeProvider"</span><br>
|
| 91 | <span class="string">name</span>=<span class="comment">"My tutorial editor"</span><span class="string">><br>
|
| 92 | <diagramType<br> id</span>=<span class="comment">"org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType"</span><span class="string">><br>
|
| 93 | </diagramType><br> </diagramTypeProvider><br> </extension><br>
|
| 94 | </plugin></span></p>
|
| 95 | <p> </p>
|
| 96 | </div>
|
| 97 | </div>
|
| 98 | <p> </p>
|
| 99 | <!-- End code ------------------------------------------------------------------------------- -->
|
| 100 | <p>For further information to these extension points, see the extension point description
|
| 101 | in the Eclipse IDE.</p>
|
| 102 | <p> </p>
|
| 103 |
|
| 104 | </body>
|
| 105 |
|
| 106 | </html>
|