Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 itemis AG ( and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at /
 package org.eclipse.xtext.ui.editor.embedded;
import  org.eclipse.jface.action.IAction;
import  org.eclipse.swt.custom.VerifyKeyListener;
import  org.eclipse.ui.texteditor.IReadOnlyDependent;
import  org.eclipse.ui.texteditor.IUpdate;

VerifyKeyListener that will trigger a matching action directly instead of using the key binding API.

Sebastian Zarnekow - Initial contribution and API
public class ActivationCodeTrigger implements VerifyKeyListener {
	private Map<String, IAction> actions;
	public ActivationCodeTrigger(Map<String, IAction> actionsList<ActionActivationCodeactivationCodes) {
		this. = actions;
		this. = activationCodes;
	public void verifyKey(VerifyEvent event) {
		ActionActivationCode codenull;
		int size.size();
		for (int i= 0; i < sizei++) {
			if (code.matches(event)) {
				IAction action.get(code.fActionId);
				if (action != null) {
					if (action instanceof IUpdate)
						((IUpdate) action).update();
					if (!action.isEnabled() && action instanceof IReadOnlyDependent) {
						IReadOnlyDependent dependent= (IReadOnlyDependent) action;
						boolean writabledependent.isEnabled(true);
						if (writable) {
							event.doit= false;
else if (action.isEnabled()) {
						event.doit= false;;
New to GrepCode? Check out our FAQ X