| <html> |
| |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" > |
| <title>Features</title> |
| <link href="../book.css" rel="Stylesheet" type="text/css"> |
| <link href="../code.css" rel="Stylesheet" type="text/css"> |
| </head> |
| |
| <body> |
| |
| <h1>Features</h1> |
| <h2>Architecture: Diagram Type Agent and Interaction Component</h2> |
| <p>In the graphics framework's architecture a UI platform dependent and a |
| diagram type independent interaction component communicates with a platform |
| independent diagram type agent (see Figure). A diagram type agent consists |
| mainly of a diagram type provider, a feature provider and its provided features.</p> |
| <p> </p> |
| <p style="page-break-after: avoid"> |
| <img height="276" src="visio\diagram-type-agent.gif" width="375"> </p> |
| <p><strong>Figure: Interaction Component talks to Diagram Type Agent</strong></p> |
| <p> </p> |
| <p>In this chapter we want to implement a feature provider and wire it with the |
| diagram type provider.</p> |
| <h2><span lang="EN-GB">Create a Feature Provider</span></h2> |
| <p>A feature provider has to implement interface <span class="code1"> |
| <span lang="EN-US" style="color: black"> |
| <a href="../../../javadoc/org/eclipse/graphiti/features/IFeatureProvider.html"> |
| <span style="font-style: normal">IFeatureProvider</span></a></span></span>. |
| Instead of implementing it directly you should extend one of the available base |
| classes. In this example we extend class <span class="code1"> |
| <span lang="EN-US" style="color: black"> |
| <a href="../../../javadoc/org/eclipse/graphiti/ui/features/DefaultFeatureProvider.html"> |
| <span style="font-style: normal">DefaultFeatureProvider</span></a></span></span> |
| and do not have to implement or overwrite any methods initially.</p> |
| <p>You can see the complete implementation of the feature provider here:</p> |
| <p> </p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"><span class="keyword">package </span> |
| org.eclipse.graphiti.examples.tutorial.diagram;<br> |
| <br><span class="keyword">public class</span> TutorialFeatureProvider |
| <span class="keyword">extends </span>DefaultFeatureProvider {<br> <br> |
| <span class="keyword">public </span> |
| TutorialFeatureProvider(IDiagramTypeProvider dtp) {<br> |
| <span class="keyword">super</span>(dtp);<br> }<br>} |
| </p> |
| </div> |
| </div> |
| <p> </p> |
| <p>To create and set our feature provider in the diagram type provider we just |
| have to add one line in the diagram type provider’s constructor:</p> |
| <p> </p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> <span class="keyword">public </span> |
| MyTutorialDiagramTypeProvider() {<br> <span class="keyword"> |
| super</span>();<br> |
| setFeatureProvider(new TutorialFeatureProvider(this));<br> |
| }</p> |
| </div> |
| </div> |
| <h2>Test: Open the Empty Diagram Editor</h2> |
| <p>Since the basic steps are done you can run the first version of this tutorial |
| editor. It should be possible to create and open a diagram.</p> |
| <p>For this follow the steps described in the <a href="example-projects.htm"> |
| example project</a> to open the empty diagram editor.</p> |
| |
| </body> |
| |
| </html> |