Search in sources :

Example 11 with IViewpoint

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

the class ArchimateDiagramEditorActionBarContributor method createViewMenu.

@Override
protected IMenuManager createViewMenu(IMenuManager menuManager) {
    IMenuManager viewMenu = super.createViewMenu(menuManager);
    // Viewpoints
    IMenuManager viewPointMenu = new MenuManager(Messages.ArchimateDiagramEditorActionBarContributor_0);
    viewMenu.add(viewPointMenu);
    for (IViewpoint viewPoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        viewPointMenu.add(getAction(viewPoint.toString()));
    }
    return viewMenu;
}
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)

Example 12 with IViewpoint

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

the class ViewpointSection method update.

@Override
protected void update() {
    if (fIsExecutingCommand) {
        return;
    }
    String id = ((IArchimateDiagramModel) getFirstSelectedObject()).getViewpoint();
    IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
    // A Viewer will get a selectionChanged event when setting it
    fIsRefreshing = true;
    fComboViewer.setSelection(new StructuredSelection(viewPoint));
    fIsRefreshing = false;
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 13 with IViewpoint

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

the class ViewpointSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.ViewpointSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboViewer = new ComboViewer(new Combo(parent, SWT.READ_ONLY | SWT.BORDER));
    fComboViewer.getCombo().setVisibleItemCount(12);
    fComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    getWidgetFactory().adapt(fComboViewer.getControl(), true, true);
    fComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (fIsRefreshing) {
                // A Viewer will get a selectionChanged event when setting it
                return;
            }
            IViewpoint viewPoint = (IViewpoint) ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (viewPoint != null) {
                CompoundCommand result = new CompoundCommand();
                for (EObject diagramModel : getEObjects()) {
                    if (isAlive(diagramModel)) {
                        Command cmd = new EObjectFeatureCommand(Messages.ViewpointSection_1, diagramModel, IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL__VIEWPOINT, viewPoint.getID());
                        if (cmd.canExecute()) {
                            result.add(cmd);
                        }
                    }
                }
                executeCommand(result.unwrap());
            }
        }
    });
    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 ViewpointManager.INSTANCE.getAllViewpoints().toArray();
        }
    });
    fComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IViewpoint) element).getName();
        }
    });
    // $NON-NLS-1$
    fComboViewer.setInput("");
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Viewer(org.eclipse.jface.viewers.Viewer) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ComboViewer(org.eclipse.jface.viewers.ComboViewer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObject(org.eclipse.emf.ecore.EObject) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) EObject(org.eclipse.emf.ecore.EObject) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 14 with IViewpoint

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

the class ZestViewerContentProviderTests method testSetViewpointFilter.

@Test
public void testSetViewpointFilter() {
    // Default VP
    IViewpoint defaultViewpoint = ViewpointManager.NONE_VIEWPOINT;
    assertTrue(provider.getViewpointFilter() == defaultViewpoint);
    provider.setViewpointFilter(ViewpointManager.INSTANCE.getAllViewpoints().get(1));
    assertSame(provider.getViewpointFilter(), ViewpointManager.INSTANCE.getAllViewpoints().get(1));
    // Back to default
    provider.setViewpointFilter(defaultViewpoint);
}
Also used : IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) Test(org.junit.Test)

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