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);
}
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());
}
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());
}
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));
}
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());
}
}
Aggregations