Search in sources :

Example 51 with IDiagramModelArchimateObject

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;
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 52 with IDiagramModelArchimateObject

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;
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 53 with IDiagramModelArchimateObject

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());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 54 with IDiagramModelArchimateObject

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());
}
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 55 with IDiagramModelArchimateObject

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));
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Aggregations

IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)64 Test (org.junit.Test)34 IArchimateElement (com.archimatetool.model.IArchimateElement)28 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)19 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)14 ArrayList (java.util.ArrayList)13 IDiagramModel (com.archimatetool.model.IDiagramModel)10 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IArchimateModel (com.archimatetool.model.IArchimateModel)8 EClass (org.eclipse.emf.ecore.EClass)7 Command (org.eclipse.gef.commands.Command)7 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)6 EObject (org.eclipse.emf.ecore.EObject)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)4 Dimension (org.eclipse.draw2d.geometry.Dimension)4