Java Code Examples for org.eclipse.swt.widgets.MenuItem#dispose()

The following examples show how to use org.eclipse.swt.widgets.MenuItem#dispose() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Executed when the menu is shown: fills the group-menu
 */
@Override
public void handleEvent(Event event) {
	ProcessGrouping group = Viewers.getFirstSelected(groupViewer);
	if (group == null)
		return;
	for (MenuItem item : groupMoveMenu.getItems()) {
		item.removeSelectionListener(this);
		item.dispose();
	}
	List<ProcessGrouping> other = getOther(group);
	for (ProcessGrouping g : other) {
		MenuItem menuItem = new MenuItem(groupMoveMenu, SWT.PUSH);
		menuItem.setText(g.name);
		menuItem.setData(g);
		menuItem.addSelectionListener(this);
	}
}
 
Example 2
Source File: MenuManager.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void createRecentAudiosMenu() {
	for (MenuItem mi : recentAudiosM.getItems())
		mi.dispose();

	CacheList<File> audioFilesCache = pmTrans.getRecentAudios();
	for (int i = 0; i < audioFilesCache.size(); i++)
		addMenuItem(recentAudiosM, audioFilesCache.get(i).getName(),
				SWT.NONE, audioFilesCache.get(i), new SelectionAdapter() {
					@Override
					public void widgetSelected(SelectionEvent e) {
						pmTrans.openAudioFile((File) ((MenuItem) e
								.getSource()).getData());
					}
				});
}
 
Example 3
Source File: MenuManager.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void createRecentTextsMenu() {
	for (MenuItem mi : recentTextsM.getItems())
		mi.dispose();

	CacheList<File> textFilesCache = pmTrans.getRecentTrasncriptions();
	for (int i = 0; i < textFilesCache.size(); i++)
		addMenuItem(recentTextsM, textFilesCache.get(i).getName(),
				SWT.NONE, textFilesCache.get(i), new SelectionAdapter() {
					@Override
					public void widgetSelected(SelectionEvent e) {
						pmTrans.openTranscriptionFile((File) ((MenuItem) e
								.getSource()).getData());
					}
				});
}
 
Example 4
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void
 addCopyToClipMenu(
final Menu		menu,
final String	text )
 {
  for ( MenuItem e: menu.getItems()){
	  
	  if ( e.getData( MENU_ITEM_KEY ) != null ){
		  
		  e.dispose();
	  }
  }
  
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  item.setData( MENU_ITEM_KEY, "" );

  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()});
		  }
	  });
 }
 
Example 5
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void
 addCopyToClipMenu(
final Menu					menu,
final copyToClipProvider	provider )
 {
  for ( MenuItem e: menu.getItems()){
	  
	  if ( e.getData( MENU_ITEM_KEY ) != null ){
		  
		  e.dispose();
	  }
  }
  
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  item.setData( MENU_ITEM_KEY, "" );
  
  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[] { provider.getText()}, new Transfer[] {TextTransfer.getInstance()});
		  }
	  });
 }
 
Example 6
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void
 removeCopyToClipMenu(
final Menu					menu )
 {
  for ( MenuItem e: menu.getItems()){
	  
	  if ( e.getData( MENU_ITEM_KEY ) != null ){
		  
		  e.dispose();
	  }
  }	
 }
 
Example 7
Source File: TLAEditor.java    From tlaplus with MIT License 5 votes vote down vote up
private void removeMenuItemWithDisplayText(final String text, final Menu menu) {
	final MenuItem[] items = menu.getItems();
	
	for (final MenuItem item : items) {
		final String menuItemText = item.getText();
		
		if ((menuItemText != null) && menuItemText.startsWith(text)) {
			item.dispose();
			
			return;
		}
	}
}
 
Example 8
Source File: GamaMenu.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void reset() {
	if (mainMenu != null && !mainMenu.isDisposed()) {
		for (final MenuItem item : mainMenu.getItems()) {
			item.dispose();
		}
	}
}
 
Example 9
Source File: SurroundWithTemplateMenuAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void disposeMenuItems() {
	if (fMenu == null || fMenu.isDisposed()) {
		return;
	}
	MenuItem[] items = fMenu.getItems();
	for (int i=0; i < items.length; i++) {
		MenuItem menuItem= items[i];
		if (!menuItem.isDisposed()) {
			menuItem.dispose();
		}
	}
}
 
Example 10
Source File: AnalysisToolComposite.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Removes and disposes of all of the IAnalysisViews for a particular
 * DataSource.
 * 
 * @param dataSource
 *            The DataSource whose Views need to be removed.
 * @param factory
 *            The factory used to generate the IAnalysisViews for the
 *            DataSource.
 */
private void removeViews(DataSource dataSource,
		IAnalysisWidgetFactory factory) {
	logger.info("AnalysisToolComposite message: "
			+ "Removing views for data source " + dataSource);

	// Get the list of available views.
	List<String> viewNames = factory.getAvailableViews(dataSource);

	// Disable the dataSource's view menu Item. (The dataSource
	// should *always* be a key in the map.)
	MenuItem dataSourceItem = dataSourceItems.get(dataSource);
	dataSourceItem.setEnabled(false);

	// Dispose of all MenuItems from the dataSource's view Menu.
	Menu dataSourceMenu = dataSourceItem.getMenu();
	for (MenuItem item : dataSourceMenu.getItems()) {
		item.dispose();
	}

	// Dispose of the ViewPart for each view.
	for (String viewName : viewNames) {
		logger.info(
				"AnalysisToolComposite message: Removing view " + viewName);

		ViewPart viewPart = viewPartMap.remove(dataSource + "-" + viewName);
		if (viewPart != null) {
			viewPart.dispose();
		}
	}

	return;
}