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());
}
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));
}
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());
}
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());
}
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;
}
Aggregations