Java Code Examples for org.eclipse.jface.action.IToolBarManager#find()

The following examples show how to use org.eclipse.jface.action.IToolBarManager#find() . 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: Zoom.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set action check state of a view action for a given action ID.
 *
 * @param id The action ID
 * @param checked true to check the action, false to uncheck the action
 */
protected void setActionChecked(String id, boolean checked) {
    if (getView() != null) {
        IActionBars bar = getView().getViewSite().getActionBars();
        if (bar == null) {
            return;
        }
        IToolBarManager barManager = bar.getToolBarManager();
        if (barManager == null) {
            return;
        }
        IContributionItem nextPage = barManager.find(id);
        if (nextPage instanceof ActionContributionItem) {
            IAction action = ((ActionContributionItem) nextPage).getAction();
            if (action != null) {
                action.setChecked(checked);
            }
        }
    }
}
 
Example 2
Source File: ShowWhitespaceCharactersActionContributor.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
	public void contributeActions(XtextEditor editor) {
		IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
		IAction action = editor.getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
		action.setImageDescriptor(imageHelper
				.getImageDescriptor("full/etool16/show_whitespace_chars.gif"));
		action.setDisabledImageDescriptor(imageHelper
				.getImageDescriptor("full/dtool16/show_whitespace_chars.gif"));
		if(toolBarManager.find(action.getId())==null) {
			toolBarManager.add(new ActionContributionItemExtension(action));				
//			toolBarManager.add(action);				
		}
	}
 
Example 3
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 4
Source File: GamlMarkOccurrenceActionContributor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void contributeActions(final XtextEditor editor) {
	super.contributeActions(editor);
	final IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
	final IContributionItem item = toolBarManager.find(getAction().getId());
	if (item != null) {
		toolBarManager.remove(item);
	}

}
 
Example 5
Source File: GraphicalView.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
private void updateAutoSyncToggleButtonState() {
    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    ActionContributionItem autoSyncToggleContribution = (ActionContributionItem) toolBarManager
            .find("com.abstratt.imageviewer.autoUpdate");
    if (autoSyncToggleContribution != null) {
        IAction action = autoSyncToggleContribution.getAction();
        action.setChecked(isAutoSync());
    }
}
 
Example 6
Source File: SDView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Updates the view coolbar buttons state according to the value return by: -
 * ISDExtendedActionBarProvider.hasNextPage()<br>
 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
 *
 */
public void updateCoolBar() {
    if (fSdPagingProvider != null) {
        IActionBars bar = getViewSite().getActionBars();
        if (bar == null) {
            return;
        }
        IToolBarManager barManager = bar.getToolBarManager();
        if (barManager == null) {
            return;
        }
        IContributionItem nextPage = barManager.find(NextPage.ID);
        if (nextPage instanceof ActionContributionItem) {
            IAction nextPageAction = ((ActionContributionItem) nextPage).getAction();
            if (nextPageAction instanceof NextPage) {
                ((NextPage) nextPageAction).setEnabled(fSdPagingProvider.hasNextPage());
            }
        }

        IContributionItem prevPage = barManager.find(PrevPage.ID);
        if (prevPage instanceof ActionContributionItem) {
            IAction prevPageAction = ((ActionContributionItem) prevPage).getAction();
            if (prevPageAction instanceof PrevPage) {
                ((PrevPage) prevPageAction).setEnabled(fSdPagingProvider.hasPrevPage());
            }
        }

        IContributionItem firstPage = barManager.find(FirstPage.ID);
        if (firstPage instanceof ActionContributionItem) {
            IAction firstPageAction = ((ActionContributionItem) firstPage).getAction();
            if (firstPageAction instanceof FirstPage) {
                ((FirstPage) firstPageAction).setEnabled(fSdPagingProvider.hasPrevPage());
            }
        }

        IContributionItem lastPage = barManager.find(LastPage.ID);
        if (lastPage instanceof ActionContributionItem) {
            IAction lastPageAction = ((ActionContributionItem) lastPage).getAction();
            if (lastPageAction instanceof LastPage) {
                ((LastPage) lastPageAction).setEnabled(fSdPagingProvider.hasNextPage());
            }
        }

        updatePagesMenuItem(bar);
    }
}