当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem类代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.MenuItem的典型用法代码示例。如果您正苦于以下问题:Java MenuItem类的具体用法?Java MenuItem怎么用?Java MenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuItem类属于org.eclipse.swt.widgets包,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildContextMenu

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
private void buildContextMenu(MouseEvent e) {
	Point point = new Point(e.x, e.y);
	TreeItem  treeItem = getTree().getItem(point);
	Menu menu = new Menu((Control)e.getSource());
	Iterator<MenuMaker> i = menuMakers.iterator();
	int cpt = 0;
	while(i.hasNext()) {
		i.next().makeMenu(this, treeItem, e, menu);
		if (i.hasNext() && menu.getItemCount() != cpt) {
			new MenuItem(menu, SWT.SEPARATOR);
			cpt = menu.getItemCount();
		}
	}
	if (menu.getItemCount() > 0) {
		menu.setVisible(true);
	} else {
		menu.dispose();
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:20,代码来源:TwsDomTree.java

示例2: DropDownSelectionListener

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
/**
 * Construct the DropDownSelectionListener with the specific menu to be used.
 */
public DropDownSelectionListener(Menu menu) {
	this.menu = menu;
	
	MenuItem[] menuItems = menu.getItems();
	for (int i=0; i<menuItems.length; i++) {
		/*
		 * Add a menu selection listener so that the menu is hidden
		 * when the user selects an item from the drop down menu.
		 */
		menuItems[i].addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				setMenuVisible(false);
			}
		});
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:20,代码来源:DropDownSelectionListener.java

示例3: showPreferenceDialogMAC

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
private SWTBotShell showPreferenceDialogMAC() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	workbench.getDisplay().asyncExec(new Runnable() {
		public void run() {
			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
			if (window != null) {
				Menu appMenu = workbench.getDisplay().getSystemMenu();
				for (MenuItem item : appMenu.getItems()) {
					if (item.getText().startsWith("Preferences")) {
						Event event = new Event();
						event.time = (int) System.currentTimeMillis();
						event.widget = item;
						event.display = workbench.getDisplay();
						item.setSelection(true);
						item.notifyListeners(SWT.Selection, event);
						break;
					}
				}
			}
		}
	});
	return  getPreferenceDialog() ;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:GW4EPreferencePage.java

示例4: addCopyToClipMenu

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
public static void
 addCopyToClipMenu(
final Menu		menu,
final String	text )
 {
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  String	msg_text_id= "label.copy.to.clipboard";

  item.setText( MessageText.getString( msg_text_id ));

  item.addSelectionListener(
	  new SelectionAdapter()
	  {
		  @Override
		  public void
		  widgetSelected(
				  SelectionEvent arg0)
		  {
			  new Clipboard(menu.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
		  }
	  });
 }
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:24,代码来源:ClipboardCopy.java

示例5: openPopupMenu

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
protected void openPopupMenu(NodeType[] availableTypes, final AvroNode targetNode, final AvroContext context) {
	
	Shell shell = Display.getCurrent().getActiveShell();
	final Menu menu = new Menu(shell, SWT.POP_UP);
	for (NodeType availableType : availableTypes) {
		final NodeType type = availableType;
		MenuItem item = new MenuItem(menu, SWT.PUSH);
		item.setText(type.getDisplayLabel());
		item.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				menu.dispose();
				IEditCommand cmd = context.getService(IEditCommandFactory.class)
						.createAddElementCommand(targetNode, type, getNotifications());
				context.getService(ICommandExecutor.class).execute(cmd);
			}
		});
	}
       
	Point location = MouseInfo.getPointerInfo().getLocation();
	int x = location.x;
	int y = location.y;
       menu.setLocation(x, y);
       menu.setVisible(true);
       
}
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:26,代码来源:AddElementAction.java

示例6: widgetSelected

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
public void widgetSelected(SelectionEvent event) {
	    	System.out.println("You selected " + ((MenuItem) event.widget).getText());
	    	System.out.println("You selected cont.1 " + EnumUtils.fromString(EditStatus.class, ((MenuItem) event.widget).getText()));
//	    	System.out.println("You selected cont.2 " + EnumUtils.indexOf(EnumUtils.fromString(EditStatus.class, ((MenuItem) event.widget).getText())));

	    	//Storage.getInstance().getTranscriptMetadata().setStatus(EnumUtils.fromString(EditStatus.class, ((MenuItem) event.widget).getText()));
//				Storage.getInstance().saveTranscript(Storage.getInstance().getCurrentDocumentCollectionId(), null);
//				Storage.getInstance().setLatestTranscriptAsCurrent();
	    		/*
	    		 * change status: 
	    		 */
    		String tmp = ((MenuItem) event.widget).getText();
    		changeVersionStatus(tmp);   		
    		
			gallery.redraw();
			gallery.deselectAll();	    	
	    }
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:18,代码来源:ThumbnailManager.java

示例7: 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

示例8: getSubActionMenu

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
protected Menu getSubActionMenu(final Control parent) {
    if (subActionMenu != null) {
        return subActionMenu;
    }

    subActionMenu = new Menu(parent);

    for (final Iterator<IAction> it = subActions.iterator(); it.hasNext();) {
        final IAction subAction = it.next();
        final ActionContributionItem aci = new ActionContributionItem(subAction);
        aci.fill(subActionMenu, -1);
        final MenuItem menuItem = subActionMenu.getItem(subActionMenu.getItemCount() - 1);
        menuItem.addSelectionListener(menuItemSelectionListener);
    }

    return subActionMenu;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:18,代码来源:ToolbarPulldownAction.java

示例9: click

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
/**
 * Clicks on the {@link MenuItem}.
 *
 * @param menuItem
 *          the {@link MenuItem} to click on
 */
private static void click(final MenuItem menuItem) {
  final Event event = new Event();
  event.time = (int) System.currentTimeMillis();
  event.widget = menuItem;
  event.display = menuItem.getDisplay();
  event.type = SWT.Selection;

  UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
    @Override
    public void run() {
      if (SWTUtils.hasStyle(menuItem, SWT.CHECK) || SWTUtils.hasStyle(menuItem, SWT.RADIO)) {
        menuItem.setSelection(!menuItem.getSelection());
      }
      menuItem.notifyListeners(SWT.Selection, event);
    }
  });
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:24,代码来源:ContextActionUiTestUtil.java

示例10: fill

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
@Override
public void fill(Menu menu, int index) {
	final IProject project = getSelectedProject();
	final boolean exists = AddBuilder.hasBuilder(project);
	MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
	menuItem.setText((exists ? "Remove" : "Add") + " Layered Builder");
	menuItem.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			G.reset();
			if (exists) {
				RemoveBuilder.removeBuilder(project);
			} else {
				AddBuilder.addBuilder(project);
			}
			Activator.getDefault().getAnalysis().removeWarnings(1000);
		}
	});
}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:20,代码来源:BuildHandler.java

示例11: 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

示例12: updateTypes

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
public void updateTypes(){
	MenuItem[] items = this.newCollection.getItems();
	for(int i = 0;i < items.length; i ++){
		items[i].dispose();
	}
	Iterator<TGBrowserFactory> bookTypes = TGBrowserManager.getInstance(getBrowser().getContext()).getFactories();
	while(bookTypes.hasNext()){
		final TGBrowserFactory bookType = (TGBrowserFactory)bookTypes.next();
		MenuItem item = new MenuItem(this.newCollection,SWT.PUSH);
		item.setText(bookType.getName());
		item.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				newCollection( bookType.getType());
			}
		});
	}
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:18,代码来源:TGBrowserMenuBar.java

示例13: createMenu

import org.eclipse.swt.widgets.MenuItem; //导入依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	Menu menu = new Menu(item.getParent().getShell());
	
	TGCustomChordManager customChordManager = TuxGuitar.getInstance().getCustomChordManager();
	for(int i = 0; i < customChordManager.countChords(); i++){
		TGChord chord = TuxGuitar.getInstance().getCustomChordManager().getChord(i);
		MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
		menuItem.setText(chord.getName());
		menuItem.addSelectionListener(this.createInsertChordAction(toolBar, chord));
	}
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:18,代码来源:TGToolBarSectionChord.java

示例14: 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

示例15: 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


注:本文中的org.eclipse.swt.widgets.MenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。