Java Code Examples for org.eclipse.jface.action.IContributionItem#dispose()

The following examples show how to use org.eclipse.jface.action.IContributionItem#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: CleanupHelper.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example 2
Source File: CategoryFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateMenu(IMenuManager manager) {
	IContributionItem[] items= manager.getItems();
	if (items != null) {
		for (int i= 0; i < items.length; i++) {
			IContributionItem item= items[i];
			if (item != null && item.getId() != null && item.getId().equals(FILTER_CATEGORY_ACTION_ID)) {
				IContributionItem removed= manager.remove(item);
				if (removed != null) {
					item.dispose();
				}
			}
		}
	}
	List<String> menuEntries= new ArrayList<String>();
	boolean hasUncategorizedMembers= getMenuCategories(menuEntries);
	Collections.sort(menuEntries, Collator.getInstance());

	if (menuEntries.size() > 0 && hasUncategorizedMembers)
		manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new FilterUncategorizedMembersAction());

	int count= 0;
	for (Iterator<String> iter= menuEntries.iterator(); iter.hasNext();) {
		String category= iter.next();
		manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new CategoryFilterAction(category, count + 1));
		count++;
	}
}
 
Example 3
Source File: WorkingSetShowActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void cleanViewMenu(IMenuManager menuManager) {
	for (Iterator<IContributionItem> iter= fContributions.iterator(); iter.hasNext();) {
		IContributionItem removed= menuManager.remove(iter.next());
		if (removed != null) {
			removed.dispose();
		}
	}
	fContributions.clear();
}
 
Example 4
Source File: WorkingSetFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void removePreviousLRUWorkingSetActions(IMenuManager mm) {
	for (int i= 1; i < fLRUMenuCount; i++) {
		String id= WorkingSetMenuContributionItem.getId(i);
		IContributionItem item= mm.remove(id);
		if (item != null) {
			item.dispose();
			fContributions.remove(item);
		}
	}
}
 
Example 5
Source File: WorkingSetFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void cleanViewMenu(IMenuManager menuManager) {
	for (Iterator<IContributionItem> iter= fContributions.iterator(); iter.hasNext();) {
		IContributionItem removed= menuManager.remove(iter.next());
		if (removed != null) {
			removed.dispose();
		}
	}
	fContributions.clear();
	fMenuManager.removeMenuListener(fMenuListener);
	fMenuListener= null;
}
 
Example 6
Source File: ActionTree.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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();
}