Java Code Examples for org.eclipse.core.commands.ExecutionEvent#getParameters()

The following examples show how to use org.eclipse.core.commands.ExecutionEvent#getParameters() . 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: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.core.commands.IExecutionListener#postExecuteSuccess(java.lang.String, java.lang.Object)
 */
public void postExecuteSuccess(String commandId, Object returnValue) {
	// true, if command was invoked by a binding
	ExecutionEvent event = popEvent();
	Event trigger = getTrigger(event); 
	// save cmdId if it immediately follows an M-x or if it was called from a key binding
	boolean addCmd = isInMetaXCommand() || trigger != null;
	if (isInMetaXCommand(commandId)) {
		; // ignore.  Sets flag as side-effect
	} else if (KEYBOARD_QUIT.equals(commandId)) {
		; // ignore. This can happen during appending to a definition			
	} else if (KBDMACRO_END_CALL.equals(commandId)) {
		; // ignore during definition
	} else if (KBDMACRO_END.equals(commandId)) {
		// check if called from minibuffer
		kbdMacro.checkTrigger(commandId, null, trigger,true);
	} else if (KBDMACRO_EXECUTE.equals(commandId)) {
		// check if called from minibuffer
		kbdMacro.checkTrigger(commandId, null, trigger,true);
		// If you enter `C-x e' while defining a macro, the macro is terminated and executed immediately.
		endKbdMacro();
	} else if (addCmd) {
		Map<?,?> parameters = event.getParameters();
		if (parameters != null && parameters.isEmpty()) {
			parameters = null;
		}
		// Add to queue
		addToMacro(commandId, parameters, trigger);
	}
	currentCommand = null;
}
 
Example 2
Source File: Handler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return the given single Parameter. This is to be called from within the execute method of the
 * command
 * 
 * @param eev
 *            the ExecutionEnvironment of the command
 * @return the Object as given from the caller to execute(...) or null if no such object was
 *         given
 */
@SuppressWarnings("unchecked")
public static Object getParam(ExecutionEvent eev){
	Map<String, String> params = eev.getParameters();
	String np = params.get(Handler.DEFAULTPARAM);
	if (np != null) {
		HashMap<String, Object> map = (HashMap<String, Object>) getParam(np);
		if (map != null) {
			return map.get(STR_PARAM);
		}
	}
	return null;
}
 
Example 3
Source File: Handler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * get the ProgressMonitor supplied by the caller
 * 
 * @param eev
 *            the ExecutionEnvironment of the Command
 * @return the monitor if any or null if none was given.
 */
@SuppressWarnings("unchecked")
public static IProgressMonitor getMonitor(ExecutionEvent eev){
	Map<String, String> params = eev.getParameters();
	String np = params.get(Handler.DEFAULTPARAM);
	HashMap<String, Object> map = (HashMap<String, Object>) getParam(np);
	if (map != null) {
		return (IProgressMonitor) map.get(STR_MONITOR);
	}
	return null;
}
 
Example 4
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
	 * @see org.eclipse.core.commands.IExecutionListener#preExecute(java.lang.String, org.eclipse.core.commands.ExecutionEvent)
	 */
	public void preExecute(String commandId, ExecutionEvent event) {
		currentCommand = commandId;		
		currentEvent.push(event);
		// Emacs+ commands handle universal argument directly as a parameter, so remove the command
		// other Eclipse commands require the universalArgument command to be part of the macro  
//		if (inUniversalArg && commandId.startsWith(EmacsPlusUtils.MULGASOFT)) {
			Map<?,?> parameters = event.getParameters();
			// when a command has a universal arg parameter, remove the preceding universal arg command
			if (parameters != null && parameters.containsKey(EmacsPlusUtils.UNIVERSAL_ARG)) {
				popUniversal();
			}
//		}
//		inUniversalArg = ((IEmacsPlusCommandDefinitionIds.UNIVERSAL_ARGUMENT.equals(commandId)) ? true : false);

//		// true, if command was invoked by a binding
//		Event trigger = ((event.getTrigger() != null && event.getTrigger() instanceof Event) ? ((Event)event.getTrigger()) : null);
//		// save cmdId if it immediately follows an M-x or if it was called from a key binding
//		boolean addCmd = inMetaXCommand || trigger != null;
//		if (inUniversalArg && commandId.startsWith(EmacsPlusUtils.MULGASOFT)) {
//			popUniversal();
//		}
//		inMetaXCommand = false;
//		inUniversalArg = false;
//		if (IEmacsPlusCommandDefinitionIds.KBDMACRO_END.equals(commandId)) {
//			// check if called from minibuffer
//			kbdMacro.checkTrigger(commandId, null, trigger,true);
//		} else if (IEmacsPlusCommandDefinitionIds.KBDMACRO_EXECUTE.equals(commandId)) {
//			// check if called from minibuffer
//			kbdMacro.checkTrigger(commandId, null, trigger,true);
//			// If you enter `C-x e' while defining a macro, the macro is terminated and executed immediately.
//			endKbdMacro();
//		} else if (IEmacsPlusCommandDefinitionIds.METAX_EXECUTE.equals(commandId)) {
//			inMetaXCommand = true;			
//		} else if (IEmacsPlusCommandDefinitionIds.KEYBOARD_QUIT.equals(commandId)) {
//			; // ignore. This can happen during appending to a definition			
//		} else if (IEmacsPlusCommandDefinitionIds.KBDMACRO_END_CALL.equals(commandId)) {
//			; // ignore during definition
//		} else if (addCmd) {
//			if (IEmacsPlusCommandDefinitionIds.UNIVERSAL_ARGUMENT.equals(commandId)) {
//				inUniversalArg = true;
//			}
//			Map<?,?> parameters = event.getParameters();
//			if (parameters != null && parameters.isEmpty()) {
//				parameters = null;
//			}
//			// Add to queue
//			addToMacro(commandId, parameters, trigger);
//		}
	}
 
Example 5
Source File: RepeatCommandSupport.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
private Cmd(String id, ExecutionEvent event) {
	this(id, event.getParameters());
}