Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » UUIDs Not Working
UUIDs Not Working [message #205204] Thu, 11 September 2008 10:35 Go to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
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 10:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: UUIDs Not Working [message #205231 is a reply to message #205212] Thu, 11 September 2008 11:04 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
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 11:28 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
(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 12:17 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: aggregation relation & containmentfeature
Next Topic:Link Constraints Problem
Goto Forum:
  


Current Time: Fri Apr 26 19:23:25 GMT 2024

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

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

Back to the top