Home » Modeling » EMF » Using RemoveCommand
|
Re: Using RemoveCommand [message #422368 is a reply to message #422361] |
Wed, 03 September 2008 12:13 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080509070607010509080105
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Paul,
Comments below.
phantomjinx wrote:
> Hi people,
>
> First post so greetings to everyone ...
>
> Am having a small problem invoking the RemoveCommand on my model. It
> works correctly for owner features but returns an unexecutable
> instance for references. To explain a little more clearly...
>
> I have an XMI resource that holds an EObject called Project.
> Project has 2 features, folders and elements.
>
> The Project to Element relationship is contained so all elements are
> persisted in the Project's XMI resource.
>
> The Project to Folder relationship is a non-contained reference and
> when a new Folder is added to the Project, it is persisted in its own
> XMI resource in the same directory as the Project's.
EMF does support cross resource containment...
>
> A RemoveCommand is created correctly for an Element using the following:
> RemoveCommand.create(editingDomain, element);
>
> but fails to be created for a Folder:
> RemoveCommand.create(editingDomain, folder);
A remove command without a specified owner will need to try to deduce
the owner, which it does by looking up the container and you've
explained there isn't one.
>
> Doing some debugging I found that the createCommand eventually works
> its way through to the factorRemoveCommand() method in the
> ItemProviderAdapter class. In this method a call is made to
> CommandParameter.getEOwner() which in the latter case is null as the
> owner has been set by the editingDomain as the folder's XMIResource.
Exactly.
>
> Can someone give me a pointer how I have to do this differently
> please. Happy to provide more information if any of this is unclear.
Use this version:
public static Command create(EditingDomain domain, Object owner,
Object feature, Object value)
Specify the Project instance as the owner as well as
XyzPackage.Literals.PROJECT__FOLDERS. I wonder if you'll want to delete
the underlying resource in this case as well?
>
> Thanks
>
> Paul
--------------080509070607010509080105
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
Comments below.<br>
<br>
phantomjinx wrote:
<blockquote cite="mid:g9kg63$ubu$1@build.eclipse.org" type="cite">Hi
people,
<br>
<br>
First post so greetings to everyone ...
<br>
<br>
Am having a small problem invoking the RemoveCommand on my model. It
works correctly for owner features but returns an unexecutable instance
for references. To explain a little more clearly...
<br>
<br>
I have an XMI resource that holds an EObject called Project.
<br>
Project has 2 features, folders and elements.
<br>
<br>
The Project to Element relationship is contained so all elements are
persisted in the Project's XMI resource.
<br>
<br>
The Project to Folder relationship is a non-contained reference and
when a new Folder is added to the Project, it is persisted in its own
XMI resource in the same directory as the Project's.
<br>
</blockquote>
EMF does support cross resource containment...<br>
<blockquote cite="mid:g9kg63$ubu$1@build.eclipse.org" type="cite"><br>
A RemoveCommand is created correctly for an Element using the
following:
<br>
RemoveCommand.create(editingDomain, element);
<br>
<br>
but fails to be created for a Folder:
<br>
RemoveCommand.create(editingDomain, folder);
<br>
</blockquote>
A remove command without a specified owner will need to try to deduce
the owner, which it does by looking up the container and you've
explained there isn't one.<br>
<blockquote cite="mid:g9kg63$ubu$1@build.eclipse.org" type="cite"><br>
Doing some debugging I found that the createCommand eventually works
its way through to the factorRemoveCommand() method in the
ItemProviderAdapter class. In this method a call is made to
CommandParameter.getEOwner() which in the latter case is null as the
owner has been set by the editingDomain as the folder's XMIResource.
<br>
</blockquote>
Exactly.<br>
<blockquote cite="mid:g9kg63$ubu$1@build.eclipse.org" type="cite"><br>
Can someone give me a pointer how I have to do this differently please.
Happy to provide more information if any of this is unclear.
<br>
</blockquote>
Use this version: <br>
<blockquote> public static Command create(EditingDomain domain, Object
owner, Object feature, Object value) <br>
</blockquote>
Specify the Project instance as the owner as well as
XyzPackage.Literals.PROJECT__FOLDERS. I wonder if you'll want to
delete the underlying resource in this case as well?<br>
<br>
<blockquote cite="mid:g9kg63$ubu$1@build.eclipse.org" type="cite"><br>
Thanks
<br>
<br>
Paul
<br>
</blockquote>
</body>
</html>
--------------080509070607010509080105--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Using RemoveCommand [message #422382 is a reply to message #422368] |
Wed, 03 September 2008 14:49 |
Paul Richardson Messages: 33 Registered: July 2009 |
Member |
|
|
Ed,
Many thanks. Owner and feature passed in and all is well. :)
Incidentally, yes, I do delete the resource after recursively deleting
any resources persisting sub-folders and sub-sub-folders.
Cheers for your help.
PGR
Ed Merks wrote:
> Paul,
>
> Comments below.
>
> phantomjinx wrote:
>> Hi people,
>>
>> First post so greetings to everyone ...
>>
>> Am having a small problem invoking the RemoveCommand on my model. It
>> works correctly for owner features but returns an unexecutable
>> instance for references. To explain a little more clearly...
>>
>> I have an XMI resource that holds an EObject called Project.
>> Project has 2 features, folders and elements.
>>
>> The Project to Element relationship is contained so all elements are
>> persisted in the Project's XMI resource.
>>
>> The Project to Folder relationship is a non-contained reference and
>> when a new Folder is added to the Project, it is persisted in its own
>> XMI resource in the same directory as the Project's.
> EMF does support cross resource containment...
>>
>> A RemoveCommand is created correctly for an Element using the following:
>> RemoveCommand.create(editingDomain, element);
>>
>> but fails to be created for a Folder:
>> RemoveCommand.create(editingDomain, folder);
> A remove command without a specified owner will need to try to deduce
> the owner, which it does by looking up the container and you've
> explained there isn't one.
>>
>> Doing some debugging I found that the createCommand eventually works
>> its way through to the factorRemoveCommand() method in the
>> ItemProviderAdapter class. In this method a call is made to
>> CommandParameter.getEOwner() which in the latter case is null as the
>> owner has been set by the editingDomain as the folder's XMIResource.
> Exactly.
>>
>> Can someone give me a pointer how I have to do this differently
>> please. Happy to provide more information if any of this is unclear.
> Use this version:
>
> public static Command create(EditingDomain domain, Object owner,
> Object feature, Object value)
>
> Specify the Project instance as the owner as well as
> XyzPackage.Literals.PROJECT__FOLDERS. I wonder if you'll want to delete
> the underlying resource in this case as well?
>
>>
>> Thanks
>>
>> Paul
|
|
|
Re: Using RemoveCommand [message #422383 is a reply to message #422368] |
Wed, 03 September 2008 14:51 |
Paul Richardson Messages: 33 Registered: July 2009 |
Member |
|
|
Ed,
Many thanks. Owner and feature passed in and all is well. :)
Incidentally, yes, I do delete the resource after recursively deleting
any resources persisting sub-folders and sub-sub-folders.
Cheers for your help.
PGR
Ed Merks wrote:
> Paul,
>
> Comments below.
>
> phantomjinx wrote:
>> Hi people,
>>
>> First post so greetings to everyone ...
>>
>> Am having a small problem invoking the RemoveCommand on my model. It
>> works correctly for owner features but returns an unexecutable
>> instance for references. To explain a little more clearly...
>>
>> I have an XMI resource that holds an EObject called Project.
>> Project has 2 features, folders and elements.
>>
>> The Project to Element relationship is contained so all elements are
>> persisted in the Project's XMI resource.
>>
>> The Project to Folder relationship is a non-contained reference and
>> when a new Folder is added to the Project, it is persisted in its own
>> XMI resource in the same directory as the Project's.
> EMF does support cross resource containment...
>>
>> A RemoveCommand is created correctly for an Element using the following:
>> RemoveCommand.create(editingDomain, element);
>>
>> but fails to be created for a Folder:
>> RemoveCommand.create(editingDomain, folder);
> A remove command without a specified owner will need to try to deduce
> the owner, which it does by looking up the container and you've
> explained there isn't one.
>>
>> Doing some debugging I found that the createCommand eventually works
>> its way through to the factorRemoveCommand() method in the
>> ItemProviderAdapter class. In this method a call is made to
>> CommandParameter.getEOwner() which in the latter case is null as the
>> owner has been set by the editingDomain as the folder's XMIResource.
> Exactly.
>>
>> Can someone give me a pointer how I have to do this differently
>> please. Happy to provide more information if any of this is unclear.
> Use this version:
>
> public static Command create(EditingDomain domain, Object owner,
> Object feature, Object value)
>
> Specify the Project instance as the owner as well as
> XyzPackage.Literals.PROJECT__FOLDERS. I wonder if you'll want to delete
> the underlying resource in this case as well?
>
>>
>> Thanks
>>
>> Paul
|
|
|
Goto Forum:
Current Time: Fri Apr 26 12:53:47 GMT 2024
Powered by FUDForum. Page generated in 0.03441 seconds
|