Generating Java-classes? [message #478440] |
Wed, 20 May 2009 11:37  |
Eclipse User |
|
|
|
Hi,
I want to use the UML-metamodel in order to develop a modeling-tool. So I
generated a UML.genmodel from the uml.ecore . Then I right-clicked the
genmodel and chose "Generate Model Code".
Unfortunatly the generated classes contain one error. That is located in
the generated CombinedFragment.java, where a method was created named
"break", which is obviously a Java-keyword. "break" is the name of an
operation in the CombinedFragment-type in the metamodel.
So my question is, how can I fix it? Or am I going in a wrong direction?
I guess this is a noob-question, because people probably generate the
Java-classes from the model all the time, right?
thank you
|
|
|
Re: Generating Java-classes? [message #478443 is a reply to message #478440] |
Fri, 22 May 2009 10:02   |
Eclipse User |
|
|
|
Usul,
Actually, it's not very common to need to regenerate the source for UML2
(it's already done for you!), unless you're building your own UML-like
DSL...
The only reason I can think of for a method named "break" to appear in the
generated code (since it doesn't appear in the InteractionOperatorKind
enumeration) would be the constraint (unfortunately named "break") on the
CombinedFragment class. One way to get around this (as UML2 itself does)
would be to specify a prefix via the "Invariant Prefix" option on the UML2
generator model (UML2 itself uses "validate").
Kenn
" Usul" <skobilke@gmx.de> wrote in message
news:f28bcb58a477ab27bc33db064b99dc36$1@www.eclipse.org...
> Hi,
>
> I want to use the UML-metamodel in order to develop a modeling-tool. So I
> generated a UML.genmodel from the uml.ecore . Then I right-clicked the
> genmodel and chose "Generate Model Code".
>
> Unfortunatly the generated classes contain one error. That is located in
> the generated CombinedFragment.java, where a method was created named
> "break", which is obviously a Java-keyword. "break" is the name of an
> operation in the CombinedFragment-type in the metamodel.
>
> So my question is, how can I fix it? Or am I going in a wrong direction?
> I guess this is a noob-question, because people probably generate the
> Java-classes from the model all the time, right?
>
>
> thank you
>
>
>
|
|
|
|
|
Re: Generating Java-classes? [message #627621 is a reply to message #478440] |
Fri, 22 May 2009 10:02  |
Eclipse User |
|
|
|
Usul,
Actually, it's not very common to need to regenerate the source for UML2
(it's already done for you!), unless you're building your own UML-like
DSL...
The only reason I can think of for a method named "break" to appear in the
generated code (since it doesn't appear in the InteractionOperatorKind
enumeration) would be the constraint (unfortunately named "break") on the
CombinedFragment class. One way to get around this (as UML2 itself does)
would be to specify a prefix via the "Invariant Prefix" option on the UML2
generator model (UML2 itself uses "validate").
Kenn
" Usul" <skobilke@gmx.de> wrote in message
news:f28bcb58a477ab27bc33db064b99dc36$1@www.eclipse.org...
> Hi,
>
> I want to use the UML-metamodel in order to develop a modeling-tool. So I
> generated a UML.genmodel from the uml.ecore . Then I right-clicked the
> genmodel and chose "Generate Model Code".
>
> Unfortunatly the generated classes contain one error. That is located in
> the generated CombinedFragment.java, where a method was created named
> "break", which is obviously a Java-keyword. "break" is the name of an
> operation in the CombinedFragment-type in the metamodel.
>
> So my question is, how can I fix it? Or am I going in a wrong direction?
> I guess this is a noob-question, because people probably generate the
> Java-classes from the model all the time, right?
>
>
> thank you
>
>
>
|
|
|
Re: Generating Java-classes? [message #627623 is a reply to message #478443] |
Fri, 22 May 2009 12:59  |
Eclipse User |
|
|
|
Thank you for answering Kenn,
but I still dont understand. I need the Java-classes which represent the
metamodel. Are you saying they already exist? Where can I find them?
What I want to do is to write an eclipse-plugin which can create
uml-models. So I need the Java-classes in order to do this:
// create root of model
umlFac = UmlFactory.eINSTANCE;
Model root = umlFac .createModel();
// build model
...
// save model
ResourceSet resourceSet = new ResourceSetImpl();
IProject project = selectedFolder.getCorrespondingResource().getProject();
IFolder modelFolder = this.getModelFolder(project);
IFile file = modelFolder.getFile("themodel.uml");
String path = file.getLocation().toFile().getAbsolutePath();
URI fileURI = URI.createFileURI(path);
Resource resource = resourceSet.createResource(fileURI);
resource.getContents().add(root );
system.resource.save(Collections.EMPTY_MAP);
|
|
|
|
Powered by
FUDForum. Page generated in 0.08095 seconds