Search in sources :

Example 91 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.text by eclipse.

the class SearchDropDownAction method getMenu.

@Override
public Menu getMenu(Control parent) {
    if (fMenu != null)
        fMenu.dispose();
    fMenu = new Menu(parent);
    boolean checkedOne = false;
    Iterator<Search> iter = SearchManager.getDefault().getPreviousSearches().iterator();
    Search selected = SearchManager.getDefault().getCurrentSearch();
    int i = 0;
    while (iter.hasNext() && i++ < RESULTS_IN_DROP_DOWN) {
        Search search = iter.next();
        ShowSearchAction action = new ShowSearchAction(search);
        action.setChecked(search.equals(selected));
        if (search.equals(selected))
            checkedOne = true;
        addActionToMenu(fMenu, action);
    }
    new MenuItem(fMenu, SWT.SEPARATOR);
    if (iter.hasNext()) {
        Action others = new ShowSearchesAction();
        others.setChecked(!checkedOne);
        addActionToMenu(fMenu, others);
    }
    addActionToMenu(fMenu, new RemoveAllSearchesAction());
    return fMenu;
}
Also used : Action(org.eclipse.jface.action.Action) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 92 with MenuItem

use of org.eclipse.swt.widgets.MenuItem 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 93 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project linuxtools by eclipse.

the class DataGrid method initMenus.

private Menu initMenus() {
    Menu menu = new Menu(table.getShell(), SWT.POP_UP);
    Menu formatMenu = new Menu(menu);
    formatMenuItem = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    formatMenuItem.setText(Localization.getString("DataGrid.FormatAs"));
    formatMenuItem.setMenu(formatMenu);
    filterMenu = new Menu(menu);
    MenuItem item = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    item.setText(Localization.getString("DataGrid.AddFilter"));
    item.addSelectionListener(new AddFilterSelection());
    removeFiltersMenuItem = new MenuItem(menu, SWT.CASCADE);
    // $NON-NLS-1$
    removeFiltersMenuItem.setText(Localization.getString("DataGrid.RemoveFilter"));
    removeFiltersMenuItem.setMenu(filterMenu);
    IDataSetFilter[] filters = filteredDataSet.getFilters();
    if (filters != null && filters.length > 0) {
        for (int i = 0; i < filters.length; i++) {
            item = new MenuItem(filterMenu, SWT.CASCADE);
            item.setText(AvailableFilterTypes.getFilterName(filters[i].getID()));
            item.setData(filters[i]);
            item.addSelectionListener(new RemoveFilterSelection());
        }
    } else {
        removeFiltersMenuItem.setEnabled(false);
    }
    autoResizeMenuItem = new MenuItem(menu, SWT.CHECK);
    // $NON-NLS-1$
    autoResizeMenuItem.setText(Localization.getString("DataGrid.AutoResize"));
    autoResizeMenuItem.setSelection(prefs.getBoolean(GraphingPreferenceConstants.P_AUTO_RESIZE));
    jumpToEntryMenuItem = new MenuItem(menu, SWT.CHECK);
    // $NON-NLS-1$
    jumpToEntryMenuItem.setText(Localization.getString("DataGrid.JumpToEntry"));
    jumpToEntryMenuItem.setSelection(prefs.getBoolean(GraphingPreferenceConstants.P_JUMP_NEW_TABLE_ENTRY));
    for (int i = 0; i < IFormattingStyles.FORMAT_TITLES.length; i++) {
        item = new MenuItem(formatMenu, SWT.RADIO);
        item.setText(IFormattingStyles.FORMAT_TITLES[i]);
        item.addSelectionListener(new MenuFormatSelection());
    }
    formatMenuItem.setEnabled(filteredDataSet.getRowCount() > 0);
    formatMenu.addMenuListener(new FormatMenuListener());
    return menu;
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Point(org.eclipse.swt.graphics.Point) IDataSetFilter(org.eclipse.linuxtools.systemtap.graphing.core.filters.IDataSetFilter)

Example 94 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project linuxtools by eclipse.

the class ContextMenuHelper method getMenuItem.

private static MenuItem getMenuItem(final AbstractSWTBot<?> bot, final String... texts) {
    MenuItem theItem = null;
    Control control = (Control) bot.widget;
    // for dynamic menus, we need to issue this event
    control.notifyListeners(SWT.MenuDetect, new Event());
    Menu menu = control.getMenu();
    for (String text : texts) {
        Matcher<MenuItem> matcher = allOf(instanceOf(MenuItem.class), withMnemonic(text));
        theItem = show(menu, matcher);
        if (theItem != null) {
            menu = theItem.getMenu();
        } else {
            hide(menu);
            break;
        }
    }
    return theItem;
}
Also used : Control(org.eclipse.swt.widgets.Control) Event(org.eclipse.swt.widgets.Event) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 95 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project knime-core by knime.

the class WrappedNodeDialog method configureShell.

/**
 * Configure shell, create top level menu.
 *
 * {@inheritDoc}
 */
@Override
protected void configureShell(final Shell newShell) {
    super.configureShell(newShell);
    Menu menuBar = new Menu(newShell, SWT.BAR);
    newShell.setMenuBar(menuBar);
    Menu menu = new Menu(newShell, SWT.DROP_DOWN);
    MenuItem rootItem = new MenuItem(menuBar, SWT.CASCADE);
    rootItem.setText("File");
    rootItem.setAccelerator(SWT.MOD1 | 'F');
    rootItem.setMenu(menu);
    final FileDialog openDialog = new FileDialog(newShell, SWT.OPEN);
    final FileDialog saveDialog = new FileDialog(newShell, SWT.SAVE);
    MenuItem itemLoad = new MenuItem(menu, SWT.PUSH);
    itemLoad.setText("Load Settings");
    itemLoad.setAccelerator(SWT.MOD1 | 'L');
    itemLoad.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            String file = openDialog.open();
            if (file != null) {
                NodeContext.pushContext(m_nodeContainer);
                try {
                    m_dialogPane.loadSettingsFrom(new FileInputStream(file));
                } catch (IOException ioe) {
                    showErrorMessage(ioe.getMessage());
                } catch (NotConfigurableException ex) {
                    showErrorMessage(ex.getMessage());
                } finally {
                    NodeContext.removeLastContext();
                }
            }
        }
    });
    MenuItem itemSave = new MenuItem(menu, SWT.PUSH);
    itemSave.setText("Save Settings");
    itemSave.setAccelerator(SWT.MOD1 | 'S');
    itemSave.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            String file = saveDialog.open();
            if (file != null) {
                NodeContext.pushContext(m_nodeContainer);
                try {
                    m_dialogPane.saveSettingsTo(new FileOutputStream(file));
                } catch (IOException ioe) {
                    showErrorMessage(ioe.getMessage());
                    // SWT-AWT-Bridge doesn't properly
                    // repaint after dialog disappears
                    m_dialogPane.getPanel().repaint();
                } catch (InvalidSettingsException ise) {
                    showErrorMessage("Invalid Settings\n" + ise.getMessage());
                    // SWT-AWT-Bridge doesn't properly
                    // repaint after dialog disappears
                    m_dialogPane.getPanel().repaint();
                } finally {
                    NodeContext.removeLastContext();
                }
            }
        }
    });
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FileOutputStream(java.io.FileOutputStream) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) IOException(java.io.IOException) FileDialog(org.eclipse.swt.widgets.FileDialog) FileInputStream(java.io.FileInputStream)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29