Search in sources :

Example 1 with IDiagramModelReference

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

the class DiagramModelReferenceEditPart method removeECoreAdapter.

@Override
protected void removeECoreAdapter() {
    super.removeECoreAdapter();
    // Unlisten to referenced model
    IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
    if (ref != null) {
        ref.eAdapters().remove(getECoreAdapter());
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

Example 2 with IDiagramModelReference

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

the class DiagramModelReferenceFigure method drawIcon.

/**
 * Draw the icon
 */
protected void drawIcon(Graphics graphics) {
    // Draw the icon depending on the diagramModelObject
    IDiagramModel dm = ((IDiagramModelReference) getDiagramModelObject()).getReferencedModel();
    IGraphicsIcon graphicsIcon = ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(dm);
    if (graphicsIcon != null) {
        graphicsIcon.drawIcon(graphics, getIconOrigin());
    }
}
Also used : IGraphicsIcon(com.archimatetool.editor.ui.IGraphicsIcon) IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference)

Example 3 with IDiagramModelReference

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

the class DeleteCommandHandler method getElementsToDelete.

/**
 * Create the list of objects to delete and check
 * @return
 */
private void getElementsToDelete() {
    // Actual elements to delete
    fElementsToDelete = new ArrayList<Object>();
    // First, gather up the list of Archimate objects to be deleted...
    for (Object object : fSelectedObjects) {
        if (canDelete(object)) {
            addToList(object, fElementsToDelete);
            addFolderChildElements(object);
            addElementRelationships(object);
        }
    }
    // Gather referenced diagram objects to be deleted checking that the parent diagram model is not also selected to be deleted
    for (Object object : new ArrayList<>(fElementsToDelete)) {
        // Archimate Components
        if (object instanceof IArchimateConcept) {
            IArchimateConcept archimateConcept = (IArchimateConcept) object;
            for (IDiagramModel diagramModel : archimateConcept.getArchimateModel().getDiagramModels()) {
                // Check diagram model is not selected to be deleted - no point in deleting any of its children
                if (!fElementsToDelete.contains(diagramModel)) {
                    for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, archimateConcept)) {
                        addToList(dc, fElementsToDelete);
                    }
                }
            }
        }
        // Diagram Models and their references
        if (object instanceof IDiagramModel) {
            IDiagramModel diagramModelDeleted = (IDiagramModel) object;
            for (IDiagramModel diagramModel : diagramModelDeleted.getArchimateModel().getDiagramModels()) {
                // is there one?
                List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel, diagramModelDeleted);
                fElementsToDelete.addAll(list);
            }
        }
    }
}
Also used : IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) ArrayList(java.util.ArrayList) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) EObject(org.eclipse.emf.ecore.EObject)

Example 4 with IDiagramModelReference

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

the class CreateMapViewCheatSheetActionTests method testNewMapViewCommand.

@Test
public void testNewMapViewCommand() throws IOException {
    // Load ArchiMate model
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IArchimateModel model = tm.loadModel();
    // Has 17 diagrams
    assertEquals(17, model.getDiagramModels().size());
    NewMapViewCommand cmd = new NewMapViewCommand(model);
    cmd.execute();
    assertNotNull(cmd.diagramModel);
    assertNotNull(cmd.diagramModel.eContainer());
    // Model now has 18 diagrams
    assertEquals(18, model.getDiagramModels().size());
    // New diagram has 17 children...
    assertEquals(17, cmd.diagramModel.getChildren().size());
    // ...all of which are IDiagramModelReference types with IDs
    for (IDiagramModelObject dmo : cmd.diagramModel.getChildren()) {
        assertTrue(dmo instanceof IDiagramModelReference);
        assertNotNull(dmo.getId());
    }
    // Undo
    cmd.undo();
    assertEquals(17, model.getDiagramModels().size());
    assertNull(cmd.diagramModel.eContainer());
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) NewMapViewCommand(com.archimatetool.help.cheatsheets.CreateMapViewCheatSheetAction.NewMapViewCommand) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 5 with IDiagramModelReference

use of com.archimatetool.model.IDiagramModelReference 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)

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