use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ArchimateTestModel method createDiagramModelArchimateObjectAndAddToParent.
/**
* Create a DiagramModelArchimateObject, add an Archimate element to it and add it to a parent container
*/
public static IDiagramModelArchimateObject createDiagramModelArchimateObjectAndAddToParent(IArchimateElement element, IDiagramModelContainer parent) {
IDiagramModelArchimateObject dmo = createDiagramModelArchimateObject(element);
parent.getChildren().add(dmo);
return dmo;
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ArchimateTestModel method createDiagramModelArchimateObject.
// ======================================= Factory methods =============================================
/**
* Create a DiagramModelArchimateObject and add an Archimate element to it
*/
public static IDiagramModelArchimateObject createDiagramModelArchimateObject(IArchimateElement element) {
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setBounds(0, 0, 120, 55);
dmo.setArchimateElement(element);
return dmo;
}
use of com.archimatetool.model.IDiagramModelArchimateObject 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());
}
use of com.archimatetool.model.IDiagramModelArchimateObject 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.IDiagramModelArchimateObject 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));
}
Aggregations