UUIDs Not Working [message #205204] |
Thu, 11 September 2008 06:35  |
Eclipse User |
|
|
|
Hi, I have Tryed to get the UUIDs() working AND FAILED
I have documented the method I used, any corrections would be greatly
appreciated!
I Created a class called IDXMIResource.java (shown below)(located in
project.util):
----------------------------------------------------
package project.util;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
public class IDXMIResource extends XMIResourceImpl{
public IDXMIResource() {
super();
}
public IDXMIResource(URI uri) {
super(uri);
}
@Override
protected boolean useUUIDs() {
return true;
}
}
-------------------------------------------------
....I have created a class called projectResourceFactory (shown
below)(also located in project.util):
-------------------------------------------------
package project.util;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
public class projectResourceFactory extends XMIResourceFactoryImpl {
public projectResourceFactory() {
super();
}
public Resource createResource(URI uri) {
return new IDXMIResource(uri);
}
}
----------------------------------------------------
Then I added the following extention to plugin.xml:
----------------------------------------------------
<extension point="org.eclipse.emf.ecore.extension_parser">
<parser
type="project"
class="project.util.projectResourceFactory">
</parser>
</extension>
-----------------------------------------------------
Thanks In Advance,
Gary
|
|
|
|
|
|
Re: UUIDs Not Working [message #205335 is a reply to message #205256] |
Thu, 11 September 2008 08:17  |
Eclipse User |
|
|
|
Gary,
Well, I'm not sure how copy and paste works in GMF but relying on UUIDs
always being present seems very limiting to me. Especially given that
UUID maintenance has about a 175 bytes per object in-memory overhead.
In any case, a copied object should not have the same ID as the old
one. The resource maintains the UUIDs and unless you've done something
to override .equals of your objects, now two different objects can ever
be assigned the same ID in the map maintained by the resource...
Gary wrote:
> (typing error for extention caused it not to work properly)it is now
> using the factory and the UUIDs work! However the reason for doing
> this was to get the copy and paste function working (I was hoping that
> generating a unique id for each element in my diagram would work)
> Thing is I think the copyed version keeps the same ID of the old one!
>
> This causes the copied(and pasted) node to vanish when the diagram is
> refreshed, this also means that the copied(and pasted) node is not
> stored in the model or diagram file! as if it was never copied
>
> Do you know of any solution to this?
>
> Thanks in advance,
> Gary
|
|
|
Powered by
FUDForum. Page generated in 0.06128 seconds