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


Java Menu類代碼示例

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


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

示例1: createContextMenuFor

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:ProtocolEditor.java

示例2: createContextMenuFor

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] {
            LocalTransfer.getInstance (),
            LocalSelectionTransfer.getTransfer (),
            FileTransfer.getInstance (),
            ItemTransfer.getInstance ()
    };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:29,代碼來源:ChartEditor.java

示例3: createContextMenuFor

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension. <!-- begin-user-doc --> <!--
 * end-user-doc -->
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( this.editingDomain, viewer ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:ChartConfiguratorView.java

示例4: openPopupMenu

import org.eclipse.swt.widgets.Menu; //導入依賴的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

示例5: createContextMenuFor

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:MemoryEditor.java

示例6: createContextMenuFor

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:24,代碼來源:ComponentEditor.java

示例7: buildContextMenu

import org.eclipse.swt.widgets.Menu; //導入依賴的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

示例8: addCopyToClipMenu

import org.eclipse.swt.widgets.Menu; //導入依賴的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

示例9: DropDownSelectionListener

import org.eclipse.swt.widgets.Menu; //導入依賴的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

示例10: showPreferenceDialogMAC

import org.eclipse.swt.widgets.Menu; //導入依賴的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

示例11: configurePopupMenu

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
protected void configurePopupMenu(TreeViewer treeViewer) {
	MenuManager mgr = new MenuManager();
       mgr.setRemoveAllWhenShown(true);
       mgr.addMenuListener(new IMenuListener() {
		
		@Override
		public void menuAboutToShow(IMenuManager manager) {
			fillPopupMenu(manager);
		}
	});           
       Menu menu = mgr.createContextMenu(treeViewer.getControl());
       treeViewer.getControl().setMenu(menu);
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:14,代碼來源:SchemaRegistryView.java

示例12: menuWillBeShown

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
@Override
public void menuWillBeShown(MdiEntry entry, Menu menuTree) {
	// todo: This even work?
	TableView<?> tv = SelectedContentManager.getCurrentlySelectedTableView();
	menuTree.setData("TableView", tv);
	DownloadManager manager = DataSourceUtils.getDM(((BaseMdiEntry) entry).getDatasourceCore());
	if (manager != null) {
		menuTree.setData("downloads", new DownloadManager[] {
			manager
		});
	}
	menuTree.setData("is_detailed_view", Boolean.TRUE);

	MenuFactory.buildTorrentMenu(menuTree);
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:16,代碼來源:SBC_TorrentDetailsView.java

示例13: runWithEvent

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
@Override
public void runWithEvent(final Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		@SuppressWarnings("hiding")
		final Menu menu = getMenu(control);
		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:DropDownAction.java

示例14: hookContextMenu

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
private void hookContextMenu() {
	final MenuManager menuMgr = new MenuManager("#PopupMenu");
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager) {
			TestResultsView.this.fillContextMenu(manager);
		}
	});
	Menu menu = menuMgr.createContextMenu(testTreeViewer.getControl());
	testTreeViewer.getControl().setMenu(menu);
	getSite().registerContextMenu(menuMgr, testTreeViewer);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:TestResultsView.java

示例15: runWithEvent

import org.eclipse.swt.widgets.Menu; //導入依賴的package包/類
@Override
public void runWithEvent(Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		final Menu menu = getMenuCreator().getMenu(control);

		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:ShowHistoryAction.java


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