Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to use the provided edit.helpers?
How to use the provided edit.helpers? [message #218007] Mon, 09 February 2009 17:44 Go to next message
Eclipse UserFriend
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 #218080 is a reply to message #218007] Tue, 10 February 2009 10:39 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cayla,

See generated XXXBaseItemSemanticEditPolicy.getSemanticCommand() to see then
the EditHelpers are called.
If you just need to modify delete element behaviour why don't you change
corresponding ElementItemSemanticEditPolicy.getDestroyElementCommand()?

-----------------
Alex Shatalin
Re: How to use the provided edit.helpers? [message #218118 is a reply to message #218080] Tue, 10 February 2009 13:31 Go to previous messageGo to next message
Eclipse UserFriend
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 #218173 is a reply to message #218118] Tue, 10 February 2009 13:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cayla,

> should call getDestroyElementCommand() in LocationEditHelper.
Isn't LocationEditHelper extends XXXBaseEditHelper?..

-----------------
Alex Shatalin
Re: How to use the provided edit.helpers? [message #218181 is a reply to message #218118] Tue, 10 February 2009 13:58 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #218197 is a reply to message #218173] Tue, 10 February 2009 14:00 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Alex,

> Isn't LocationEditHelper extends XXXBaseEditHelper?..
Well, this can be one of the other sublcasses of XXXBaseEditHelper (not only
LocationEditHelper).. Try placing a breakpoint into XXXBaseEditHelper.getDestroyElementCommand()
to see wich particular XXXEditHelper class will be called on deleting this
element (you can see a class of "this" variable in variables window of the
debugger.

-----------------
Alex Shatalin
Re: How to use the provided edit.helpers? [message #218205 is a reply to message #218118] Tue, 10 February 2009 15:10 Go to previous message
Linda Damus is currently offline Linda DamusFriend
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
>>
>>
Previous Topic:About BorderItemFigure like logic example
Next Topic:How GMF reuse EMF ?
Goto Forum:
  


Current Time: Sun Mar 07 06:34:27 GMT 2021

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

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

Back to the top