Search in sources :

Example 26 with ActionContributionItem

use of org.eclipse.jface.action.ActionContributionItem in project eclipse.platform.text by eclipse.

the class OpenSearchDialogPageAction method addToMenu.

private void addToMenu(Menu localMenu, IAction action, int accelerator) {
    StringBuilder label = new StringBuilder();
    if (accelerator >= 0 && accelerator < 10) {
        // add the numerical accelerator
        label.append('&');
        label.append(accelerator);
        label.append(' ');
    }
    label.append(action.getText());
    action.setText(label.toString());
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(localMenu, -1);
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem)

Example 27 with ActionContributionItem

use of org.eclipse.jface.action.ActionContributionItem in project linuxtools by eclipse.

the class AbstractMassifTest method getToolbarAction.

protected IAction getToolbarAction(String actionId) {
    IAction result = null;
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager();
    for (IContributionItem item : manager.getItems()) {
        if (item instanceof ActionContributionItem) {
            ActionContributionItem actionItem = (ActionContributionItem) item;
            if (actionItem.getAction().getId().equals(actionId)) {
                result = actionItem.getAction();
            }
        }
    }
    return result;
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IContributionItem(org.eclipse.jface.action.IContributionItem)

Example 28 with ActionContributionItem

use of org.eclipse.jface.action.ActionContributionItem in project linuxtools by eclipse.

the class MultiProcessTest method testExecPidMenu.

@Test
public void testExecPidMenu() throws CoreException, URISyntaxException, IOException {
    ILaunchConfigurationWorkingCopy config = createConfiguration(proj.getProject()).getWorkingCopy();
    config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
    config.doSave();
    // $NON-NLS-1$
    doLaunch(config, "testExec");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    MassifViewPart dynamicView = (MassifViewPart) view.getDynamicView();
    MassifOutput output = dynamicView.getOutput();
    MassifPidMenuAction menuAction = null;
    IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager();
    for (IContributionItem item : manager.getItems()) {
        if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() instanceof MassifPidMenuAction) {
            menuAction = (MassifPidMenuAction) ((ActionContributionItem) item).getAction();
        }
    }
    assertNotNull(menuAction);
    Integer[] pids = dynamicView.getOutput().getPids();
    Shell shell = new Shell(Display.getCurrent());
    Menu pidMenu = menuAction.getMenu(shell);
    assertEquals(2, pidMenu.getItemCount());
    ActionContributionItem firstPid = (ActionContributionItem) pidMenu.getItem(0).getData();
    ActionContributionItem secondPid = (ActionContributionItem) pidMenu.getItem(1).getData();
    // check initial state
    assertTrue(firstPid.getAction().isChecked());
    assertFalse(secondPid.getAction().isChecked());
    assertArrayEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
    // select second pid
    selectItem(pidMenu, 1);
    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertArrayEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());
    // select second pid again
    selectItem(pidMenu, 1);
    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertArrayEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());
    // select first pid
    selectItem(pidMenu, 0);
    assertTrue(firstPid.getAction().isChecked());
    assertFalse(secondPid.getAction().isChecked());
    assertArrayEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Shell(org.eclipse.swt.widgets.Shell) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IContributionItem(org.eclipse.jface.action.IContributionItem) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Menu(org.eclipse.swt.widgets.Menu) MassifOutput(org.eclipse.linuxtools.internal.valgrind.massif.MassifOutput) MassifPidMenuAction(org.eclipse.linuxtools.internal.valgrind.massif.MassifPidMenuAction) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart) Test(org.junit.Test)

Example 29 with ActionContributionItem

use of org.eclipse.jface.action.ActionContributionItem in project linuxtools by eclipse.

the class MassifPidMenuAction method getMenu.

@Override
public Menu getMenu(Control parent) {
    if (menu == null) {
        if (pids != null) {
            menu = new Menu(parent);
            for (int i = 0; i < pids.length; i++) {
                final Integer pid = pids[i];
                ActionContributionItem item = new ActionContributionItem(new // $NON-NLS-1$
                Action(// $NON-NLS-1$
                "PID " + pids[i], // $NON-NLS-1$
                IAction.AS_RADIO_BUTTON) {

                    @Override
                    public void run() {
                        MenuItem[] items = menu.getItems();
                        for (int j = 0; j < items.length; j++) {
                            IAction action = ((ActionContributionItem) items[j].getData()).getAction();
                            action.setChecked(false);
                        }
                        setChecked(true);
                        view.setPid(pid);
                        Display.getDefault().syncExec(() -> view.refreshView());
                    }
                });
                item.fill(menu, -1);
            }
        }
        // Check first item
        ActionContributionItem item = (ActionContributionItem) menu.getItem(0).getData();
        item.getAction().setChecked(true);
    }
    return menu;
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction) Menu(org.eclipse.swt.widgets.Menu)

Example 30 with ActionContributionItem

use of org.eclipse.jface.action.ActionContributionItem in project knime-core by knime.

the class KnimeResourceNavigator method fillContextMenu.

/**
 * Fills the context menu with the actions contained in this group and its
 * subgroups. Additionally the close project item is removed as not intended
 * for the knime projects. Note: Projects which are closed in the default
 * navigator are not shown in the knime navigator any more.
 *
 * @param menu the context menu
 */
@Override
public void fillContextMenu(final IMenuManager menu) {
    // fill the menu
    super.fillContextMenu(menu);
    // remove the close project item
    menu.remove(CloseResourceAction.ID);
    // items do not have an id
    for (IContributionItem item : menu.getItems()) {
        if (item instanceof ActionContributionItem) {
            ActionContributionItem aItem = (ActionContributionItem) item;
            // remove the gointo item
            if (aItem.getAction() instanceof GoIntoAction) {
                menu.remove(aItem);
            } else if (aItem.getAction() instanceof OpenInNewWindowAction) {
                menu.remove(aItem);
            } else if (aItem.getAction() instanceof CloseUnrelatedProjectsAction) {
                menu.remove(aItem);
            }
        }
    }
    // move must be our own action (due to workflow locks)
    if (menu.find(MoveResourceAction.ID) != null) {
        menu.insertBefore(MoveResourceAction.ID, new MoveWorkflowAction(getTreeViewer()));
        menu.remove(MoveResourceAction.ID);
    }
    // remove the default import export actions to store the own one
    // that invokes the knime export wizard directly
    menu.remove("import");
    menu.insertBefore("export", new ImportKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
    menu.remove("export");
    menu.insertAfter(ImportKnimeWorkflowAction.ID, new ExportKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
    String id = ImportKnimeWorkflowAction.ID;
    // add an open action which is not listed as the project is normally
    // not openable.
    menu.insertBefore(id, new Separator());
    menu.insertBefore(id, new OpenKnimeProjectAction(this));
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new EditMetaInfoAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
    if (NodeExecutionJobManagerPool.getNumberOfJobManagersFactories() > 1) {
        menu.insertAfter(ExportKnimeWorkflowAction.ID, new WFShowJobMgrViewAction());
    }
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new ResetWorkflowAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new CancelWorkflowAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new ExecuteWorkflowAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new ConfigureWorkflowAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new OpenCredentialVariablesDialogAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new OpenWorkflowVariablesDialogAction());
    menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
    menu.insertBefore(RefreshAction.ID, new GroupMarker(KNIME_ADDITIONS));
    menu.insertBefore(RefreshAction.ID, new Separator());
    menu.insertBefore(id, new Separator());
    // another bad workaround to replace the first "New" menu manager
    // with the "Create New Workflow" action
    // store all items, remove all, add the action and then
    // add all but the first one
    IContributionItem[] items = menu.getItems();
    for (IContributionItem item : items) {
        menu.remove(item);
    }
    menu.add(new NewKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
    menu.add(new CreateWorkflowGroupAction());
    for (int i = 1; i < items.length; i++) {
        menu.add(items[i]);
    }
}
Also used : EditMetaInfoAction(org.knime.workbench.ui.navigator.actions.EditMetaInfoAction) IContributionItem(org.eclipse.jface.action.IContributionItem) CancelWorkflowAction(org.knime.workbench.ui.navigator.actions.CancelWorkflowAction) GoIntoAction(org.eclipse.ui.views.framelist.GoIntoAction) OpenInNewWindowAction(org.eclipse.ui.actions.OpenInNewWindowAction) WFShowJobMgrViewAction(org.knime.workbench.ui.navigator.actions.WFShowJobMgrViewAction) ExportKnimeWorkflowAction(org.knime.workbench.ui.navigator.actions.ExportKnimeWorkflowAction) ResetWorkflowAction(org.knime.workbench.ui.navigator.actions.ResetWorkflowAction) ImportKnimeWorkflowAction(org.knime.workbench.ui.navigator.actions.ImportKnimeWorkflowAction) ExecuteWorkflowAction(org.knime.workbench.ui.navigator.actions.ExecuteWorkflowAction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) MoveWorkflowAction(org.knime.workbench.ui.navigator.actions.MoveWorkflowAction) ConfigureWorkflowAction(org.knime.workbench.ui.navigator.actions.ConfigureWorkflowAction) OpenCredentialVariablesDialogAction(org.knime.workbench.ui.navigator.actions.OpenCredentialVariablesDialogAction) OpenWorkflowVariablesDialogAction(org.knime.workbench.ui.navigator.actions.OpenWorkflowVariablesDialogAction) GroupMarker(org.eclipse.jface.action.GroupMarker) CreateWorkflowGroupAction(org.knime.workbench.ui.navigator.actions.CreateWorkflowGroupAction) Separator(org.eclipse.jface.action.Separator) CloseUnrelatedProjectsAction(org.eclipse.ui.actions.CloseUnrelatedProjectsAction)

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