DeleteModelCommand Problems [message #483542] |
Wed, 02 September 2009 00:38 |
Eclipse User |
|
|
|
Originally posted by: derek.pfister.gmail.com
I have the following problems when trying to delete an EObject with the
DeleteModel command:
http://sites.google.com/site/deletemodelpics/
It seems as if the framework returns a DeleteCommand that has its
isExecutable = false. Does anyone know why?
Here are some additional questions I have:
1.) Why would overriding the ItemProvider help? What are the differences
between ModelProviders and ItemProviders? How would you start going about
overriding these? How would that help with deleting an object that is
only contained within a resource? How can you tell if an object is only
contained within a resource?
2.) If I had to override the DeleteCommand, how would I override it?
What would I put in execute()? Would I always have isExecutable()
return true?
|
|
|
Re: DeleteModelCommand Problems [message #483664 is a reply to message #483542] |
Wed, 02 September 2009 14:13 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000900010200040707040906
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Derek,
Comments below.
Derek Pfister wrote:
> I have the following problems when trying to delete an EObject with
> the DeleteModel command:
>
> http://sites.google.com/site/deletemodelpics/
>
> It seems as if the framework returns a DeleteCommand that has its
> isExecutable = false. Does anyone know why?
I see that isPrepared is false as well though, so it seems to me it's
never been tested for executability.
/**
* Returns whether the command is valid to <code>execute</code>.
* The {@link
UnexecutableCommand#INSTANCE}.<code>canExecute()</code> always
returns <code>false</code>.
* This <b>must</b> be called before calling <code>execute</code>.
* @return whether the command is valid to <code>execute</code>.
*/
boolean canExecute();
>
> Here are some additional questions I have:
>
> 1.) Why would overriding the ItemProvider help?
Help what?
> What are the differences between ModelProviders and ItemProviders?
Reading the introductory EMF Edit paper would help, or better yet, the
EMF book...
> How would you start going about overriding these?
ItemProviderAdapter is the base class for each AbcItemProvider (for each
EClass Abc) and it has methods like createRemoveCommand and so on that
you could specialize if you want to do more than just the basic things
the base class does for you.
> How would that help with deleting an object that is only contained
> within a resource?
ResourceItemProvider doesn't by default support removing objects from
Resource.getContents().
> How can you tell if an object is only contained within a resource?
EObject.eContainer will be null. But you don't need to tell, you only
need to look at the situations where the ResourceItemProvider's
createRemoveCommand is called.
>
> 2.) If I had to override the DeleteCommand, how would I override it?
Typically you don't need to override it because it's composed from more
primitive commands, e.g., RemoveCommand in particular.
> What would I put in execute()? Would I always have isExecutable()
> return true?
You should be able to create the Remove command using this constructor:
/**
* This constructs a primitive command to remove a particular
value from the specified extent.
*/
public RemoveCommand(EditingDomain domain, EList<?> list, Object
value)
{
this(domain, list, Collections.singleton(value));
}
Passing in Resource.getContents() as the list and the thing to remove as
the value...
--------------000900010200040707040906
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Derek,<br>
<br>
Comments below.<br>
<br>
Derek Pfister wrote:
<blockquote
cite="mid:5179211e8e160d2feee8f84dc5e5f19c$1@www.eclipse.org"
type="cite">I have the following problems when trying to delete an
EObject with the DeleteModel command:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://sites.google.com/site/deletemodelpics/">http://sites.google.com/site/deletemodelpics/</a>
<br>
<br>
It seems as if the framework returns a DeleteCommand that has its
isExecutable = false.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Re: DeleteModelCommand Problems [message #483743 is a reply to message #483714] |
Wed, 02 September 2009 19:32 |
Eclipse User |
|
|
|
Originally posted by: derek.pfister.gmail.com
It looks like the object is contained within another object. What I said
previously is incorrect, as this object has another object as its
container. Sorry about that. How do I go about deleting it based on the
presented evidence?
|
|
|
|
Re: DeleteModelCommand Problems [message #483944 is a reply to message #483874] |
Thu, 03 September 2009 17:14 |
Eclipse User |
|
|
|
Originally posted by: derek.pfister.gmail.com
It seems as if the ownerList that is created doesn't contain the object I
want to delete.
org.eclipse.emf.common.command.Command cmd = new
RemoveCommand(domain.getEMFEditingDomain(),
model.eResource().getContents(), model);
Is it possible that model.eResource().getContents() doesn't contain the
model object that I want to delete? Could there be another list that I
should pass instead of model.eResource().getContents() as the second
argument to the RemoveCommand?
|
|
|
|
|
|
Re: DeleteModelCommand Problems [message #484013 is a reply to message #484001] |
Thu, 03 September 2009 21:04 |
Eclipse User |
|
|
|
Originally posted by: derek.pfister.gmail.com
I don't do it that way because when I call
DeleteCommand.create(domain.getEMFEditingDomain(), model); the
RemoveCommand that is created internally returns an Unexecutable command.
Is there anything I can provide you that would help identify the problem?
Any advice?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02994 seconds