Search in sources :

Example 1 with IViewpoint

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

use of com.archimatetool.model.viewpoints.IViewpoint 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 3 with IViewpoint

use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.

the class ArchimateDiagramEditor method createActions.

/**
 * Add some extra Actions - *after* the graphical viewer has been created
 */
@Override
@SuppressWarnings("unchecked")
protected void createActions(GraphicalViewer viewer) {
    super.createActions(viewer);
    ActionRegistry registry = getActionRegistry();
    IAction action;
    // Delete from Model
    action = new DeleteFromModelAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    // Viewpoints
    for (IViewpoint viewPoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        action = new ViewpointAction(this, viewPoint);
        registry.registerAction(action);
    }
    // Find/Replace
    action = new FindReplaceAction(getEditorSite().getWorkbenchWindow());
    registry.registerAction(action);
    // Generate View For
    action = new GenerateViewAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
}
Also used : ViewpointAction(com.archimatetool.editor.diagram.actions.ViewpointAction) IAction(org.eclipse.jface.action.IAction) DeleteFromModelAction(com.archimatetool.editor.diagram.actions.DeleteFromModelAction) FindReplaceAction(com.archimatetool.editor.diagram.actions.FindReplaceAction) GenerateViewAction(com.archimatetool.editor.diagram.actions.GenerateViewAction) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry)

Example 4 with IViewpoint

use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.

the class ArchimateDiagramEditorActionBarContributor method buildActions.

@Override
protected void buildActions() {
    super.buildActions();
    // Delete From Model
    RetargetAction retargetAction = new RetargetAction(DeleteFromModelAction.ID, DeleteFromModelAction.TEXT);
    addRetargetAction(retargetAction);
    // Viewpoints
    for (IViewpoint viewPoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        retargetAction = new RetargetAction(viewPoint.toString(), viewPoint.getName(), IAction.AS_RADIO_BUTTON);
        addRetargetAction(retargetAction);
    }
}
Also used : RetargetAction(org.eclipse.ui.actions.RetargetAction) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint)

Example 5 with IViewpoint

use of com.archimatetool.model.viewpoints.IViewpoint in project archi by archimatetool.

the class ArchimateDiagramEditorContextMenuProvider method buildContextMenu.

/**
 * @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
 */
@Override
public void buildContextMenu(IMenuManager menu) {
    super.buildContextMenu(menu);
    // Delete from Model
    menu.appendToGroup(GROUP_EDIT, actionRegistry.getAction(DeleteFromModelAction.ID));
    // Select Element in Tree
    menu.appendToGroup(GROUP_RENAME, new Separator());
    menu.appendToGroup(GROUP_RENAME, actionRegistry.getAction(SelectElementInTreeAction.ID));
    // Generate View For Element
    menu.appendToGroup(GROUP_RENAME, actionRegistry.getAction(ArchiActionFactory.GENERATE_VIEW.getId()));
    // Viewpoints
    menu.appendToGroup(GROUP_CONNECTIONS, new Separator(GROUP_VIEWPOINTS));
    IMenuManager viewPointMenu = new MenuManager(Messages.ArchimateDiagramEditorContextMenuProvider_0);
    menu.appendToGroup(GROUP_VIEWPOINTS, viewPointMenu);
    for (IViewpoint viewPoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        viewPointMenu.add(actionRegistry.getAction(viewPoint.toString()));
    }
}
Also used : IMenuManager(org.eclipse.jface.action.IMenuManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) Separator(org.eclipse.jface.action.Separator)

Aggregations

IViewpoint (com.archimatetool.model.viewpoints.IViewpoint)14 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IMenuManager (org.eclipse.jface.action.IMenuManager)3 MenuManager (org.eclipse.jface.action.MenuManager)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 IAction (org.eclipse.jface.action.IAction)2 Separator (org.eclipse.jface.action.Separator)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Viewer (org.eclipse.jface.viewers.Viewer)2 GridData (org.eclipse.swt.layout.GridData)2 Combo (org.eclipse.swt.widgets.Combo)2 DeleteFromModelAction (com.archimatetool.editor.diagram.actions.DeleteFromModelAction)1 FindReplaceAction (com.archimatetool.editor.diagram.actions.FindReplaceAction)1 GenerateViewAction (com.archimatetool.editor.diagram.actions.GenerateViewAction)1