use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class DiagramModelUtilsTests method getAncestorContainer.
// =================================================================================================
@Test
public void getAncestorContainer() {
IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
IDiagramModelGroup group1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelGroup group2 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelObject child = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
dm.getChildren().add(group1);
group1.getChildren().add(group2);
assertNull(DiagramModelUtils.getAncestorContainer(child));
group2.getChildren().add(child);
assertEquals(group1, DiagramModelUtils.getAncestorContainer(child));
}
use of com.archimatetool.model.IDiagramModelGroup in project archi by archimatetool.
the class DiagramModelUtilsTests method isArchimateConceptReferencedInDiagrams.
@Test
public void isArchimateConceptReferencedInDiagrams() {
// This should be in a diagram
IArchimateElement element = (IArchimateElement) tm.getObjectByID(data1[0][0]);
assertNotNull(element);
assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
// This should be in a diagram
element = (IArchimateElement) tm.getObjectByID(data2[0][0]);
assertNotNull(element);
assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
// This should not be in a diagram
element = IArchimateFactory.eINSTANCE.createBusinessActor();
model.getDefaultFolderForObject(element).getElements().add(element);
assertFalse(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
// Unless we add it to a diagram
// And we'll nest it inside a Group to be cunning
IDiagramModelArchimateObject dmo = ArchimateTestModel.createDiagramModelArchimateObject(element);
IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
group.getChildren().add(dmo);
model.getDefaultDiagramModel().getChildren().add(group);
assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element));
}
use of com.archimatetool.model.IDiagramModelGroup 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.IDiagramModelGroup in project archi by archimatetool.
the class SketchEditPartFactoryTests method testSketchGroupEditPart.
@Test
public void testSketchGroupEditPart() {
IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
EditPart editPart = editPartFactory.createEditPart(null, group);
assertTrue(editPart instanceof SketchGroupEditPart);
assertEquals(group, editPart.getModel());
}
use of com.archimatetool.model.IDiagramModelGroup 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