Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Questions regarding implementing MetaModelContributor
[Xpand] Questions regarding implementing MetaModelContributor [message #757511] Fri, 18 November 2011 17:26 Go to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
As far as I understand, the metamodel contributor returns all the metamodels which is referenced from the resources in the workspace. Is this correct?

Does implementing this give "full" editor support for my custom Xpand metamodel? If not, what needs to be implemented?

What kind of functionality is getUnderlyingStorage in MetamodelContributor2 supposed to provide?

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #757514 is a reply to message #757511] Fri, 18 November 2011 17:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

(1) not referenced, defined!
(2) of course you have to implement an IMetamodel too
(3) if guess this is currently not used at all, bzr i guess it is intended to return the physical resource
the metamodel is stored in

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #757767 is a reply to message #757514] Mon, 21 November 2011 15:08 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Thanks a lot for the answers!

I'm having some issues with loading the contributor. It seems it is recognized on startup, but
when the MetamodelContributorRegistry#getActiveMetamodelContributors is called it only returns EmfMetaModelContributor.

Do I have to explicitly associate my metamodel with a resource and then write it to the preference store?

Right now, the test project that uses this custom metamodel was initially using the EmfRegistryMetamodel (created using the Xpand wizard). Now it uses my custom metamodel from a workflow file.
Can this be why my contributor isn't loaded?
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #758290 is a reply to message #757767] Tue, 22 November 2011 15:01 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Figured it out. Needed to add it manually in the preferences.

Any simple way to add it automatically btw?
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #758300 is a reply to message #758290] Tue, 22 November 2011 16:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

did you use the extension point
e.g.

<plugin>
   <extension
         point="org.eclipse.xtend.shared.ui.metamodelContributor">
      <metamodelContributor
            class="org.eclipse.xtend.typesystem.uml2.ui.Uml2MetamodelContributor"
            name="UML2 profiles"/>
   </extension>
</plugin>


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #758345 is a reply to message #758300] Tue, 22 November 2011 20:52 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Yes, but registering the extension only makes it available. It does not enable it.
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #758362 is a reply to message #758345] Tue, 22 November 2011 21:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
You can set a default on workspace level

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #759941 is a reply to message #757511] Wed, 30 November 2011 16:03 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Instead of posting new thread, I'll ask a few more questions here:

What do I have to do to make my own metamodel be usable in a workflow file?
Do I have to implement AbstractWorkflowComponent?

My metamodel takes a certain object as parameter, is this impossible/bad practice?
Should it rather use setter in the workflow component?


Re: [Xpand] Questions regarding implementing MetaModelContributor [message #759956 is a reply to message #759941] Wed, 30 November 2011 17:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
No,

simply pass it to any metamodel using component.
of course you will need a kind of reader/creator component that creates a model that conforms to your metamodel or to be specific the type system the metamodel provides.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #760331 is a reply to message #759956] Thu, 01 December 2011 22:29 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
If im understanding correctly, such a component would be like org.eclipse.emf.mwe.utils.Reader which is used in the Xpand example project. This component inherits AbstractWorkflowComponent. What am I missing?
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #760351 is a reply to message #760331] Fri, 02 December 2011 05:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Since i have no idea about your mm this is not answerable without any
additional information on your specific metamodel and workflow


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #760506 is a reply to message #760351] Fri, 02 December 2011 16:01 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
The metamodel uses an object which is loaded from a xmi file as an internal DSM. It is based on our discussion here: http://www.eclipse.org/forums/index.php/t/249444/
When calling evaluate, I use another object loaded from another xmi file, which is the instancemodel of the DSM.

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #760507 is a reply to message #760506] Fri, 02 December 2011 16:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
and what is the error message you get, what do you do and what does not work as expected?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #761553 is a reply to message #760507] Tue, 06 December 2011 16:41 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
When I try to instantiate the metamodel with the bean tag, I get an error saying that the class cannot be found:
369 ERROR WorkflowEngine - [ERROR]: Class not found: 'no.hib.dpf.codegen.xpand.metamodel.DpfMetaModel'(Element: bean bean class='no.hib.dpf.codegen.xpand.metamodel.DpfMetaModel' id='mm_emf' ... Reported by: -UNKNOWN-)
370 WARN WorkflowEngine - [WARNING]: The type of the referred bean (java.lang.Object) is not assignable to org.eclipse.xtend.typesystem.MetaModel(Element: -UNKNOWN-; Reported by: -UNKNOWN-)
370 ERROR WorkflowEngine - Workflow interrupted because of configuration errors.

This would indeed fail at some point since the meta model isn't loaded with an xmi, but I shouldnt get a Class not found error. The meta model is added to the project dependencies.
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #761593 is a reply to message #761553] Tue, 06 December 2011 17:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

are you sure you classpath is set correct? can you please post your workflow / your classes (at least stubs) ?

~Christian


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

[Updated on: Tue, 06 December 2011 21:25]

Report message to a moderator

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #761936 is a reply to message #761593] Wed, 07 December 2011 10:17 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

You could debug into the workflow engine and set an exception breakpoint on ClassNotFoundException. This way you may identify if your class is really found on the classpath or not. If the error says "Class not found: 'no.hib.dpf.codegen.xpand.metamodel.DpfMetaModel'" it may be the right error message Wink So, identify why your class is not found.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #762206 is a reply to message #761593] Wed, 07 December 2011 17:45 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Christian Dietrich wrote on Tue, 06 December 2011 12:47

HI,
are you sure you classpath is set correct? can you please post your workflow / your classes (at least stubs) ?

~Christian


Workflow:
<?xml version="1.0"?>
<workflow>
	<property name="model" value="testproject/model/yabe2.dpf.xmi" />
	
	<property name="src-gen" value="src-gen" />
	
	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="no.hib.dpf.codegen.xpand.metamodel.DpfMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>

	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="testproject::src::test::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>


Can also post the metamodel, but I cant see how that causes this problem.

Karsten:
Do you have any hints on which class this is? I have browsed trough the *emf.mwe* projects, and I cant find anything :\
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #762262 is a reply to message #762206] Wed, 07 December 2011 19:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

is your metamodel class in the same project as the workflow?
if not: does the defining plugin export the package with the metamodel? does the workflow plugin have a bundle dep to the defining plugin or import the package?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #762270 is a reply to message #762262] Wed, 07 December 2011 19:38 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Christian Dietrich wrote on Wed, 07 December 2011 14:22

is your metamodel class in the same project as the workflow?


No, the workflow is created in a running Eclipse instance.
Edit: an instance where the xpand metamodel is created

Christian Dietrich wrote on Wed, 07 December 2011 14:22

if not: does the defining plugin export the package with the metamodel?


Yes

Christian Dietrich wrote on Wed, 07 December 2011 14:22

does the workflow plugin have a bundle dep to the defining plugin or import the package?


It is included as dependency. I can successfully use the class when using Xpand without the workflow.

[Updated on: Wed, 07 December 2011 19:39]

Report message to a moderator

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #762276 is a reply to message #762270] Wed, 07 December 2011 19:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

this looks ok for me. so debug org.eclipse.emf.mwe.internal.core.ast.util.VisitorCreator as Karsten said.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #762443 is a reply to message #762276] Thu, 08 December 2011 04:29 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

More specific: ResourceLoaderDefaultImpl#loadClass()

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #763416 is a reply to message #762443] Fri, 09 December 2011 18:19 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
It seems Class.forName fails... so it's probably a class path problem then. When I load the class from my project, it works.
Any ideas?
Re: [Xpand] Questions regarding implementing MetaModelContributor [message #763420 is a reply to message #763416] Fri, 09 December 2011 18:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

no i have no idea. without having anything reproducable it is hard to help.
can you elaborate a bit more on the setup of your worklow plugin?

~Christian


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

[Updated on: Fri, 09 December 2011 18:45]

Report message to a moderator

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #763430 is a reply to message #763420] Fri, 09 December 2011 18:52 Go to previous messageGo to next message
Anders S is currently offline Anders SFriend
Messages: 29
Registered: February 2011
Junior Member
Kind of embarrassing, but it worked itself out. *cough*misspelled class name*cough*

Re: [Xpand] Questions regarding implementing MetaModelContributor [message #763521 is a reply to message #763430] Fri, 09 December 2011 22:54 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

You are kidding... Wink

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Previous Topic:[Xpand] Access ClassAttribute before DEFINE Class
Next Topic:[Xpand] Access EAnnotations
Goto Forum:
  


Current Time: Thu Apr 18 07:41:28 GMT 2024

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

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

Back to the top