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


Java MenuItem.addListener方法代碼示例

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


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

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

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

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

示例4: addMenuItems

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
 protected void
 addMenuItems(
Menu	menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );
  
  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
	  @Override
	  public void handleEvent(Event e) {
		  try{
		   	this_mon.enter();
		   	
		   	nbValues		= 0;
		   	currentPosition	= 0;
		   		
		   	for ( int i=0;i<all_values.length;i++ ){
		   		all_values[i] = new int[all_values[i].length];
		   	}
		  }finally{
			  
			this_mon.exit();
		  }
		  
		  refresh( true );
	  }
  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:33,代碼來源:PingGraphic.java

示例5: addMenuItems

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
 protected void
 addMenuItems(
Menu	menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );
  
  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
	  @Override
	  public void handleEvent(Event e) {
		  try{
		   	this_mon.enter();
		   	
		   	nbValues		= 0;
		   	currentPosition	= 0;
	 		
		   	for ( int i=0;i<all_values.length;i++ ){
		   		all_values[i] = new int[all_values[i].length];
		   	}		
		  }finally{
			  
			this_mon.exit();
		  }
		  
		  refresh( true );
	  }
  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:33,代碼來源:MultiPlotGraphic.java

示例6: addMenuItems

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
 protected void
 addMenuItems(
Menu	menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );
  
  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
	  @Override
	  public void handleEvent(Event e) {
		  try{
		   	this_mon.enter();
		   	
		   	nbValues		= 0;
		   	currentPosition	= 0;
	 		
		   	for ( int i=0;i<all_values.length;i++ ){
		   		all_values[i] = new int[all_values[i].length];
		   	}	
		  }finally{
			  
			this_mon.exit();
		  }
		  
		  refresh( true );
	  }
  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:33,代碼來源:SpeedGraphic.java

示例7: openPopupMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
protected void openPopupMenu(List<DragAndDropPolicy.Action> availableActions,
		final AvroNode sourceNode, final AvroNode targetNode, final TargetPosition position) {
	
	Shell shell = Display.getCurrent().getActiveShell();
	final Menu menu = new Menu(shell, SWT.POP_UP);
	
	for (DragAndDropPolicy.Action availableAction : availableActions) {
		final DragAndDropPolicy.Action action = availableAction;
		MenuItem item = new MenuItem(menu, SWT.PUSH);
		item.setText(action.getLabel());
		item.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				menu.dispose();
				IEditCommand cmd = context.getService(IEditCommandFactory.class)
						.createDnDElementCommand(action, sourceNode, targetNode, position, Notifications.NOT_REF);					
				if (cmd != null) {	
					context.getService(ICommandExecutor.class).execute(cmd);
				}
			}
		});
	}
       
	java.awt.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,代碼行數:30,代碼來源:AvroSchemaViewerDropPolicy.java

示例8: fillMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
public void
fillMenu(
	String sColumnName, Menu menu)
{
	List<Object>	ds = tv.getSelectedDataSources();

	final List<DownloadStubFile> files = new ArrayList<>();

	for ( Object o: ds ){

		files.add((DownloadStubFile)o);
	}

	boolean	hasSelection = files.size() > 0;

		// Explore (or open containing folder)

	final boolean use_open_containing_folder = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");

	final MenuItem itemExplore = new MenuItem(menu, SWT.PUSH);

	Messages.setLanguageText(itemExplore, "MyTorrentsView.menu."
			+ (use_open_containing_folder ? "open_parent_folder" : "explore"));

	itemExplore.addListener(SWT.Selection, new Listener() {
		@Override
		public void
		handleEvent(
			Event event)
		{
			for ( DownloadStubFile file: files ){

				ManagerUtils.open( new File( file.getFile().getAbsolutePath()), use_open_containing_folder);
			}
		}
	});

	itemExplore.setEnabled(hasSelection);

	new MenuItem( menu, SWT.SEPARATOR );
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:43,代碼來源:ArchivedFilesView.java

示例9: ContextMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public ContextMenu(final EarthquakeBulletinGui gui) {
	final Table table = ResultsTable.this.getTableViewer().getTable();
	menu = new Menu(table);

	// Show map...
	showMapMenuItem = new MenuItem(menu, SWT.PUSH);
	showMapMenuItem.setText(Messages.get(LBL_MENU_ITEM_SHOW_MAP));
	showMapMenuItem.addListener(SWT.Selection, new ShowMapListener(gui));
	menu.setDefaultItem(showMapMenuItem);

	new MenuItem(menu, SWT.SEPARATOR);

	// Open in browser...
	openBrowserMenuItem = new MenuItem(menu, SWT.PUSH);
	openBrowserMenuItem.setText(Messages.get(LBL_MENU_ITEM_OPEN_BROWSER));
	openBrowserMenuItem.addSelectionListener(new OpenInBrowserSelectionListener(gui));

	// Copy link...
	copyLinkMenuItem = new MenuItem(menu, SWT.PUSH);
	copyLinkMenuItem.setText(Messages.get(LBL_MENU_ITEM_COPY_LINK));
	copyLinkMenuItem.addSelectionListener(new CopyLinkSelectionListener(gui));

	new MenuItem(menu, SWT.SEPARATOR);

	// Google Maps Popup...
	googleMapsPopupMenuItem = new MenuItem(menu, SWT.PUSH);
	googleMapsPopupMenuItem.setText(Messages.get(LBL_MENU_ITEM_GOOGLE_MAPS_POPUP));
	googleMapsPopupMenuItem.addSelectionListener(new GoogleMapsPopupSelectionListener(gui));

	// Google Maps in browser...
	googleMapsBrowserMenuItem = new MenuItem(menu, SWT.PUSH);
	googleMapsBrowserMenuItem.setText(Messages.get(LBL_MENU_ITEM_GOOGLE_MAPS_BROWSER));
	googleMapsBrowserMenuItem.addSelectionListener(new GoogleMapsBrowserSelectionListener(gui));

	new MenuItem(menu, SWT.SEPARATOR);

	exportCsvMenuItem = new MenuItem(menu, SWT.PUSH);
	exportCsvMenuItem.setText(Messages.get(LBL_MENU_ITEM_EXPORT_CSV) + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_SAVE));
	exportCsvMenuItem.addSelectionListener(new ExportCsvSelectionListener(gui));
	exportCsvMenuItem.setAccelerator(SWT.MOD1 | SwtUtils.KEY_SAVE);

	table.addMenuDetectListener(new ResultsTableContextMenuDetectListener(ResultsTable.this));
}
 
開發者ID:Albertus82,項目名稱:EarthquakeBulletin,代碼行數:44,代碼來源:ResultsTable.java


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