Search in sources :

Example 36 with IDiagramModelArchimateObject

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

the class DiagramFigureTypeSection method update.

@Override
protected void update() {
    IDiagramModelArchimateObject diagramObject = (IDiagramModelArchimateObject) getFirstSelectedObject();
    IArchimateElement element = diagramObject.getArchimateElement();
    Image image1 = FigureImagePreviewFactory.getFigurePreviewImageForClass(element.eClass());
    Image image2 = FigureImagePreviewFactory.getAlternateFigurePreviewImageForClass(element.eClass());
    figure1.setImage(image1);
    figure2.setImage(image2);
    figure1.getParent().layout();
    int type = diagramObject.getType();
    figure1.setSelected(type == 0);
    figure2.setSelected(type == 1);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Image(org.eclipse.swt.graphics.Image)

Example 37 with IDiagramModelArchimateObject

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

the class DiagramModelUtils method shouldBeHiddenConnection.

/**
 * @param connection The connection to check
 * @return true if a connection should be hidden when its source (parent) element contains its target (child) element
 */
public static boolean shouldBeHiddenConnection(IDiagramModelArchimateConnection connection) {
    if (!ConnectionPreferences.useNestedConnections()) {
        return false;
    }
    // Only if the connection's source and target are both ArchiMate concepts
    if (!(connection.getSource() instanceof IDiagramModelArchimateComponent) && !(connection.getTarget() instanceof IDiagramModelArchimateComponent)) {
        return false;
    }
    IDiagramModelArchimateComponent source = (IDiagramModelArchimateComponent) connection.getSource();
    IDiagramModelArchimateComponent target = (IDiagramModelArchimateComponent) connection.getTarget();
    // If the connection's source element contains the target element, or the connection's target element contains the source element
    if (source instanceof IDiagramModelArchimateObject && target instanceof IDiagramModelArchimateObject) {
        if (((IDiagramModelContainer) source).getChildren().contains((IDiagramModelArchimateObject) target) || ((IDiagramModelContainer) target).getChildren().contains((IDiagramModelArchimateObject) source)) {
            // And it's a relationship type we have chosen to hide
            for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
                if (connection.getArchimateRelationship().eClass() == eClass) {
                    return true;
                }
            }
        }
    }
    // If connection's source is an element and target is a connection
    if (source instanceof IDiagramModelArchimateObject && target instanceof IDiagramModelArchimateConnection) {
        IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) source;
        IConnectable connectionSource = ((IDiagramModelArchimateConnection) target).getSource();
        IConnectable connectionTarget = ((IDiagramModelArchimateConnection) target).getTarget();
        if (parent.getChildren().contains(connectionSource) && parent.getChildren().contains(connectionTarget)) {
            // And it's a relationship type we have chosen to hide
            for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
                if (connection.getArchimateRelationship().eClass() == eClass) {
                    return true;
                }
            }
        }
    }
    // TODO: Not sure if this directionality should be allowed
    if (target instanceof IDiagramModelArchimateObject && source instanceof IDiagramModelArchimateConnection) {
        IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) target;
        IConnectable connectionSource = ((IDiagramModelArchimateConnection) source).getSource();
        IConnectable connectionTarget = ((IDiagramModelArchimateConnection) source).getTarget();
        if (parent.getChildren().contains(connectionSource) && parent.getChildren().contains(connectionTarget)) {
            // And it's a relationship type we have chosen to hide
            for (EClass eClass : ConnectionPreferences.getRelationsClassesForHiding()) {
                if (connection.getArchimateRelationship().eClass() == eClass) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IConnectable(com.archimatetool.model.IConnectable) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 38 with IDiagramModelArchimateObject

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

the class JunctionFigureTests method createFigure.

@Override
protected JunctionFigure createFigure() {
    // Add a DiagramModelObject
    IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo.setBounds(IArchimateFactory.eINSTANCE.createBounds());
    dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createJunction());
    dm.getChildren().add(dmo);
    // Layout
    editor.layoutPendingUpdates();
    return (JunctionFigure) editor.findFigure(dmo);
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 39 with IDiagramModelArchimateObject

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

the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_ArchimateDiagramModelConnection.

@Test
public void testIsValidConnection_ArchimateDiagramModelConnection() {
    EClass relationshipType = IArchimatePackage.eINSTANCE.getAssociationRelationship();
    IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmao1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    IDiagramModelArchimateObject dmao2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmao2.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    // OK
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, relationshipType));
    // OK if relationshipType is null (magic connector)
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, null));
    // Nope
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(IArchimateFactory.eINSTANCE.createDiagramModelGroup(), dmao2, relationshipType));
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(IArchimateFactory.eINSTANCE.createDiagramModelNote(), dmao2, relationshipType));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 40 with IDiagramModelArchimateObject

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

the class FormatPainterInfoTests method testUpdatePaintFormat.

@Test
public void testUpdatePaintFormat() {
    // Set FormatPainterInfo to Source component
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    info.updatePaintFormat(sourceComponent);
    PaintFormat pf = info.getPaintFormat();
    assertNotNull(pf);
    assertEquals(sourceComponent, pf.getSourceComponent());
    // Check cursor
    assertEquals(new RGB(255, 255, 181), pf.getCursorColor());
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) RGB(org.eclipse.swt.graphics.RGB) 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