For the creation of an editor or viewer, it is necessary to implement a diagram type agent. This diagram type agent consists of a diagram type provider and a feature provider. The minimum implementation of the diagram type provider is described in this chapter.
Create a plug-in project for your diagram type specific graphical tool. Please keep in mind not to use the ID org.eclipse.graphiti.examples.tutorial, which is the ID of our implementation of the tutorial. Additionally use different ID's for implementations of our extension points, see below.
You should have references to following plug-ins: org.eclipse.graphiti, org.eclipse.graphiti.ui, org.eclipse.graphiti.examples.common, org.eclipse.core.resources, org.eclipse.core.runtime, org.eclipse.ui.views.properties.tabbed.
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.
A diagram type provider has to implement the interface IDiagramTypeProvider. Instead of implementing it directly it should extend one of the available base classes. In this example we extend the base class AbstractDiagramTypeProvider.
You can see the complete implementation of the diagram type provider here:
package
org.eclipse.graphiti.examples.tutorial.diagram;
public class MyTutorialDiagramTypeProvider
extends AbstractDiagramTypeProvider {
public
MyTutorialDiagramTypeProvider() {
super();
}
}
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.The diagram type advertises that the containing diagram type provider understands the given diagram type and is suitable for editing and viewing diagrams of that type.
The information about a diagram type must be declared in the plugin.xml.
The newly created diagram type provider and diagram type are registered through the extension points:
The corresponding plugin.xml looks similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="org.eclipse.graphiti.ui.diagramTypes">
<diagramType
description="This is the
diagram type for my Graphiti tutorial"
id="org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType"
name="My Graphiti Tutorial
Diagram Type"
type="mytutorial">
</diagramType>
</extension>
<extension
point="org.eclipse.graphiti.ui.diagramTypeProviders">
<diagramTypeProvider
class="org.eclipse.graphiti.examples.tutorial.diagram.
MyTutorialDiagramTypeProvider"
description="This is my
editor for the Graphiti tutorial"
id="org.eclipse.graphiti.examples.tutorial.diagram.
MyTutorialDiagramTypeProvider"
name="My tutorial editor">
<diagramType
id="org.eclipse.graphiti.examples.tutorial.diagram.MyTutorialDiagramType">
</diagramType>
</diagramTypeProvider>
</extension>
</plugin>
For further information to these extension points, see the extension point description in the Eclipse IDE.