當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setData方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:21,代碼來源:TeamExplorerWorkItemPage.java

示例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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:11,代碼來源:BarManager.java

示例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;
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:33,代碼來源:RunAsAlloyContributionItem.java

示例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;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:53,代碼來源:DropdownToolItemSelectionListener.java

示例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;
		}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:38,代碼來源:DropDownToolItem.java

示例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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:7,代碼來源:MenuManager.java

示例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");
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:78,代碼來源:TrpMenuBar.java


注:本文中的org.eclipse.swt.widgets.MenuItem.setData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。