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


Java IContributionItem.dispose方法代碼示例

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


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

示例1: removeToolbarContribution

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
/**
 * Remove a list of controls from a subtoolbar inside the manager. the removed controls are disposed, the toolbar
 * is not removed
 * 
 * @param cbm The toolbar manager
 * @param toolbarId the toolbar id where the controls should be 
 * @param itemsToRemove the list of control to remove
 */
public static void removeToolbarContribution(ICoolBarManager cbm, String toolbarId, List<IContributionItem> itemsToRemove){
	IContributionItem ictb = findToolbar(cbm, toolbarId);
	if (ictb instanceof ToolBarContributionItem) {
		HashSet<String> itemsToRemoveIds = new HashSet<String>();
		for(IContributionItem itemToRemove : itemsToRemove){
			itemsToRemoveIds.add(itemToRemove.getId());
		}
		IToolBarManager tbmanager = ((ToolBarContributionItem) ictb).getToolBarManager();
		if (tbmanager != null){
		for (IContributionItem ci : tbmanager.getItems()) {
				if (itemsToRemove.isEmpty()) break;
				if (itemsToRemoveIds.contains(ci.getId())){
					tbmanager.remove(ci);
					ci.dispose();
					itemsToRemoveIds.remove(ci.getId());
				}
			}
			tbmanager.update(true);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:30,代碼來源:CommonToolbarHandler.java

示例2: changeIcon

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
private static void changeIcon(final IMenuManager menu, final IContributionItem item,
		final ImageDescriptor image) {
	if (item instanceof ActionContributionItem) {
		((ActionContributionItem) item).getAction().setImageDescriptor(image);
	} else if (item instanceof CommandContributionItem) {
		final CommandContributionItemParameter data = ((CommandContributionItem) item).getData();
		data.commandId = ((CommandContributionItem) item).getCommand().getId();
		data.icon = image;
		final CommandContributionItem newItem = new CommandContributionItem(data);
		newItem.setId(item.getId());
		menu.insertAfter(item.getId(), newItem);
		menu.remove(item);
		item.dispose();
	} else if (item instanceof ActionSetContributionItem) {
		changeIcon(menu, ((ActionSetContributionItem) item).getInnerItem(), image);
	} else if (item instanceof MenuManager) {
		((MenuManager) item).setImageDescriptor(image);
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:20,代碼來源:CleanupHelper.java

示例3: dispose

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
/**
 * Disposes of any resources occupied by this IMenuCreator
 * implementation.
 */
@Override
public void dispose() {
	if (menu == null) {
		return;
	}
	// Dispose of the Menu.
	menu.dispose();

	// Dispose of all of the IContributionItems and clear the List.
	for (IContributionItem item : items) {
		item.dispose();
	}
	items.clear();
}
 
開發者ID:eclipse,項目名稱:eavp,代碼行數:19,代碼來源:VizActionTree.java

示例4: hideUnrelatedUI

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
/** Remove toolbar and menu entries unrelated to the display builder
 *  @param page {@link IWorkbenchPage}
 */
public static void hideUnrelatedUI(final IWorkbenchPage page)
{
    // Hide BOY "Top Files" tool bar drop-down
    page.hideActionSet("org.csstudio.opibuilder.actionSet");
    // Hide "Search" (git, file) from tool bar
    page.hideActionSet("org.eclipse.search.searchActionSet");

    if (! (page.getWorkbenchWindow() instanceof WorkbenchWindow))
        return;
    final WorkbenchWindow window = (WorkbenchWindow)page.getWorkbenchWindow();

    final ICoolBarManager toolbar = window.getCoolBarManager2();
    for (IContributionItem item : toolbar.getItems())
    {
        // System.out.println(item.getId());
        if (remove_from_toolbar.contains(item.getId()))
        {   // Result of trial-and-error:
            // * item.setVisible(false) has no effect
            // * toolbar.remove(item) results in
            //   Error disposing widget for : org.eclipse.e4.ui.model.application.ui.menu.impl.ToolBarImpl
            //     java.lang.NullPointerException
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUpCopy(ToolBarManagerRenderer.java:554)
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUp(ToolBarManagerRenderer.java:534)
            //     at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer$4.widgetDisposed(ToolBarManagerRenderer.java:423
            // * disposing the item without removing it from the toolbar "works" ?!
            item.dispose();
        }
    }
    toolbar.update(true);

    patchMenu(window);
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:36,代碼來源:RCPHacks.java

示例5: isElementPresentInToolbar

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
/**
 * Check if a control for the toolbar is already inside the passed toolbar. The presence is verified
 * using the element id
 * 
 * @param toolbar toolbar where the element is searched
 * @param itemToCheck the searched element
 * @return true if an element with the same id of itemToCheck is already present in toolbar, otherwise false
 */
private static boolean isElementPresentInToolbar(ToolBarContributionItem toolbar, CommonToolbarHandler itemToCheck){
	for(IContributionItem item : toolbar.getToolBarManager().getItems()){
		if (item.getId().equals(itemToCheck.getId())) {
			if (!item.getClass().equals(itemToCheck.getClass())){
				toolbar.getToolBarManager().remove(item);
				item.dispose();
				return false;
			}
			return true;
		}
	}
	return false;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:22,代碼來源:CommonToolbarHandler.java

示例6: removeToolbar

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
/**
 * Remove a toolbar from the manager. It dosen't do nothing if the toolbar is not in the manager.
 * If the toolbar is found before to be removed all the controls inside are disposed. The parent
 * toolbar of the item is not removed to have it's position preserved if other elements will
 * be added to it with a following selection. However since it's empty it isn't visible.
 * This method it is equivalent to removeToolbarContribution with all the content of the toolbar
 * inside the items to remove list. But since this need to done less control it has better performance
 * and it is preferred when we just want to remove all the content of the toolbar
 * 
 * @param cbm2 the toolbar manager
 * @param tbarid the id of the toolbar to remove
 */
public static void removeToolbar(ICoolBarManager cbm2, String tbarid) {
	IContributionItem ictb = findToolbar(cbm2, tbarid);
	if (ictb instanceof ToolBarContributionItem) {
		IToolBarManager tbmanager = ((ToolBarContributionItem) ictb).getToolBarManager();
		if (tbmanager != null){
			//the controls inside the toolbar are disposed
			for (IContributionItem ci : tbmanager.getItems()) {
				tbmanager.remove(ci);
				ci.dispose();
			}
			tbmanager.update(true);
		}
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:27,代碼來源:CommonToolbarHandler.java

示例7: removeAll

import org.eclipse.jface.action.IContributionItem; //導入方法依賴的package包/類
public void removeAll() {
	for (IContributionItem it : tbManager.getItems()) {	
		if (it instanceof ActionContributionItem && ((ActionContributionItem) it).getAction() instanceof IDisposable)
			((IDisposable) ((ActionContributionItem) it).getAction()).dispose();
		else if (it instanceof ContributionItem)
			it.dispose();
	}
	tbManager.removeAll();
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:10,代碼來源:ATopToolBarManager.java


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