本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeyStroke类的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke类的具体用法?Java KeyStroke怎么用?Java KeyStroke使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyStroke类属于org.eclipse.jface.bindings.keys包,在下文中一共展示了KeyStroke类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHotKey
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
public static KeyStroke getHotKey(String commondID) throws ParseException {
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
if (bindingService != null) {
TriggerSequence trigger = bindingService.getBestActiveBindingFor(commondID);
if (trigger != null) {
Trigger[] tiggers = trigger.getTriggers();
if (tiggers.length > 0) {
Trigger tigger = tiggers[0];
if (tigger instanceof KeyStroke) {
return (KeyStroke) tigger;
}
}
}
}
return KeyStroke.getInstance("Ctrl+Space");
}
示例2: updateKeyCustomProperty
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
public void updateKeyCustomProperty(SWTBotGefEditPart part, String key, String newkey) {
GraphElement element = selectPart(part);
selectTab(part, CUSTOM);
SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON);
bot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
int row = table.indexOf(key, "PROPERTY");
if (row == -1) return true;
table.click(row, 0);
bot.sleep(1000);
bot.text(key, 0).setText(newkey);
bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0);
return false;
}
@Override
public String getFailureMessage() {
return "key not set";
}
},2 * 60 * 1000);
}
示例3: updateValueCustomProperty
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
public void updateValueCustomProperty(SWTBotGefEditPart part, String key, String oldvalue, String newValue) {
GraphElement element = selectPart(part);
selectTab(part, CUSTOM);
SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON);
bot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
int row = table.indexOf(oldvalue, "VALUE");
if (row == -1) return true;
table.click(row, 1);
bot.sleep(1000);
bot.text(oldvalue, 0).setText(newValue);
bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0);
return false;
}
@Override
public String getFailureMessage() {
return "value not set";
}
},2 * 60 * 1000);
}
示例4: LineEditor
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
public LineEditor(final SWTCanvas canvas, int style) {
super(canvas, style, TrpTextLineType.class);
textField = new StyledText(SWTUtil.dummyShell, SWT.SINGLE | SWT.BORDER);
textField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// this one highlights words that are tagged:
textField.addLineStyleListener(new LineStyleListener() {
@Override
public void lineGetStyle(LineStyleEvent event) {
if (shape==null)
return;
// List<StyleRange> styleList = ATranscriptionWidget.getTagStylesForLine(shape, event.lineOffset);
// event.styles = (StyleRange[]) ArrayUtils.addAll(event.styles, styleList.toArray(new StyleRange[0]));
}
});
addWidget(textField);
// autocomplete field:
autocomplete = new TrpAutoCompleteField(textField,
new StyledTextContentAdapter(textField), new String[]{},
KeyStroke.getInstance(SWT.CTRL, SWT.SPACE), null
);
autocomplete.getAdapter().setEnabled(false);
}
示例5: TrpAutoCompleteField
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
public TrpAutoCompleteField(Control control, IControlContentAdapter controlContentAdapter, String[] proposals,
KeyStroke keyStroke, char[] autoActivationCharacters)
{
assert(proposals != null);
this.proposals = proposals;
proposalProvider = new SimpleContentProposalProvider(proposals);
proposalProvider.setFiltering(true);
adapter = new MyContentProposalAdapter(control, controlContentAdapter,
proposalProvider, keyStroke, autoActivationCharacters);
adapter.setPropagateKeys(false);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
adapter.setAutoActivateOnLetter(true);
adapter.setAutoCloseOnSpace(true);
adapter.setPopupSize(new Point(300, 150));
}
示例6: setupContentProposal
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
private void setupContentProposal() {
try {
final KeyStroke keyStroke = KeyStroke
.getInstance(StringTable.KEYSTROKE_SHORTCUT_FOR_PROPOSAL);
char[] autoActivationCharacters = new char[Character.MAX_VALUE];
for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++)
autoActivationCharacters[c] = c;
adapter = new ContentProposalAdapter(constraintText,
new SimpleSyntaxHighlighterConstraintContentAdapter(),
new ConstraintContentProposalProvider(featureController
.getFeatureExpressions().getFeatureExpressionsAsSet()),
keyStroke, autoActivationCharacters);
adapter.setAutoActivationDelay(PROPOSAL_AUTO_ACTIVATION_DELAY);
adapter.setPopupSize(new Point(250, 85));
adapter.setLabelProvider(new ConstraintProposalLabelProvider());
} catch (ParseException e) {
e.printStackTrace();
}
}
示例7: addContentAssistSimple
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
private ContentProposalAdapter addContentAssistSimple(Text textControl) {
char[] autoActivationCharacters = new char[] { '$', '{' };
KeyStroke keyStroke = null;
try {
keyStroke = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// assume that myTextControl has already been created in some way
List<Variable> variables = Variable.getVisibleVariables();
String[] proposals = new String [variables.size()];
for(int i=0;i<variables.size();i++) {
proposals[i] = variables.get(i).getFullVariableName();
}
ContentProposalAdapter adapter = new ContentProposalAdapter(
textControl , new TextContentAdapter(),
new SimpleContentProposalProvider(proposals),
keyStroke, autoActivationCharacters);
adapter.setPropagateKeys(false);
adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
//adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
return adapter;
}
示例8: 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;
}
示例9: openDBMgmgDialog
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
/**
* @param from
* 入口,请使用 TSUIConstants 类中提供的枚举。
* @return 打开的库管理对话框;
*/
public DatabaseManagementDialog openDBMgmgDialog(Entry from) {
if (from.equals(TsUIConstants.Entry.MENU)) {
ts.menuDBManagement().click();
} else if (from.equals(TsUIConstants.Entry.SHORTCUT)) {
try {
ts.pressShortcut(SWTBotUtils.getCtrlOrCmdKey(), Keystrokes.SHIFT, KeyStroke.getInstance("D"));
} catch (ParseException e) {
e.printStackTrace();
assertTrue("快捷键解析错误。", false);
}
} else {
assertTrue("参数错误,该功能无此入口:" + from, false);
}
dialog = new DatabaseManagementDialog(DatabaseManagementDialog.MANAGEMENT);
return dialog;
}
示例10: openDBMgmgDialog
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
/**
* @param from
* 入口,请使用 TSUIConstants 类中提供的枚举。
* @return 打开的库管理对话框;
*/
public MemoryDatabaseManagementDialog openDBMgmgDialog(Entry from) {
if (from.equals(TsUIConstants.Entry.MENU)) {
if (isMemory){
ts.menuDBManagement().click();
} else {
ts.menuTeriDBManagement().click();
}
} else if (from.equals(TsUIConstants.Entry.SHORTCUT)) {
try {
ts.pressShortcut(SWTBotUtils.getCtrlOrCmdKey(), Keystrokes.SHIFT, KeyStroke.getInstance("D"));
} catch (ParseException e) {
e.printStackTrace();
assertTrue("快捷键解析错误。", false);
}
} else {
assertTrue("参数错误,该功能无此入口:" + from, false);
}
dialog = new MemoryDatabaseManagementDialog(MemoryDatabaseManagementDialog.MANAGEMENT,isMemory?"dlgTitleMemoryManagement":"dlgTitletreiTbManagement");
return dialog;
}
示例11: 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();
}
示例12: getAccelerator
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
/**
* @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAccelerator(String)
*/
public final Integer getAccelerator(final String commandId) {
final TriggerSequence triggerSequence = bindingManager
.getBestActiveBindingFor(commandId);
if (triggerSequence != null) {
final Trigger[] triggers = triggerSequence.getTriggers();
if (triggers.length == 1) {
final Trigger trigger = triggers[0];
if (trigger instanceof KeyStroke) {
final KeyStroke keyStroke = (KeyStroke) trigger;
final int accelerator = SWTKeySupport
.convertKeyStrokeToAccelerator(keyStroke);
return new Integer(accelerator);
}
}
}
return null;
}
示例13: 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;
}
示例14: init
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
@Override
public void init(IPageBookViewPage viewPage, IConsole console) {
super.init(viewPage, console);
SimpleContentProposalProvider proposalsProvider = new SimpleContentProposalProvider(
proposals);
proposalsProvider.setFiltering(true);
KeyStroke ctrlSpace = null;
try {
ctrlSpace = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException e) {
e.printStackTrace();
}
ContentProposalAdapter adapter = new ContentProposalAdapter(tc,
new StyledTextContentAdapter(util), proposalsProvider,
ctrlSpace, null);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
}
示例15: hasBinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入依赖的package包/类
protected boolean hasBinding(KeyEvent event, int mode) {
boolean result = false;
// ensure key is upper case
KeyStroke key = KeyStroke.getInstance(mode, Character.toUpperCase(event.keyCode));
boolean isFilterDisabled = !getKeyFilter();
try {
if (isFilterDisabled) {
setKeyFilter(true);
}
result = bindingService.isPerfectMatch(KeySequence.getInstance(key));
} finally {
if (isFilterDisabled) {
setKeyFilter(false);
}
}
return result;
}