use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class CanvasModelEditPartFactoryTests method testSketchDiagramModelReferenceEditPart.
@Test
public void testSketchDiagramModelReferenceEditPart() {
IDiagramModelReference ref = IArchimateFactory.eINSTANCE.createDiagramModelReference();
EditPart editPart = editPartFactory.createEditPart(null, ref);
assertTrue(editPart instanceof CanvasDiagramModelReferenceEditPart);
assertEquals(ref, editPart.getModel());
}
use of com.archimatetool.model.IDiagramModelReference in project archi-modelrepository-plugin by archi-contribs.
the class GraficoModelImporter method resolveProxies.
/**
* Iterate through all model objects, and resolve proxies on known classes
*/
private void resolveProxies() {
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateRelationship) {
// Resolve proxies for Relations
IArchimateRelationship relation = (IArchimateRelationship) eObject;
relation.setSource((IArchimateConcept) resolve(relation.getSource(), relation));
relation.setTarget((IArchimateConcept) resolve(relation.getTarget(), relation));
} else if (eObject instanceof IDiagramModelArchimateObject) {
// Resolve proxies for Elements
IDiagramModelArchimateObject element = (IDiagramModelArchimateObject) eObject;
element.setArchimateElement((IArchimateElement) resolve(element.getArchimateElement(), element));
// Update cross-references
element.getArchimateElement().getReferencingDiagramObjects().add(element);
} else if (eObject instanceof IDiagramModelArchimateConnection) {
// Resolve proxies for Connections
IDiagramModelArchimateConnection archiConnection = (IDiagramModelArchimateConnection) eObject;
archiConnection.setArchimateRelationship((IArchimateRelationship) resolve(archiConnection.getArchimateRelationship(), archiConnection));
// Update cross-reference
archiConnection.getArchimateRelationship().getReferencingDiagramConnections().add(archiConnection);
} else if (eObject instanceof IDiagramModelReference) {
// Resolve proxies for Model References
IDiagramModelReference element = (IDiagramModelReference) eObject;
element.setReferencedModel((IDiagramModel) resolve(element.getReferencedModel(), element));
}
}
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DeleteCommandHandlerTests method testDelete_DiagramModel_Deleted_Diagram_Reference.
@Test
public void testDelete_DiagramModel_Deleted_Diagram_Reference() {
IDiagramModel dm2 = model.getDiagramModels().get(1);
// Reference to dm2 in dm1
IDiagramModelReference dmRef = (IDiagramModelReference) ArchimateModelUtils.getObjectByID(model, "99a52921");
assertNotNull(dmRef);
// Zap
DeleteCommandHandler commandHandler = new DeleteCommandHandler(treeModelViewer, new Object[] { dm2 });
commandHandler.delete();
// All gone
assertNull(ArchimateModelUtils.getObjectByID(model, dm2.getId()));
assertNull(ArchimateModelUtils.getObjectByID(model, dmRef.getId()));
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DiagramModelUtilsTests method findDiagramModelReferences.
// =================================================================================================
@Test
public void findDiagramModelReferences() {
IDiagramModel diagramModel1 = tm.addNewArchimateDiagramModel();
IDiagramModel diagramModel2 = tm.addNewArchimateDiagramModel();
IDiagramModel diagramModel3 = tm.addNewArchimateDiagramModel();
// Should not be found
List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel1);
assertTrue(list.isEmpty());
// Create some child objects
createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel3);
// Create some refs
IDiagramModelReference ref1 = IArchimateFactory.eINSTANCE.createDiagramModelReference();
ref1.setReferencedModel(diagramModel1);
diagramModel3.getChildren().add(ref1);
IDiagramModelReference ref2 = IArchimateFactory.eINSTANCE.createDiagramModelReference();
ref2.setReferencedModel(diagramModel2);
dmo4.getChildren().add(ref2);
list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel1);
assertEquals(1, list.size());
list = DiagramModelUtils.findDiagramModelReferences(diagramModel3, diagramModel2);
assertEquals(1, list.size());
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DiagramModelReferenceEditPart method addECoreAdapter.
@Override
protected void addECoreAdapter() {
super.addECoreAdapter();
// Listen to referenced model
IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
if (ref != null) {
ref.eAdapters().add(getECoreAdapter());
}
}
Aggregations