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


Java MenuItem.setSelection方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.MenuItem.setSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setSelection方法的具體用法?Java MenuItem.setSelection怎麽用?Java MenuItem.setSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.MenuItem的用法示例。


在下文中一共展示了MenuItem.setSelection方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(Menu menu, BookmarkId selectedBookmarkId, BookmarkNumber bookmarkNumber) {
	Optional<BookmarkId> bookmarkId = numberedBookmarks.getBookmark(bookmarkNumber);
	final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
	menuItem.setSelection(bookmarkId.isPresent() ? bookmarkId.get().equals(selectedBookmarkId) : false);
	menuItem.setText(getText(bookmarkId));
	menuItem.setAccelerator('0' + bookmarkNumber.getNumber());
	Image image = getImage(bookmarkNumber, bookmarkId);
	if (image != null) {
		menuItem.setImage(image);
	}
	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			switch (event.type) {
			case SWT.Selection:
				if (menuItem.getSelection()) {
					bookmarksService.addNumberedBookmark(selectedBookmarkId, bookmarkNumber);
				}
				break;
			}
		}
	};
	menuItem.addListener(SWT.Selection, listener);
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:25,代碼來源:SetNumberForBookmarkMenu.java

示例2: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(Menu parent, final TableColumn column) {
	final MenuItem itemName = new MenuItem(parent, SWT.CHECK);
	itemName.setText(column.getText());
	itemName.setSelection(column.getResizable());
	itemName.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event event) {
			if (itemName.getSelection()) {
				column.setWidth(150);
				column.setResizable(true);
			} else {
				column.setWidth(0);
				column.setResizable(false);
			}
		}
	});

}
 
開發者ID:aroog,項目名稱:code,代碼行數:18,代碼來源:ObjectTreeView.java

示例3: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createItem(final Menu parent, final int index,
    final ICoverageSession session, final boolean selected,
    final int position, final ISessionManager sm) {
  final MenuItem item = new MenuItem(parent, SWT.RADIO, index);
  item.setImage(EclEmmaUIPlugin.getImage(EclEmmaUIPlugin.ELCL_SESSION));
  item.setText(getLabel(session, position));
  item.setSelection(selected);
  item.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      sm.activateSession(session);
    }
  });
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:15,代碼來源:SelectActiveSessionsItems.java

示例4: updateDockingStateButtons

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void updateDockingStateButtons() {
	logger.debug("updateDockingStateButtons");
	for (MenuItem mi : dockingMenuItems.values()) {
		PositionDocking pd = (PositionDocking) mi.getData();
		
		Docking currentDocking = portalWidget.getDocking(pd.pos);
		mi.setSelection(pd.docking.equals(currentDocking)); // set selection depending on docking state!
	}
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:10,代碼來源:TrpMainWidgetView.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: update

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
public void update(MenuItem m) {
    m.setEnabled(isEnabled(m));
    if (isCheckable())
        m.setSelection(isChecked(m));
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:7,代碼來源:MenuCommand.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

示例8: selectItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public void selectItem(MenuItem item, boolean fireSelectionEvent) {
			Assert.assertNotNull(item);

			selected = item;
			if (renderTextInMainItem) {
				Object altText = item.getData(ALT_TXT_KEY);
				if (altText != null) {
					dropdown.setText((String) altText);	
				} else {
					dropdown.setText(item.getText());	
				}
			}
			
			if ( (itemStyle & SWT.RADIO) == SWT.RADIO) {
				for (MenuItem mi : menu.getItems()) {
					mi.setSelection(mi==selected);
				}
			}

//			selected.setSelection(true);
			if (renderImageInMainItem)
				dropdown.setImage(item.getImage());
			dropdown.getParent().pack();
			
			
			if (item.getData("tooltip") != null && item.getData("tooltip") instanceof String) {
				dropdown.setToolTipText((String)item.getData("tooltip"));
			}

			// fire selection event on dropdown:
			if (fireSelectionEvent) {
				Event e = new Event();
				e.index = findItemIndex(item);
				logger.debug("firing selection event, data = "+item.getData());
				e.data = item.getData();
				e.detail = IS_DROP_DOWN_ITEM_DETAIL;
				
//				dropdown.notifyListeners(SWT.Selection, new Event());
				dropdown.notifyListeners(SWT.Selection, e);
			}
		}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:42,代碼來源:DropDownToolItem.java

示例9: addMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private static void addMenuItem(Menu menu, int style, String label, boolean state, SelectionListener listener) {
	MenuItem item = new MenuItem(menu, style);
	item.setText(label);
	item.setSelection(state);
	item.addSelectionListener(listener);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:7,代碼來源:ParameterWindow.java


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