Java Reference
In-Depth Information
command that creates our domain element instance and passes it to the view
service. The view service uses our registered
MindmapViewProvider
and
obtains our
TopicViewFactory
based on the provided semanticHint.
For further clarification on how the runtime knows to create a new
Topic
object and store it in the proper feature in our
Map
class, let's take a closer look
at the compound command that the creation tool uses and see how it works.
First, we need to cover our
EditPart
definition.
EditPart Definition
We must define our
EditPart
s for the diagram, which are provided by con-
tributing to the
org.eclipse.gmf.runtime.diagram.ui.editpart
Providers
extension-point. As with our view provider, we declare a provider
class that we need to implement.
<extension
point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders">
<editpartProvider class=
"org.eclipse.mindmap.diagram.providers.MindmapEditPartProvider">
<Priority name="Lowest"/>
</editpartProvider>
</extension>
The implementation of our
MindmapEditPartProvider
is similar to that
of our
ViewProvider
, with a
HashMap
that contains our shape
EditPart
classes keyed by their
semanticHint
, which is available from the passed
View
using the
getType()
method. For now, we have only a single entry for our
Topic
element. Our diagram
EditPart
is simply the default
DiagramEdit
Part
class that the runtime provides.
public class
MindmapEditPartProvider
extends
AbstractEditPartProvider {
private final
Map<String, Class<?>> diagramMap =
new
HashMap<String,
Class<?>>();
{
diagramMap.put(MindmapDiagramEditor.ID, DiagramEditPart.
class
);
}
private final
Map<String, Class<?>> shapeMap =
new
HashMap<String,
Class<?>>();
{
shapeMap.put("Topic", TopicEditPart.
class
);
}
@Override
protected
Class getDiagramEditPartClass(View view) {
Search WWH ::
Custom Search