本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeyStroke.getNaturalKey方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke.getNaturalKey方法的具体用法?Java KeyStroke.getNaturalKey怎么用?Java KeyStroke.getNaturalKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.bindings.keys.KeyStroke
的用法示例。
在下文中一共展示了KeyStroke.getNaturalKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalMatchesKeybinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private static boolean internalMatchesKeybinding(int keyCode, int stateMask, TriggerSequence seq)
{
KeySequence keySequence = (KeySequence) seq;
KeyStroke[] keyStrokes = keySequence.getKeyStrokes();
if (keyStrokes.length > 1)
{
return false; // Only handling one step binding... the code below does not support things as "CTRL+X R" for
// redo.
}
for (KeyStroke keyStroke : keyStrokes)
{
if (keyStroke.getNaturalKey() == keyCode && keyStroke.getModifierKeys() == stateMask)
{
return true;
}
}
return false;
}
示例2: format
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
public String format(final KeyStroke keyStroke) {
final String keyDelimiter = getKeyDelimiter();
// Format the modifier keys, in sorted order.
final int modifierKeys = keyStroke.getModifierKeys();
final int[] sortedModifierKeys = sortModifierKeys(modifierKeys);
final StringBuffer stringBuffer = new StringBuffer();
if (sortedModifierKeys != null) {
for (int i = 0; i < sortedModifierKeys.length; i++) {
final int modifierKey = sortedModifierKeys[i];
if (modifierKey != KeyStroke.NO_KEY) {
stringBuffer.append(format(modifierKey));
stringBuffer.append(keyDelimiter);
}
}
}
// Format the natural key, if any.
final int naturalKey = keyStroke.getNaturalKey();
if (naturalKey != 0) {
stringBuffer.append(format(naturalKey));
}
return stringBuffer.toString();
}
示例3: getFormattedShortcut
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private String getFormattedShortcut(String commandId, Event trigger) {
IPreferenceStore store = getPreferenceStore();
int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(trigger);
KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator);
if (KeyStroke.NO_KEY != keyStroke.getNaturalKey()) {
if (store.getBoolean(PREF_KEY_SHORTCUTS_ENABLED)) {
String formattedStroke = SWTKeySupport.getKeyFormatterForPlatform().format(keyStroke);
if (debug && debugTrace != null) {
debugTrace.trace(DEBUG_PATH, "Formatted stroke is: " + formattedStroke); //$NON-NLS-1$
}
return formattedStroke;
} else { // keystroke found, but we're disabled
return null;
}
}
else if (store.getBoolean(PREF_KEY_MOUSE_TRIGGER_ENABLED)) {
IBindingService bindingService = (IBindingService) getWorkbench().getService(IBindingService.class);
return bindingService.getBestActiveBindingFormattedFor(commandId);
}
return null;
}
示例4: getShifted
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Does the trigger for this movement command contain the SHIFT key?
*
* Enforce that the <binding> and <binding>+SHIFT belong to the same Command.
* If not, don't apply shift selection (if enabled) for this command (i.e. return false).
*
* @param event the Execution event that invoked this command
*
* @return true if SHIFT modifier was set, else false
*/
private boolean getShifted(ExecutionEvent event) {
// NB: only single keystroke commands are valid
boolean result = false;
Object trigger = event.getTrigger();
Event e = null;
if (trigger != null && trigger instanceof Event && ((e = (Event)trigger).stateMask & SWT.SHIFT )!= 0) {
String cmdId = event.getCommand().getId();
int mask = (e.stateMask & SWT.MODIFIER_MASK) ^ SWT.SHIFT;
int u_code = Character.toUpperCase((char)e.keyCode);
IBindingService bs = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
if (cmdId != null && bs != null) {
TriggerSequence[] sequences = bs.getActiveBindingsFor(cmdId);
for (TriggerSequence s : sequences) {
if (s instanceof KeySequence) {
KeyStroke[] strokes = ((KeySequence)s).getKeyStrokes();
if (strokes.length == 1) {
KeyStroke k = strokes[strokes.length - 1];
// if keyCode is alpha, then we test uppercase, else keyCode
if (k.getModifierKeys() == mask
&& (k.getNaturalKey() == u_code || k.getNaturalKey() == e.keyCode)) {
result = true;
break;
}
}
}
}
}
}
return result;
}
示例5: makeEvent
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private Event makeEvent(IUniversalResult ua) {
Event result = new Event();
KeySequence keys = ua.getTrigger();
if (keys != null) {
Trigger[] triggers = keys.getTriggers();
if (triggers[0] instanceof KeyStroke) { // really, all it can be anyway
KeyStroke ks = (KeyStroke)triggers[triggers.length - 1];
result.keyCode = ks.getNaturalKey();
result.stateMask = ks.getModifierKeys() & SWT.MODIFIER_MASK;
}
}
return result;
}
示例6: matchesKeybinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
public static boolean matchesKeybinding(int keyCode, int stateMask, KeySequence keySequence) {
KeyStroke[] keyStrokes = keySequence.getKeyStrokes();
for (KeyStroke keyStroke : keyStrokes) {
if (keyStroke.getNaturalKey() == keyCode
&& ((keyStroke.getModifierKeys() & stateMask) != 0 || keyStroke.getModifierKeys() == stateMask)) {
return true;
}
}
return false;
}
示例7: getKeyCode
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private int getKeyCode(final KeySequence inSequence) {
int out = 0;
for (final KeyStroke lStroke : inSequence.getKeyStrokes()) {
out |= lStroke.getModifierKeys() | lStroke.getNaturalKey();
}
return out;
}
示例8: getKeyCode
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private int getKeyCode(final KeySequence inSequence) {
int out = 0;
if (inSequence == null) {
return out;
}
for (final KeyStroke lStroke : inSequence.getKeyStrokes()) {
out |= lStroke.getModifierKeys() | lStroke.getNaturalKey();
}
return out;
}
示例9: handleVerifyKeyPressed
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private void handleVerifyKeyPressed(VerifyEvent event) {
if (!event.doit) {
return;
}
try {
KeyStroke triggerKeyStroke = HotKeyUtil.getHotKey(HotKeyUtil.contentAssist);
if (triggerKeyStroke != null) {
if ((triggerKeyStroke.getModifierKeys() == KeyStroke.NO_KEY && triggerKeyStroke.getNaturalKey() == event.character)
||
(((triggerKeyStroke.getNaturalKey() == event.keyCode)
|| (Character.toLowerCase(triggerKeyStroke.getNaturalKey()) == event.keyCode) || (Character
.toUpperCase(triggerKeyStroke.getNaturalKey()) == event.keyCode)) && ((triggerKeyStroke
.getModifierKeys() & event.stateMask) == triggerKeyStroke.getModifierKeys()))) {
doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
event.doit = false;
return;
}
}
}
catch (Exception e) {
}
if (event.stateMask != SWT.CTRL) {
return;
}
switch (event.character) {
case ' ':
doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
event.doit = false;
break;
case '.':
doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
event.doit = false;
break;
case 'y' - 'a' + 1:
doOperation(ITextOperationTarget.REDO);
event.doit = false;
break;
case 'z' - 'a' + 1:
doOperation(ITextOperationTarget.UNDO);
event.doit = false;
break;
default:
}
}