Search in sources :

Example 1 with IDiagramModelNote

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

the class DiagramModelNoteTests method testGetCopy.

@Override
@Test
public void testGetCopy() {
    super.testGetCopy();
    note.setContent("hello");
    IDiagramModelNote copy = (IDiagramModelNote) note.getCopy();
    assertNotSame(note, copy);
    assertEquals(note.getContent(), note.getContent());
}
Also used : IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Example 2 with IDiagramModelNote

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

the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_DiagramModelConnection.

@Test
public void testIsValidConnection_DiagramModelConnection() {
    EClass relationshipType = IArchimatePackage.eINSTANCE.getDiagramModelConnection();
    IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmao2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelReference dmRef = IArchimateFactory.eINSTANCE.createDiagramModelReference();
    // Source == Target
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, group, relationshipType));
    // Both ArchiMate types
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, relationshipType));
    // Target ArchiMate type
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, dmao2, relationshipType));
    // Target ArchiMate type
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmRef, dmao2, relationshipType));
    // Source ArchiMate type to Note
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, note, relationshipType));
    // OK
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(note, group, relationshipType));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Example 3 with IDiagramModelNote

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

the class ArchimateDiagramModelFactoryTests method testGetNewObjectNote.

@Test
public void testGetNewObjectNote() {
    ICreationFactory factory = new ArchimateDiagramModelFactory(IArchimatePackage.eINSTANCE.getDiagramModelNote());
    IDiagramModelNote note = (IDiagramModelNote) factory.getNewObject();
    assertEquals("", note.getName());
}
Also used : IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Example 4 with IDiagramModelNote

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

the class ArchimateDiagramEditPartFactoryTests method testNoteEditPart.

@Test
public void testNoteEditPart() {
    IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    EditPart editPart = editPartFactory.createEditPart(null, note);
    assertTrue(editPart instanceof NoteEditPart);
    assertEquals(note, editPart.getModel());
}
Also used : GroupEditPart(com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Example 5 with IDiagramModelNote

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

the class ArchimateDiagramConnectionPolicy method isValidConnection.

/**
 * @param source
 * @param target
 * @param relationshipType
 * @return True if valid connection source/target for connection type
 */
static boolean isValidConnection(IConnectable source, IConnectable target, EClass relationshipType) {
    /*
         * Diagram Connection from/to notes/groups/diagram refs.
         * Allowed between notes, visual groups, diagram refs and ArchiMate components
         */
    if (relationshipType == IArchimatePackage.eINSTANCE.getDiagramModelConnection()) {
        // Not circular
        if (source == target) {
            return false;
        }
        // Notes
        if (source instanceof IDiagramModelNote || target instanceof IDiagramModelNote) {
            return true;
        }
        // Groups
        if (source instanceof IDiagramModelGroup || target instanceof IDiagramModelGroup) {
            return !(source instanceof IDiagramModelArchimateComponent) && !(target instanceof IDiagramModelArchimateComponent);
        }
        // Diagram Refs
        if (source instanceof IDiagramModelReference || target instanceof IDiagramModelReference) {
            return !(source instanceof IDiagramModelArchimateComponent) && !(target instanceof IDiagramModelArchimateComponent);
        }
        return false;
    }
    // Connection from Archimate concept to Archimate concept (but not from relation to relation)
    if ((source instanceof IDiagramModelArchimateComponent && target instanceof IDiagramModelArchimateComponent) && !(source instanceof IDiagramModelArchimateConnection && target instanceof IDiagramModelArchimateConnection)) {
        // Special case if relationshipType == null. Means that the Magic connector is being used
        if (relationshipType == null) {
            return true;
        }
        IArchimateConcept sourceConcept = ((IDiagramModelArchimateComponent) source).getArchimateConcept();
        IArchimateConcept targetConcept = ((IDiagramModelArchimateComponent) target).getArchimateConcept();
        return ArchimateModelUtils.isValidRelationship(sourceConcept, targetConcept, relationshipType);
    }
    return false;
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote)

Aggregations

IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)7 Test (org.junit.Test)5 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)2 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)1 GroupEditPart (com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateElement (com.archimatetool.model.IArchimateElement)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)1 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 EClass (org.eclipse.emf.ecore.EClass)1 EditPart (org.eclipse.gef.EditPart)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1