use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelUtilsTests method getAncestorContainer.
// =================================================================================================
@Test
public void getAncestorContainer() {
IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
IDiagramModelGroup group1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelGroup group2 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelObject child = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
dm.getChildren().add(group1);
group1.getChildren().add(group2);
assertNull(DiagramModelUtils.getAncestorContainer(child));
group2.getChildren().add(child);
assertEquals(group1, DiagramModelUtils.getAncestorContainer(child));
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class CommandsTests method testDeleteDiagramModelCommand.
// ---------------------------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------------------------
@Test
public void testDeleteDiagramModelCommand() {
IDiagramModel dm = model.getDiagramModels().get(0);
assertNotNull(dm);
DeleteDiagramModelCommand cmd = new DeleteDiagramModelCommand(dm);
cmd.execute();
assertNull(dm.eContainer());
assertFalse(model.getDiagramModels().contains(dm));
cmd.undo();
assertEquals(0, model.getDiagramModels().indexOf(dm));
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testGetDiagramExtents_WithConnections.
@Test
public void testGetDiagramExtents_WithConnections() {
IDiagramModel dm = model.getDiagramModels().get(3);
Shell shell = new Shell();
GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
shell.dispose();
org.eclipse.draw2d.geometry.Rectangle rect = DiagramUtils.getDiagramExtents(viewer);
assertEquals(new org.eclipse.draw2d.geometry.Rectangle(12, 24, 587, 323), rect);
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramUtilsTests method testGetDiagram_IsMinimumSize.
@Test
public void testGetDiagram_IsMinimumSize() {
IDiagramModel dm = model.getDiagramModels().get(0);
Shell shell = new Shell();
GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
shell.dispose();
org.eclipse.draw2d.geometry.Rectangle rect = DiagramUtils.getDiagramExtents(viewer);
assertEquals(new org.eclipse.draw2d.geometry.Rectangle(0, 0, 100, 100), rect);
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DuplicateCommandHandlerTests method testDuplicateDiagramModel.
@Test
public void testDuplicateDiagramModel() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
dmo1.setName("dm");
dm.getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
dm.getChildren().add(dmo2);
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
assertEquals(2, model.getDiagramModels().size());
IDiagramModel dmCopy = model.getDiagramModels().get(1);
assertNotSame(dm, dmCopy);
assertEquals(dm.getName() + " (copy)", dmCopy.getName());
EList<IDiagramModelObject> children = dmCopy.getChildren();
assertEquals(2, children.size());
IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
assertNotSame(dmo1, dmo1Copy);
assertNotSame(dmo2, dmo2Copy);
assertSame(actor, dmo1Copy.getArchimateConcept());
assertSame(role, dmo2Copy.getArchimateConcept());
EList<IDiagramModelConnection> connections = dmo1Copy.getSourceConnections();
assertEquals(1, connections.size());
IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) connections.get(0);
assertNotSame(dmc1, dmc1Copy);
assertSame(relation, dmc1Copy.getArchimateConcept());
}
Aggregations