| <!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>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 alt="" 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>Create a Feature Provider</h2> |
| <p>A feature provider has to implement interface |
| <a href="../../../javadoc/org/eclipse/graphiti/features/IFeatureProvider.html">IFeatureProvider. |
| Instead of implementing it directly you should extend one of the available base |
| classes. In this example we extend class </a> |
| <a href="../../../javadoc/org/eclipse/graphiti/ui/features/DefaultFeatureProvider.html"> |
| DefaultFeatureProvider</a> 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> |
| <!-- Begin code ------------------------------------------------------------------------------- --> |
| <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> |
| <!-- End code ------------------------------------------------------------------------------- --> |
| <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> |
| <!-- Begin code ------------------------------------------------------------------------------- --> |
| <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> |
| <p> </p> |
| <!-- End code ------------------------------------------------------------------------------- --> |
| <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> |
| <p> </p> |
| |
| </body> |
| |
| </html> |