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


Java IBindingService类代码示例

本文整理汇总了Java中org.eclipse.ui.keys.IBindingService的典型用法代码示例。如果您正苦于以下问题:Java IBindingService类的具体用法?Java IBindingService怎么用?Java IBindingService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getHotKey

import org.eclipse.ui.keys.IBindingService; //导入依赖的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");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:HotKeyUtil.java

示例2: ModernActionKeyBindingSupport

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
private ModernActionKeyBindingSupport(
    final IAdaptable serviceLocator,
    final Expression expression,
    final int sourcePriorities) {
    Check.notNull(serviceLocator, "serviceLocator"); //$NON-NLS-1$
    Check.notNull(expression, "expression"); //$NON-NLS-1$

    bindingService = (IBindingService) serviceLocator.getAdapter(IBindingService.class);
    handlerService = (IHandlerService) serviceLocator.getAdapter(IHandlerService.class);

    if (bindingService == null || handlerService == null) {
        throw new IllegalArgumentException(
            "specified IAdapable could not provide IBindingService or IHandlerService"); //$NON-NLS-1$
    }

    this.expression = expression;
    this.sourcePriorities = sourcePriorities;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:19,代码来源:ModernActionKeyBindingSupport.java

示例3: getShortcutDescription

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
/**
 * Returns key binding as a String for a given ShortcutCommand.
 * 
 * @param shortcut
 * @return
 */
private String getShortcutDescription(String commandID) {
	Binding bestBinding = null;
	for (Binding binding : getViewSite().getService(IBindingService.class).getBindings()) {
		if (binding.getParameterizedCommand() != null
				&& commandID.equals(binding.getParameterizedCommand().getId())) {
			if (bestBinding == null) {
				bestBinding = binding;
			} else if (binding.getType() == Binding.USER) {
				// Give higher priority to a user type binding (user has overriden default).
				bestBinding = binding;
				break;
			}
		}
	}
	return bestBinding == null ? "" : " " + bestBinding.getTriggerSequence().format();
}
 
开发者ID:PyvesB,项目名称:Notepad4e,代码行数:23,代码来源:NotepadView.java

示例4: matchesKeybinding

import org.eclipse.ui.keys.IBindingService; //导入依赖的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;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:20,代码来源:KeyBindingHelper.java

示例5: handleEvent

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
public static void handleEvent(Event e)
{
	IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);

	Listener keyDownFilter = ((BindingService) bindingService).getKeyboard().getKeyDownFilter();
	boolean enabled = bindingService.isKeyFilterEnabled();
	Control focusControl = e.display.getFocusControl();
	try
	{
		bindingService.setKeyFilterEnabled(true);
		keyDownFilter.handleEvent(e);
	}
	finally
	{
		if (focusControl == e.display.getFocusControl()) // $codepro.audit.disable useEquals
		{
			bindingService.setKeyFilterEnabled(enabled);
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:KeyBindingHelper.java

示例6: getKeyboardShortcut

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
private static String getKeyboardShortcut(ParameterizedCommand command) {
	IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
	fgLocalBindingManager.setBindings(bindingService.getBindings());
	try {
		Scheme activeScheme= bindingService.getActiveScheme();
		if (activeScheme != null)
			fgLocalBindingManager.setActiveScheme(activeScheme);
	} catch (NotDefinedException e) {
		JavaPlugin.log(e);
	}

	TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
	if (bindings.length > 0)
		return bindings[0].format();
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:CodeAssistAdvancedConfigurationBlock.java

示例7: execute

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
	BindingService service = (BindingService) bindingService;
	ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings()));
	List<String> lstRemove = Constants.lstRemove;
	Iterator<Binding> it = lstBinding.iterator();
	while (it.hasNext()) {
		Binding binding = it.next();
		ParameterizedCommand pCommand = binding.getParameterizedCommand();
		if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) {
			it.remove();
		}
	}
	service.getKeyboard().openKeyAssistShell(lstBinding);
	return null;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:KeyAssistHandler.java

示例8: loadModelBackend

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
private static BindingManager loadModelBackend(IServiceLocator locator) {
	IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
	BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
	final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
	try {
		Scheme modelActiveScheme = null;
		for (int i = 0; i < definedSchemes.length; i++) {
			final Scheme scheme = definedSchemes[i];
			final Scheme copy = bindingManager.getScheme(scheme.getId());
			copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
			if (definedSchemes[i] == bindingService.getActiveScheme()) {
				modelActiveScheme = copy;
			}
		}
		bindingManager.setActiveScheme(modelActiveScheme);
	} catch (final NotDefinedException e) {
		StatusManager.getManager()
				.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
						"Keys page found an undefined scheme", e)); //$NON-NLS-1$
	}
	bindingManager.setLocale(bindingService.getLocale());
	bindingManager.setPlatform(bindingService.getPlatform());
	bindingManager.setBindings(bindingService.getBindings());
	return bindingManager;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:26,代码来源:KeyController2.java

示例9: setDefaultBindings

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
/**
 * Sets the bindings to default.
 * @param bindingService
 * @throws NotDefinedException
 */
public void setDefaultBindings(IBindingService bindingService, List<String> lstRemove) throws NotDefinedException {
	// Fix the scheme in the local changes.
	final String defaultSchemeId = bindingService.getDefaultSchemeId();
	final Scheme defaultScheme = fBindingManager.getScheme(defaultSchemeId);
	try {
		fBindingManager.setActiveScheme(defaultScheme);
	} catch (final NotDefinedException e) {
		// At least we tried....
	}

	// Restore any User defined bindings
	Binding[] bindings = fBindingManager.getBindings();
	for (int i = 0; i < bindings.length; i++) {
		ParameterizedCommand pCommand = bindings[i].getParameterizedCommand();
		String commandId = null;
		if (pCommand != null) {
			commandId = pCommand.getCommand().getId();
		}
		if (bindings[i].getType() == Binding.USER || (commandId != null && lstRemove.contains(commandId))) {
			fBindingManager.removeBinding(bindings[i]);
		}
	}
	bindingModel.refresh(contextModel, lstRemove);
	saveBindings(bindingService);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:31,代码来源:KeyController2.java

示例10: getFormattedShortcut

import org.eclipse.ui.keys.IBindingService; //导入依赖的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;
}
 
开发者ID:chgeo,项目名称:show-shortcuts,代码行数:26,代码来源:Activator.java

示例11: earlyStartup

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
public void earlyStartup() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	workbench.getDisplay().asyncExec(new Runnable() {
		
		public void run() {
			// 在工作台初始化后,移除平台默认的 scheme
			IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
			
			Scheme[] schemes = bindingService.getDefinedSchemes();
			for (int i = 0; i < schemes.length; i++) {
				String id = schemes[i].getId();
				if (id.equals(platformDefaultScheme) || id.equals(platformEmacsScheme)) {
					schemes[i].undefine();
				}
			}
		}
	});
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:19,代码来源:ShieldStartup.java

示例12: bindMacro

import org.eclipse.ui.keys.IBindingService; //导入依赖的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);
		}
	}				
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:28,代码来源:KbdMacroLoadHandler.java

示例13: checkTrigger

import org.eclipse.ui.keys.IBindingService; //导入依赖的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));
	}
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:33,代码来源:KbdMacroSupport.java

示例14: matchesKeybinding

import org.eclipse.ui.keys.IBindingService; //导入依赖的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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:17,代码来源:KeyBindingHelper.java

示例15: getActiveContentAssistBinding

import org.eclipse.ui.keys.IBindingService; //导入依赖的package包/类
/**
 * Returns the active key binding for content assist.
 *
 * If no binding is set null is returned.
 */
private KeyStroke getActiveContentAssistBinding() {
	IBindingService bindingService = PlatformUI.getWorkbench().getService(IBindingService.class);
	TriggerSequence[] activeBindingsFor = bindingService
			.getActiveBindingsFor(CONTENT_ASSIST_ECLIPSE_COMMAND_ID);

	if (activeBindingsFor.length > 0 && activeBindingsFor[0] instanceof KeySequence) {
		KeyStroke[] strokes = ((KeySequence) activeBindingsFor[0]).getKeyStrokes();
		if (strokes.length == 1) {
			return strokes[0];
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:WorkspaceWizardPage.java


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