Search in sources :

Example 41 with IDiagramModelObject

use of com.archimatetool.model.IDiagramModelObject 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 42 with IDiagramModelObject

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

the class DiagramModelUtilsTests method hasCycle.

@Test
public void hasCycle() {
    IDiagramModelObject source = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    IDiagramModelObject target = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    ;
    IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
    conn.connect(source, target);
    assertFalse(DiagramModelUtils.hasCycle(source, target));
    conn.connect(target, source);
    assertTrue(DiagramModelUtils.hasCycle(source, target));
    conn.disconnect();
    assertFalse(DiagramModelUtils.hasCycle(source, target));
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 43 with IDiagramModelObject

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

the class FixDefaultSizesHandlerTests method testGetDefaultSize.

@Test
public void testGetDefaultSize() {
    IDiagramModelObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    dmo.setBounds(0, 0, -1, -1);
    assertEquals(new Dimension(185, 80), handler.getDefaultSize(dmo));
    dmo.setBounds(0, 0, 23, 23);
    assertEquals(new Dimension(23, 23), handler.getDefaultSize(dmo));
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Example 44 with IDiagramModelObject

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

the class FixDefaultSizesHandlerTests method testGetNewSize_ArchiMateElement.

@Test
public void testGetNewSize_ArchiMateElement() {
    IDiagramModelArchimateObject parent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    parent.setBounds(0, 0, -1, -1);
    IDiagramModelObject child = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    child.setBounds(300, 120, -1, -1);
    parent.getChildren().add(child);
    assertEquals(new Dimension(430, 185), handler.getNewSize(parent));
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Example 45 with IDiagramModelObject

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

the class FixDefaultSizesHandlerTests method testGetNewSize_Group.

@Test
public void testGetNewSize_Group() {
    IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    group.setBounds(0, 0, -1, -1);
    IDiagramModelObject note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    note.setBounds(300, 114, -1, -1);
    group.getChildren().add(note);
    assertEquals(new Dimension(495, 204), handler.getNewSize(group));
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Aggregations

IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)51 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)12 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)12 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)10 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 Test (org.junit.Test)10 IArchimateElement (com.archimatetool.model.IArchimateElement)9 Dimension (org.eclipse.draw2d.geometry.Dimension)9 IDiagramModel (com.archimatetool.model.IDiagramModel)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IBounds (com.archimatetool.model.IBounds)6 Command (org.eclipse.gef.commands.Command)6 ILockable (com.archimatetool.model.ILockable)5 ArrayList (java.util.ArrayList)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 EObject (org.eclipse.emf.ecore.EObject)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 ILineObject (com.archimatetool.model.ILineObject)3