Search in sources :

Example 1 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept 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 2 with IArchimateConcept

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

the class ValidatorView method selectObjects.

void selectObjects(IStructuredSelection selection) {
    if (selection != null) {
        List<IArchimateConcept> treeList = new ArrayList<IArchimateConcept>();
        List<IDiagramModel> viewList = new ArrayList<IDiagramModel>();
        List<IDiagramModelComponent> viewComponentList = new ArrayList<IDiagramModelComponent>();
        for (Object o : selection.toArray()) {
            if (o instanceof IIssue) {
                IIssue issue = (IIssue) o;
                if (issue.getObject() instanceof IArchimateConcept) {
                    treeList.add((IArchimateConcept) issue.getObject());
                } else if (issue.getObject() instanceof IDiagramModel) {
                    viewList.add((IDiagramModel) issue.getObject());
                } else if (issue.getObject() instanceof IDiagramModelComponent) {
                    viewList.add(((IDiagramModelComponent) issue.getObject()).getDiagramModel());
                    viewComponentList.add(((IDiagramModelComponent) issue.getObject()));
                }
            }
        }
        if (!treeList.isEmpty()) {
            ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, false);
            if (view != null) {
                view.getViewer().setSelection(new StructuredSelection(treeList), true);
            }
        }
        if (!viewList.isEmpty()) {
            for (IDiagramModel dm : viewList) {
                IDiagramModelEditor editor = EditorManager.openDiagramEditor(dm);
                if (editor instanceof IArchimateDiagramEditor) {
                    ((IArchimateDiagramEditor) editor).selectObjects(viewComponentList.toArray());
                }
            }
        }
    }
}
Also used : ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IDiagramModelEditor(com.archimatetool.editor.diagram.IDiagramModelEditor) IArchimateDiagramEditor(com.archimatetool.editor.diagram.IArchimateDiagramEditor) IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IIssue(com.archimatetool.hammer.validation.issues.IIssue)

Example 3 with IArchimateConcept

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

the class TreeViewpointFilterProvider method getTextColor.

/**
 * If the element is disallowed in a Viewpoint grey it out
 * @param element
 * @return Color or null
 */
Color getTextColor(Object element) {
    if (isActive() && fActiveDiagramModel != null && element instanceof IArchimateConcept) {
        String id = fActiveDiagramModel.getViewpoint();
        IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
        if (viewpoint != null) {
            // From same model as active diagram
            IArchimateModel model = ((IArchimateConcept) element).getArchimateModel();
            if (model == fActiveDiagramModel.getArchimateModel()) {
                if (element instanceof IArchimateRelationship) {
                    IArchimateConcept source = ((IArchimateRelationship) element).getSource();
                    IArchimateConcept target = ((IArchimateRelationship) element).getTarget();
                    if (!viewpoint.isAllowedConcept(source.eClass()) || !viewpoint.isAllowedConcept(target.eClass())) {
                        return ColorFactory.get(128, 128, 128);
                    }
                } else if (element instanceof IArchimateElement) {
                    if (!viewpoint.isAllowedConcept(((IArchimateElement) element).eClass())) {
                        return ColorFactory.get(128, 128, 128);
                    }
                }
            }
        }
    }
    return null;
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 4 with IArchimateConcept

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

the class ArchimateModelUtilsTests method testHasDirectRelationship.

/*
     * NOTE - Tests for ArchimateModelUtils.isValidRelationshipStart() and ArchimateModelUtils.isValidRelationship() are in ViewpointTests
     */
@Test
public void testHasDirectRelationship() {
    IArchimateConcept sourceConcept = IArchimateFactory.eINSTANCE.createBusinessActor();
    IArchimateConcept someTarget = IArchimateFactory.eINSTANCE.createBusinessRole();
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    assertFalse(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
    assertFalse(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
    relationship.connect(sourceConcept, someTarget);
    assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
    assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
    relationship.connect(someTarget, sourceConcept);
    assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
    assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 5 with IArchimateConcept

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

the class HTMLReportExporterTests method testCreateReport.

@Test
public void testCreateReport() throws Exception {
    // Create test model
    ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IArchimateModel model = tm.loadModel();
    // Create Exporter and output folder
    HTMLReportExporter exporter = new HTMLReportExporter(model);
    File targetFolder = TestUtils.createTempFolder("archi-html-report");
    File outputFile = exporter.createReport(targetFolder, "index.html");
    // Check main file and folders exist
    assertTrue(outputFile.exists());
    File modelFolder = new File(targetFolder, model.getId());
    assertTrue(modelFolder.exists());
    File elementsFolder = new File(modelFolder, "elements");
    assertTrue(elementsFolder.exists());
    File imagesFolder = new File(modelFolder, "images");
    assertTrue(imagesFolder.exists());
    File viewsFolder = new File(modelFolder, "views");
    assertTrue(viewsFolder.exists());
    assertTrue(new File(targetFolder, "css").exists());
    assertTrue(new File(targetFolder, "elements").exists());
    assertTrue(new File(targetFolder, "hints").exists());
    assertTrue(new File(targetFolder, "js").exists());
    assertTrue(new File(targetFolder, "lib").exists());
    // Check element and view files created
    assertTrue(new File(elementsFolder, "model.html").exists());
    for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        // Concepts
        if (eObject instanceof IArchimateConcept) {
            assertTrue(new File(elementsFolder, ((IArchimateConcept) eObject).getId() + ".html").exists());
        }
        // Views & Images
        if (eObject instanceof IArchimateDiagramModel) {
            assertTrue(new File(imagesFolder, ((IArchimateDiagramModel) eObject).getId() + ".png").exists());
            assertTrue(new File(viewsFolder, ((IArchimateDiagramModel) eObject).getId() + ".html").exists());
        }
    }
    // Clean up
    FileUtils.deleteFolder(TestUtils.TMP_FOLDER);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateModel(com.archimatetool.model.IArchimateModel) File(java.io.File) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Aggregations

IArchimateConcept (com.archimatetool.model.IArchimateConcept)38 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)14 ArrayList (java.util.ArrayList)9 IDiagramModel (com.archimatetool.model.IDiagramModel)7 EObject (org.eclipse.emf.ecore.EObject)7 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Test (org.junit.Test)6 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)3 IDiagramModelEditor (com.archimatetool.editor.diagram.IDiagramModelEditor)3 IArchimateModel (com.archimatetool.model.IArchimateModel)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 CSVParseException (com.archimatetool.csv.CSVParseException)2 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)2 IConnectable (com.archimatetool.model.IConnectable)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2