Search in sources :

Example 86 with IArchimateElement

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

the class ZestViewerContentProviderTests method testGetSource_Relationship.

@Test
public void testGetSource_Relationship() {
    IArchimateRelationship inputElement = (IArchimateRelationship) tm.getObjectByID("460");
    IArchimateElement expected = (IArchimateElement) tm.getObjectByID("409");
    Object source = provider.getSource(inputElement);
    assertEquals(expected, source);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 87 with IArchimateElement

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

the class ZestViewerContentProviderTests method testGetDestination_Element.

@Test
public void testGetDestination_Element() {
    IArchimateElement inputElement = (IArchimateElement) tm.getObjectByID("521");
    Object destination = provider.getDestination(inputElement);
    assertNull(destination);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 88 with IArchimateElement

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

the class CSVImporter method createElementFromRecord.

/**
 * Create an Archimate Element from a given CSVRecord
 */
private void createElementFromRecord(CSVRecord csvRecord) throws CSVParseException {
    // ID
    String id = csvRecord.get(0);
    if (!StringUtils.isSet(id)) {
        id = generateID();
    } else {
        checkIDForInvalidCharacters(id);
    }
    // Class type
    String type = csvRecord.get(1);
    EClass eClass = (EClass) IArchimatePackage.eINSTANCE.getEClassifier(type);
    // Can only be Archimate element type
    if (!isArchimateElementEClass(eClass)) {
        throw new CSVParseException(Messages.CSVImporter_3);
    }
    String name = normalise(csvRecord.get(2));
    String documentation = csvRecord.get(3);
    // Is the element already in the model?
    IArchimateElement element = (IArchimateElement) findArchimateConceptInModel(id, eClass);
    // Yes it is, so update values
    if (element != null) {
        storeUpdatedConceptFeature(element, IArchimatePackage.Literals.NAMEABLE__NAME, name);
        storeUpdatedConceptFeature(element, IArchimatePackage.Literals.DOCUMENTABLE__DOCUMENTATION, documentation);
    } else // No, create a new element
    {
        element = (IArchimateElement) IArchimateFactory.eINSTANCE.create(eClass);
        element.setId(id);
        element.setName(name);
        element.setDocumentation(documentation);
        newConcepts.put(id, element);
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IArchimateElement(com.archimatetool.model.IArchimateElement) CSVParseException(com.archimatetool.csv.CSVParseException)

Example 89 with IArchimateElement

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

the class AbstractModelView method getDiagramElementsToUpdate.

/**
 * Find all elements contained in Diagram or Diagram objects including any child objects
 */
private void getDiagramElementsToUpdate(List<Object> list, IDiagramModelContainer container) {
    // ArchiMate element
    if (container instanceof IDiagramModelArchimateObject) {
        IArchimateElement element = ((IDiagramModelArchimateObject) container).getArchimateElement();
        if (!list.contains(element)) {
            list.add(element);
            getRelationshipsToUpdate(list, element);
        }
    }
    // Children
    for (IDiagramModelObject child : container.getChildren()) {
        if (child instanceof IDiagramModelContainer) {
            getDiagramElementsToUpdate(list, (IDiagramModelContainer) child);
        }
    }
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 90 with IArchimateElement

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

the class AbstractModelView method getElementsToUpdateFromNotification.

/**
 * @return All the tree element nodes that may need updating when a change occurs
 */
protected List<Object> getElementsToUpdateFromNotification(Notification msg) {
    int type = msg.getEventType();
    Object element = null;
    if (type == Notification.REMOVE) {
        element = msg.getOldValue();
    } else if (type == Notification.ADD) {
        element = msg.getNewValue();
    } else if (type == Notification.SET) {
        element = msg.getNotifier();
    }
    List<Object> list = new ArrayList<Object>();
    // If it's a diagram object or a diagram dig in and treat it separately
    if (element instanceof IDiagramModelContainer) {
        getDiagramElementsToUpdate(list, (IDiagramModelContainer) element);
        return list;
    }
    // If it's a diagram connection get the relationship
    if (element instanceof IDiagramModelArchimateConnection) {
        element = ((IDiagramModelArchimateConnection) element).getArchimateRelationship();
    }
    // Got either a folder, a relationship or an element
    if (element != null) {
        if (!list.contains(element)) {
            list.add(element);
        }
        // If an element, also add any attached relationships
        if (element instanceof IArchimateElement) {
            getRelationshipsToUpdate(list, (IArchimateElement) element);
        }
    }
    return list;
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3