use of org.eclipse.jface.bindings.keys.KeySequence in project KaiZen-OpenAPI-Editor by RepreZen.
the class QuickOutline method isInvocationEvent.
protected boolean isInvocationEvent(KeyEvent e) {
int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
return keySequence.startsWith(triggerSequence, true);
}
use of org.eclipse.jface.bindings.keys.KeySequence in project whole by wholeplatform.
the class ActionRegistry method registerKeyActions.
public void registerKeyActions(AbstractKeyHandler keyHandler) {
keyHandler.put(KeySequence.getInstance(KeyStroke.getInstance(SWT.F2)), true, actionFactory.createDirectEditAction());
for (IEditorKit editorKit : ReflectionFactory.getEditorKits()) {
for (ILanguageKit lk : ReflectionFactory.getLanguageKits(false)) {
if (!editorKit.canApply(lk))
continue;
for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
KeySequence keySequence = (KeySequence) textAction[0];
Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
try {
IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(context);
keyHandler.put(editorKit, keySequence, true, action);
} catch (Exception e) {
}
}
}
}
}
use of org.eclipse.jface.bindings.keys.KeySequence in project erlide_eclipse by erlang.
the class KeyBindingHelper method matchesKeybinding.
// END pre-defined helpers
/**
* @param event
* the key event to be checked
* @param commandId
* the command to be checked
* @return true if the given key event can trigger the passed command (and false
* otherwise).
*/
public static boolean matchesKeybinding(final KeyEvent event, final String commandId) {
final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingSvc == null) {
return false;
}
final TriggerSequence[] activeBindingsFor = bindingSvc.getActiveBindingsFor(commandId);
for (final TriggerSequence seq : activeBindingsFor) {
if (seq instanceof KeySequence) {
final KeySequence keySequence = (KeySequence) seq;
final KeyStroke[] keyStrokes = keySequence.getKeyStrokes();
for (final KeyStroke keyStroke : keyStrokes) {
if (keyStroke.getNaturalKey() == event.keyCode && (keyStroke.getModifierKeys() & event.stateMask) != 0) {
return true;
}
}
}
}
return false;
}
use of org.eclipse.jface.bindings.keys.KeySequence in project erlide_eclipse by erlang.
the class KeyBindingHelper method getCommandKeyBinding.
/**
* @param commandId
* the command we want to know about
* @return the 'best' key sequence that will activate the given command
*/
public static KeySequence getCommandKeyBinding(final String commandId) {
final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingSvc == null) {
return null;
}
final TriggerSequence binding = bindingSvc.getBestActiveBindingFor(commandId);
if (binding instanceof KeySequence) {
return (KeySequence) binding;
}
return null;
}
Aggregations