本文整理汇总了Java中org.eclipse.swt.widgets.MenuItem.setData方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setData方法的具体用法?Java MenuItem.setData怎么用?Java MenuItem.setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewWorkItemMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private Menu createNewWorkItemMenu(final Shell shell, final TeamExplorerContext context) {
final WorkItemClient client = context.getServer().getConnection().getWorkItemClient();
final Project project = client.getProjects().get(context.getCurrentProjectInfo().getName());
final Menu menu = new Menu(shell, SWT.POP_UP);
for (final WorkItemType workItemType : project.getVisibleWorkItemTypes()) {
final MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(workItemType.getName());
menuItem.setData(workItemType);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final WorkItem workItem = client.newWorkItem(workItemType);
WorkItemEditorHelper.openEditor(context.getServer(), workItem);
}
});
}
return menu;
}
示例2: addMenuItem
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
Object data, SelectionListener listener) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText(text);
item.addSelectionListener(listener);
if (accelerator != SWT.NONE)
item.setAccelerator(accelerator);
item.setData(data);
return item;
}
示例3: fill
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
@Override
public void fill(Menu menu, int index) {
super.fill(menu, index);
int i = index;
// FIXME y this works on Sirius editor?
try {
String filePath = "";
IFile selectedFile = AlloyParseUtil.getSelectedFile();
if (selectedFile == null) {
editor = Activator.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
editor.doSave(new NullProgressMonitor());
filePath = ((FileEditorInput) editor.getEditorInput()).getPath().toOSString();
} else {
filePath = selectedFile.getRawLocation().toOSString();
}
alloyExecuter.parse(filePath);
final ConstList<Command> allCommands = alloyExecuter.getRunCommands();
if (allCommands.size() > 0) {
for (final Command com : allCommands) {
final MenuItem menuItem = new MenuItem(menu, SWT.PUSH, i++);
menuItem.setText(com.toString());
menuItem.setData("command", com);
menuItem.addSelectionListener(this);
}
}
} catch (Exception e) {
// e.printStackTrace();
return;
}
}
示例4: addMenuItem
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
/**
* Adds an item to the menu shown when
* {@link #widgetSelected(SelectionEvent)} is invoked.
*
* This class does <b>not</b> dispose the given {@link Image}.
*
* @param text
* the text of the menu item (may be <code>null</code>)
* @param image
* the image for the menu item (may be <code>null</code>)
* @param toolTipText
* tool tip text to use for the tool item when this menu item is the
* selected item (may be <code>null</code>)
* @param menuItemStyle
* style for the {@link MenuItem}
* @param menuSelectedHandler
* handles when the menu is selected (must not be <code>null</code>)
* @return the {@link MenuItem} added so the caller can listen for events,
* etc. (never <code>null</code>)
*/
public MenuItem addMenuItem(
final String text,
final Image image,
final String toolTipText,
final int menuItemStyle,
final MenuItemSelectedHandler menuSelectedHandler) {
Check.notNull(menuSelectedHandler, "clickHandler"); //$NON-NLS-1$
final MenuItem menuItem = new MenuItem(menu, menuItemStyle);
menuItem.setText(text);
menuItem.setImage(image);
menuItem.setData(TOOLTIP_TEXT_WIDGET_DATA_KEY, toolTipText);
menuItem.setData(MENU_ITEM_SELECTED_HANDLER_WIDGET_DATA_KEY, menuSelectedHandler);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
/*
* Simply update the tool item with the text, image, and tooltip
* text from this menu item. The tool item will fire an event
* the user can handle to detect the switch.
*/
final MenuItem selected = (MenuItem) event.widget;
setDefaultToolItem(selected);
menuSelectedHandler.onMenuItemSelected(menuItem);
}
});
return menuItem;
}
示例5: add
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
public MenuItem add(String item, Image image, String toolTipText, int itemStyle, boolean isSelected, Object data) {
MenuItem menuItem = new MenuItem(menu, itemStyle);
// MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
menuItem.setData("tooltip", toolTipText);
menuItem.setText(item);
if (image != null){
menuItem.setImage(image);
}
// menuItem.setSelection(false);
menuItem.setSelection(isSelected);
menuItem.setData(data);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (isKeepMenuOpenOnClick()) {
Display.getDefault().asyncExec(() -> { showMenu(); });
}
MenuItem selected = (MenuItem) event.widget;
logger.debug("menuitem selected: "+selected.getData()+" source = "+event.getSource()+ " isselected: "+selected.getSelection());
if ( ( (selected.getStyle() & SWT.RADIO) != SWT.RADIO) || selected.getSelection() ) { // only one selection event for radio menuitem's!!
selectItem(selected, true);
}
}
});
if (selected == null) {
selectItem(menuItem, false);
}
return menuItem;
}
示例6: addMenuItem
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
Object data, SelectionListener listener) {
MenuItem item = addMenuItem(menu, text, accelerator, listener);
item.setData(data);
return item;
}
示例7: init
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private void init(Decorations parent) {
menuBar = new Menu(parent, SWT.POP_UP);
// DOCUMENTS MENU:
docsMenu = createCascadeMenu(menuBar, null, "&Document");
openLocalDocItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER, "Open local document...");
uploadItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER_IMPORT, "Import document(s)...");
exportItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER_GO, "Export document...");
syncXmlItem = createItem(docsMenu.m, SWT.NONE, Images.getOrLoad("/icons/database_refresh.png"), "Sync local transcriptions with doc...");
createThumbsMenuItem = createItem(docsMenu.m, SWT.CHECK, null, "Create thumbs when opening local folder");
// FILE MENU:
fileMenu = createCascadeMenu(menuBar, null, "&Page");
saveTranscriptionMenuItem = createItem(fileMenu.m, SWT.NONE, Images.DISK, "Save");
saveTranscriptionToNewFileMenuItem = createItem(fileMenu.m, SWT.NONE, Images.getOrLoad("/icons/page_save.png"), "Save transcription to new file");
replaceImageItem = createItem(fileMenu.m, SWT.NONE, Images.IMAGE_EDIT, "Replace image of current page on server...");
openLocalPageFileItem = createItem(fileMenu.m, 0, null, "Open local page file for current page...");
deletePageMenuItem = createItem(fileMenu.m, 0, null, "Delete current page from server");
addPageMenuItem = createItem(fileMenu.m, 0, null, "Add page to document on server...");
syncWordsWithLinesMenuItem = createItem(fileMenu.m, SWT.NONE, null, "Sync word transcription with text in lines");
collMenu = createCascadeMenu(menuBar, null, "&Collections");
manageCollectionsItem = createItem(collMenu.m, SWT.NONE, null, "Manage...");
userActivityItem = createItem(collMenu.m, SWT.NONE, null, "Show user activity...");
// VIEW menu
viewMenu = createCascadeMenu(menuBar, null, "&View");
viewSettingsMenuItem = createItem(viewMenu.m, SWT.PUSH, Images.getOrLoad("/icons/palette.png"), "Change viewing settings");
// SEGMENTATION SUB-MENU:
segmentationMenu = createCascadeMenu(viewMenu.m, null, "Segmentation");
showAllMenuItem = createItem(segmentationMenu.m, SWT.PUSH, null, "Show all");
hideAllMenuItem = createItem(segmentationMenu.m, SWT.PUSH, null, "Hide all");
showRegionsMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show regions");
showLinesMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show lines");
showBaselinesMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show baselines");
showWordsMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show words");
showPrintspaceMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show printspace");
tipsOfTheDayMenuItem = createItem(viewMenu.m, SWT.PUSH, null, "Show tips of the day...");
// HELP MENU:
// mntmhelp = new MenuItem(menuBar, SWT.CASCADE);
// mntmhelp.setText("&Help");
//
// helpMenu = new Menu(mntmhelp);
// mntmhelp.setMenu(helpMenu);
proxySettingsMenuItem = createItem(menuBar, SWT.PUSH, Images.getOrLoad("/icons/server_connect.png"), "Proxy settings...");
autoSaveSettingsMenuItem = createItem(menuBar, SWT.NONE, Images.DISK, "Autosave settings");
if (false) {
languageMenu = createCascadeMenu(menuBar, null, "Language (todo)");
for (Locale l : Msgs.LOCALES) {
MenuItem li = new MenuItem(languageMenu.m, SWT.RADIO);
li.setText(l.getDisplayName());
li.setData(l);
if (l.equals(TrpConfig.getTrpSettings().getLocale()))
li.setSelection(true);
}
}
updateMenuItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/update_wiz.gif"), "Check for updates");
installMenuItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/install_wiz.gif"), "Install a specific version...");
bugReportItem = createItem(menuBar, SWT.NONE, Images.BUG, "Send a bug report or feature request");
aboutMenuIItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/information.png"), "About");
exitItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/door_out.png"), "Exit");
}