Search in sources :

Example 56 with IDiagramModel

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

the class DiagramModelUtilsTests method hasDiagramModelArchimateConnection.

@Test
public void hasDiagramModelArchimateConnection() {
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IArchimateRelationship relationship2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Create various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
    // And make some connections using the relationship
    createDataForDiagramModelConnections(relationship);
    // Should not be found
    boolean result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo1, dmo2, relationship2);
    assertFalse(result);
    // Should be found
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo1, dmo2, relationship);
    assertTrue(result);
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo3, dmo4, relationship);
    assertTrue(result);
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo4, dmo1, relationship);
    assertTrue(result);
    // Reverse the target and source
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo2, dmo1, relationship);
    assertFalse(result);
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo4, dmo3, relationship);
    assertFalse(result);
    result = DiagramModelUtils.hasDiagramModelArchimateConnection(dmo1, dmo4, relationship);
    assertFalse(result);
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 57 with IDiagramModel

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

the class DiagramModelUtilsTests method findDiagramModelReferences.

// =================================================================================================
@Test
public void findDiagramModelReferences() {
    IDiagramModel diagramModel1 = tm.addNewArchimateDiagramModel();
    IDiagramModel diagramModel2 = tm.addNewArchimateDiagramModel();
    IDiagramModel diagramModel3 = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel1);
    assertTrue(list.isEmpty());
    // Create some child objects
    createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel3);
    // Create some refs
    IDiagramModelReference ref1 = IArchimateFactory.eINSTANCE.createDiagramModelReference();
    ref1.setReferencedModel(diagramModel1);
    diagramModel3.getChildren().add(ref1);
    IDiagramModelReference ref2 = IArchimateFactory.eINSTANCE.createDiagramModelReference();
    ref2.setReferencedModel(diagramModel2);
    dmo4.getChildren().add(ref2);
    list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel1);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel2);
    assertEquals(1, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Test(org.junit.Test)

Example 58 with IDiagramModel

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

the class DiagramModelUtilsTests method testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram.

// =================================================================================================
@Test
public void testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModel dm = model.getDefaultDiagramModel();
    IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
    dm.getChildren().add(dmo1);
    IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
    dm.getChildren().add(dmo2);
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(actor);
    relation.setTarget(role);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
    dmc1.connect(dmo1, dmo2);
    List<?> list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(1, list.size());
    // Duplicate
    DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
    handler.duplicate();
    list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(2, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler) Test(org.junit.Test)

Example 59 with IDiagramModel

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

the class DiagramModelUtilsTests method findDiagramModelComponentsForArchimateConcept_Relationship.

@Test
public void findDiagramModelComponentsForArchimateConcept_Relationship() {
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateComponent> list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship);
    assertTrue(list.isEmpty());
    // Create various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
    // And make some connections using the relationship
    createDataForDiagramModelConnections(relationship);
    // Found in diagram
    list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship);
    assertEquals(3, list.size());
    assertTrue(list.contains(conn1));
    assertTrue(list.contains(conn2));
    assertTrue(list.contains(conn3));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 60 with IDiagramModel

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

the class DiagramModelReferenceEditPart method addECoreAdapter.

@Override
protected void addECoreAdapter() {
    super.addECoreAdapter();
    // Listen to referenced model
    IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
    if (ref != null) {
        ref.eAdapters().add(getECoreAdapter());
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

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