Create Object from String [message #478249] |
Thu, 19 March 2009 09:24  |
Eclipse User |
|
|
|
Hi all,
Is it possible to use the UMLFactory to create an object from the String
representation of its type? For example, I want to create a new class
using "org.eclipse.uml2.uml.Class".
Thanks a lot for your help!
|
|
|
|
|
Re: Create Object from String [message #478254 is a reply to message #478253] |
Tue, 24 March 2009 08:11  |
Eclipse User |
|
|
|
Iris,
The extrinsic IDs are managed by the resource so until you add the new
object to a resource (directly or indirectly by adding it to a
containing object already in a resource) it won't have an ID.
Iris Groher wrote:
> Thank you so much for your help! I managed to create UML objects. Is
> there a way to set the ID of the object? I usually get the ID by calling:
>
> eobject.eResource().getURIFragment(eobject)
>
> But eResource is of course null after creating the object the way I did.
>
>
>
|
|
|
Re: Create Object from String [message #627445 is a reply to message #478249] |
Fri, 20 March 2009 18:56  |
Eclipse User |
|
|
|
This is more of an EMF question. The API you want is
EPackage#getEClassifier(String) and EFactory#create(EClass).
In the case of UML2, this would do the trick:
EObject aClass =
UMLFactory.eInstance.create(
UMLPackage.eInstance.getEClassifier(
"org.eclipse.uml2.uml.Class"
)
);
Cheers,
Rafael
http://abstratt.com/blog/
Iris Groher wrote:
> Hi all,
>
> Is it possible to use the UMLFactory to create an object from the String
> representation of its type? For example, I want to create a new class
> using "org.eclipse.uml2.uml.Class".
> Thanks a lot for your help!
>
>
>
|
|
|
Re: Create Object from String [message #627447 is a reply to message #478251] |
Tue, 24 March 2009 07:29  |
Eclipse User |
|
|
|
Thank you so much for your help! I managed to create UML objects. Is there
a way to set the ID of the object? I usually get the ID by calling:
eobject.eResource().getURIFragment(eobject)
But eResource is of course null after creating the object the way I did.
|
|
|
Re: Create Object from String [message #627448 is a reply to message #478253] |
Tue, 24 March 2009 08:11  |
Eclipse User |
|
|
|
Iris,
The extrinsic IDs are managed by the resource so until you add the new
object to a resource (directly or indirectly by adding it to a
containing object already in a resource) it won't have an ID.
Iris Groher wrote:
> Thank you so much for your help! I managed to create UML objects. Is
> there a way to set the ID of the object? I usually get the ID by calling:
>
> eobject.eResource().getURIFragment(eobject)
>
> But eResource is of course null after creating the object the way I did.
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.42866 seconds