@Override
protected void configureGraphicalViewer()
{
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
this.diagramPresentation = new DiagramPagePresentation(this.part, this.configManager, viewer.getControl().getShell());
this.diagramModel = new DiagramModel(this.diagramPresentation);
viewer.setEditPartFactory(new SapphireDiagramEditorEditPartFactory(getConfigurationManager()));
viewer.setRootEditPart(new ScalableFreeformRootEditPart()
{
@Override
protected GridLayer createGridLayer()
{
return new SapphireDiagramGridLayer(diagramModel);
}
});
// configure the context menu provider
ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(this);
viewer.setContextMenu(cmProvider);
// Configure grid and guide properties
boolean isGridVisibleInViewer = false;
if (viewer.getProperty(SnapToGrid.PROPERTY_GRID_VISIBLE) != null)
{
isGridVisibleInViewer = (Boolean) viewer.getProperty(SnapToGrid.PROPERTY_GRID_VISIBLE);
}
if (this.part.isGridVisible() != isGridVisibleInViewer)
{
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, this.part.isGridVisible());
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, this.part.isGridVisible());
viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING,
new Dimension(this.part.getGridUnit(), this.part.getVerticalGridUnit()));
}
boolean isShowGuidesInViewer = false;
if (viewer.getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED) != null)
{
isShowGuidesInViewer = (Boolean)viewer.getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED);
}
if (this.part.isShowGuides() != isShowGuidesInViewer)
{
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, this.part.isShowGuides());
}
// Support context help
this.getGraphicalControl().addHelpListener(new HelpListener()