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