Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » shouldDeleteView in CanonicalEditPolicy
shouldDeleteView in CanonicalEditPolicy [message #109595] Wed, 07 March 2007 10:46 Go to next message
Eclipse UserFriend
Hi,
the generated method for shouldDeleteView in the CanonicalEditPolicy
looks like this:
protected boolean shouldDeleteView(View view) {
return view.isSetElement() && view.getElement() != null
// && view.getElement().eIsProxy();
}

This does not work for me, in the case when I delete a semantic model
element from a different view than the diagram. I can solve it by simply
changed the condition above to return true in any case. But I guess this
introduces some other problem. What is the rationale of the generated
code? And is my use case a bug in the current version of the generated code?

Cheers,
Steffen
Re: shouldDeleteView in CanonicalEditPolicy [message #109699 is a reply to message #109595] Wed, 07 March 2007 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi; you might want to read the thread

"Notational Model update after semantic elemeted gets deleted by
EMFOperation"

also you have to be careful about returning true always from the should
delete view, for example if there is a Note on the owner of this edit
policy, as soon as your edit policy refresh it will delete the note or
any view that had no semantic element (like geo-shapes)

to make it easy the rule is, if the container of the edit policy can
contain views with no semantic elements (like Notes or geo-shapes) then
for sure you do not want to just return true in this method.

also keep in mind the generated code is trying to handle all cases
(someone from the code generation side can correct me if I'm wrong), you
can customize the method implementation based on your diagram assumptions

Steffen Becker wrote:
> Hi,
> the generated method for shouldDeleteView in the CanonicalEditPolicy
> looks like this:
> protected boolean shouldDeleteView(View view) {
> return view.isSetElement() && view.getElement() != null
> // && view.getElement().eIsProxy();
> }
>
> This does not work for me, in the case when I delete a semantic model
> element from a different view than the diagram. I can solve it by simply
> changed the condition above to return true in any case. But I guess this
> introduces some other problem. What is the rationale of the generated
> code? And is my use case a bug in the current version of the generated
> code?
>
> Cheers,
> Steffen
Re: shouldDeleteView in CanonicalEditPolicy [message #110356 is a reply to message #109595] Thu, 08 March 2007 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Hello Steffen,

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=157148
In general as a workaround you can return true from this method and see the
result.

-----------------
Alex Shatalin
Re: shouldDeleteView in CanonicalEditPolicy [message #110391 is a reply to message #110356] Thu, 08 March 2007 14:30 Go to previous messageGo to next message
Eclipse UserFriend
Alex Shatalin wrote:
> Hello Steffen,
>
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=157148
> In general as a workaround you can return true from this method and see

I do not think that saying "in general as a workaround you can return
true" , is correct, does not that mean that if i drop a note inside this
edit part that owns this editpolicy, the very next time this edit part
refresh it will delete the note ?

I have tried it my self, i changed the canonical edit policy on my
diagram to return true, then i dropped a note on the diagram surface. It
showed up fine, then as soon as i dropped another element on the diagram
surface the note disappeared

Sorry i keep commenting about that, but it looks so wrong to me

> the result.
>
> -----------------
> Alex Shatalin
>
>
Re: shouldDeleteView in CanonicalEditPolicy [message #110451 is a reply to message #110391] Thu, 08 March 2007 16:50 Go to previous messageGo to next message
Eclipse UserFriend
Hello Mohammed,

> I do not think that saying "in general as a workaround you can return
> true" , is correct, does not that mean that if i drop a note inside
> this edit part that owns this editpolicy, the very next time this edit
> part refresh it will delete the note ?
Not sore the diagram of this customer contains notes or other design elements.
In any case, references request AFAIR contains a lot of information about
this method, so it could be used for implementing correct logic inside this
method.

-----------------
Alex Shatalin
Re: shouldDeleteView in CanonicalEditPolicy [message #110466 is a reply to message #110451] Thu, 08 March 2007 17:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex;

lex Shatalin wrote:
> Hello Mohammed,
>
>> I do not think that saying "in general as a workaround you can return
>> true" , is correct, does not that mean that if i drop a note inside
>> this edit part that owns this editpolicy, the very next time this edit
>> part refresh it will delete the note ?
> Not sore the diagram of this customer contains notes or other design

Exactly, that is why i did not like the statement "in general ... ".
Based on what i noticed in the last few days; it looks like the
canonical edit policy some times is used to do an edit helper job, which
is bad and was never the intent behind the design of the edit policy.

May be what we are missing is an article on the WIKI explaining what is
the job of a canonical edit policy and few tips on what is recommended
and what is not.

I'll try to work on that as soon I'm back from vacation, so hopefully
there will ba an article by mid or April


> elements. In any case, references request AFAIR contains a lot of
> information about this method, so it could be used for implementing
> correct logic inside this method.

Of course, i agree with you 100% there is no way the code generation or
the runtime will be able to implement the shouldDeleteView in a way that
will cover all use cases. I think the article might help users to decide
is they need to modify the shouldDeleteView method or if they just need
an edit helper and so on ...



>
> -----------------
> Alex Shatalin
>
>
Re: shouldDeleteView in CanonicalEditPolicy [message #111049 is a reply to message #110466] Mon, 12 March 2007 11:21 Go to previous messageGo to next message
Eclipse UserFriend
Hello Mohammed,

> I'll try to work on that as soon I'm back from vacation, so hopefully
> there will ba an article by mid or April
Cool! Would be nice to have it!

-----------------
Alex Shatalin
Re: shouldDeleteView in CanonicalEditPolicy [message #111708 is a reply to message #110451] Wed, 14 March 2007 02:02 Go to previous message
Eclipse UserFriend
Alex Shatalin schrieb:
> Hello Mohammed,
>
>> I do not think that saying "in general as a workaround you can return
>> true" , is correct, does not that mean that if i drop a note inside
>> this edit part that owns this editpolicy, the very next time this edit
>> part refresh it will delete the note ?
> Not sore the diagram of this customer contains notes or other design
> elements. In any case, references request AFAIR contains a lot of
> information about this method, so it could be used for implementing
> correct logic inside this method.
Hi,
indeed for my use case returning true is a valid workaround. But I very
much like the solution presented in bugzilla of checking modelID and
visualID. This really seems to be a good thing in general... I would opt
for making this the default :-)

Cheers and many thanks for all the extensive comments on this issue...
Steffen
Previous Topic:how to parse an xmi file in gmf
Next Topic:Advanced Zooming
Goto Forum:
  


Current Time: Tue Jul 15 07:07:58 EDT 2025

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

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

Back to the top