Search in sources :

Example 11 with IDiagramModelReference

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());
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) DiagramImageEditPart(com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart) DiagramConnectionEditPart(com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) Test(org.junit.Test)

Example 12 with IDiagramModelReference

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));
        }
    }
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModel(com.archimatetool.model.IDiagramModel) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 13 with IDiagramModelReference

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()));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Test(org.junit.Test)

Example 14 with IDiagramModelReference

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());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Test(org.junit.Test)

Example 15 with IDiagramModelReference

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());
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

Aggregations

IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)17 IDiagramModel (com.archimatetool.model.IDiagramModel)7 Test (org.junit.Test)7 EObject (org.eclipse.emf.ecore.EObject)5 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)4 EditPart (org.eclipse.gef.EditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)2 IObjectUIProvider (com.archimatetool.editor.ui.factory.IObjectUIProvider)2 IArchimateConcept (com.archimatetool.model.IArchimateConcept)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)2 IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)2 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)2 ArrayList (java.util.ArrayList)2 ICanvasModel (com.archimatetool.canvas.model.ICanvasModel)1 DiagramImageEditPart (com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart)1 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)1