Search in sources :

Example 46 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship 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 47 with IArchimateRelationship

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

the class ArchimateRelationship method getCopy.

@Override
public EObject getCopy() {
    IArchimateRelationship copy = (IArchimateRelationship) super.getCopy();
    // Clear source and target. This will also clear connected components' references to this
    copy.setSource(null);
    copy.setTarget(null);
    return copy;
}
Also used : IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Example 48 with IArchimateRelationship

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

the class DiagramModelArchimateConnection method addArchimateConceptToModel.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public void addArchimateConceptToModel(IFolder parent) {
    IArchimateRelationship relationship = getArchimateRelationship();
    if (relationship != null && relationship.eContainer() != null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("Relationship already has parent folder");
    }
    // If parent is null use default folder
    if (parent == null) {
        parent = getDiagramModel().getArchimateModel().getDefaultFolderForObject(relationship);
    }
    if (relationship != null) {
        parent.getElements().add(relationship);
        relationship.reconnect();
    }
}
Also used : IArchimateRelationship(com.archimatetool.model.IArchimateRelationship)

Example 49 with IArchimateRelationship

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

the class InvalidRelationsChecker method findInvalidRelations.

// Invalid Relations
List<IIssue> findInvalidRelations() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateRelationship relation : fRelations) {
        boolean valid = ArchimateModelUtils.isValidRelationship(relation.getSource(), relation.getTarget(), relation.eClass());
        if (!valid) {
            String className = ArchiLabelProvider.INSTANCE.getDefaultName(relation.eClass());
            String description = NLS.bind(fDescription, new Object[] { className, ArchiLabelProvider.INSTANCE.getLabel(relation.getSource()), ArchiLabelProvider.INSTANCE.getLabel(relation.getTarget()) });
            String explanation = NLS.bind(fExplanation, new Object[] { className, ArchiLabelProvider.INSTANCE.getDefaultName(relation.getSource().eClass()), ArchiLabelProvider.INSTANCE.getDefaultName(relation.getTarget().eClass()) });
            IIssue issue = new ErrorType(fName, description, explanation, relation);
            issues.add(issue);
        }
    }
    return issues;
}
Also used : ErrorType(com.archimatetool.hammer.validation.issues.ErrorType) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IIssue(com.archimatetool.hammer.validation.issues.IIssue)

Example 50 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship 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

IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)74 Test (org.junit.Test)39 IArchimateElement (com.archimatetool.model.IArchimateElement)33 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)22 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)15 ArrayList (java.util.ArrayList)15 IArchimateConcept (com.archimatetool.model.IArchimateConcept)14 IDiagramModel (com.archimatetool.model.IDiagramModel)12 IArchimateModel (com.archimatetool.model.IArchimateModel)9 EObject (org.eclipse.emf.ecore.EObject)9 IIssue (com.archimatetool.hammer.validation.issues.IIssue)7 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)7 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)4 IFolder (com.archimatetool.model.IFolder)4 EClass (org.eclipse.emf.ecore.EClass)4 Command (org.eclipse.gef.commands.Command)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3