use of com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory in project archi by archimatetool.
the class ArchimateDiagramEditor method configureGraphicalViewer.
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
// Register the Edit Part Factory before setting model contents
viewer.setEditPartFactory(new ArchimateDiagramEditPartFactory());
// Set Model
viewer.setContents(getModel());
// Native DnD
viewer.addDropTargetListener(new ArchimateDiagramTransferDropTargetListener(viewer));
}
use of com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory in project archi by archimatetool.
the class DiagramUtils method createViewer.
/**
* Create a GraphicalViewerImpl to show the model. The Viewer has no Scroll Bars
* @param model
* @return A Graphical Viewer
*/
public static GraphicalViewerImpl createViewer(IDiagramModel model, Composite parent) {
EditPartFactory editPartFactory = null;
if (model instanceof IArchimateDiagramModel) {
editPartFactory = new ArchimateDiagramEditPartFactory();
} else if (model instanceof ISketchModel) {
editPartFactory = new SketchEditPartFactory();
} else {
// Extensions
IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
if (factory != null) {
editPartFactory = factory.createEditPartFactory();
}
}
if (editPartFactory == null) {
// $NON-NLS-1$
throw new RuntimeException("Unsupported model type");
}
GraphicalViewerImpl viewer = new GraphicalViewerImpl();
viewer.createControl(parent);
viewer.setEditPartFactory(editPartFactory);
RootEditPart rootPart = new FreeformGraphicalRootEditPart();
viewer.setRootEditPart(rootPart);
viewer.setContents(model);
viewer.flush();
return viewer;
}
use of com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory in project archi by archimatetool.
the class DiagramUtilsTests method testCreateViewer_ArchimateModel.
@Test
public void testCreateViewer_ArchimateModel() {
IDiagramModel dm = model.getDiagramModels().get(0);
assertTrue(dm instanceof IArchimateDiagramModel);
Shell shell = new Shell();
GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
assertNotNull(viewer);
assertTrue(viewer.getEditPartFactory() instanceof ArchimateDiagramEditPartFactory);
assertTrue(viewer.getRootEditPart() instanceof FreeformGraphicalRootEditPart);
assertSame(dm, viewer.getContents().getModel());
assertSame(shell, viewer.getControl().getShell());
shell.dispose();
}
Aggregations