Search in sources :

Example 11 with ActionContributionItem

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);
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem)

Example 12 with ActionContributionItem

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);
        }
    }
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ShowWhitespaceCharactersAction(org.eclipse.ui.texteditor.ShowWhitespaceCharactersAction) IContributionItem(org.eclipse.jface.action.IContributionItem)

Example 13 with ActionContributionItem

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);
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem)

Example 14 with ActionContributionItem

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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) CoreException(org.eclipse.core.runtime.CoreException) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 15 with ActionContributionItem

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;
                }
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) STExportToCSVAction(org.eclipse.linuxtools.dataviewers.actions.STExportToCSVAction) IAction(org.eclipse.jface.action.IAction) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList)

Aggregations

ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)30 IAction (org.eclipse.jface.action.IAction)14 IContributionItem (org.eclipse.jface.action.IContributionItem)8 IMenuManager (org.eclipse.jface.action.IMenuManager)8 IToolBarManager (org.eclipse.jface.action.IToolBarManager)8 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)7 MenuManager (org.eclipse.jface.action.MenuManager)7 Separator (org.eclipse.jface.action.Separator)7 DropDownAction (com.cubrid.common.ui.common.action.DropDownAction)3 GroupMarker (org.eclipse.jface.action.GroupMarker)3 ArrayList (java.util.ArrayList)2 Action (org.eclipse.jface.action.Action)2 ToolBarManager (org.eclipse.jface.action.ToolBarManager)2 ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)2 Menu (org.eclipse.swt.widgets.Menu)2 Shell (org.eclipse.swt.widgets.Shell)2 Workspace (aQute.bnd.build.Workspace)1 MDSashForm (bndtools.editor.common.MDSashForm)1 AvailableBundlesPart (bndtools.editor.project.AvailableBundlesPart)1 RepositorySelectionPart (bndtools.editor.project.RepositorySelectionPart)1