Search in sources :

Example 16 with IDiagramModelObject

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

the class OpacityAction method run.

@Override
public void run() {
    List<?> selection = getSelectedObjects();
    IDiagramModelObject dmo = (IDiagramModelObject) getFirstValidSelectedModelObject(selection);
    if (dmo == null) {
        return;
    }
    // Set default alpha on first selected connection
    int alpha = dmo.getAlpha();
    OpacityDialog dialog = new OpacityDialog(getWorkbenchPart().getSite().getShell(), alpha);
    if (dialog.open() == Window.OK) {
        execute(createCommand(selection, dialog.getAlpha()));
    }
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject)

Example 17 with IDiagramModelObject

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

the class DiagramModelUtilsTests method hasExistingConnectionType.

@Test
public void hasExistingConnectionType() {
    IDiagramModelObject source = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
    IDiagramModelObject target = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createArtifact());
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    IDiagramModelConnection conn = ArchimateTestModel.createDiagramModelArchimateConnection(relation);
    conn.connect(source, target);
    assertTrue(DiagramModelUtils.hasExistingConnectionType(source, target, relation.eClass()));
    assertFalse(DiagramModelUtils.hasExistingConnectionType(source, target, IArchimatePackage.eINSTANCE.getAccessRelationship()));
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 18 with IDiagramModelObject

use of com.archimatetool.model.IDiagramModelObject 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));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 19 with IDiagramModelObject

use of com.archimatetool.model.IDiagramModelObject 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());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 20 with IDiagramModelObject

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

the class ArchimateContainerEditPolicy method createNewConnectionCommands.

/**
 * When Archimate child objects are dragged out of a parent Archimate object check to see if new connections should be created
 *
 * TODO A3: If O1--C1--O2 and in parent. C1 is also connected to parent (and hidden).
 *          O1 or O2 is removed from parent - should add connection from C1 to parent?
 *          Or should it be only when O1 AND O2 are removed from parent?
 */
void createNewConnectionCommands(IDiagramModelArchimateObject parentObject, List<?> childEditParts, CompoundCommand command) {
    IArchimateElement parentElement = parentObject.getArchimateElement();
    for (Object o : childEditParts) {
        IDiagramModelObject child = (IDiagramModelObject) ((EditPart) o).getModel();
        // If it's an Archimate type child object...
        if (child instanceof IDiagramModelArchimateObject) {
            IDiagramModelArchimateObject childObject = (IDiagramModelArchimateObject) child;
            IArchimateElement childElement = childObject.getArchimateElement();
            // See if there are any (nested type) relationships between parent element and child element...
            for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
                if (relation.getTarget() == childElement && DiagramModelUtils.isNestedConnectionTypeRelationship(relation)) {
                    // And there's not a connection already there then add one
                    if (!DiagramModelUtils.hasDiagramModelArchimateConnection(parentObject, childObject, relation)) {
                        command.add(new CreateDiagramArchimateConnectionCommand(parentObject, childObject, relation));
                    }
                }
            }
        }
    }
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Aggregations

IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)51 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)12 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)12 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)10 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 Test (org.junit.Test)10 IArchimateElement (com.archimatetool.model.IArchimateElement)9 Dimension (org.eclipse.draw2d.geometry.Dimension)9 IDiagramModel (com.archimatetool.model.IDiagramModel)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IBounds (com.archimatetool.model.IBounds)6 Command (org.eclipse.gef.commands.Command)6 ILockable (com.archimatetool.model.ILockable)5 ArrayList (java.util.ArrayList)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 EObject (org.eclipse.emf.ecore.EObject)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 ILineObject (com.archimatetool.model.ILineObject)3