use of org.eclipse.ui.keys.IBindingService in project dbeaver by serge-rider.
the class ActionUtils method findCommandDescription.
@Nullable
public static String findCommandDescription(String commandId, IServiceLocator serviceLocator, boolean shortcutOnly) {
String commandName = null;
String shortcut = null;
ICommandService commandService = serviceLocator.getService(ICommandService.class);
if (commandService != null) {
Command command = commandService.getCommand(commandId);
if (command != null && command.isDefined()) {
try {
commandName = command.getName();
} catch (NotDefinedException e) {
log.debug(e);
}
}
}
IBindingService bindingService = serviceLocator.getService(IBindingService.class);
if (bindingService != null) {
TriggerSequence sequence = null;
for (Binding b : bindingService.getBindings()) {
ParameterizedCommand parameterizedCommand = b.getParameterizedCommand();
if (parameterizedCommand != null && commandId.equals(parameterizedCommand.getId())) {
sequence = b.getTriggerSequence();
}
}
if (sequence == null) {
sequence = bindingService.getBestActiveBindingFor(commandId);
}
if (sequence != null) {
shortcut = sequence.format();
}
}
if (shortcutOnly) {
return shortcut == null ? "?" : shortcut;
}
if (shortcut == null) {
return commandName;
}
if (commandName == null) {
return shortcut;
}
return commandName + " (" + shortcut + ")";
}
use of org.eclipse.ui.keys.IBindingService in project translationstudio8 by heartsome.
the class ShieldStartup method earlyStartup.
public void earlyStartup() {
IWorkbench workbench = PlatformUI.getWorkbench();
// 在工作台初始化后,移除平台默认的 scheme
IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
Scheme[] schemes = bindingService.getDefinedSchemes();
for (int i = 0; i < schemes.length; i++) {
String id = schemes[i].getId();
if (id.equals(platformDefaultScheme) || id.equals(platformEmacsScheme)) {
schemes[i].undefine();
}
}
}
use of org.eclipse.ui.keys.IBindingService in project translationstudio8 by heartsome.
the class TmMatchEditDialog method close.
@Override
public boolean close() {
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
bindingService.setKeyFilterEnabled(true);
srcSegmentViewer.reset();
tgtSegmentViewer.reset();
return super.close();
}
use of org.eclipse.ui.keys.IBindingService in project translationstudio8 by heartsome.
the class KeyController2 method filterDupliteBind.
@SuppressWarnings("restriction")
public void filterDupliteBind() {
IWorkbench workbench = PlatformUI.getWorkbench();
IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
BindingService service = (BindingService) bindingService;
BindingManager bindingManager = service.getBindingManager();
//service.getBindingManager().
Binding[] bindings = bindingManager.getBindings();
List<Binding> bindTemp = new ArrayList<Binding>();
List<String> ids = new ArrayList<String>();
for (Binding bind : bindings) {
if (null == bind) {
continue;
}
ParameterizedCommand command = bind.getParameterizedCommand();
if (null == command) {
continue;
}
String id = command.getId();
if (!ids.contains(id)) {
ids.add(id);
bindTemp.add(bind);
}
}
bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()]));
}
use of org.eclipse.ui.keys.IBindingService in project translationstudio8 by heartsome.
the class KeyController2 method loadModelBackend.
private static BindingManager loadModelBackend(IServiceLocator locator) {
IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
try {
Scheme modelActiveScheme = null;
for (int i = 0; i < definedSchemes.length; i++) {
final Scheme scheme = definedSchemes[i];
final Scheme copy = bindingManager.getScheme(scheme.getId());
copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
if (definedSchemes[i] == bindingService.getActiveScheme()) {
modelActiveScheme = copy;
}
}
bindingManager.setActiveScheme(modelActiveScheme);
} catch (final NotDefinedException e) {
StatusManager.getManager().handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH, "Keys page found an undefined scheme", //$NON-NLS-1$
e));
}
bindingManager.setLocale(bindingService.getLocale());
bindingManager.setPlatform(bindingService.getPlatform());
bindingManager.setBindings(bindingService.getBindings());
return bindingManager;
}
Aggregations