Search in sources :

Example 51 with IDiagramModel

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

the class DeleteCommandHandlerTests method testDelete_DiagramModel_Deleted_Diagram_Reference.

@Test
public void testDelete_DiagramModel_Deleted_Diagram_Reference() {
    IDiagramModel dm2 = model.getDiagramModels().get(1);
    // Reference to dm2 in dm1
    IDiagramModelReference dmRef = (IDiagramModelReference) ArchimateModelUtils.getObjectByID(model, "99a52921");
    assertNotNull(dmRef);
    // Zap
    DeleteCommandHandler commandHandler = new DeleteCommandHandler(treeModelViewer, new Object[] { dm2 });
    commandHandler.delete();
    // All gone
    assertNull(ArchimateModelUtils.getObjectByID(model, dm2.getId()));
    assertNull(ArchimateModelUtils.getObjectByID(model, dmRef.getId()));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Test(org.junit.Test)

Example 52 with IDiagramModel

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

the class DuplicateCommandHandlerTests method testDuplicateDiagramModel_AddsConnectionsToConnections.

@Test
public void testDuplicateDiagramModel_AddsConnectionsToConnections() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModel dm = model.getDefaultDiagramModel();
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(element1);
    dm.getChildren().add(dmo1);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(element2);
    dm.getChildren().add(dmo2);
    IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo3 = tm.createDiagramModelArchimateObjectAndAddToModel(element3);
    dm.getChildren().add(dmo3);
    IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation1.setSource(element1);
    relation1.setTarget(element2);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation1);
    dmc1.connect(dmo1, dmo2);
    IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    relation2.setSource(element3);
    relation2.setTarget(relation1);
    IDiagramModelArchimateConnection dmc2 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation2);
    dmc2.connect(dmo3, dmc1);
    DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
    handler.duplicate();
    IDiagramModel dmCopy = model.getDiagramModels().get(1);
    EList<IDiagramModelObject> children = dmCopy.getChildren();
    assertEquals(3, children.size());
    IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
    IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
    IDiagramModelArchimateObject dmo3Copy = (IDiagramModelArchimateObject) children.get(2);
    assertSame(element1, dmo1Copy.getArchimateConcept());
    assertSame(element2, dmo2Copy.getArchimateConcept());
    assertSame(element3, dmo3Copy.getArchimateConcept());
    IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) dmo1Copy.getSourceConnections().get(0);
    assertSame(relation1, dmc1Copy.getArchimateConcept());
    assertSame(dmo2Copy, dmc1Copy.getTarget());
    // Connection to Connection
    assertSame(dmc1Copy, dmo3Copy.getSourceConnections().get(0).getTarget());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 53 with IDiagramModel

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

the class DiagramModelUtilsTests method findReferencedDiagramsForArchimateConcept.

private void findReferencedDiagramsForArchimateConcept(String[][] data) {
    IArchimateElement element = (IArchimateElement) tm.getObjectByID(data[0][0]);
    assertNotNull(element);
    List<IDiagramModel> list = DiagramModelUtils.findReferencedDiagramsForArchimateConcept(element);
    assertEquals(data[1].length, list.size());
    for (int i = 0; i < data[1].length; i++) {
        String id = data[1][i];
        assertEquals(id, list.get(i).getId());
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement)

Example 54 with IDiagramModel

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

the class DiagramModelUtilsTests method findDiagramModelObjectsForElement.

@Test
public void findDiagramModelObjectsForElement() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateObject> list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
    assertTrue(list.isEmpty());
    // Add the element to various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(element, diagramModel);
    // Should be found in a dm
    list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
    assertEquals(4, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 55 with IDiagramModel

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

the class DiagramModelUtilsTests method findReferencedDiagramsForArchimateConcept.

@Test
public void findReferencedDiagramsForArchimateConcept() {
    IArchimateElement element = null;
    // Null element should at least return an empty list
    List<IDiagramModel> list = DiagramModelUtils.findReferencedDiagramsForArchimateConcept(element);
    assertNotNull(list);
    assertEquals(0, list.size());
    findReferencedDiagramsForArchimateConcept(data1);
    findReferencedDiagramsForArchimateConcept(data2);
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Aggregations

IDiagramModel (com.archimatetool.model.IDiagramModel)68 Test (org.junit.Test)28 IArchimateElement (com.archimatetool.model.IArchimateElement)16 IArchimateModel (com.archimatetool.model.IArchimateModel)12 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)12 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)11 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)9 File (java.io.File)8 EObject (org.eclipse.emf.ecore.EObject)8 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)8 Image (org.eclipse.swt.graphics.Image)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)7 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)7 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Command (org.eclipse.gef.commands.Command)6 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)6 Shell (org.eclipse.swt.widgets.Shell)6