Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
mrodrigo Missing name is currently offline mrodrigo Missing nameFriend
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.
Re: [Xpand] Workflow execution programatically [message #667620 is a reply to message #666170] Sat, 30 April 2011 00:25 Go to previous messageGo to next message
mrodrigo Missing name is currently offline mrodrigo Missing nameFriend
Messages: 6
Registered: March 2011
Junior Member
Hello again,

the problem may be the location of the metamodel? The metamodel is inside another plug-in (Plug-in B). My plug-in (Plug-in A), requires it (B), but how I can know if (A) really finds metamodel inside (B)? If I put the ecore file with the metamodel inside plug-in A, I could delete the requirement in plugin.xml of plug-in A?

Regards.
Re: [Xpand] Workflow execution programatically [message #1088208 is a reply to message #667620] Fri, 16 August 2013 19:03 Go to previous message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi mrodrigo,
I have the same Problem , Have you reached to any solution ?
please post it here if there is .
Previous Topic:[Acceleo] Error installing 'Ecore to Python code generator' for Acceleo 3.2
Next Topic:[acceleo] Run Acceleo M2T JUnit Test from tycho
Goto Forum:
  


Current Time: Fri Mar 29 05:48:43 GMT 2024

Powered by FUDForum. Page generated in 0.02448 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top