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);
}
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);
}
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;
}
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();
}
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
}
Aggregations