Search in sources :

Example 31 with IArchimateConcept

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

the class ArchimateDiagramEditor method selectArchimateConcepts.

@Override
public void selectArchimateConcepts(IArchimateConcept[] archimateConcepts) {
    List<Object> objects = new ArrayList<Object>();
    for (IArchimateConcept archimateConcept : archimateConcepts) {
        // Find Diagram Concepts
        for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(getModel(), archimateConcept)) {
            if (!objects.contains(dc)) {
                objects.add(dc);
            }
        }
    }
    selectObjects(objects.toArray());
}
Also used : IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) ArrayList(java.util.ArrayList) IArchimateConcept(com.archimatetool.model.IArchimateConcept)

Example 32 with IArchimateConcept

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

the class ArchimateRelationship method setTarget.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public void setTarget(IArchimateConcept newTarget) {
    IArchimateConcept oldTarget = target;
    target = newTarget;
    if (oldTarget != null) {
        oldTarget.getTargetRelationships().remove(this);
    }
    if (newTarget != null) {
        newTarget.getTargetRelationships().add(this);
    }
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, IArchimatePackage.ARCHIMATE_RELATIONSHIP__TARGET, oldTarget, target));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) IArchimateConcept(com.archimatetool.model.IArchimateConcept)

Example 33 with IArchimateConcept

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

the class ArchimateConcept method getCopy.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public EObject getCopy() {
    IArchimateConcept newObject = EcoreUtil.copy(this);
    // need a new ID
    newObject.setId(null);
    return newObject;
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept)

Example 34 with IArchimateConcept

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

the class FieldDataFactory method getFieldValue.

public static Object getFieldValue(Object dataElement, String fieldName) {
    if ("this".equals(fieldName)) {
        // $NON-NLS-1$
        return dataElement;
    }
    if ("id".equals(fieldName) && dataElement instanceof IIdentifier) {
        // $NON-NLS-1$
        return ((IIdentifier) dataElement).getId();
    }
    if ("name".equals(fieldName) && dataElement instanceof INameable) {
        // $NON-NLS-1$
        String name = ((INameable) dataElement).getName();
        if (name == null || "".equals(name)) {
            // $NON-NLS-1$
            name = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
        }
        return name;
    }
    if ("type".equals(fieldName) && dataElement instanceof EObject) {
        // $NON-NLS-1$
        return ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
    }
    if ("documentation".equals(fieldName) && dataElement instanceof IDocumentable) {
        // $NON-NLS-1$
        String s = ((IDocumentable) dataElement).getDocumentation();
        return StringUtils.isSet(s) ? s : null;
    }
    if ("purpose".equals(fieldName) && dataElement instanceof IArchimateModel) {
        // $NON-NLS-1$
        String s = ((IArchimateModel) dataElement).getPurpose();
        return StringUtils.isSet(s) ? s : null;
    }
    if ("relation_source".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
        // $NON-NLS-1$
        IArchimateRelationship relation = (IArchimateRelationship) dataElement;
        IArchimateConcept source = relation.getSource();
        String s = source.getName();
        return StringUtils.isSet(s) ? s : null;
    }
    if ("relation_target".equals(fieldName) && dataElement instanceof IArchimateRelationship) {
        // $NON-NLS-1$
        IArchimateRelationship relation = (IArchimateRelationship) dataElement;
        IArchimateConcept target = relation.getTarget();
        String s = target.getName();
        return StringUtils.isSet(s) ? s : null;
    }
    return null;
}
Also used : IDocumentable(com.archimatetool.model.IDocumentable) IIdentifier(com.archimatetool.model.IIdentifier) INameable(com.archimatetool.model.INameable) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 35 with IArchimateConcept

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

the class ArchimateConceptTests method testGetCopy.

@Test
public void testGetCopy() {
    concept.setName("name");
    concept.setDocumentation("doc");
    concept.getProperties().add(IArchimateFactory.eINSTANCE.createProperty());
    IArchimateConcept copy = (IArchimateConcept) concept.getCopy();
    assertNotSame(concept, copy);
    assertNull(copy.getId());
    assertEquals(concept.getName(), copy.getName());
    assertEquals(concept.getDocumentation(), copy.getDocumentation());
    assertNotSame(concept.getProperties(), copy.getProperties());
    assertEquals(concept.getProperties().size(), copy.getProperties().size());
    assertNotSame(concept.getSourceRelationships(), copy.getSourceRelationships());
    assertNotSame(concept.getTargetRelationships(), copy.getTargetRelationships());
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) Test(org.junit.Test)

Aggregations

IArchimateConcept (com.archimatetool.model.IArchimateConcept)38 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)14 ArrayList (java.util.ArrayList)9 IDiagramModel (com.archimatetool.model.IDiagramModel)7 EObject (org.eclipse.emf.ecore.EObject)7 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Test (org.junit.Test)6 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)3 IDiagramModelEditor (com.archimatetool.editor.diagram.IDiagramModelEditor)3 IArchimateModel (com.archimatetool.model.IArchimateModel)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 CSVParseException (com.archimatetool.csv.CSVParseException)2 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)2 IConnectable (com.archimatetool.model.IConnectable)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2