Search in sources :

Example 16 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project erlide_eclipse by erlang.

the class ErlangOutlinePage method contextMenuAboutToShow.

protected void contextMenuAboutToShow(final IMenuManager menu) {
    ErlideUIPlugin.createStandardGroups(menu);
    final IStructuredSelection selection = (IStructuredSelection) getSelection();
    fActionGroups.setContext(new ActionContext(selection));
    fActionGroups.fillContextMenu(menu);
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionContext(org.eclipse.ui.actions.ActionContext)

Example 17 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project erlide_eclipse by erlang.

the class ErlangScratchPad method editorContextMenuAboutToShow.

@Override
protected void editorContextMenuAboutToShow(final IMenuManager menu) {
    super.editorContextMenuAboutToShow(menu);
    // if (ErlideUtil.isTest()) {
    // menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, testAction);
    // }
    addCommonActions(menu);
    final ActionContext context = new ActionContext(getSelectionProvider().getSelection());
    fContextMenuGroup.setContext(context);
    fContextMenuGroup.fillContextMenu(menu);
    fContextMenuGroup.setContext(null);
}
Also used : ActionContext(org.eclipse.ui.actions.ActionContext)

Example 18 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project webtools.servertools by eclipse.

the class ServersView2 method createDefaultPage.

/**
 * Creates a page displayed when there are no servers defined.
 *
 * @param kit
 * @return Control
 */
private Control createDefaultPage(FormToolkit kit) {
    Form form = kit.createForm(book);
    Composite body = form.getBody();
    GridLayout layout = new GridLayout(2, false);
    body.setLayout(layout);
    Link hlink = new Link(body, SWT.NONE);
    hlink.setText(Messages.ServersView2_noServers);
    hlink.setBackground(book.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    GridData gd = new GridData(SWT.LEFT, SWT.FILL, true, false);
    hlink.setLayoutData(gd);
    hlink.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            NewServerWizard wizard = new NewServerWizard();
            WizardDialog wd = new WizardDialog(book.getShell(), wizard);
            if (wd.open() == Window.OK) {
                toggleDefultPage();
            }
        }
    });
    // Create the context menu for the default page
    final CommonViewer commonViewer = this.getCommonViewer();
    if (commonViewer != null) {
        ICommonViewerSite commonViewerSite = CommonViewerSiteFactory.createCommonViewerSite(this.getViewSite());
        if (commonViewerSite != null) {
            // Note: actionService cannot be null
            final NavigatorActionService actionService = new NavigatorActionService(commonViewerSite, commonViewer, commonViewer.getNavigatorContentService());
            MenuManager menuManager = new MenuManager("#PopupMenu");
            menuManager.addMenuListener(new IMenuListener() {

                public void menuAboutToShow(IMenuManager mgr) {
                    ISelection selection = commonViewer.getSelection();
                    actionService.setContext(new ActionContext(selection));
                    actionService.fillContextMenu(mgr);
                }
            });
            Menu menu = menuManager.createContextMenu(body);
            // It is necessary to set the menu in two places:
            // 1. The white space in the server view
            // 2. The text and link in the server view. If this menu is not set, if the
            // user right clicks on the text or uses shortcut keys to open the context menu,
            // the context menu will not come up
            body.setMenu(menu);
            hlink.setMenu(menu);
        } else {
            if (Trace.FINEST) {
                Trace.trace(Trace.STRING_FINEST, "The commonViewerSite is null");
            }
        }
    } else {
        if (Trace.FINEST) {
            Trace.trace(Trace.STRING_FINEST, "The commonViewer is null");
        }
    }
    return form;
}
Also used : Form(org.eclipse.ui.forms.widgets.Form) NewServerWizard(org.eclipse.wst.server.ui.internal.wizard.NewServerWizard) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ActionContext(org.eclipse.ui.actions.ActionContext) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISelection(org.eclipse.jface.viewers.ISelection) IMenuManager(org.eclipse.jface.action.IMenuManager) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 19 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project polymap4-core by Polymap4.

the class NavigatorActionService method fillActionBars.

/**
 * Request that the service invoke extensions to fill the given IActionBars with retargetable
 * actions or view menu contributions from Action Providers that are interested in the given
 * selection.
 *
 * @param theActionBars
 *            The action bars in use by the current view site.
 * @see ActionGroup#fillActionBars(IActionBars)
 */
public void fillActionBars(final IActionBars theActionBars) {
    Assert.isTrue(!disposed);
    theActionBars.clearGlobalActionHandlers();
    ActionContext context = getContext();
    if (context == null) {
        context = new ActionContext(StructuredSelection.EMPTY);
    }
    final CommonActionProviderDescriptor[] providerDescriptors = CommonActionDescriptorManager.getInstance().findRelevantActionDescriptors(contentService, context);
    if (providerDescriptors.length > 0) {
        for (int i = 0; i < providerDescriptors.length; i++) {
            final CommonActionProviderDescriptor providerDesciptorLocal = providerDescriptors[i];
            final ActionContext actionContextLocal = context;
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    if (!filterActionProvider(providerDesciptorLocal)) {
                        CommonActionProvider provider = null;
                        provider = getActionProviderInstance(providerDesciptorLocal);
                        provider.setContext(actionContextLocal);
                        provider.fillActionBars(theActionBars);
                        provider.updateActionBars();
                    }
                }
            });
        }
    }
    theActionBars.updateActionBars();
    theActionBars.getMenuManager().update();
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) CommonActionProviderDescriptor(org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor) ActionContext(org.eclipse.ui.actions.ActionContext)

Example 20 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project mdw-designer by CenturyLinkCloud.

the class ProcessHierarchyView method handleSelectionChanged.

protected void handleSelectionChanged(IStructuredSelection selection) {
    List<?> list = selection.toList();
    if (list.isEmpty())
        return;
    ActionContext actionContext = new ActionContext(selection);
    actionGroup.setContext(actionContext);
// TODO property tabs
}
Also used : ActionContext(org.eclipse.ui.actions.ActionContext)

Aggregations

ActionContext (org.eclipse.ui.actions.ActionContext)22 ISelection (org.eclipse.jface.viewers.ISelection)5 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IMenuListener (org.eclipse.jface.action.IMenuListener)3 TreeSelection (org.eclipse.jface.viewers.TreeSelection)3 Separator (org.eclipse.jface.action.Separator)2 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)1 Inject (com.google.inject.Inject)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IProject (org.eclipse.core.resources.IProject)1 IContextMenuConstants (org.eclipse.jdt.ui.IContextMenuConstants)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 ColumnViewer (org.eclipse.jface.viewers.ColumnViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1