Search in sources :

Example 6 with IArchimateElement

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

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

the class GenerateViewAction method run.

@Override
public void run() {
    List<IArchimateElement> selected = getValidSelectedObjects(getSelection());
    if (!selected.isEmpty()) {
        GenerateViewCommand command = new GenerateViewCommand(selected);
        if (command.openDialog(Display.getCurrent().getActiveShell())) {
            CommandStack commandStack = (CommandStack) ((IAdapter) selected.get(0)).getAdapter(CommandStack.class);
            commandStack.execute(command);
        }
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchimateElement(com.archimatetool.model.IArchimateElement) GenerateViewCommand(com.archimatetool.editor.tools.GenerateViewCommand)

Example 8 with IArchimateElement

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

the class UnusedElementsChecker method findUnusedElements.

List<IIssue> findUnusedElements() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateElement element : fArchimateElements) {
        if (!DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element)) {
            String name = ArchiLabelProvider.INSTANCE.getLabel(element);
            String description = NLS.bind(DESCRIPTION, name);
            String explanation = NLS.bind(EXPLANATION, name);
            IIssue issue = new WarningType(NAME, description, explanation, element);
            issues.add(issue);
        }
    }
    return issues;
}
Also used : ArrayList(java.util.ArrayList) WarningType(com.archimatetool.hammer.validation.issues.WarningType) IArchimateElement(com.archimatetool.model.IArchimateElement) IIssue(com.archimatetool.hammer.validation.issues.IIssue)

Example 9 with IArchimateElement

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

the class ViewpointChecker method findComponentsInWrongViewpoints.

List<IIssue> findComponentsInWrongViewpoints() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateDiagramModel dm : fViews) {
        String id = dm.getViewpoint();
        IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
        for (Iterator<EObject> iter = dm.eAllContents(); iter.hasNext(); ) {
            EObject eObject = iter.next();
            if (eObject instanceof IDiagramModelArchimateObject) {
                IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
                IArchimateElement element = dmo.getArchimateElement();
                if (!viewPoint.isAllowedConcept(element.eClass())) {
                    IIssue issue = createIssue(dmo, dm.getName(), viewPoint.getName());
                    issues.add(issue);
                }
            }
        }
    }
    return issues;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 10 with IArchimateElement

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

the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept_NoRelations.

@Test
public void testGetAllRelationshipsForConcept_NoRelations() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element1).getElements().add(element1);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
    model.getDefaultFolderForObject(element2).getElements().add(element2);
    assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element1).isEmpty());
    assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element2).isEmpty());
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3