Search in sources :

Example 6 with ActionContext

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

the class ReferencesSearchGroup method addWorkingSetAction.

private void addWorkingSetAction(final IWorkingSet[] workingSets, final IMenuManager manager) {
    FindAction action;
    if (fEditor != null) {
        action = new WorkingSetFindAction(fEditor, new FindReferencesInWorkingSetAction(fEditor, workingSets), SearchUtil.toString(workingSets));
    } else {
        action = new WorkingSetFindAction(fSite, new FindReferencesInWorkingSetAction(fSite, workingSets), SearchUtil.toString(workingSets));
    }
    final ActionContext context = getContext();
    if (context != null) {
        action.update(context.getSelection());
    }
    addAction(action, manager);
}
Also used : ActionContext(org.eclipse.ui.actions.ActionContext)

Example 7 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project n4js by eclipse.

the class N4JSNavigatorActionProvider method setContext.

@Override
public void setContext(final ActionContext context) {
    super.setContext(context);
    projectGroup.setContext(context);
    // context is null if disposal of the provider is triggered
    if (null != context) {
        StructuredSelection selection = (StructuredSelection) context.getSelection();
        List<Object> selectedElements = Arrays.asList(selection.toArray());
        selectionContainsWorkingSet = selectedElements.stream().anyMatch(element -> element instanceof WorkingSet);
        // try to minimize number of context updates for working set action provider
        if (selectionContainsWorkingSet) {
            workingSetActionProvider.setContext(context);
        }
        assignWorkingSetsAction.selectionChanged(selection);
    }
}
Also used : ICommonActionExtensionSite(org.eclipse.ui.navigator.ICommonActionExtensionSite) IContextMenuConstants(org.eclipse.jdt.ui.IContextMenuConstants) Arrays(java.util.Arrays) CommonActionProvider(org.eclipse.ui.navigator.CommonActionProvider) AssignWorkingSetsAction(org.eclipse.n4js.ui.workingsets.internal.AssignWorkingSetsAction) Inject(com.google.inject.Inject) IActionBars(org.eclipse.ui.IActionBars) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) N4JSWorkingSetActionProvider(org.eclipse.n4js.ui.workingsets.internal.N4JSWorkingSetActionProvider) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) N4JSProjectActionGroup(org.eclipse.n4js.ui.workingsets.internal.N4JSProjectActionGroup) ActionContext(org.eclipse.ui.actions.ActionContext) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) IViewPart(org.eclipse.ui.IViewPart) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet)

Example 8 with ActionContext

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

the class ProcessExplorerView method handleSelectionChanged.

protected void handleSelectionChanged(IStructuredSelection selection) {
    List<?> list = selection.toList();
    if (list.size() == 0)
        return;
    ActionContext actionContext = new ActionContext(selection);
    actionGroup.setContext(actionContext);
    // show the properties for this item
    Object item = list.get(0);
    if (item instanceof WorkflowElement) {
        WorkflowElement workflowElement = (WorkflowElement) item;
        selectionProvider.setSelection(workflowElement);
        // set the schema owner static qualifier
        if (workflowElement.getProject() != null)
            DBMappingUtil.setSchemaOwner(workflowElement.getProject().getMdwDataSource().getSchemaOwner());
    }
}
Also used : ActionContext(org.eclipse.ui.actions.ActionContext) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 9 with ActionContext

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

the class CommonNavigatorManager method selectionChanged.

/**
 * @param anEvent
 *            An event indicating the current selection of the
 *            {@link CommonViewer}
 *
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 */
public void selectionChanged(SelectionChangedEvent anEvent) {
    if (anEvent.getSelection() instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) anEvent.getSelection();
        actionService.setContext(new ActionContext(structuredSelection));
        actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionContext(org.eclipse.ui.actions.ActionContext)

Example 10 with ActionContext

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

the class CommonNavigatorManager method fillContextMenu.

/**
 * <p>
 * Fills aMenuManager with menu contributions from the
 * {@link NavigatorActionService}.
 * </p>
 *
 * @param aMenuManager
 *            A popup menu
 * @see NavigatorActionService#fillContextMenu(IMenuManager)
 */
protected void fillContextMenu(IMenuManager aMenuManager) {
    ISelection selection = commonNavigator.getCommonViewer().getSelection();
    actionService.setContext(new ActionContext(selection));
    actionService.fillContextMenu(aMenuManager);
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) 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