Search in sources :

Example 6 with IViewpoint

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

the class ViewModelDataSource method getViewpointName.

public String getViewpointName() {
    if (fCurrentView instanceof IArchimateDiagramModel) {
        String id = ((IArchimateDiagramModel) fCurrentView).getViewpoint();
        IViewpoint vp = ViewpointManager.INSTANCE.getViewpoint(id);
        if (vp == ViewpointManager.NONE_VIEWPOINT) {
            return Messages.ViewModelDataSource_1;
        }
        String name = vp.getName();
        // $NON-NLS-1$
        return name == null ? "" : NLS.bind(Messages.ViewModelDataSource_0, name);
    }
    return null;
}
Also used : IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 7 with IViewpoint

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

the class ZestView method makeLocalToolBar.

/**
 * Populate the ToolBar
 */
private void makeLocalToolBar() {
    IActionBars bars = getViewSite().getActionBars();
    IToolBarManager manager = bars.getToolBarManager();
    fDrillDownManager.addNavigationActions(manager);
    manager.add(new Separator());
    manager.add(fActionPinContent);
    manager.add(new Separator());
    manager.add(fActionLayout);
    final IMenuManager menuManager = bars.getMenuManager();
    IMenuManager depthMenuManager = new MenuManager(Messages.ZestView_3);
    menuManager.add(depthMenuManager);
    // Depth Actions
    fDepthActions = new Action[6];
    for (int i = 0; i < fDepthActions.length; i++) {
        fDepthActions[i] = createDepthAction(i, i + 1);
        depthMenuManager.add(fDepthActions[i]);
    }
    // Set depth from prefs
    int depth = ArchiZestPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.VISUALISER_DEPTH);
    getContentProvider().setDepth(depth);
    fDepthActions[depth].setChecked(true);
    // Set filter based on Viewpoint
    IMenuManager viewpointMenuManager = new MenuManager(Messages.ZestView_5);
    menuManager.add(viewpointMenuManager);
    // Get viewpoint from prefs
    String viewpointID = ArchiZestPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.VISUALISER_VIEWPOINT);
    getContentProvider().setViewpointFilter(ViewpointManager.INSTANCE.getViewpoint(viewpointID));
    // Viewpoint actions
    fViewpointActions = new ArrayList<IAction>();
    for (IViewpoint vp : ViewpointManager.INSTANCE.getAllViewpoints()) {
        IAction action = createViewpointMenuAction(vp);
        fViewpointActions.add(action);
        viewpointMenuManager.add(action);
        // Set checked
        if (vp.getID().equals(viewpointID)) {
            action.setChecked(true);
        }
    }
    // Set filter based on Relationship
    IMenuManager relationshipMenuManager = new MenuManager(Messages.ZestView_6);
    menuManager.add(relationshipMenuManager);
    // Get relationship from prefs
    String relationshipID = ArchiZestPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.VISUALISER_RELATIONSHIP);
    EClass eClass = (EClass) IArchimatePackage.eINSTANCE.getEClassifier(relationshipID);
    getContentProvider().setRelationshipFilter(eClass);
    // Relationship actions, first the "None" relationship
    fRelationshipActions = new ArrayList<IAction>();
    IAction action = createRelationshipMenuAction(null);
    if (eClass == null) {
        action.setChecked(true);
    }
    fRelationshipActions.add(action);
    relationshipMenuManager.add(action);
    // Then get all relationships and sort them
    ArrayList<EClass> actionList = new ArrayList<EClass>(Arrays.asList(ArchimateModelUtils.getRelationsClasses()));
    actionList.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
    for (EClass rel : actionList) {
        action = createRelationshipMenuAction(rel);
        fRelationshipActions.add(action);
        relationshipMenuManager.add(action);
        // Set checked
        if (eClass != null && rel.getName().equals(eClass.getName())) {
            action.setChecked(true);
        }
    }
    // Orientation
    IMenuManager orientationMenuManager = new MenuManager(Messages.ZestView_32);
    menuManager.add(orientationMenuManager);
    // Direction
    fDirectionActions = new Action[3];
    fDirectionActions[0] = createOrientationMenuAction(0, Messages.ZestView_33, ZestViewerContentProvider.DIR_BOTH);
    orientationMenuManager.add(fDirectionActions[0]);
    fDirectionActions[1] = createOrientationMenuAction(1, Messages.ZestView_34, ZestViewerContentProvider.DIR_IN);
    orientationMenuManager.add(fDirectionActions[1]);
    fDirectionActions[2] = createOrientationMenuAction(2, Messages.ZestView_35, ZestViewerContentProvider.DIR_OUT);
    orientationMenuManager.add(fDirectionActions[2]);
    // Set direction from prefs
    int direction = ArchiZestPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.VISUALISER_DIRECTION);
    getContentProvider().setDirection(direction);
    fDirectionActions[direction].setChecked(true);
    menuManager.add(new Separator());
    menuManager.add(fActionSelectInModelTree);
    menuManager.add(fActionCopyImageToClipboard);
    menuManager.add(fActionExportImageToFile);
}
Also used : IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) EClass(org.eclipse.emf.ecore.EClass) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars) Separator(org.eclipse.jface.action.Separator)

Example 8 with IViewpoint

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

the class GenerateViewDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.GenerateViewDialog_1);
    // $NON-NLS-1$
    String message = "";
    for (Iterator<IArchimateElement> iter = fSelectedElements.iterator(); iter.hasNext(); ) {
        message += ArchiLabelProvider.INSTANCE.getLabel(iter.next());
        if (iter.hasNext()) {
            // $NON-NLS-1$
            message += ", ";
        } else {
            // $NON-NLS-1$
            message += ".";
        }
    }
    setMessage(message);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    layout.verticalSpacing = 20;
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label label = new Label(client, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_3);
    fComboViewer = new ComboViewer(new Combo(client, SWT.READ_ONLY | SWT.BORDER));
    fComboViewer.getCombo().setVisibleItemCount(12);
    fComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    for (IViewpoint viewpoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        boolean allowed = true;
        for (IArchimateElement element : fSelectedElements) {
            if (!viewpoint.isAllowedConcept(element.eClass())) {
                allowed = false;
                break;
            }
        }
        if (allowed && !fValidViewPoints.contains(viewpoint)) {
            fValidViewPoints.add(viewpoint);
        }
    }
    fComboViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return fValidViewPoints.toArray();
        }
    });
    fComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IViewpoint) element).getName();
        }
    });
    // $NON-NLS-1$
    fComboViewer.setInput("");
    label = new Label(client, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_2);
    fNameText = new Text(client, SWT.BORDER);
    fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // $NON-NLS-1$
    fNameText.setText(Messages.GenerateViewDialog_6 + " " + ArchiLabelProvider.INSTANCE.getLabel(fSelectedElements.get(0)));
    Group groupOptions = new Group(client, SWT.NONE);
    groupOptions.setText(Messages.GenerateViewDialog_4);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    groupOptions.setLayoutData(gd);
    groupOptions.setLayout(new GridLayout(2, false));
    label = new Label(groupOptions, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_5);
    fAddAllConnectionsButton = new Button(groupOptions, SWT.CHECK);
    loadPreferences();
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) Text(org.eclipse.swt.widgets.Text) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IArchimateElement(com.archimatetool.model.IArchimateElement) ArchiLabelProvider(com.archimatetool.editor.ui.ArchiLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 9 with IViewpoint

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

the class GenerateViewDialog method loadPreferences.

void loadPreferences() {
    IPreferenceStore store = ArchiPlugin.INSTANCE.getPreferenceStore();
    fAddAllConnectionsButton.setSelection(store.getBoolean(PREFS_ALLCONNECTIONS));
    String id = store.getString(PREFS_LASTVIEWPOINT);
    IViewpoint lastViewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
    if (!fValidViewPoints.contains(lastViewpoint)) {
        lastViewpoint = ViewpointManager.NONE_VIEWPOINT;
    }
    fComboViewer.setSelection(new StructuredSelection(lastViewpoint));
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint)

Example 10 with IViewpoint

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

the class MagicConnectionCreationTool method isAllowedTargetTypeInViewpoint.

/**
 * @return True if type is an allowed target type for a given Viewpoint
 */
private boolean isAllowedTargetTypeInViewpoint(IDiagramModelArchimateComponent diagramComponent, EClass type) {
    if (!Preferences.STORE.getBoolean(IPreferenceConstants.VIEWPOINTS_HIDE_MAGIC_CONNECTOR_ELEMENTS)) {
        return true;
    }
    IArchimateDiagramModel dm = (IArchimateDiagramModel) diagramComponent.getDiagramModel();
    String id = dm.getViewpoint();
    IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
    return viewpoint == null ? true : viewpoint.isAllowedConcept(type);
}
Also used : IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

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