当前位置: 首页>>代码示例>>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;未经允许,请勿转载。