本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeySequence类的典型用法代码示例。如果您正苦于以下问题:Java KeySequence类的具体用法?Java KeySequence怎么用?Java KeySequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeySequence类属于org.eclipse.jface.bindings.keys包,在下文中一共展示了KeySequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchesKeybinding
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
public static boolean matchesKeybinding(int keyCode, int stateMask, String commandId)
{
final IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench()
.getAdapter(IBindingService.class);
TriggerSequence[] activeBindingsFor = bindingSvc.getActiveBindingsFor(commandId);
for (TriggerSequence seq : activeBindingsFor)
{
if (seq instanceof KeySequence)
{
if (matchesKeybinding(keyCode, stateMask, seq))
{
return true;
}
}
}
return false;
}
示例2: internalMatchesKeybinding
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的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;
}
示例3: setValue
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
@Override
protected void setValue(Object element, Object value) {
if (column == 1) {
// BindingElement activeBinding = (BindingElement) model.getSelectedElement();
BindingElement activeBinding = (BindingElement) element;
if (activeBinding != null) {
KeySequence keySequence = fKeySequenceText.getKeySequence();
// Bug #2740
if (keySequence == null || !keySequence.toString().endsWith("+")) {
activeBinding.setTrigger(keySequence);
}
}
changeBackground();
// isValid();
}
}
示例4: addSetKeySequenceListener
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
private void addSetKeySequenceListener() {
addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (BindingElement.PROP_TRIGGER.equals(event.getProperty())) {
// Bug #2740
if (((KeySequence) event.getNewValue()) != null) {
if (((KeySequence) event.getNewValue()).toString().endsWith("+")) {
return;
} else {
updateTrigger((BindingElement) event.getSource(), (KeySequence) event.getOldValue(),
(KeySequence) event.getNewValue());
}
}
}
}
});
}
示例5: bindMacro
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
/**
* Bind the loaded macro to its previous key binding, removing any conflicts
*
* @param editor
* @param command - the new kbd macro command
* @param sequence - key sequence for binding
* @param previous - conflicting binding
*/
private void bindMacro(ITextEditor editor, Command command, KeySequence sequence, Binding previous) {
if (command != null && sequence != null) {
IBindingService service = (editor != null) ? (IBindingService) editor.getSite().getService(IBindingService.class) :
(IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
if (service instanceof BindingService) {
BindingService bindingMgr = (BindingService) service;
if (previous != null) {
bindingMgr.removeBinding(previous);
}
ParameterizedCommand p = new ParameterizedCommand(command, null);
Binding binding = new KeyBinding(sequence, p,
KBD_SCHEMEID, KBD_CONTEXTID, null, null, null, Binding.USER);
bindingMgr.addBinding(binding);
// check for conflicts independent of the current Eclipse context
checkConflicts(bindingMgr,sequence,binding);
}
}
}
示例6: hasBinding
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的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: checkKey
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
/**
* Check if the (accumulated) key strokes have a single binding
*
* @param state
* @param keyCode
* @param character
*
* @return true if most unique binding, else false
*/
protected boolean checkKey(int state, int keyCode, int character) {
boolean result = true;
keys.add(getKey(state,keyCode,character));
trigger = KeySequence.getInstance(keys);
binding = bindingService.getPerfectMatch(trigger);
boolean partial = bindingService.isPartialMatch(trigger);
if (binding == null) {
if (!partial) {
keyCharacter = character;
result = false;
}
} else if (partial) {
// keep looking when there are additional partial matches
binding = null;
}
return result;
}
示例8: checkTrigger
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的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: matchesKeybinding
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
public static boolean matchesKeybinding(int keyCode, int stateMask, String commandId) {
final IBindingService bindingSvc = PlatformUI.getWorkbench()
.getAdapter(IBindingService.class);
TriggerSequence[] activeBindingsFor = bindingSvc.getActiveBindingsFor(commandId);
for (TriggerSequence seq : activeBindingsFor) {
if (seq instanceof KeySequence) {
KeySequence keySequence = (KeySequence) seq;
if (matchesKeybinding(keyCode, stateMask, keySequence)) {
return true;
}
}
}
return false;
}
示例10: update
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
@Override
public void update() {
IProcess process = console.getProcess();
setEnabled(true);
KeySequence binding = KeyBindingHelper
.getCommandKeyBinding("org.python.pydev.debug.ui.actions.relaunchLastAction");
String str = binding != null ? "(" + binding.format() + " with focus on editor)" : "(unbinded)";
if (process.canTerminate()) {
this.setImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH));
this.setToolTipText("Restart the current launch. " + str);
} else {
this.setImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH1));
this.setToolTipText("Relaunch with the same configuration." + str);
}
}
示例11: testUpdateTrigger
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
@Test
public void testUpdateTrigger() throws ParseException {
final BindingElement bindingEl = new BindingElement(keyController);
final KeySequence oldKeys = KeySequence.getInstance(KeyStroke.getInstance("M1+A"));
final KeySequence newKeys = KeySequence.getInstance(KeyStroke.getInstance("M1+B"));
final Command command = commandManager.getCommand("aa");
final ParameterizedCommand parametrized = new ParameterizedCommand(command, null);
final KeyBinding model = new KeyBinding(oldKeys, parametrized, SCHEME_ID, "default", null, null, null, 0);
bindingEl.setModelObject(model);
keyController.init();
keyController.setNotifying(false);
final BindingModel bindingModel = keyController.getBindingModel();
final SchemeElement scheme = new SchemeElement(keyController);
scheme.setId("myScheme");
keyController.getSchemeModel().setSelectedElement(scheme);
assertTrue(bindingModel.getBindingToElement().isEmpty());
keyController.updateTrigger(bindingEl, oldKeys, newKeys);
final Map<Binding, BindingElement> map = bindingModel.getBindingToElement();
assertEquals(1, map.size());
final Binding binding = map.keySet().iterator().next();
final BindingElement updatedEl = map.get(binding);
assertEquals(bindingEl, updatedEl);
assertEquals(newKeys, updatedEl.getTrigger());
}
示例12: setUp
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
contextManager = new ContextManager();
commandManager = new CommandManager();
bindings = new ArrayList<Binding>();
command1 = commandManager.getCommand(COMMAND_IDS[0]);
command2 = commandManager.getCommand(COMMAND_IDS[1]);
command3 = commandManager.getCommand(COMMAND_IDS[2]);
bindings.add(createBinding(command1, "a", KeySequence.getInstance("M1+A")));
bindings.add(createBinding(command2, "b", KeySequence.getInstance("M1+B")));
bindings.add(createBinding(command3, "c", KeySequence.getInstance("M1+C")));
bindingManager = new BindingManager(contextManager, commandManager);
bindingManager.addBinding(bindings.get(0));
bindingManager.addBinding(bindings.get(1));
bindingManager.addBinding(bindings.get(2));
final Scheme scheme = bindingManager.getScheme("default");
scheme.define("myScheme1", "My scheme for testing", null);
bindingManager.setActiveScheme(scheme);
}
示例13: testRefresh
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
@Test
public void testRefresh() throws Exception {
final BindingModel bindingModel = new BindingModel(controller);
final List<MBindingContext> contexts = TestBindingContext.createContexts();
final ContextModel context1 = new ContextModel(controller);
context1.init(contexts);
bindingModel.init(bindingManager, commandManager, null, context1).refresh(context1);
Set<BindingElement> bindingElements = bindingModel.getBindings();
assertEquals(3, bindingElements.size());
contexts.add(TestBindingContext.createBindingContext("new"));
bindingManager
.addBinding(createBinding(commandManager.getCommand("NN"), "nn", KeySequence.getInstance("M1+N")));
bindingModel.refresh(new ContextModel(controller).init(contexts));
bindingElements = bindingModel.getBindings();
assertEquals(4, bindingElements.size());
}
示例14: processStrokes
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
private boolean processStrokes(final List<KeyStroke> inStrokes) {
final KeySequence lSequenceBeforeStroke = state;
for (final KeyStroke lKeyStroke : inStrokes) {
final KeySequence lSequenceAfterStroke = KeySequence
.getInstance(lSequenceBeforeStroke, lKeyStroke);
final StyleContributionItem lToolItem = commands
.get(lSequenceAfterStroke);
if (lToolItem != null) {
final Map<String, String> lParameters = new HashMap<String, String>();
lParameters.put(
RelationsConstants.PN_COMMAND_STYLE_SELECTION,
lToolItem.getSelection() ? "false" : "true"); //$NON-NLS-1$ //$NON-NLS-2$
handlerService.executeHandler(
ParameterizedCommand.generateCommand(
lToolItem.getCommand(), lParameters));
state = KeySequence.getInstance();
return true;
}
state = lSequenceAfterStroke;
}
state = KeySequence.getInstance();
return !lSequenceBeforeStroke.isEmpty();
}
示例15: assistSessionStarted
import org.eclipse.jface.bindings.keys.KeySequence; //导入依赖的package包/类
@Override
public void assistSessionStarted(ContentAssistEvent event) {
if(event.processor != LangContentAssistProcessor.this)
return;
invocationIteration = 0;
isAutoActivation = event.isAutoActivated;
if (event.assistant instanceof IContentAssistantExtension2) {
IContentAssistantExtension2 extension = (IContentAssistantExtension2) event.assistant;
KeySequence binding = getGroupingIterationBinding();
boolean repeatedModeEnabled = categories.size() > 1;
setRepeatedModeStatus(extension, repeatedModeEnabled, binding);
}
listener_assistSessionStarted();
}