Search in sources :

Example 76 with MenuManager

use of org.eclipse.jface.action.MenuManager in project linuxtools by eclipse.

the class GcovTest method testGcovSummaryByLaunch.

@Test
public void testGcovSummaryByLaunch() {
    display.syncExec(() -> {
        try {
            CommonNavigator vc = (CommonNavigator) window.getActivePage().showView(ProjectExplorer.VIEW_ID);
            vc.selectReveal(new StructuredSelection(project.getFile(getBinName())));
            Menu menu = new MenuManager().createContextMenu(vc.getCommonViewer().getControl());
            new ProfileContextualLaunchAction(menu);
            for (MenuItem item : menu.getItems()) {
                if (item.getText().endsWith("Profile Code Coverage")) {
                    ((ActionContributionItem) item.getData()).getAction().run();
                    break;
                }
            }
        } catch (PartInitException e1) {
            Assert.fail("Cannot show Project Explorer.");
        }
        try {
            window.getActivePage().showView("org.eclipse.linuxtools.gcov.view");
        } catch (PartInitException e2) {
            Assert.fail("Cannot show GCov View.");
        }
    });
    // Wait for the build job to finish (note: DebugUIPlugin doesn't put launch jobs in a family)
    Job[] jobs = Job.getJobManager().find(null);
    for (Job job : jobs) {
        if (job.getName().contains("Gcov")) {
            try {
                job.join();
            } catch (InterruptedException e) {
            }
            break;
        }
    }
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MenuManager(org.eclipse.jface.action.MenuManager) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) Job(org.eclipse.core.runtime.jobs.Job) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 77 with MenuManager

use of org.eclipse.jface.action.MenuManager in project linuxtools by eclipse.

the class SystemTapView method addFileMenu.

/**
 * Create File menu -- calls the abstract protected methods
 * <code>createOpenAction()</code> and <code>createOpenDefaultAction()</code>. Have
 * these methods return false if you do not wish to create an Open or Open Default
 * option in the File menu of your view.
 */
public void addFileMenu() {
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    if (file == null) {
        // $NON-NLS-1$
        file = new MenuManager(Messages.getString("SystemTapView.FileMenu"));
        menu.add(file);
    }
    if (createOpenAction()) {
        file.add(openFile);
    }
    if (createOpenDefaultAction()) {
        file.add(openDefault);
    }
    createSaveAction();
    file.add(saveFile);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 78 with MenuManager

use of org.eclipse.jface.action.MenuManager in project linuxtools by eclipse.

the class UIUtils method createContextMenu.

/**
 * Creates context menu to a given control.
 *
 * @param control
 *            the control
 *
 * @return the i menu manager
 */
public static IMenuManager createContextMenu(final Control control) {
    Assert.isTrue(control != null && !control.isDisposed());
    MenuManager menuManager = new MenuManager();
    menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    Menu menu = menuManager.createContextMenu(control);
    control.setMenu(menu);
    return menuManager;
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) GroupMarker(org.eclipse.jface.action.GroupMarker) Menu(org.eclipse.swt.widgets.Menu)

Example 79 with MenuManager

use of org.eclipse.jface.action.MenuManager in project linuxtools by eclipse.

the class DockerImagesView method hookContextMenu.

private void hookContextMenu() {
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    // menuMgr.addMenuListener(new IMenuListener() {
    // public void menuAboutToShow(IMenuManager manager) {
    // DockerContainersView.this.fillContextMenu(manager);
    // }
    // });
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, viewer);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 80 with MenuManager

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

the class KNIMEApplicationActionBarAdvisor method fillMenuBar.

/**
 * Fills the menu bar with the main menus for the windows. Some anchors were
 * added below the last action of each division for convenience.
 * These anchors are named after the action above them, e.g.:
 * "file/ImportPreferences" is located below "Import Preferences..."
 * but above the separator.
 *
 * {@inheritDoc}
 */
@Override
protected void fillMenuBar(final IMenuManager menuBar) {
    menuBar.remove(IWorkbenchActionConstants.MB_ADDITIONS);
    final MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
    MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
    MenuManager viewMenu = new MenuManager("&View", IWorkbenchActionConstants.M_VIEW);
    MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
    // 1. File menu
    menuBar.add(fileMenu);
    // 2. Edit menu
    menuBar.add(editMenu);
    // 3. View menu
    menuBar.add(viewMenu);
    // Add a group marker indicating where action set menus will appear.
    GroupMarker marker = new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS);
    marker.setVisible(false);
    menuBar.add(marker);
    // last: Help menu
    menuBar.add(helpMenu);
    // File menu
    fileMenu.add(m_newAction);
    fileMenu.add(m_saveAction);
    fileMenu.add(m_saveAsAction);
    fileMenu.add(m_saveAllAction);
    fileMenu.add(m_closeAllAction);
    fileMenu.add(m_print);
    fileMenu.add(m_importWorkflowAction);
    fileMenu.add(m_exportWorkflowAction);
    fileMenu.add(new GroupMarker("ExportWorkflow"));
    fileMenu.add(new Separator());
    fileMenu.add(m_changeWorkspaceAction);
    fileMenu.add(new GroupMarker("SwitchWorkspace"));
    fileMenu.add(new Separator());
    fileMenu.add(m_preferencesAction);
    fileMenu.add(m_exportPrefAction);
    fileMenu.add(m_importPrefAction);
    fileMenu.add(new GroupMarker("ImportPreferences"));
    fileMenu.add(new Separator());
    fileMenu.add(m_installFeaturesAction);
    fileMenu.add(m_updateKnimeAction);
    fileMenu.add(new GroupMarker("UpdateKNIME"));
    fileMenu.add(new Separator());
    fileMenu.add(m_exitAction);
    // Edit menu
    editMenu.add(m_undoAction);
    editMenu.add(m_redoAction);
    fileMenu.add(new GroupMarker("Redo"));
    editMenu.add(new Separator());
    editMenu.add(m_cutAction);
    editMenu.add(m_copyAction);
    editMenu.add(m_pasteAction);
    fileMenu.add(new GroupMarker("Paste"));
    editMenu.add(new Separator());
    editMenu.add(m_deleteAction);
    editMenu.add(m_selectAllAction);
    editMenu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
    // View menu
    addMultiViewsToMenu(viewMenu);
    viewMenu.add(m_showViewShortlistContributionItem);
    viewMenu.add(m_resetPerspective);
    // Help menu
    // helpMenu.add(m_introAction);
    helpMenu.add(m_helpAction);
    helpMenu.add(m_helpSearchAction);
    helpMenu.add(m_introAction);
    // menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    helpMenu.add(m_aboutAction);
    final String[] unwanted = new String[] { "org.eclipse.birt.report.designer.ui.LibraryPublisAction", "org.eclipse.birt.report.designer.ui.TemplatepublisAction" };
    fileMenu.addMenuListener(new IMenuListener() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void menuAboutToShow(final IMenuManager mgr) {
            for (String id : unwanted) {
                fileMenu.remove(id);
            }
        }
    });
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) GroupMarker(org.eclipse.jface.action.GroupMarker) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator) 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