Search in sources :

Example 51 with MenuManager

use of org.eclipse.jface.action.MenuManager 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 52 with MenuManager

use of org.eclipse.jface.action.MenuManager in project xtext-eclipse by eclipse.

the class OutlinePage method configureContextMenu.

/**
 * @since 2.4
 */
protected void configureContextMenu() {
    MenuManager menuManager = new MenuManager(CONTEXT_MENU_ID, CONTEXT_MENU_ID);
    menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(getTreeViewer().getTree());
    getTreeViewer().getTree().setMenu(contextMenu);
    getSite().registerContextMenu(MENU_ID, menuManager, getTreeViewer());
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator)

Example 53 with MenuManager

use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.

the class UserPropertiesManagerDialog method hookContextMenu.

/**
 * Hook into a right-click menu
 */
private void hookContextMenu() {
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PropertiesManagerPopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(fTableViewer.getControl());
    fTableViewer.getControl().setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 54 with MenuManager

use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.

the class HeapStatusWidget method createContextMenu.

/**
 * Creates the context menu
 */
private void createContextMenu() {
    MenuManager menuMgr = new MenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuMgr) {
            fillMenu(menuMgr);
        }
    });
    Menu menu = menuMgr.createContextMenu(this);
    setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 55 with MenuManager

use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.

the class StyledTextControl method hookContextMenu.

/**
 * Hook into a right-click menu
 */
private void hookContextMenu() {
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu1");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(fStyledText);
    fStyledText.setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

MenuManager (org.eclipse.jface.action.MenuManager)657 IMenuManager (org.eclipse.jface.action.IMenuManager)498 Menu (org.eclipse.swt.widgets.Menu)303 IMenuListener (org.eclipse.jface.action.IMenuListener)246 Separator (org.eclipse.jface.action.Separator)220 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)65 Point (org.eclipse.swt.graphics.Point)63 Action (org.eclipse.jface.action.Action)55 Composite (org.eclipse.swt.widgets.Composite)49 IAction (org.eclipse.jface.action.IAction)48 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 GridData (org.eclipse.swt.layout.GridData)44 GroupMarker (org.eclipse.jface.action.GroupMarker)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Transfer (org.eclipse.swt.dnd.Transfer)35 GridLayout (org.eclipse.swt.layout.GridLayout)32 List (java.util.List)30 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30