Home » Modeling » M2T (model-to-text transformation) » [Xpand] Workflow execution programatically(How to know what are the exits of the process?)
[Xpand] Workflow execution programatically [message #666170] |
Tue, 19 April 2011 11:54 |
mrodrigo Missing name Messages: 6 Registered: March 2011 |
Junior Member |
|
|
Hello all,
I have an Eclipse plug-in which generates code by invoking the WorkflowRunner. If I run my plug-in in a second Eclipse runtime (like you always do while still developing your plug-ins), the workflow works and code is generated. But, when I export my plug-in to use it inside a clear instance of Eclipse (with modeling tools), the workflow does not work.
I do not know what happens during workflow execution. I have tried to use 'executeWorkflow(new HashMap<String, String>(), issues)' method instead of 'run()', but issues does not contain nothing.
Now I am trying to catch the progress of the generation process and print it to the console, like it is done when executing "Run as" -> "MWE Workflow" directly on a workflow file. I use the code below these lines, but it does not print anything to the console.
public class GenerateCodeHandler extends AbstractHandler implements IHandler {
// @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
WorkflowRunner wfRunner = new WorkflowRunner();
String wfFile = "workflow/workflow.mwe";
HashMap<String, Object> externalSlotContents = new HashMap<String, Object>();
HashMap<String, String> theParams = new HashMap<String, String>();
Shell shell = new Shell(Display.getDefault());
FileDialog modelDialog = new FileDialog(shell, SWT.OPEN);
modelDialog.setFilterExtensions(new String[] { "*.gormas" });
modelDialog.setText("Select Model to transform...");
String modelSelected = modelDialog.open();
DirectoryDialog genPathDialog = new DirectoryDialog(shell, SWT.SAVE);
genPathDialog.setText("Select path where save generated code...");
String genPathSelected = genPathDialog.open();
theParams.put("srcGenPath", genPathSelected);
theParams.put("modelFile", "file:/" + modelSelected);
// Redirect output of WorkflowRunner to local console.
MessageConsole console = new MessageConsole("Code Generation", null);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
MessageConsoleStream stream = console.newMessageStream();
// Store old and set new print streams.
final PrintStream oldOut = System.out;
final PrintStream oldErr = System.err;
System.setOut(new PrintStream(stream));
System.setErr(new PrintStream(stream));
// Run the workflow.
ClassLoader before = Thread.currentThread().getContextClassLoader();
wfRunner.run("workflow/workflow.mwe", null, theParams, externalSlotContents);
//wfRunner.prepare(wfFile, null, theParams);
//IssuesImpl issues = new IssuesImpl();
//wfRunner.executeWorkflow(new HashMap<String, String>(), issues);
Thread.currentThread().setContextClassLoader(before);
// Reset console redirection.
System.setOut(oldOut);
System.setErr(oldErr);
// wfRunner.prepare(wfFile, null, theParams);
// IssuesImpl issues = new IssuesImpl();
// wfRunner.executeWorkflow(new HashMap<String, String>(), issues);
// String infoMessages = "INFO:";
// String warningMessages = "WARNING:";
// String errorMessages = "ERROR:";
// for (MWEDiagnostic i : issues.getInfos()){
// infoMessages.concat("\n" + i.getMessage());
// }
//
// for (MWEDiagnostic i : issues.getWarnings()){
// warningMessages.concat("\n" + i.getMessage());
// }
//
// for (MWEDiagnostic i : issues.getErrors()){
// errorMessages.concat("\n" + i.getMessage());
// }
// IWorkbenchWindow window = HandlerUtil
// .getActiveWorkbenchWindowChecked(event);
// MessageDialog.openInformation(
// window.getShell(),
// "MenuEclipseArticle Plug-in",
// /*"Result of operation is: "
// + wfRunner.run("workflow/workflow.mwe", null, theParams,
// externalSlotContents)*/
// /*infoMessages + "\n" +
// warningMessages + "\n" +
// errorMessages*/"Transformation ends!");
//
return null;
}
}
So, at this time, I have a plug-in which generates code while it is in my developing environment, but does not produce any file when it is exported.
Any idea to solve this?
Thank you very much for your attention.
Regards.
|
|
| | |
Goto Forum:
Current Time: Fri Mar 29 05:48:43 GMT 2024
Powered by FUDForum. Page generated in 0.02448 seconds
|