use of com.archimatetool.editor.diagram.IDiagramEditorFactory in project archi by archimatetool.
the class EditorManager method openDiagramEditor.
/**
* Open the Diagram Editor for a given DiagramModel Model
* @param name
*/
public static IDiagramModelEditor openDiagramEditor(IDiagramModel model) {
if (model == null || model.eContainer() == null || !PlatformUI.isWorkbenchRunning()) {
return null;
}
String id = null;
IEditorInput editorInput = null;
if (model instanceof IArchimateDiagramModel) {
id = IArchimateDiagramEditor.ID;
editorInput = new DiagramEditorInput(model);
} else if (model instanceof ISketchModel) {
id = ISketchEditor.ID;
editorInput = new DiagramEditorInput(model);
} else {
IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
if (factory != null) {
id = factory.getEditorID();
editorInput = factory.createEditorInput(model);
}
}
if (id == null || editorInput == null) {
// $NON-NLS-1$
throw new RuntimeException("Unsupported model type");
}
IEditorPart part = openEditor(editorInput, id);
// Check it actually is IDiagramModelEditor, it could be an org.eclipse.ui.internal.ErrorEditorPart if an error occurs
return part instanceof IDiagramModelEditor ? (IDiagramModelEditor) part : null;
}
use of com.archimatetool.editor.diagram.IDiagramEditorFactory 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;
}
Aggregations