blob: 5a2dea17a53a19698028393d2180f1e525f14999 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008-2010, Istvan Rath and Daniel Varro
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.frameworkgui.views.console.commands.xform;
import java.util.List;
import org.eclipse.viatra2.framework.IFramework;
import org.eclipse.viatra2.frameworkgui.views.console.commands.IVIATRAConsoleCommandProvider;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Machine;
/**
* VIATRA2 console command to facilitate the execution of a GTASM machine.
* @author istvan rath
*
*/
public class RunMachineUndoable extends AbstractRunnerCommand implements IVIATRAConsoleCommandProvider {
public void executeCommand(IFramework fw, List<String> parameters) {
// 0. check if we have exactly two parameters
if (parameters.size()!=2) {
fw.getLogger().error("[RunMachineUndoable] Wrong number of parameters supplied.");
return;
}
// 1. check if machine exists in the framwork and is runnable
String machineFQN = parameters.get(0);
Machine m = (Machine)fw.getMachineByFQN(machineFQN);
if (m==null) {
fw.getLogger().error("[RunMachineUndoable] machine "+machineFQN+" not found.");
return;
}
commenceRunning(fw, m, parameters.get(1), m.getFqn(), true);
}
public String getCommandSignature() {
return "runmachineundoable(machineFQN,parameterMappings)";
}
public String getDescription() {
return "Executes a GTASM Machine in an undoable VIATRA2 transaction.";
}
public String getHelpText() {
return "Use runmachineundoable(<<machine fqn>>,<<parametermapping>>) to execute a GTASM machine in an undoable transaction.\n"+
"Parameter mappings take the following syntax: <<parametername=value>> and are separated by ; characters.\n"+
"Example: runmachineundoable(helloworld, target=John;message=Hello)";
}
}