use of org.eclipse.jface.bindings.TriggerSequence in project eclipse.platform.text by eclipse.
the class ContentAssistHandler method installCueLabelProvider.
/**
* Create and install the {@link LabelProvider} for fContentAssistSubjectAdapter.
*/
private void installCueLabelProvider() {
ILabelProvider labelProvider = new LabelProvider() {
@Override
public String getText(Object element) {
IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if (activeBindings.length == 0)
return ContentAssistMessages.ContentAssistHandler_contentAssistAvailable;
return NLSUtility.format(ContentAssistMessages.ContentAssistHandler_contentAssistAvailableWithKeyBinding, activeBindings[0].format());
}
};
fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider);
}
use of org.eclipse.jface.bindings.TriggerSequence in project webtools.sourceediting by eclipse.
the class CodeAssistCyclingConfigurationBlock method getKeyboardShortcut.
private static String getKeyboardShortcut(ParameterizedCommand command) {
IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
fgLocalBindingManager.setBindings(bindingService.getBindings());
try {
Scheme activeScheme = bindingService.getActiveScheme();
if (activeScheme != null)
fgLocalBindingManager.setActiveScheme(activeScheme);
} catch (NotDefinedException e) {
Logger.logException(e);
}
TriggerSequence[] bindings = fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
if (bindings.length > 0)
return bindings[0].format();
return null;
}
use of org.eclipse.jface.bindings.TriggerSequence in project webtools.servertools by eclipse.
the class ServerActionProvider method addTopSection.
protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) {
MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID);
IAction newServerAction = new NewServerWizardAction();
newServerAction.setText(Messages.actionNewServer);
newMenu.add(newServerAction);
menu.add(newMenu);
// open action
if (server != null && module == null) {
menu.add(openAction);
String text = Messages.actionShowIn;
final IWorkbench workbench = PlatformUI.getWorkbench();
final IBindingService bindingService = (IBindingService) workbench.getAdapter(IBindingService.class);
final TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor(SHOW_IN_MENU_ID);
if (activeBindings.length > 0) {
text += "\t" + activeBindings[0].format();
}
MenuManager showInMenu = new MenuManager(text, SHOW_IN_MENU_ID);
showInMenu.add(showInConsoleAction);
showInMenu.add(showInDebugAction);
menu.add(showInMenu);
}
}
use of org.eclipse.jface.bindings.TriggerSequence in project webtools.servertools by eclipse.
the class ServersView method fillContextMenu.
protected void fillContextMenu(Shell shell, IMenuManager menu) {
// get selection but avoid no selection or multiple selection
IServer server = null;
IModule[] module = null;
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
if (!selection.isEmpty()) {
Iterator iterator = selection.iterator();
Object obj = iterator.next();
if (obj instanceof IServer)
server = (IServer) obj;
if (obj instanceof ModuleServer) {
ModuleServer ms = (ModuleServer) obj;
server = ms.server;
module = ms.module;
}
if (iterator.hasNext()) {
server = null;
module = null;
}
}
// new action
MenuManager newMenu = new MenuManager(Messages.actionNew);
fillNewContextMenu(null, selection, newMenu);
menu.add(newMenu);
// open action
if (server != null && module == null) {
menu.add(openAction);
String text = Messages.actionShowIn;
final IWorkbench workbench = PlatformUI.getWorkbench();
final IBindingService bindingService = (IBindingService) workbench.getAdapter(IBindingService.class);
final TriggerSequence[] activeBindings = bindingService.getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
if (activeBindings.length > 0) {
text += "\t" + activeBindings[0].format();
}
MenuManager showInMenu = new MenuManager(text);
showInMenu.add(showInConsoleAction);
showInMenu.add(showInDebugAction);
// IActionBars actionBars = getViewSite().getActionBars();
// actionBars.setGlobalActionHandler("group.show", showInMenu);
menu.add(showInMenu);
menu.add(new Separator());
} else
menu.add(new Separator());
if (server != null) {
if (module == null) {
menu.add(copyAction);
menu.add(pasteAction);
menu.add(deleteAction);
menu.add(renameAction);
} else if (module.length == 1)
menu.add(new RemoveModuleAction(shell, server, module[0]));
menu.add(new Separator());
}
if (server != null && module == null) {
// server actions
for (int i = 0; i < actions.length; i++) menu.add(actions[i]);
menu.add(new Separator());
menu.add(actionModifyModules);
// monitor
if (server.getServerType() != null) {
final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
final IServer server2 = server;
final Shell shell2 = shell;
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
menuManager.removeAll();
if (server2.getAdapter(ServerDelegate.class) != null) {
ServerPort[] ports = server2.getServerPorts(null);
if (ports != null) {
int size = ports.length;
for (int i = 0; i < size; i++) {
if (!ports[i].isAdvanced())
menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
}
}
}
if (menuManager.isEmpty())
menuManager.add(noneAction);
menuManager.add(new Separator());
menuManager.add(monitorPropertiesAction);
}
});
// add an initial menu item so that the menu appears correctly
noneAction.setEnabled(false);
menuManager.add(noneAction);
menu.add(menuManager);
}
}
if (server != null && module != null) {
menu.add(new Separator());
menu.add(new StartModuleAction(server, module));
menu.add(new StopModuleAction(server, module));
menu.add(new RestartModuleAction(server, module));
}
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));
if (server != null) {
menu.add(new Separator());
menu.add(propertiesAction);
}
}
use of org.eclipse.jface.bindings.TriggerSequence in project sts4 by spring-projects.
the class GotoSymbolHandler method getKeybindings.
private String getKeybindings(ExecutionEvent event) {
Command invokingCommand = event.getCommand();
IBindingService service = PlatformUI.getWorkbench().getService(IBindingService.class);
TriggerSequence[] bindings = service.getActiveBindingsFor(invokingCommand.getId());
if (bindings != null && bindings.length > 0) {
return bindings[0].toString();
}
return null;
}
Aggregations