Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » getting Value from a IWorkflow component
getting Value from a IWorkflow component [message #1062257] Thu, 06 June 2013 14:47 Go to next message
Vincent De Bry is currently offline Vincent De Bry
Messages: 49
Registered: May 2013
Member
Hi,

in my mwe2 workflow, I am adding a task where I compute dynamically a value intending to replace the file.extension variable declared at the beginning of the workflow.
Is there a way to retrieve this value and do so that this value is used instead of the default one ?

example:

What is basically done:
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
var file.extensions = "dmodel"
var projectName = "org.eclipse.xtext.example.domainmodel"
var runtimeProject = "../${projectName}"

Workflow {

	bean = StandaloneSetup {
		platformUri = "${runtimeProject}/.."
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
		useDefaultExcludes = false
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		activator = "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions
...


What I would like to do (kind of)
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
var file.extensions = "dmodel"
var projectName = "org.eclipse.xtext.example.domainmodel"
var runtimeProject = "../${projectName}"

Workflow {

	bean = StandaloneSetup {
		platformUri = "${runtimeProject}/.."
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
		useDefaultExcludes = false
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

//***************************************************
	component = MyWorkFlowTask {
		// value getter (I know the following is wrong ...)
		file.extensions = getFileExtension()
	}
//***************************************************

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		activator = "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions
...


Thanks.
Re: getting Value from a IWorkflow component [message #1062317 is a reply to message #1062257] Fri, 07 June 2013 03:46 Go to previous messageGo to next message
Edwin Tuzar is currently offline Edwin Tuzar
Messages: 33
Registered: April 2013
Location: Kaiserslautern
Member

Hi,
did you try to use the * instead of your extension dmodel (but I think is not a good idea to use it) ? or create different workflows with the desired extensions.
I don't think this works as you wish.


Edwin W.T.
Re: getting Value from a IWorkflow component [message #1062327 is a reply to message #1062317] Fri, 07 June 2013 04:46 Go to previous messageGo to next message
Vincent De Bry is currently offline Vincent De Bry
Messages: 49
Registered: May 2013
Member
Hi Edwin,

Indeed, your advise does not fit my need.

Thanks.
Re: getting Value from a IWorkflow component [message #1062329 is a reply to message #1062257] Fri, 07 June 2013 04:48 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
I know two possibilities to get variables and values into the
IWorkflowContext

1) On launch, e.g. as command line parameter. You can for example add
-p fileExtension="myext"
to the arguments in the launch configuration of your workflow

2) Create your own workflow component that adds a variable to the context:

public class ExtensionSetter implements IWorkflowComponent {
public void invoke(final IWorkflowContext ctx) {
ctx.put("fileExtension", "myext");
}

public void postInvoke() {
}

public void preInvoke() {
}
}

and execute it first:

module test.plugin.Test

....
Workflow {
component = ExtensionSetter {}
....
}

Am 06.06.13 20:47, schrieb Vincent De Bry:
> Hi,
>
> in my mwe2 workflow, I am adding a task where I compute dynamically a
> value intending to replace the file.extension variable declared at the
> beginning of the workflow.
> Is there a way to retrieve this value and do so that this value is used
> instead of the default one ?
>
> example:
>
> What is basically done:
>
> import org.eclipse.xtext.generator.*
> import org.eclipse.xtext.ui.generator.*
>
> var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
> var file.extensions = "dmodel"
> var projectName = "org.eclipse.xtext.example.domainmodel"
> var runtimeProject = "../${projectName}"
>
> Workflow {
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}/src-gen"
> useDefaultExcludes = false
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}.ui/src-gen"
> }
>
> component = Generator {
> pathRtProject = runtimeProject
> pathUiProject = "${runtimeProject}.ui"
> projectNameRt = projectName
> projectNameUi = "${projectName}.ui"
> activator =
> "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
> language = {
> uri = grammarURI
> fileExtensions = file.extensions
> ..
>
>
> What I would like to do (kind of)
>
> import org.eclipse.xtext.generator.*
> import org.eclipse.xtext.ui.generator.*
>
> var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
> var file.extensions = "dmodel"
> var projectName = "org.eclipse.xtext.example.domainmodel"
> var runtimeProject = "../${projectName}"
>
> Workflow {
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}/src-gen"
> useDefaultExcludes = false
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}.ui/src-gen"
> }
>
> //***************************************************
> component = MyWorkFlowTask {
> // value getter (I know the following is wrong ...)
> file.extensions = getFileExtension()
> }
> //***************************************************
>
> component = Generator {
> pathRtProject = runtimeProject
> pathUiProject = "${runtimeProject}.ui"
> projectNameRt = projectName
> projectNameUi = "${projectName}.ui"
> activator =
> "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
> language = {
> uri = grammarURI
> fileExtensions = file.extensions
> ..
>
>
> Thanks.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: getting Value from a IWorkflow component [message #1062330 is a reply to message #1062257] Fri, 07 June 2013 04:49 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
BTW, what is the usecase for changing the file extension dynamically?

Am 06.06.13 20:47, schrieb Vincent De Bry:
> Hi,
>
> in my mwe2 workflow, I am adding a task where I compute dynamically a
> value intending to replace the file.extension variable declared at the
> beginning of the workflow.
> Is there a way to retrieve this value and do so that this value is used
> instead of the default one ?
>
> example:
>
> What is basically done:
>
> import org.eclipse.xtext.generator.*
> import org.eclipse.xtext.ui.generator.*
>
> var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
> var file.extensions = "dmodel"
> var projectName = "org.eclipse.xtext.example.domainmodel"
> var runtimeProject = "../${projectName}"
>
> Workflow {
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}/src-gen"
> useDefaultExcludes = false
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}.ui/src-gen"
> }
>
> component = Generator {
> pathRtProject = runtimeProject
> pathUiProject = "${runtimeProject}.ui"
> projectNameRt = projectName
> projectNameUi = "${projectName}.ui"
> activator =
> "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
> language = {
> uri = grammarURI
> fileExtensions = file.extensions
> ..
>
>
> What I would like to do (kind of)
>
> import org.eclipse.xtext.generator.*
> import org.eclipse.xtext.ui.generator.*
>
> var grammarURI = "classpath:/org/eclipse/xtext/example/Domainmodel.xtext"
> var file.extensions = "dmodel"
> var projectName = "org.eclipse.xtext.example.domainmodel"
> var runtimeProject = "../${projectName}"
>
> Workflow {
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}/src-gen"
> useDefaultExcludes = false
> }
>
> component = DirectoryCleaner {
> directory = "${runtimeProject}.ui/src-gen"
> }
>
> //***************************************************
> component = MyWorkFlowTask {
> // value getter (I know the following is wrong ...)
> file.extensions = getFileExtension()
> }
> //***************************************************
>
> component = Generator {
> pathRtProject = runtimeProject
> pathUiProject = "${runtimeProject}.ui"
> projectNameRt = projectName
> projectNameUi = "${projectName}.ui"
> activator =
> "org.eclipse.xtext.example.ui.internal.DomainmodelActivator"
> language = {
> uri = grammarURI
> fileExtensions = file.extensions
> ..
>
>
> Thanks.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: getting Value from a IWorkflow component [message #1062435 is a reply to message #1062330] Fri, 07 June 2013 12:49 Go to previous message
Vincent De Bry is currently offline Vincent De Bry
Messages: 49
Registered: May 2013
Member
Thanks Jan,

Both your advises look great to me.

Actually, this is not a real "dynamic change", but I plan to add a task to the wokflow providing the user with a dialog allowing to set a context for the xtext framework generation, from a single xtext "generic" project. Part of this context may be the file extension, among others.

I am also looking at a way to interrupt the workflow depending on the context set (i.e a "Cancel" button in the dialog).
Do you know if it is possible to have conditional treatements in the context (kind of "if {...} within the workflow) ?
Previous Topic:Xtext unordered group
Next Topic:Multiple ANTLR versions in set of projects
Goto Forum:
  


Current Time: Fri Jul 25 21:23:20 EDT 2014

Powered by FUDForum. Page generated in 0.02361 seconds