How to use the provided edit.helpers? [message #218007] |
Mon, 09 February 2009 17:44 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Hello!
There is a package called ...diagram.edit.helpers with empty classes for
every shape in the diagram.
I want special behaviour at the deletion of one of my shapes.
I thought, that I can implement my own actions in this EditHelpers when
one of my shapes is created, edited or deleted. Is that right?
But what do I have to do, that my methods are called?
I put in one of the XXXEditHelpers the method
getDestroyElementCommand(), but it`s never called.
The method XXXBaseEditHelper.getDestroyElementCommand() is always called.
Thanks in advance
Best wishes
Julia
|
|
|
|
Re: How to use the provided edit.helpers? [message #218118 is a reply to message #218080] |
Tue, 10 February 2009 13:31 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Alex Shatalin schrieb:
> Hello Cayla,
>
> See generated XXXBaseItemSemanticEditPolicy.getSemanticCommand() to see
> then the EditHelpers are called.
I already debugged the call of the EditHelpers.
The problem is, that
XXXBaseItemSemanticEditPolicy.getSemanticCommand() calls (indirectly)
AbstractEditHelper.getEditCommand().
This calls XXXBaseEditHelper.getInsteadCommand().
This calls AbstractEditHelper.getInsteadCommand().
And this calls getDestroyElementCommand() - in XXXBaseEditHelper. But it
should call getDestroyElementCommand() in LocationEditHelper.
I don`t even understand, why it calls
XXXBaseEditHelper.getDestroyElementCommand() and not
AbstractEditHelper.getDestroyElementCommand(), because
AbstractEditHelper has its own method getDestroyElementCommand().
I already tried to out-comment the
XXXBaseEditHelper.getDestroyElementCommand(), because I hoped, that then
LocationEditHelper.getDestroyElementCommand() is called, but it didn`t work.
Perhaps I should call LocationEditHelper.getDestroyElementCommand() from
XXXBaseEditHelper.getDestroyElementCommand()? But I don`t know how I
should determine, that this call belongs to a Location and not to any
other class.
How do others use the edit-helpers? I already googled for edit helpers
but I didn`t find a lot. Only this page:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/common/Extensible%20Type%20Registry/extens ibleTypeRegistryTutorial.html
But they don`t do anything else then writing the method in the empty
helper-class. I already checked my plugin.xml: the metamodelType with
the edithelper is there.
> If you just need to modify delete element behaviour why don't you change
> corresponding ElementItemSemanticEditPolicy.getDestroyElementCommand()?
I think, thats not so good in my case, because I have one class called
"Location". This Location is represented by 6 different EditParts. I
want the special behaviour when the Location is deleted, no matter which
appearance it has at the moment.
There is one LocationEditHelper, but there are 6
ElementItemSemantivEditPolicies one for each EditPart. That means, I
would need to edit 6 classes instead of 1.
>
> -----------------
> Alex Shatalin
>
>
|
|
|
|
Re: How to use the provided edit.helpers? [message #218181 is a reply to message #218118] |
Tue, 10 February 2009 13:58 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Problem solved :D
I did what I proposed in my former mail:
I call my LocationEditHelper.getDestroyElementCommand() in
XXXBaseEditHelper.getDestroyElementCommand():
/**
* @generated NOT
*/
protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
if(req.getElementToDestroy().getClass().getSimpleName().
equals("LocationImpl"))
{
LocationEditHelper helper = new LocationEditHelper();
return helper.getDestroyElementCommand(req);
}
else
{
return null;
}
}
|
|
|
Re: How to use the provided edit.helpers? [message #218190 is a reply to message #218173] |
Tue, 10 February 2009 13:59 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
> Hello Cayla,
>
>> should call getDestroyElementCommand() in LocationEditHelper.
> Isn't LocationEditHelper extends XXXBaseEditHelper?..
>
Jupp, but how should this help?
> -----------------
> Alex Shatalin
>
>
|
|
|
|
Re: How to use the provided edit.helpers? [message #218205 is a reply to message #218118] |
Tue, 10 February 2009 15:10 |
Linda Damus Messages: 85 Registered: July 2009 |
Member |
|
|
Hello Julia,
I see you've already found a workaround for your issue, but in case you
need further information at a later date, I just wanted to point you to
the dev guide for the edit helpers:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/prog-guide/runtime/Developers%20Guide%20to%20the%20E xtensible%20Type%20Registry/Developers%20Guide%20to%20the%20 Extensible%20Type%20Registry.html
For deletion (and creation) the edit helper that corresponds to the
container of the element being deleted is the one that will be consulted.
Regards,
Linda
Cayla Sha wrote:
>
> Alex Shatalin schrieb:
>> Hello Cayla,
>>
>> See generated XXXBaseItemSemanticEditPolicy.getSemanticCommand() to
>> see then the EditHelpers are called.
>
> I already debugged the call of the EditHelpers.
> The problem is, that
> XXXBaseItemSemanticEditPolicy.getSemanticCommand() calls (indirectly)
> AbstractEditHelper.getEditCommand().
> This calls XXXBaseEditHelper.getInsteadCommand().
> This calls AbstractEditHelper.getInsteadCommand().
> And this calls getDestroyElementCommand() - in XXXBaseEditHelper. But it
> should call getDestroyElementCommand() in LocationEditHelper.
> I don`t even understand, why it calls
> XXXBaseEditHelper.getDestroyElementCommand() and not
> AbstractEditHelper.getDestroyElementCommand(), because
> AbstractEditHelper has its own method getDestroyElementCommand().
>
> I already tried to out-comment the
> XXXBaseEditHelper.getDestroyElementCommand(), because I hoped, that then
> LocationEditHelper.getDestroyElementCommand() is called, but it didn`t
> work.
>
> Perhaps I should call LocationEditHelper.getDestroyElementCommand() from
> XXXBaseEditHelper.getDestroyElementCommand()? But I don`t know how I
> should determine, that this call belongs to a Location and not to any
> other class.
>
> How do others use the edit-helpers? I already googled for edit helpers
> but I didn`t find a lot. Only this page:
> http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/common/Extensible%20Type%20Registry/extens ibleTypeRegistryTutorial.html
>
> But they don`t do anything else then writing the method in the empty
> helper-class. I already checked my plugin.xml: the metamodelType with
> the edithelper is there.
>
>
>
>> If you just need to modify delete element behaviour why don't you
>> change corresponding
>> ElementItemSemanticEditPolicy.getDestroyElementCommand()?
>
> I think, thats not so good in my case, because I have one class called
> "Location". This Location is represented by 6 different EditParts. I
> want the special behaviour when the Location is deleted, no matter which
> appearance it has at the moment.
> There is one LocationEditHelper, but there are 6
> ElementItemSemantivEditPolicies one for each EditPart. That means, I
> would need to edit 6 classes instead of 1.
>
>
>>
>> -----------------
>> Alex Shatalin
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03508 seconds