Search in sources :

Example 1 with IJunction

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

the class JunctionsChecker method findBogusJunctions.

List<IIssue> findBogusJunctions() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateElement element : fArchimateElements) {
        if (element instanceof IJunction) {
            IArchimateRelationship rel = null;
            for (IArchimateRelationship relation : ArchimateModelUtils.getAllRelationshipsForConcept(element)) {
                if (rel != null && rel.eClass() != relation.eClass()) {
                    String name = ArchiLabelProvider.INSTANCE.getLabel(element);
                    String description = NLS.bind(DESCRIPTION, name);
                    String explanation = NLS.bind(EXPLANATION, name);
                    IIssue issue = new ErrorType(NAME, description, explanation, element);
                    issues.add(issue);
                    break;
                }
                rel = relation;
            }
        }
    }
    return issues;
}
Also used : ErrorType(com.archimatetool.hammer.validation.issues.ErrorType) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IJunction(com.archimatetool.model.IJunction)

Example 2 with IJunction

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

the class AllArchimateElementTypeTests method testGetJuntion_Type.

@Test
public void testGetJuntion_Type() {
    Assume.assumeTrue(concept instanceof IJunction);
    IJunction junction = (IJunction) concept;
    assertEquals(IJunction.AND_JUNCTION_TYPE, junction.getType());
    junction.setType(IJunction.OR_JUNCTION_TYPE);
    assertEquals(IJunction.OR_JUNCTION_TYPE, junction.getType());
}
Also used : IJunction(com.archimatetool.model.IJunction) Test(org.junit.Test)

Example 3 with IJunction

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

the class FixDefaultSizesHandler method getDefaultSize.

Dimension getDefaultSize(IDiagramModelObject dmo) {
    IBounds bounds = dmo.getBounds();
    if (bounds.getWidth() != -1 && bounds.getHeight() != -1) {
        return new Dimension(bounds.getWidth(), bounds.getHeight());
    }
    // Legacy size of ArchiMate figure
    if (dmo instanceof IDiagramModelArchimateObject) {
        if (!(((IDiagramModelArchimateObject) dmo).getArchimateElement() instanceof IJunction)) {
            return new Dimension(120, 55);
        }
    }
    IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(dmo);
    return provider != null ? provider.getUserDefaultSize() : new Dimension(120, 55);
}
Also used : IBounds(com.archimatetool.model.IBounds) IGraphicalObjectUIProvider(com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider) Dimension(org.eclipse.draw2d.geometry.Dimension) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IJunction(com.archimatetool.model.IJunction)

Example 4 with IJunction

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

the class JunctionFigure method paintFigure.

@Override
public void paintFigure(Graphics graphics) {
    graphics.pushState();
    graphics.setAntialias(SWT.ON);
    if (!isEnabled()) {
        setDisabledState(graphics);
    }
    Rectangle bounds = getBounds().getCopy();
    String type = ((IJunction) ((DiagramModelArchimateObject) getDiagramModelObject()).getArchimateElement()).getType();
    switch(type) {
        case IJunction.AND_JUNCTION_TYPE:
        default:
            graphics.setBackgroundColor(getFillColor());
            graphics.fillOval(bounds.getCopy());
            break;
        case IJunction.OR_JUNCTION_TYPE:
            graphics.setBackgroundColor(getFillColor());
            graphics.drawOval(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1);
            break;
    }
    graphics.popState();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IJunction(com.archimatetool.model.IJunction)

Example 5 with IJunction

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

the class NestedElementsChecker method isNestedWithoutValidRelation.

boolean isNestedWithoutValidRelation(IDiagramModelArchimateObject parent, IDiagramModelArchimateObject child) {
    IArchimateElement parentElement = parent.getArchimateElement();
    IArchimateElement childElement = child.getArchimateElement();
    // Ignore nested Junctions
    if (childElement instanceof IJunction) {
        return false;
    }
    // Specialization relationship goes the other way around
    for (IArchimateRelationship relation : parentElement.getTargetRelationships()) {
        if (relation.getSource() == childElement) {
            if (relation instanceof ISpecializationRelationship) {
                return false;
            }
        }
    }
    // Other relationships
    for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
        if (relation.getTarget() == childElement) {
            if (relation instanceof ICompositionRelationship || relation instanceof IAggregationRelationship || relation instanceof IAssignmentRelationship || relation instanceof IRealizationRelationship || relation instanceof IAccessRelationship) {
                return false;
            }
        }
    }
    return true;
}
Also used : ICompositionRelationship(com.archimatetool.model.ICompositionRelationship) IRealizationRelationship(com.archimatetool.model.IRealizationRelationship) ISpecializationRelationship(com.archimatetool.model.ISpecializationRelationship) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IAggregationRelationship(com.archimatetool.model.IAggregationRelationship) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IAccessRelationship(com.archimatetool.model.IAccessRelationship) IJunction(com.archimatetool.model.IJunction)

Aggregations

IJunction (com.archimatetool.model.IJunction)6 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IArchimateElement (com.archimatetool.model.IArchimateElement)2 Test (org.junit.Test)2 IGraphicalObjectUIProvider (com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider)1 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)1 IIssue (com.archimatetool.hammer.validation.issues.IIssue)1 IAccessRelationship (com.archimatetool.model.IAccessRelationship)1 IAggregationRelationship (com.archimatetool.model.IAggregationRelationship)1 IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)1 IBounds (com.archimatetool.model.IBounds)1 IBusinessActor (com.archimatetool.model.IBusinessActor)1 IBusinessRole (com.archimatetool.model.IBusinessRole)1 ICompositionRelationship (com.archimatetool.model.ICompositionRelationship)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 IRealizationRelationship (com.archimatetool.model.IRealizationRelationship)1 ISpecializationRelationship (com.archimatetool.model.ISpecializationRelationship)1 ArrayList (java.util.ArrayList)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1