Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Generating Java-classes?
Generating Java-classes? [message #478440] Wed, 20 May 2009 15:37 Go to next message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
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 14:02 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
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 #478445 is a reply to message #478443] Fri, 22 May 2009 16:59 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
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);
Re: Generating Java-classes? [message #478446 is a reply to message #478445] Fri, 22 May 2009 17:45 Go to previous message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
Oh, nevermind, I found it: org.eclipse.uml2.uml_3.0.0.v200905041045.jar .

Thanx!
Re: Generating Java-classes? [message #627621 is a reply to message #478440] Fri, 22 May 2009 14:02 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
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 16:59 Go to previous message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
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);
Re: Generating Java-classes? [message #627624 is a reply to message #478445] Fri, 22 May 2009 17:45 Go to previous message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
Oh, nevermind, I found it: org.eclipse.uml2.uml_3.0.0.v200905041045.jar .

Thanx!
Previous Topic:Preserving uuid to xmi:id mapping converting uml2 to eCore
Next Topic:Preserving uuid to xmi:id mapping converting uml2 to eCore
Goto Forum:
  


Current Time: Wed Apr 24 14:57:09 GMT 2024

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

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

Back to the top