Search in sources :

Example 16 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel 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;
}
Also used : IDiagramEditorFactory(com.archimatetool.editor.diagram.IDiagramEditorFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) EditPartFactory(org.eclipse.gef.EditPartFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) RootEditPart(org.eclipse.gef.RootEditPart) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)

Example 17 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel 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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) IDiagramModel(com.archimatetool.model.IDiagramModel) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 18 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class SelectAllActionTests method testSelectAll.

@Test
public void testSelectAll() throws Exception {
    ArchimateTestEditor editor = new ArchimateTestEditor();
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IArchimateModel model = tm.loadModelWithCommandStack();
    IArchimateDiagramModel dm = (IArchimateDiagramModel) ArchimateModelUtils.getObjectByID(model, "4165");
    editor.setDiagramModel(dm);
    SelectAllAction action = new SelectAllAction(mock(IWorkbenchPart.class));
    Set<GraphicalEditPart> selected = action.getSelectableEditParts(editor.getGraphicalViewer().getContents());
    assertEquals(47, selected.size());
    editor.dispose();
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ArchimateTestEditor(com.archimatetool.testingtools.ArchimateTestEditor) IArchimateModel(com.archimatetool.model.IArchimateModel) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 19 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class ArchimateDiagramEditPartFactoryTests method testArchimateDiagramPart.

@Test
public void testArchimateDiagramPart() {
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    EditPart editPart = editPartFactory.createEditPart(null, dm);
    assertTrue(editPart instanceof ArchimateDiagramPart);
    assertEquals(dm, editPart.getModel());
}
Also used : GroupEditPart(com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 20 with IArchimateDiagramModel

use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.

the class EmptyViewsChecker method findEmptyViews.

// Empty Views
List<IIssue> findEmptyViews() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateDiagramModel view : fViews) {
        if (view.getChildren().isEmpty()) {
            String viewName = ArchiLabelProvider.INSTANCE.getLabel(view);
            String description = NLS.bind(fDescription, viewName);
            String explanation = NLS.bind(fExplanation, viewName);
            IIssue issue = new AdviceType(fName, description, explanation, view);
            issues.add(issue);
        }
    }
    return issues;
}
Also used : AdviceType(com.archimatetool.hammer.validation.issues.AdviceType) ArrayList(java.util.ArrayList) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)29 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)8 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateModel (com.archimatetool.model.IArchimateModel)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IViewpoint (com.archimatetool.model.viewpoints.IViewpoint)5 EObject (org.eclipse.emf.ecore.EObject)5 AdviceType (com.archimatetool.hammer.validation.issues.AdviceType)4 ISketchModel (com.archimatetool.model.ISketchModel)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)3 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)2 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)2 IFolder (com.archimatetool.model.IFolder)2 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)2 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2