Search in sources :

Example 16 with IDiagramModelGroup

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

the class ArchimateDiagramModelFactory method getNewObject.

public Object getNewObject() {
    if (fTemplate == null) {
        return null;
    }
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Connection created from Relationship Template
    if (object instanceof IArchimateRelationship) {
        return createDiagramModelArchimateConnection((IArchimateRelationship) object);
    } else // Archimate Diagram Object created from Archimate Element Template
    if (object instanceof IArchimateElement) {
        IArchimateElement element = (IArchimateElement) object;
        element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        return createDiagramModelArchimateObject(element);
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
        ((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Note
    if (object instanceof IDiagramModelNote) {
        ColorFactory.setDefaultColors((IDiagramModelObject) object);
        ((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        ColorFactory.setDefaultColors((IDiagramModelConnection) object);
    }
    return object;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote)

Example 17 with IDiagramModelGroup

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

the class HTMLReportExporter method addNewBounds.

/**
 * Add new bounds for each diagram object in relation to its parent offset x,y
 */
private void addNewBounds(IDiagramModelObject dmo, int offsetX, int offsetY) {
    // Add new bounds caled to device zoom
    BoundsWithAbsolutePosition newBounds = new BoundsWithAbsolutePosition(dmo.getBounds(), ImageFactory.getDeviceZoom() / 100);
    // Add offset
    newBounds.setOffset(offsetX, offsetY);
    childBoundsMap.put(dmo.getId(), newBounds);
    // Children
    if (dmo instanceof IDiagramModelArchimateObject || dmo instanceof IDiagramModelGroup) {
        for (IDiagramModelObject child : ((IDiagramModelContainer) dmo).getChildren()) {
            addNewBounds(child, newBounds.getX1(), newBounds.getY1());
        }
    }
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 18 with IDiagramModelGroup

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

the class FixDefaultSizesHandlerTests method testGetNewSize_Group.

@Test
public void testGetNewSize_Group() {
    IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    group.setBounds(0, 0, -1, -1);
    IDiagramModelObject note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    note.setBounds(300, 114, -1, -1);
    group.getChildren().add(note);
    assertEquals(new Dimension(495, 204), handler.getNewSize(group));
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Example 19 with IDiagramModelGroup

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

the class DiagramModelConnectionTests method testGetArchimateModel.

@Test
public void testGetArchimateModel() {
    assertNull(connection.getArchimateModel());
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    IDiagramModelGroup dmo = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(dmo);
    connection.connect(dmo, dmo);
    assertSame(model, connection.getArchimateModel());
}
Also used : IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 20 with IDiagramModelGroup

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

the class DiagramModelExtraTests method testDiagramModelArchimateConnection_eInverseAdd_Relationship_getReferencingDiagramObjects.

/**
 * See {@link DiagramModelArchimateConnection#eInverseAdd(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 * See {@link DiagramModelArchimateConnection#eInverseRemove(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 */
@Test
public void testDiagramModelArchimateConnection_eInverseAdd_Relationship_getReferencingDiagramObjects() {
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IArchimateElement element4 = IArchimateFactory.eINSTANCE.createBusinessActor();
    IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IArchimateRelationship relation3 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    relation1.setSource(element1);
    relation1.setTarget(element2);
    relation2.setSource(element2);
    relation2.setTarget(element3);
    relation3.setSource(element3);
    relation3.setTarget(element4);
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo4 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(element1);
    dmo2.setArchimateElement(element2);
    dmo3.setArchimateElement(element3);
    dmo4.setArchimateElement(element4);
    IDiagramModelArchimateConnection conn1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    IDiagramModelArchimateConnection conn2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    IDiagramModelArchimateConnection conn3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    // conn3a shares a relationship with conn3
    IDiagramModelArchimateConnection conn3a = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    conn1.setArchimateRelationship(relation1);
    conn2.setArchimateRelationship(relation2);
    conn3.setArchimateRelationship(relation3);
    // same
    conn3a.setArchimateRelationship(relation3);
    // Set up model and diagram model
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    // Add some parents
    IDiagramModelGroup parent1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    dm.getChildren().add(parent1);
    IDiagramModelArchimateObject parent2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    parent1.getChildren().add(parent2);
    // Add the dmos
    dm.getChildren().add(dmo1);
    parent1.getChildren().add(dmo2);
    parent2.getChildren().add(dmo3);
    dm.getChildren().add(dmo4);
    // Starts at sizes
    assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
    // Connect
    conn1.connect(dmo1, dmo2);
    assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
    conn2.connect(dmo2, dmo3);
    assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    conn3.connect(dmo3, dmo4);
    assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    conn3a.connect(dmo3, dmo4);
    assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
    // Remove diagram model, should be the same
    ((IFolder) dm.eContainer()).getElements().remove(dm);
    assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
    // Add diagram model back again
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
    // Disconnect
    conn1.disconnect();
    conn2.disconnect();
    conn3.disconnect();
    conn3a.disconnect();
    assertEquals(0, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(0, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(0, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
    assertEquals(0, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Aggregations

IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)20 Test (org.junit.Test)14 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)4 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)3 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IDiagramModel (com.archimatetool.model.IDiagramModel)3 IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)3 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)3 EditPart (org.eclipse.gef.EditPart)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 ICreationFactory (com.archimatetool.editor.diagram.ICreationFactory)1 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)1 GroupEditPart (com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart)1 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)1 IObjectUIProvider (com.archimatetool.editor.ui.factory.IObjectUIProvider)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1