Java Reference
In-Depth Information
PaletteFactory.Adapter
provided by the runtime. Note the aforementioned
reference to the
IElementType
for our
Topic
domain element being passed as
a constructor argument to the GMF runtime's
CreationTool
class.
public class
MindmapPaletteFactory
extends
PaletteFactory.Adapter {
@Override
public
Tool createTool(String toolId) {
if
(toolId.equals("Topic")) {
return new
CreationTool(MindmapElementTypes.TOPIC);
}
return null
;
}
}
View Definition
As you learned earlier, the creation tool of the palette first creates a domain ele-
ment and then views using the view service. For this, we need to contribute to
the
org.eclpse.gmf.runtime.diagram.core.viewProviders
extension-
point. Below, we declare the contribution and our
MindmapViewProvider
class, which we will need to implement.
<extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders">
<viewProvider
class="org.eclipse.mindmap.diagram.providers.MindmapViewProvider">
<Priority name="Lowest"/>
</viewProvider>
</extension>
Our
MindmapViewProvider
extends the provided
AbstractView
Provider
and overrides the
getNodeViewClass()
and
getDiagramView
Class()
methods. These methods use the
semanticHint
parameters to return
the appropriate
ViewFactory
classes for the
Topic
node diagram, respectively.
public class
MindmapViewProvider
extends
AbstractViewProvider {
private final
Map<String, Class<?>> diagramMap =
new
HashMap<String,
Class<?>>();
{
diagramMap.put(MindmapDiagramEditor.ID,
DiagramViewFactory.
class
);
}
Search WWH ::
Custom Search