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

The following examples show how to use org.eclipse.jface.action.IContributionItem#setVisible() . 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 processItems(final IMenuManager menu) {
	// final StringBuilder sb = new StringBuilder();
	// sb.append("Menu ").append(menu.getId()).append(" :: ");
	for (final IContributionItem item : menu.getItems()) {
		final String name = item.getId();
		// DEBUG.LOG(name);
		if (MENU_ITEMS_TO_REMOVE.contains(name)) {
			item.setVisible(false);
			continue;
		}
		if (item.isGroupMarker() || item.isSeparator() || !item.isVisible()) {
			continue;
		}
		if (MENU_IMAGES.containsKey(name)) {
			changeIcon(menu, item, GamaIcons.create(MENU_IMAGES.get(name)).descriptor());
		}
		// sb.append(Strings.LN).append(Strings.TAB);
		// sb.append(name).append('[').append(item.getClass().getSimpleName()).append("]:: ");
	}
	// DEBUG.LOG(sb.toString());
}
 
Example 2
Source File: MendeleyOverlayDecorator.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * THis method sets the main menu contribution 'Mendeley' to visible
 */
private void updateMenuContribution() {
	if(window instanceof WorkbenchWindow) {
		MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();
	    
	    //you'll need to find the id for the item
	    String mainMenuId = "de.tudresden.slr.model.mendeley.menus.mainMenu";
	    IContributionItem item = menuManager.find(mainMenuId);
	    item.update();
	    if (item != null) {
	        // clean old one
	        item.setVisible(true);

	        // refresh menu gui
	        menuManager.update();
	    }
	}
}
 
Example 3
Source File: SDView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Enables/Disables an action with given name.
 *
 * @param actionName The action name
 * @param state true or false
 */
public void setEnableAction(String actionName, boolean state) {
    IActionBars bar = getViewSite().getActionBars();
    if (bar != null) {
        IContributionItem item = bar.getMenuManager().find(actionName);
        if ((item != null) && (item instanceof ActionContributionItem)) {
            IAction action = ((ActionContributionItem) item).getAction();
            if (action != null) {
                action.setEnabled(state);
            }
            item.setVisible(state);
            bar.updateActionBars();
        }
    }
}
 
Example 4
Source File: DisableButtonsByPerspectiveListener.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void enableEditingButtons(IToolBarManager tb, boolean isVisible) {
	for (String id : BUTTON_IDS) {
		IContributionItem item = tb.find(id);
		if (item != null) {
			item.setVisible(isVisible);
		}
	}
	tb.update(true);
}
 
Example 5
Source File: ApplicationWorkbenchWindowAdvisor.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
private void hideSearchMenu() {
	IMenuManager menuManager = this.actionBarConfigurer.getMenuManager();
	IContributionItem[] menuItems =  menuManager.getItems();
	for (IContributionItem item : menuItems) {
		if(item.getId().equalsIgnoreCase("org.eclipse.search.menu")) {
       		item.setVisible(false);
       		}
	}
}
 
Example 6
Source File: StatusItemSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
	 * Each editor type adds their own org.eclipse.jface.action.SubContributionManager with a parallel
 * set of items to the other editors.  On some platforms, we need to add ourselves to each set as 
 * we encounter them. Eclipse uses the exact same initialization code to modify the EditAction menu, 
 * while duplicating the StausLineManager setup (in text editors afaik).
 *  
 * @param editor - the current editor
 */
protected synchronized void addStatusContribution(ITextEditor editor, String place) {
	IStatusLineManager slm = EmacsPlusUtils.getStatusLineManager(editor);
	IContributionItem item = initStatusLineItem();
	if (!hasInnerItem(slm, item)) {
		slm.insertBefore((slm.find(place) != null ? place : STATUS_CATEGORY_ELEMENT_STATE), item);
	}
	item.setVisible(true);
}
 
Example 7
Source File: FilteringMenuManager.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean allowItem(IContributionItem itemToAdd) {
	if (itemToAdd.getId() != null && Arrays.contains(exclusionSet, itemToAdd.getId()))
		itemToAdd.setVisible(false);
	return super.allowItem(itemToAdd);
}
 
Example 8
Source File: DiagramPartitioningEditor.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean allowItem(IContributionItem itemToAdd) {
	if (Arrays.contains(exclude, itemToAdd.getId())) {
		itemToAdd.setVisible(false);
	}
	return true;
}