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;
}
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;
}
}
}
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;
}
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;
}
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();
}
}
}
});
}
Aggregations