本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeyStroke.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke.getInstance方法的具体用法?Java KeyStroke.getInstance怎么用?Java KeyStroke.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.bindings.keys.KeyStroke
的用法示例。
在下文中一共展示了KeyStroke.getInstance方法的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: 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);
}
示例3: 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();
}
}
示例4: 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;
}
示例5: 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);
}
示例6: 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;
}
示例7: checkBinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Check for a full command binding that was executed directly by the minibuffer
* Remove the binding entry and add the command id entry
*
* @param binding
*/
void checkBinding(Binding binding) {
boolean processed = false;
int index = macro.size() -1;
Event keyevent = macro.get(index).getEvent();
if (keyevent != null) {
KeyStroke keyStroke = KeyStroke.getInstance(keyevent.stateMask, (int)Character.toUpperCase((char)keyevent.keyCode));
if (keyStroke.equals(binding.getTriggerSequence().getTriggers()[0])) {
// remove (possibly partial) binding
macro.remove(index);
// flag for minibuffer exit
addExit();
// and insert command
macro.add(new KbdEvent(binding.getParameterizedCommand().getId()));
processed = true;
}
}
if (!processed) {
// then it's a command unto itself (e.g. ARROW_RIGHT)
// flag for minibuffer exit
addExit();
// and insert command
macro.add(new KbdEvent(binding.getParameterizedCommand().getId()));
processed = true;
}
}
示例8: checkTrigger
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Check for a binding that is not a full command and was not handled by the minibuffer
* Remove the partial binding and add the command id entry
*
* @param cmdId
* @param trigger
* @param onExit - it is the endMacro command, ignore id entry
*/
void checkTrigger(String cmdId, Map<?,?> parameters, Event trigger, boolean onExit) {
int index = macro.size() -1;
if (!macro.isEmpty() && trigger != null && macro.get(index).isSubCmd()) {
Event event = macro.get(index).getEvent();
// have trigger and previous entry is a subCmd type
KeyStroke key = KeyStroke.getInstance(event.stateMask, Character.toUpperCase(event.keyCode));
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
Collection<Binding> values = EmacsPlusUtils.getPartialMatches(bindingService,KeySequence.getInstance(key)).values();
// Check partial binding
for (Binding v : values) {
if (cmdId.equals((v.getParameterizedCommand().getId()))) {
// remove (possibly partial) binding
macro.remove(index);
// flag for minibuffer exit
macro.add(new KbdEvent(true));
break;
}
}
}
if (!onExit) {
macro.add(new KbdEvent(cmdId, parameters));
}
}
示例9: addContentProposal
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private void addContentProposal(Text text) {
char[] autoActivationCharacters = null;// new char[] { '.' };
KeyStroke keyStroke = null;
try {
keyStroke = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException e) {
e.printStackTrace();
}
adapter = new VersionContentProposalAdapter(text, new TextContentAdapter(),
new VersionContentProposalProvider(), keyStroke, autoActivationCharacters);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
adapter.setPropagateKeys(true);
adapter.setLabelProvider(VersionLabelProvider.getInstance());
}
示例10: enableXtext
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
protected void enableXtext(Control styledText, Injector injector) {
final StyledTextXtextAdapter xtextAdapter = new StyledTextXtextAdapter(injector);
xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(new ContextElementAdapter(this));
xtextAdapter.adapt((StyledText) styledText);
initContextMenu(styledText);
completionProposalAdapter = new CompletionProposalAdapter(styledText, xtextAdapter.getContentAssistant(),
KeyStroke.getInstance(SWT.CTRL, SWT.SPACE), null);
}
示例11: createDecoration
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/***************************************************************************
* Create decoration for the input field
**************************************************************************/
private void createDecoration()
{
// Field decoration
deco = new ControlDecoration(m_contents, SWT.RIGHT);
deco.setDescriptionText("Use CTRL+Space to see the possible commands");
deco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION)
.getImage());
deco.setShowOnlyOnFocus(false);
deco.setShowHover(true);
KeyStroke keyStroke;
ArrayList<String> possibleCommandsList = new ArrayList<String>();
for (GuiExecutorCommand cmd : GuiExecutorCommand.values())
{
possibleCommandsList.add(cmd.label.toLowerCase());
}
String[] possibleCommands = possibleCommandsList.toArray(new String[0]);
char[] autoActivationCharacters = new char[0];
provider = new SimpleContentProposalProvider(possibleCommands);
try
{
keyStroke = KeyStroke.getInstance("Ctrl+Space");
adp = new ContentProposalAdapter(m_contents, new TextContentAdapter(), provider, keyStroke,
autoActivationCharacters);
adp.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
adp.addContentProposalListener((IContentProposalListener) m_contents.getParent().getParent());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例12: getKeyStroke
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* @param keyStroke
* @param triggerKey
* @return
*/
private KeyStroke getKeyStroke( String triggerKey )
{
try
{
return KeyStroke.getInstance( triggerKey );
}
catch ( Exception e ) // Catch all exceptions to avoid breaking UI.
{
return KeyStroke.getInstance( SWT.F10 );
}
}
示例13: getBinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Return the exact binding if it exists and is enabled, else null
*
* @param editor
* @param keyCode
* @param mode
* @return binding if it exists and is enabled, else null
*/
private Binding getBinding(ITextEditor editor, char keyCode, int mode) {
Binding result = null;
// ensure key is upper case
IBindingService bindingService = (IBindingService) editor.getSite().getService(IBindingService.class);
KeyStroke key = KeyStroke.getInstance(mode, Character.toUpperCase(keyCode));
result = bindingService.getPerfectMatch(KeySequence.getInstance(key));
if (result != null && !result.getParameterizedCommand().getCommand().isEnabled()) {
result = null;
}
return result;
}
示例14: getBinding
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Based on the KeyEvent, get the perfect match binding
*
* @param event
* @param checkEnabled if true, the command in the binding must be enabled
* @return a binding that perfectly matches the KeyEvent, or null
*/
// TODO explain why always force ALT in normal case?
private Binding getBinding(KeyEvent event, int mode, boolean checkEnabled) {
Binding result = null;
// ensure key is upper case
KeyStroke key = KeyStroke.getInstance(mode, Character.toUpperCase(event.keyCode));
boolean isFilterDisabled = !getKeyFilter();
try {
if (isFilterDisabled) {
setKeyFilter(true);
}
// Shadowed commands shouldn't be enabled, but they are ... so protect
// (e.g. C-x will perfect match and be enabled even though shadowed by C-x C-x)
if (checkEnabled && bindingService.isPartialMatch(KeySequence.getInstance(key))) {
result = null;
} else {
result = bindingService.getPerfectMatch(KeySequence.getInstance(key));
if (result != null && checkEnabled && !result.getParameterizedCommand().getCommand().isEnabled()) {
result = null;
}
}
} finally {
if (isFilterDisabled) {
setKeyFilter(false);
}
}
return result;
}
示例15: checkKeyCode
import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
* Dynamically determine the bindings for forward and reverse i-search
* For repeat search, Emacs treats i-search and i-search-regexp identically
*
* @param event
* @return the FORWARD, REVERSE, or the source keyCode
*/
private int checkKeyCode(VerifyEvent event) {
int result = event.keyCode;
Integer val = keyHash.get(Integer.valueOf(event.keyCode + event.stateMask));
if (val == null) {
KeyStroke keyst = KeyStroke.getInstance(event.stateMask, Character.toUpperCase(result));
IBindingService bindingService = getBindingService();
Binding binding = bindingService.getPerfectMatch(KeySequence.getInstance(keyst));
if (binding != null) {
if (ISF.equals(binding.getParameterizedCommand().getId())){
result = FORWARD;
keyHash.put(Integer.valueOf(event.keyCode + event.stateMask),Integer.valueOf(FORWARD));
} else if (ISB.equals(binding.getParameterizedCommand().getId())) {
result = REVERSE;
keyHash.put(Integer.valueOf(event.keyCode + event.stateMask),Integer.valueOf(REVERSE));
} else if (ISRF.equals(binding.getParameterizedCommand().getId())) {
result = FORWARD;
keyHash.put(Integer.valueOf(event.keyCode + event.stateMask),Integer.valueOf(FORWARD));
} else if (ISRB.equals(binding.getParameterizedCommand().getId())) {
result = REVERSE;
keyHash.put(Integer.valueOf(event.keyCode + event.stateMask),Integer.valueOf(REVERSE));
}
}
} else {
result = val;
}
return result;
}