当前位置: 首页>>代码示例>>Java>>正文


Java KeySequence.getInstance方法代码示例

本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeySequence.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java KeySequence.getInstance方法的具体用法?Java KeySequence.getInstance怎么用?Java KeySequence.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.bindings.keys.KeySequence的用法示例。


在下文中一共展示了KeySequence.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:27,代码来源:KeyHandlerMinibuffer.java

示例2: 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());
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:25,代码来源:KeyControllerTest.java

示例3: 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();
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:24,代码来源:AbstractEditForm.java

示例4: modifyBindingsForAddChangeSet

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
private void modifyBindingsForAddChangeSet(final KbaChangeSet changeSet,
    final KeyBindings bindings, final Scheme scheme) {
  for (KbaBinding toAdd : changeSet.getBindingList()) {
    Command commandToAdd = commandService.getCommand(toAdd.getCid());
    if (!commandToAdd.isDefined()) {
      log.logWarning("Command '" + toAdd.getCid() + "' does not exist. Skipping.");
      continue;
    }
    ParameterizedCommand parameterizedCommandToAdd =
        ParameterizedCommand.generateCommand(commandToAdd, toAdd.getParameters());

    KeySequence triggerSequence;
    try {
      triggerSequence = KeySequence.getInstance(toAdd.getKeySequence());
    } catch (ParseException e) {
      log.logError(e, "Invalid key sequence: %s", toAdd.getKeySequence());
      throw new RuntimeException(e);
    }

    bindings.addIfNotPresent(
        scheme, 
        changeSet.getPlatform(), 
        changeSet.getContextId(), 
        triggerSequence,
        parameterizedCommandToAdd);
  }
}
 
开发者ID:alfsch,项目名称:workspacemechanic,代码行数:28,代码来源:KeyboardBindingsTask.java

示例5: getKeySequences

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
/**
 * getKeySequence
 * 
 * @return
 */
public static KeySequence[] getKeySequences(CommandElement command)
{
	String[] bindings = command.getKeyBindings();
	if (ArrayUtil.isEmpty(bindings))
	{
		return NO_BINDINGS;
	}

	List<KeySequence> result = new ArrayList<KeySequence>(bindings.length);
	for (String binding : bindings)
	{
		try
		{
			// Need to convert the format
			String normalizedKeyBinding = normalizeKeyBinding(binding);
			KeySequence sequence = KeySequence.getInstance(normalizedKeyBinding);

			result.add(sequence);
		}
		catch (ParseException e)
		{
			String message = MessageFormat.format(Messages.CommandElement_Invalid_Key_Binding, new Object[] {
					binding, command.getDisplayName(), command.getPath(), e.getMessage() });
			// Log to scripting console
			ScriptLogger.logError(message);
			IdeLog.logError(ScriptingUIPlugin.getDefault(), message);
		}
	}

	return result.toArray(new KeySequence[result.size()]);
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:37,代码来源:KeyBindingUtil.java

示例6: isAcceleratorInUse

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
/**
 * @see org.eclipse.jface.action.ExternalActionManager.ICallback#isAcceleratorInUse(int)
 */
public final boolean isAcceleratorInUse(final int accelerator) {
	final KeySequence keySequence = KeySequence
			.getInstance(SWTKeySupport
					.convertAcceleratorToKeyStroke(accelerator));
	return bindingManager.isPerfectMatch(keySequence)
			|| bindingManager.isPartialMatch(keySequence);
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:11,代码来源:ExternalActionManager.java

示例7: getBinding

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
/**
 * Check for C-x C-k <key> binding conflict
 * 
 * @param editor
 * @param c
 * @return IBindingResult with C-x C-k <key> information
 */
private IBindingResult getBinding(ITextEditor editor, char c) {
	IBindingResult result = null;
	try {
		final KeySequence sequence = KeySequence.getInstance(KeySequence.getInstance(STD_KBD_PREFIX), KeyStroke.getInstance(c));
		final Binding binding = checkForBinding(editor, sequence);
		result = new IBindingResult() {
			public Binding getKeyBinding() { return binding; }
			public String getKeyString() { return sequence.format(); }
			public KeySequence getTrigger() { return sequence; }
		};
	} catch (ParseException e) { }
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:21,代码来源:KbdMacroBindHandler.java

示例8: getTrigger

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
/**
 * @throws ParseException
 */
public KeySequence getTrigger() throws ParseException {
	if (trigger == null) {
		trigger = KeySequence.getInstance(keyString);
	}
	return trigger;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:10,代码来源:DynamicInitializer.java

示例9: testKeyStrokes

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
@Test
public void testKeyStrokes() {
	final KeyStroke lKeyStroke = KeyStroke.getInstance(SWT.MOD1, 'I');
	assertEquals(SWT.MOD1 | 'I',
	        lKeyStroke.getModifierKeys() | lKeyStroke.getNaturalKey());
	assertEquals("CTRL+I", lKeyStroke.format());

	final KeySequence lSequence = KeySequence.getInstance(lKeyStroke);

	assertEquals("CTRL+I", lSequence.format());
	assertEquals(SWT.MOD1 | 'I', getKeyCode(lSequence));
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:13,代码来源:AbstractEditFormTest.java

示例10: testSetTrigger

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
@Test
public void testSetTrigger() throws Exception {
	final BindingElement binding = new BindingElement(controller);
	final TriggerSequence trigger1 = KeySequence.getInstance("M1+A");
	binding.setTrigger(trigger1);
	verify(controller).firePropertyChange(binding, BindingElement.PROP_TRIGGER, null, trigger1);
	assertEquals(trigger1, binding.getTrigger());

	final TriggerSequence trigger2 = KeySequence.getInstance("M1+B");
	binding.setTrigger(trigger2);
	verify(controller).firePropertyChange(binding, BindingElement.PROP_TRIGGER, trigger1, trigger2);
	assertEquals(trigger2, binding.getTrigger());
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:14,代码来源:BindingElementTest.java

示例11: createKeyBinding

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
private KeyBinding createKeyBinding(final MKeyBinding inBinding,
        final String inSchemeId) throws ParseException {
	return new KeyBinding(
	        KeySequence.getInstance(inBinding.getKeySequence()),
	        commandService.createCommand(
	                inBinding.getCommand().getElementId(), null),
	        inSchemeId, contextId, null, null, null, Binding.SYSTEM);
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:9,代码来源:SaveHelper.java

示例12: isInvocationEvent

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
protected boolean isInvocationEvent(KeyEvent e) {
    int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
    KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));

    return keySequence.startsWith(triggerSequence, true);
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:7,代码来源:QuickOutline.java

示例13: getKeySequence

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
public static KeySequence getKeySequence(String text) throws ParseException, IllegalArgumentException {
    KeySequence keySequence = KeySequence.getInstance(KeyStroke.getInstance(text));
    return keySequence;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:5,代码来源:KeyBindingHelper.java

示例14: isSameBinding

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
private boolean isSameBinding(MKeyBinding existingBinding, MCommand cmd,
        Binding newBinding) {
	// see org.eclipse.jface.bindings.Binding#equals(final Object object)
	if (!cmd.equals(existingBinding.getCommand())) {
		return false;
	}
	final String lExistingKeySequence = existingBinding.getKeySequence();
	if (lExistingKeySequence == null) {
		return false;
	}
	try {
		final KeySequence lExistingSequence = KeySequence
		        .getInstance(lExistingKeySequence);
		if (!lExistingSequence.equals(newBinding.getTriggerSequence())) {
			return false;
		}
	}
	catch (final ParseException exc) {
		return false;
	}

	// tags to look for:
	final List<String> lModelTags = existingBinding.getTags();

	final String lSchemeId = newBinding.getSchemeId();
	if (lSchemeId != null
	        && !lSchemeId.equals(BindingPersistence.getDefaultSchemeId())) {
		if (!lModelTags.contains(
		        EBindingService.SCHEME_ID_ATTR_TAG + ":" + lSchemeId)) { //$NON-NLS-1$
			return false;
		}
	}
	final String lLocale = newBinding.getLocale();
	if (lLocale != null) {
		if (!lModelTags.contains(
		        EBindingService.LOCALE_ATTR_TAG + ":" + lLocale)) { //$NON-NLS-1$
			return false;
		}
	}
	final String lPlatform = newBinding.getPlatform();
	if (lPlatform != null) {
		if (!lModelTags.contains(
		        EBindingService.PLATFORM_ATTR_TAG + ":" + lPlatform)) { //$NON-NLS-1$
			return false;
		}
	}
	if (newBinding.getType() == Binding.USER) {
		if (!lModelTags.contains(EBindingService.TYPE_ATTR_TAG + ":user")) { //$NON-NLS-1$
			return false;
		}
	}
	return true;
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:54,代码来源:SaveHelper.java

示例15: KeyBindingState

import org.eclipse.jface.bindings.keys.KeySequence; //导入方法依赖的package包/类
/**
 * Constructs a new instance of <code>KeyBindingState</code> with an empty key sequence, set to reset fully.
 * 
 * @param workbenchToNotify
 *            The workbench that this state should keep advised of changes to the key binding state; must not be
 *            <code>null</code>.
 */
KeyBindingState(IWorkbench workbenchToNotify)
{
	currentSequence = KeySequence.getInstance();
	workbench = workbenchToNotify;
	associatedWindow = workbench.getActiveWorkbenchWindow();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:14,代码来源:KeyBindingState.java


注:本文中的org.eclipse.jface.bindings.keys.KeySequence.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。