org.eclipse.core.commands.AbstractHandler Java Examples

The following examples show how to use org.eclipse.core.commands.AbstractHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FindBarActions.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setFindBarContextActive(boolean activate)
{
	fActivated = activate;
	IWorkbenchPartSite site = textEditor.getSite();
	IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
	IBindingService service = (IBindingService) site.getService(IBindingService.class);

	if (activate)
	{

		// These will be the only active commands (note that they may have multiple keybindings
		// defined in plugin.xml)
		for (Map.Entry<String, AbstractHandler> entry : fCommandToHandler.entrySet())
		{
			AbstractHandler handler = entry.getValue();
			if (handler != null)
			{
				fHandlerActivations.add(handlerService.activateHandler(entry.getKey(), handler));
			}
		}

		// Yes, no longer execute anything from the binding service (we'll do our own handling so that the commands
		// we need still get executed).
		service.setKeyFilterEnabled(false);

		service.addBindingManagerListener(fClearCommandToBindingOnChangesListener);
	}
	else
	{
		fCommandToBinding = null;
		service.setKeyFilterEnabled(true);

		service.removeBindingManagerListener(fClearCommandToBindingOnChangesListener);
		handlerService.deactivateHandlers(fHandlerActivations);
		fHandlerActivations.clear();
	}
}
 
Example #2
Source File: JDTQuickMenuCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a handler that can create and open the quick menu.
 * 
 * @return a handler that can create and open the quick menu
 */
public IHandler createHandler() {
	return new AbstractHandler() {
		public Object execute(ExecutionEvent event) throws ExecutionException {
			createMenu();
			return null;
		}
	};
}
 
Example #3
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected AbstractHandler getHandler_OpenDefinition() {
	return getEditorHandler((editor) -> {
		OpenNewEditorMode newEditorMode = OpenNewEditorMode.TRY_REUSING_EXISTING;
		SourceRange selection = EditorUtils.getSelectionSR(editor);
		return createOpenDefinitionOperation(editor, selection, newEditorMode);
	});
}
 
Example #4
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected void activateHandler(String string, AbstractHandler handler) {
	IHandlerActivation handlerActivation = getHandlerService_2().activateHandler(string, handler);
	handlerActivations.add(handlerActivation);
}
 
Example #5
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected AbstractHandler getHandler_GoToMatchingBracket() {
	return new GoToMatchingBracketHandler(getPage());
}
 
Example #6
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected AbstractHandler getHandler_ToggleComment() {
	return new ToggleCommentHandler(getPage());
}
 
Example #7
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected AbstractHandler getHandler_QuickOutline() {
	return new OpenQuickOutlineHandler(getPage());
}