Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » mwe2 workflow and EMF stuff
mwe2 workflow and EMF stuff [message #646825] Fri, 31 December 2010 15:56 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in my DSL I let the programmer refer to an ecore with, e.g.,

"./models/FJ.ecore"

or

"http://www.eclipse.org/emf/2002/Ecore"

and I have a LinkingService which correctly loads the corresponding
EPackage.

When I generate code from my DSL source file using mwe2, the workflow
validates the program again, and, during that validation, the
corresponding EPackage cannot be found anymore by my LinkingService,
with an error

LINKER: Cannot load package with URI 'http://example.xtext.org/FJ',
java.lang.RuntimeException: Cannot create a resource for
'http://example.xtext.org/FJ'; a registered resource factory is needed

while during the validation in the editor, the EPackage is loaded
correctly...

thus, when running the mwe2 workflow, the "environment" is not the same?

I mean, all the plugins and emf stuff that are available in the editor
for my DSL are not available when running the workflow?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #646832 is a reply to message #646825] Fri, 31 December 2010 18:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

This is what StandaloneSetups are for.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #646846 is a reply to message #646832] Sat, 01 January 2011 11:21 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/31/2010 07:27 PM, Christian Dietrich wrote:
> Hi,
>
> This is what StandaloneSetups are for.
>
> ~Christian

could you please be more explicit? :)

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #646848 is a reply to message #646846] Sat, 01 January 2011 12:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Workflows run in a Standalone Java Environment, the Editor runs in an Eclipse / OSGi Environment. Registering resource factory is done with Eclipse Means e.g. via Plugin XML. To Affect the same in the Standalone Workflow you have to Execute some extra Stuff that faces the Eclipse / OSGi Stuff. (Workspace / EMF Resource Factories / Register EPackages) e.g.

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


	component = org.eclipse.xtext.mwe.Reader {
		......

		// this class will be generated by the xtext generator 
		register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
		.....
	}


   <bean class="org.eclipse.mwe.emf.StandaloneSetup" >
   		<platformUri value=".."/>
   		<registerGeneratedEPackage value="test.SomePackage"/>
   </bean>



~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #646862 is a reply to message #646848] Sat, 01 January 2011 17:26 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
thanks Christian

I'll try to detail my problem, also because I found other issues.

As I said in my original post in my DSL I refer to an ecore with the
following syntax (that ecore corresponds to the one generated by Xtext,
since I refer to the ecore of another Xtext DSL), for instance

grammar "platform:/resource/myproject/src/model/FJ.ecore"

and I have a linking service implementation which loads the
corresponding EPackage like that (where resourceOrNsURI is the string
specified in the DSL)

private EPackage loadEPackage(String resourceOrNsURI,
ResourceSet resourceSet) {
if (EPackage.Registry.INSTANCE.containsKey(resourceOrNsURI))
return EPackage.Registry.INSTANCE.getEPackage(resourceOrNsURI);
try {
URI uri = URI.createURI(resourceOrNsURI);
if (uri.fragment() == null) {
Resource resource = resourceSet.getResource(uri, true);
EPackage result = (EPackage) resource.getContents().get(0);
return result;
}
return (EPackage) resourceSet.getEObject(uri, true);
} catch (RuntimeException ex) {
System.out.println("LINKER: " + "Cannot load package with URI '"
+ resourceOrNsURI + "', " + ex);
}
return null;
}

if in the new eclipse instance I specify that string for the grammar
keyword, the editor correctly validates the program, and the EPackage is
correctly loaded, but when I run the workflow I get this error from my
LinkingService (when the workflow validates the program):

LINKER: Cannot load package with URI
'platform:/resource/myproject/src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped

if, instead I specify in my DSL program:

grammar "src/model/FJ.ecore"

the editor complains because the LinkingService cannot load the EPackage
with this error

LINKER: Cannot load package with URI 'src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.FileNotFoundException: src/model/FJ.ecore (No such file or
directory)

but the workflow successfully runs and generates code :)

I suppose that the correct way to specify an URI for an .ecore is the
first one, i.e., "platform:/resource/myproject/src/model/FJ.ecore", am I
right about that?

If that's true, from what I understand, I should execute some extra
stuff in the workflow as you say... so I should load the standalone
setup of the DSL I refer to in my program, but I cannot write it in the
workflow since I don't know that: it's written in the program...

thus is could be
grammar "platform:/resource/myproject/src/model/FJ.ecore"
or
grammar " platform:/resource/anotherproject/src/model/domainmodel.ecor e "

should I invoke the workflow programmatically so that, when I run it, I
know the corresponding standalone setup?

or should I do something else?

For instance, could I implement the LinkingService so that it is able to
load an .ecore when running the workflow even if it's in the platform shape?

Let me specify that I took the code of the LinkingService from the
ecoredsl example in the Xtext sources :)

many thanks in advance
Lorenzo


On 01/01/2011 01:29 PM, Christian Dietrich wrote:
> Workflows run in a Standalone Java Environment, the Editor runs in an
> Eclipse / OSGi Environment. Registering resource factory is done with
> Eclipse Means e.g. via Plugin XML. To Affect the same in the Standalone
> Workflow you have to Execute some extra Stuff that faces the Eclipse /
> OSGi Stuff. (Workspace / EMF Resource Factories / Register EPackages) e.g.
>
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
>
>
> component = org.eclipse.xtext.mwe.Reader {
> ......
>
> // this class will be generated by the xtext generator register =
> org.xtext.example.mydsl.MyDslStandaloneSetup {}
> .....
> }
>
>
>
> <bean class="org.eclipse.mwe.emf.StandaloneSetup" >
> <platformUri value=".."/>
> <registerGeneratedEPackage value="test.SomePackage"/>
> </bean>
>
>
>
> ~Christian


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #646863 is a reply to message #646862] Sat, 01 January 2011 18:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

LINKER: Cannot load package with URI
'platform:/resource/myproject/src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped


means that /myproject/src/model/FJ.ecore cannot be found in the "fake" standalone workspace. the workspace is faked with

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


or

bean = StandaloneSetup {
		platformUri = ".."
	}


or something similar.

so it should work if "${runtimeProject}/.." points to the parent directory of myproject.

if you have some special stuctures that wont work with StandaloneSetup have a look into the source code and build a own workflow compoment that does the stuff you need.

the platform:/resource uris should then work even standalone

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 01 January 2011 18:24]

Report message to a moderator

Re: mwe2 workflow and EMF stuff [message #648607 is a reply to message #646863] Thu, 13 January 2011 15:47 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/01/2011 07:18 PM, Christian Dietrich wrote:
> Hi,
>
>
> LINKER: Cannot load package with URI
> 'platform:/resource/myproject/src/model/FJ.ecore',
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException:
> java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped
>
>
> means that /myproject/src/model/FJ.ecore cannot be found in the "fake"
> standalone workspace. the workspace is faked with
>
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
>
> or
>
>
> bean = StandaloneSetup {
> platformUri = ".."
> }
>
>
> or something similar.
>
> so it should work if "${runtimeProject}/.." points to the parent
> directory of myproject.
>

OK, so now probably I understand a few things, and by setting

platformUri = ".."

it works if the referenced .ecore is in the same project of my program.

But this does not solve completely what I'd like to achieve:

Let me remind that as I said in my original post in my DSL I refer to an
ecore with the following syntax (that ecore corresponds to the one
generated by Xtext, since I refer to the ecore of another Xtext DSL),
for instance

// myfile.mydsl
grammar "platform:/resource/myproject/src/model/myecore.ecore"

Now if this is written in, say, myfile.mydsl and this is in the same
project of myecore.ecore, e.g., in this example, 'myproject' then the
workflow correctly finds everything (with the fakes the workspace).

But if I write

// myfile.mydsl
grammar "platform:/resource/myotherproject/src/model/myecore.ecore"

i.e., I refer to an .ecore in a different project of myfile.mydsl this
does not work anymore (unless ".." is the actual path of
'myotherproject' too, which is not always the case).

Let me stress that the problem comes in the workflow: when editing
myfile.mydsl the myecore.ecore is correctly found and loaded.

Thus, the 'faking' mechanism is not easily extensible to fake a
situation where the workspace contains project spread throughout the
hard disk... probably it does not even aim to, does it?

> if you have some special stuctures that wont work with StandaloneSetup
> have a look into the source code and build a own workflow compoment that
> does the stuff you need.
>

so probably, for what I need to do (i.e., generate code), using a
workflow, which runs in standalone java environment, will not be enough,
will it?

Probably I should implement a sort of context menu (say "Generate
code")? But would this mean reimplement all the workflow stuff?

Or is it possible to run programmatically the same workflow code in an
Eclipse/OSGI environment?

thanks
Lore


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #648610 is a reply to message #648607] Thu, 13 January 2011 16:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, Standalone Setup is meant to work with plain workspaces. To be
able to deal with linked workflows you could write an enhanced
standalone setup workflow component. IE you Do Not work with
workflows at all and call XpandFacade from an Action directly

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #648611 is a reply to message #648610] Thu, 13 January 2011 16:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sorry I meant linked workspace resources

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #648624 is a reply to message #648610] Thu, 13 January 2011 17:16 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/13/2011 05:31 PM, Christian Dietrich wrote:
> Hi, Standalone Setup is meant to work with plain workspaces. To be able
> to deal with linked workflows you could write an enhanced standalone

you mean here linked workspace resources... though it's not clear to me
what is a plain workspace... a workspace where files are in the same
directory of the workspace?

> setup workflow component. IE you Do Not work with workflows at all and
> call XpandFacade from an Action directly
> ~Christian

I don't understand here: did you mean "I.e."? it looks like the second
sentence contradicts the first one? Or did I get it completely wrong?

any example of what you say please?

thanks
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #648639 is a reply to message #648624] Thu, 13 January 2011 18:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
On Thu, 13 Jan 2011 18:16:14 +0100, Lorenzo Bettini
<bettini@dsi.unifi.it> wrote:
> you mean here linked workspace resources... though it's not clear
to me
> what is a plain workspace... a workspace where files are in the
same

Sorry, my android auto spelling drives me crazy. With plain workspace
I mean that all projects and resources are physically contained in
the workspace root.


> I don't understand here: did you mean "I.e."? it looks like the
second

I mean if you do not want to use workflows at all just call
XpandFacade from an action


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #648725 is a reply to message #648639] Fri, 14 January 2011 09:03 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/13/2011 07:23 PM, Christian Dietrich wrote:
> On Thu, 13 Jan 2011 18:16:14 +0100, Lorenzo Bettini
> <bettini@dsi.unifi.it> wrote:
>> you mean here linked workspace resources... though it's not clear
> to me
>> what is a plain workspace... a workspace where files are in the
> same
> Sorry, my android auto spelling drives me crazy. With plain workspace I
> mean that all projects and resources are physically contained in the
> workspace root.
>
>> I don't understand here: did you mean "I.e."? it looks like the
> second
>
> I mean if you do not want to use workflows at all just call XpandFacade
> from an action

OK, I'll give it a try... I suppose, in such case, i.e., using
XpandFacade directly, would require to manually open the template file,
and mydsl program, and validate it? Am I right? In that case where
could I find 'inspiration' please?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: mwe2 workflow and EMF stuff [message #648729 is a reply to message #648725] Fri, 14 January 2011 09:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

as always the search function and google help:

http://www.eclipse.org/forums/index.php?t=tree&th=175562
http://www.eclipse.org/forums/index.php?t=msg&goto=63829 9
http://www.eclipse.org/forums/index.php?t=msg&goto=55356 6
http://www.eclipse.org/forums/index.php?t=msg&goto=64181 6

http://www.peterfriese.de/using-xpand-in-your-eclipse-wizard s/

Have a look at the domainmodel example too

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mwe2 workflow and EMF stuff [message #648764 is a reply to message #648729] Fri, 14 January 2011 12:40 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/14/2011 10:44 AM, Christian Dietrich wrote:
> Hi,
>
> as always the search function and google help:
>
> http://www.eclipse.org/forums/index.php?t=tree&th=175562
> http://www.eclipse.org/forums/index.php?t=msg&goto=63829 9
> http://www.eclipse.org/forums/index.php?t=msg&goto=55356 6
> http://www.eclipse.org/forums/index.php?t=msg&goto=64181 6
>
> http://www.peterfriese.de/using-xpand-in-your-eclipse-wizard s/
>
> Have a look at the domainmodel example too

Thanks Chris

actually I had searched for it, but I didn't run into that blog post.

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:create a class without attributes neither relations
Next Topic:same qualifiedName in ecore files
Goto Forum:
  


Current Time: Sat Apr 20 02:48:02 GMT 2024

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

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

Back to the top