Executing: OaW Workflow out of Eclipse Plugin [message #509608] |
Sat, 23 January 2010 15:27 |
No real name Messages: 7 Registered: January 2010 |
Junior Member |
|
|
Hello,
I tried several hours to get a Oaw-Workflow executed out of Java Code.
I want to use the eclipse-extension-point: ..ui.popupMenus in the generator-project
to give a user the possiblity to use mouse + right-click on any file in any project to
generate the code out of the file:
public void run(IAction action) {
try {
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSele ctionService().getSelection();
if(null != selection && selection instanceof StructuredSelection){
StructuredSelection ss = (StructuredSelection) selection;
IFile file = (IFile) ss.getFirstElement();
if(null == file)return;
generate(file);
}
} catch (Exception e) {
MessageDialog.openError(shell, "test.xtext.xtestdsl.generator",e.getMessage());
}
}
private void generate(IFile file) throws MalformedURLException {
String wfFile = "workflow/generator.mwe";
Map<String,String> properties = new HashMap<String,String>();
//Run Workflow:
properties.put("modelFile", file.getLocation().makeAbsolute().toOSString()).toString();
properties.put("targetDir", file.getParent().getFullPath().toPortableString()).toString( );
new WorkflowRunner().run(wfFile, null, properties, new HashMap<String,String>());
}
But the runner never finds my modelFile and target-directory... I tried everyting... . I read already some postings from other people having the same problem. But they used an older version. I use the last itemis version of the eclipse modeling IDE and did not find a solution jet. Can anyone help me?
Thank you!
[Updated on: Sat, 23 January 2010 15:30] Report message to a moderator
|
|
|
Re: Executing: OaW Workflow out of Eclipse Plugin [message #509657 is a reply to message #509608] |
Sun, 24 January 2010 11:54 |
Joerg Reichert Messages: 80 Registered: July 2009 Location: Leipzig |
Member |
|
|
Hello No Real Name,
You have to use this scheme to be passed as model file URI to the workflow runner: "platform:/resource/" + pathToTheModelFileInYourWorkspace.
...
StructuredSelection strSel = (StructuredSelection) sel;
final IFile dslFile = (IFile) strSel.getFirstElement();
final IProject project = dslFile.getProject();
WorkflowRunner runner = new WorkflowRunner();
Map<String, String> params = new HashMap<String, String>();
IProject project = dslFile.getProject();
String projectPath = project.getName() + "/";
params.put("modelFile", "platform:/resource/" + projectPath + dslFile.getProjectRelativePath().toString());
String targetDir = project.getLocation().toPortableString() + "/src-gen";
params.put("targetDir", targetDir);
runner.prepare("workflow/generator.mwe", new NullProgressMonitor(), params);
Issues issues = new IssuesImpl();
runner.executeWorkflow(new HashMap<String, String>(), issues);
...
Hope, that solves your problem,
Joerg
--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
|
|
|
|
Powered by
FUDForum. Page generated in 0.03320 seconds