Search in sources :

Example 1 with IDiagramModelArchimateObject

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

the class AbstractDiagramModelObjectFigure method getToolTip.

@Override
public IFigure getToolTip() {
    if (!Preferences.doShowViewTooltips()) {
        return null;
    }
    ToolTipFigure toolTipFigure = (ToolTipFigure) super.getToolTip();
    if (toolTipFigure == null) {
        toolTipFigure = new ToolTipFigure();
        setToolTip(toolTipFigure);
    }
    // Set text to object's default text
    String text = ArchiLabelProvider.INSTANCE.getLabel(getDiagramModelObject());
    toolTipFigure.setText(text);
    // If an ArchiMate type, set text to element type if blank
    if (fDiagramModelObject instanceof IDiagramModelArchimateObject) {
        IArchimateElement element = ((IDiagramModelArchimateObject) fDiagramModelObject).getArchimateElement();
        String type = ArchiLabelProvider.INSTANCE.getDefaultName(element.eClass());
        if (!StringUtils.isSet(text)) {
            // Name was blank
            toolTipFigure.setText(type);
        }
        // $NON-NLS-1$
        toolTipFigure.setType(Messages.AbstractDiagramModelObjectFigure_0 + " " + type);
    }
    return toolTipFigure;
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 2 with IDiagramModelArchimateObject

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

the class ViewpointChecker method findComponentsInWrongViewpoints.

List<IIssue> findComponentsInWrongViewpoints() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateDiagramModel dm : fViews) {
        String id = dm.getViewpoint();
        IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
        for (Iterator<EObject> iter = dm.eAllContents(); iter.hasNext(); ) {
            EObject eObject = iter.next();
            if (eObject instanceof IDiagramModelArchimateObject) {
                IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
                IArchimateElement element = dmo.getArchimateElement();
                if (!viewPoint.isAllowedConcept(element.eClass())) {
                    IIssue issue = createIssue(dmo, dm.getName(), viewPoint.getName());
                    issues.add(issue);
                }
            }
        }
    }
    return issues;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 3 with IDiagramModelArchimateObject

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

the class ViewpointManagerTests method testIsAllowedDiagramModelComponent.

@Test
public void testIsAllowedDiagramModelComponent() {
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setViewpoint("organization");
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    dm.getChildren().add(dmo1);
    assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo1));
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createNode());
    dm.getChildren().add(dmo2);
    assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo2));
    IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    conn.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
    conn.connect(dmo1, dmo2);
    assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
    IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo3.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessRole());
    dm.getChildren().add(dmo3);
    conn.connect(dmo1, dmo3);
    assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 4 with IDiagramModelArchimateObject

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

the class DiagramModelArchimateObjectTests method testGetCopy.

@Override
@Test
public void testGetCopy() {
    super.testGetCopy();
    IDiagramModelArchimateObject copy = (IDiagramModelArchimateObject) object.getCopy();
    assertNotSame(copy, object);
    assertNotNull(copy.getArchimateElement());
    assertNotSame(copy.getArchimateElement(), object.getArchimateElement());
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 5 with IDiagramModelArchimateObject

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

the class DiagramModelExtraTests method testDiagramModelArchimateObject_eInverseAdd_ArchimateElement_getReferencingDiagramObjects.

/**
 * See {@link DiagramModelArchimateObject#eInverseAdd(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 * See {@link DiagramModelArchimateObject#eInverseRemove(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
 */
@Test
public void testDiagramModelArchimateObject_eInverseAdd_ArchimateElement_getReferencingDiagramObjects() {
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmo3a = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmo3.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    // dmo3a shares an archimate element with dmo3
    dmo3a.setArchimateElement(dmo3.getArchimateElement());
    // 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);
    // Starts at sizes
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to dm
    dm.getChildren().add(dmo1);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to parent 1
    parent1.getChildren().add(dmo2);
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    // Add to parent 2
    parent2.getChildren().add(dmo3);
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add dmo3a - dmo3.getArchimateElement() should be same
    dm.getChildren().add(dmo3a);
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Remove diagram model, should be the same
    ((IFolder) dm.eContainer()).getElements().remove(dm);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Add diagram model back again, should be the same
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    assertEquals(1, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(2, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Simple remove from direct parent
    dm.getChildren().remove(dmo1);
    parent1.getChildren().remove(dmo2);
    parent2.getChildren().remove(dmo3);
    assertEquals(0, dmo1.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(0, dmo2.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(1, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
    // Remove Again
    dm.getChildren().remove(dmo3a);
    assertEquals(0, dmo3.getArchimateElement().getReferencingDiagramObjects().size());
    assertEquals(0, dmo3a.getArchimateElement().getReferencingDiagramObjects().size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IArchimateModel(com.archimatetool.model.IArchimateModel) 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