Search in sources :

Example 1 with IDiagramModelGroup

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

the class DiagramModelConnectionTests method testGetID.

@Test
public void testGetID() {
    assertNull(component.getId());
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    IDiagramModelGroup dmo = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(dmo);
    connection.connect(dmo, dmo);
    assertNotNull(connection.getId());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 2 with IDiagramModelGroup

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

the class DiagramModelConnectionTests method testGetDiagramModel.

@Test
public void testGetDiagramModel() {
    assertNull(connection.getDiagramModel());
    IDiagramModelGroup dmo = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(dmo);
    connection.connect(dmo, dmo);
    assertSame(dm, connection.getDiagramModel());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) Test(org.junit.Test)

Example 3 with IDiagramModelGroup

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

the class DiagramModelExtraTests method testDiagramModelArchimateObject_eInverseAdd_ArchimateElement_getReferencingDiagramObjects.

/**
 * See {@link DiagramModelArchimateObject#eInverseAdd(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 * See {@link DiagramModelArchimateObject#eInverseRemove(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 */
@Test
public void testDiagramModelArchimateObject_eInverseAdd_ArchimateElement_getReferencingDiagramObjects() {
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo3a = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmo3.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    // dmo3a shares an archimate element with dmo3
    dmo3a.setArchimateElement(dmo3.getArchimateElement());
    // Set up model and diagram model
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    // Add some parents
    IDiagramModelGroup parent1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(parent1);
    IDiagramModelArchimateObject parent2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    parent1.getChildren().add(parent2);
    // Starts at sizes
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to dm
    dm.getChildren().add(dmo1);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to parent 1
    parent1.getChildren().add(dmo2);
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to parent 2
    parent2.getChildren().add(dmo3);
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add dmo3a - dmo3.getArchimateElement() should be same
    dm.getChildren().add(dmo3a);
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Remove diagram model, should be the same
    ((IFolder) dm.eContainer()).getElements().remove(dm);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add diagram model back again, should be the same
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Simple remove from direct parent
    dm.getChildren().remove(dmo1);
    parent1.getChildren().remove(dmo2);
    parent2.getChildren().remove(dmo3);
    assertEquals(0, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(0, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Remove Again
    dm.getChildren().remove(dmo3a);
    assertEquals(0, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(0, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 4 with IDiagramModelGroup

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

the class DiagramModelGroupTests method testGetCopy.

@Override
@Test
public void testGetCopy() {
    super.testGetCopy();
    group.getProperties().add(IArchimateFactory.eINSTANCE.createProperty());
    IDiagramModelGroup copy = (IDiagramModelGroup) group.getCopy();
    assertNotSame(group, copy);
    assertNotSame(group.getChildren(), copy.getChildren());
    assertTrue(copy.getChildren().isEmpty());
    assertNotSame(group.getProperties(), copy.getProperties());
    assertEquals(group.getProperties().size(), copy.getProperties().size());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) Test(org.junit.Test)

Example 5 with IDiagramModelGroup

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

the class DiagramModelGroup method getCopy.

@Override
public EObject getCopy() {
    IDiagramModelGroup newObject = (IDiagramModelGroup) super.getCopy();
    newObject.getChildren().clear();
    return newObject;
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup)

Aggregations

IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)20 Test (org.junit.Test)14 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)4 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)3 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IDiagramModel (com.archimatetool.model.IDiagramModel)3 IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)3 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)3 EditPart (org.eclipse.gef.EditPart)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 GroupEditPart (com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart)1 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)1 IObjectUIProvider (com.archimatetool.editor.ui.factory.IObjectUIProvider)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1