use of org.eclipse.jface.action.ActionContributionItem in project eclipse.platform.text by eclipse.
the class SearchHistoryDropDownAction method addActionToMenu.
protected void addActionToMenu(Menu parent, Action action) {
ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
use of org.eclipse.jface.action.ActionContributionItem in project xtext-xtend by eclipse.
the class ShowWhitespaceCharactersActionContributor method editorDisposed.
@Override
public void editorDisposed(XtextEditor editor) {
IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
IContributionItem i = toolBarManager.remove(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
if (i instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem) i).getAction();
if (action instanceof ShowWhitespaceCharactersAction) {
((ShowWhitespaceCharactersAction) action).setEditor(null);
}
}
}
use of org.eclipse.jface.action.ActionContributionItem in project xtext-xtend by eclipse.
the class DerivedSourceDropDownAction method addActionToMenu.
private void addActionToMenu(Menu parent, Action action) {
ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
use of org.eclipse.jface.action.ActionContributionItem in project linuxtools by eclipse.
the class ValgrindViewPart method createDynamicContent.
/**
* Returns a refreshable view specific of a Valgrind tool.
*
* @param description the content description
* @param toolID the Valgrind tool identifier
* @return the Valgrind tool view
* @throws CoreException the toolbar is disposed
*/
public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
setContentDescription(description);
// remove tool specific toolbar controls
IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
ToolBar tb = ((ToolBarManager) toolbar).getControl();
if (tb == null || tb.isDisposed()) {
// $NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, ValgrindUIPlugin.PLUGIN_ID, "Toolbar is disposed"));
}
if (dynamicActions != null) {
for (ActionContributionItem item : dynamicActions) {
toolbar.remove(item);
}
}
// remove old view controls
if (dynamicView != null) {
dynamicView.dispose();
}
// remove old messages
if (messages != null) {
messagesViewer.getTreeViewer().setInput(null);
messages = null;
}
for (Control child : dynamicViewHolder.getChildren()) {
if (!child.isDisposed()) {
child.dispose();
}
}
if (toolID != null) {
dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
dynamicView.createPartControl(dynamicViewHolder);
// create toolbar items
IAction[] actions = dynamicView.getToolbarActions();
if (actions != null) {
dynamicActions = new ActionContributionItem[actions.length];
for (int i = 0; i < actions.length; i++) {
dynamicActions[i] = new ActionContributionItem(actions[i]);
toolbar.appendToGroup(TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
}
}
} else {
dynamicView = null;
}
// remove old menu items
IMenuManager menu = getViewSite().getActionBars().getMenuManager();
menu.removeAll();
// was content was created?
hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
if (hasDynamicContent) {
menu.add(showCoreAction);
menu.add(showToolAction);
}
menu.update(true);
toolbar.update(true);
// Update to notify the workbench items have been changed
getViewSite().getActionBars().updateActionBars();
dynamicViewHolder.layout(true);
return dynamicView;
}
use of org.eclipse.jface.action.ActionContributionItem in project linuxtools by eclipse.
the class GcovTest method testGcovSummary.
private void testGcovSummary(final String filename, String binPath, final boolean testProducedReference) {
openGcovResult(project.getFile(filename), binPath, true);
IViewPart vp = window.getActivePage().findView("org.eclipse.linuxtools.gcov.view");
// No IDs on toolbar items, so explicitly check each one for tooltip texts
List<String> sortTypes = new ArrayList<>(Arrays.asList("function", "file", "folder"));
IContributionItem[] items = vp.getViewSite().getActionBars().getToolBarManager().getItems();
STExportToCSVAction csvAction = null;
for (IContributionItem item : items) {
if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() instanceof STExportToCSVAction) {
csvAction = (STExportToCSVAction) ((ActionContributionItem) item).getAction();
}
}
Assert.assertNotNull("CSV-Export toolbar button does not exist.", csvAction);
for (IContributionItem item : items) {
if (item instanceof ActionContributionItem) {
final IAction action = ((ActionContributionItem) item).getAction();
for (int i = 0, n = sortTypes.size(); i < n; i++) {
String sortType = sortTypes.get(i);
if (action.getText().equals("Sort coverage per " + sortType)) {
dumpCSV(action, csvAction, sortType, testProducedReference);
if (sortTypes.size() == 1) {
return;
}
sortTypes.remove(i);
break;
}
}
}
}
}
Aggregations