Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » UUIDs Not Working
UUIDs Not Working [message #205204] Thu, 11 September 2008 06:35 Go to next message
Eclipse UserFriend
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 #205212 is a reply to message #205204] Thu, 11 September 2008 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Gary,

You've set breakpoints to confirm that your factory is being used to
create the resource? I assume of course that the resource you're
opening has a "project" extension.


Gary wrote:
> 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 {
Isn't it kind of odd to start a class name with a lower case letter?
>
> 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 #205231 is a reply to message #205212] Thu, 11 September 2008 07:04 Go to previous messageGo to next message
Eclipse UserFriend
sorry I changed the class name for the sake of demonstrating code, the
factory is not been used, I'll check the extention again, I could have got
it wrong!
Re: UUIDs Not Working [message #205256 is a reply to message #205231] Thu, 11 September 2008 07:28 Go to previous messageGo to next message
Eclipse UserFriend
(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
Re: UUIDs Not Working [message #205335 is a reply to message #205256] Thu, 11 September 2008 08:17 Go to previous message
Eclipse UserFriend
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
Previous Topic:Re: aggregation relation & containmentfeature
Next Topic:Link Constraints Problem
Goto Forum:
  


Current Time: Tue Jul 08 13:31:08 EDT 2025

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

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

Back to the top