Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Editor does not become dirty when i use Same File for model and diagram
Editor does not become dirty when i use Same File for model and diagram [message #226068] Wed, 15 April 2009 06:33 Go to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Hi

I have set "Same File for Model and Diagram" true for my editor and my
editor is not getting dirty whenever I drop an element from my palette. I
wrote a custom command for this.
I generated my ecore model from an xsd and so i commented
((XMLResource)diagramResource).getDefaultSaveOptions().put(X MLResource.OPTION_EXTENDED_META_DATA,Boolean.TRUE);
((XMLResource)diagramResource).getDefaultLoadOptions().put(X MLResource.OPTION_EXTENDED_META_DATA,Boolean.TRUE);
lines in XXXDiagramUtil#createDiagram method.

I tried modifying XXXDocumentProvider#ResourceSetModificationListener
class to include Notification.ADD and Notification.REMOVE. I tried
debugging the XXXDocumentProvider class to find that
myModifiedFilter.matches(notification) was never true in notifyChanged
method.

I am using GMF version 2.1.2 and EMF 2.4.1

Thanks for any help,

Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #226163 is a reply to message #226068] Wed, 15 April 2009 09:56 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

It it necessary to call setTrackingModification(true) for all the underlying
EMF resources then creating an editor. Can you please check that corresponding
flag was set to true? This is a precondition for marking aditor as "dirty"
on any changes in EMF resources.

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #226935 is a reply to message #226163] Wed, 22 April 2009 06:57 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Thanks for the reply Alex.

I checked isTrackingModification is true for the EMF resources. And the
editor becomes dirty for other actions like delete. I am using a custom
command for create node. This command is not firing the notifyChanged with
GMFResource unlike other commands.
Once the editor becomes dirty for the first time with any other command,
it is working fine with create command also.

Thanks,
Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #227008 is a reply to message #226935] Wed, 22 April 2009 11:33 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

Try to debug this command execution to see why corresponding notification
was not sent by EMF. AFAIK EMF objects should throw notification (Resource.modified)
in case ANY objects in this resource were changed + this Resource was not
changed betore..

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #227936 is a reply to message #227008] Tue, 28 April 2009 12:02 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Thanks Alex.

The problem is caused due to my custom command. That got fixed. But I am
facing a similar problem with the Properties now. My property changes are
not making the editor dirty. This again works fine when I do "Same File
for Model and Diagram" false.

I am calling the following to handle the changes in my properties UI.

TransactionalEditingDomain domain = getEditingDomain();
domain.getCommandStack().execute( SetCommand.create(domain, property,
getFeature(), newVal));

Do I have to explicitly handle something when I make "Same File for Model
and Diagram" true?

Thanks for any help,
Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #227971 is a reply to message #227936] Tue, 28 April 2009 13:25 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

> Do I have to explicitly handle something when I make "Same File for
> Model and Diagram" true?
No, everything should work in a similar way.. Again - try to debug this command
to see why corresponding notification was not sent by EMF.

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #227999 is a reply to message #227971] Tue, 28 April 2009 14:03 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Thanks for the quick reply Alex.

I tried debugging the command.
In GMFResource#createModificationTrackingAdapter class, the notifyChanged
method checks whether the notifier is transient or not. I have an abstract
class in the containment hierarchy of the notifier. Hence isTransient
method is always returning true and the notifyChanged is never getting
called with GMFResource. In XXXDocumentProvider#notifyChanged the check
myModifiedFilter.matches(notification) always returns false as the
notifier is not a Resource.

Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #228014 is a reply to message #227999] Tue, 28 April 2009 14:11 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

AFAIU this is a method returning incorrect value in your case:

private static boolean isTransient(EObject eObject) {
EStructuralFeature containmentFeature = eObject.eContainmentFeature();
while (containmentFeature != null) {
if (containmentFeature.isTransient())
return true;
eObject = eObject.eContainer();
if (eObject != null)
containmentFeature = eObject.eContainmentFeature();
else
break;
}
return false;
};

As you can see "true" is returned only if one of the features containing
this EObject or it's parents is transient. Looks like you have to determine
wich feature is transient and make it non-transient. ;-)

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #228112 is a reply to message #228014] Wed, 29 April 2009 08:06 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Thanks Alex.

Changing the feature's transient property to true worked. But that feature
is an EReference of DocumentRoot since I created the ecore from an xsd
model. Is it okay do that or will it cause any other problems?

Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #228229 is a reply to message #228112] Wed, 29 April 2009 10:14 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

> Changing the feature's transient property to true worked. But that
To false i suppose.

> feature is an EReference of DocumentRoot since I created the ecore
> from an xsd model. Is it okay do that or will it cause any other
> problems?
Well, please raise this question in EMF nesgroup. In case this code was generated
by EMF from XSD then it looks like we have to change GMF and make it working
properly in this situation. Can you please file a bugzilla request for it?

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #228266 is a reply to message #228229] Wed, 29 April 2009 11:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Alex,

I do expect the Document root's features to be derived and transient
because they are derived from the mixed feature map and only the mixed
feature has is serialized or copied...


Alex Shatalin wrote:
> Hello Lavanya,
>
>> Changing the feature's transient property to true worked. But that
> To false i suppose.
>
>> feature is an EReference of DocumentRoot since I created the ecore
>> from an xsd model. Is it okay do that or will it cause any other
>> problems?
> Well, please raise this question in EMF nesgroup. In case this code
> was generated by EMF from XSD then it looks like we have to change GMF
> and make it working properly in this situation. Can you please file a
> bugzilla request for it?
>
> -----------------
> Alex Shatalin
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Editor does not become dirty when i use Same File for model and diagram [message #228289 is a reply to message #228266] Wed, 29 April 2009 12:02 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Alex,

I created a bug for this
https://bugs.eclipse.org/bugs/show_bug.cgi?id=274286. Can you suggest any
workaround for this issue since there is an urgent requirement?

Thanks
Lavanya.
Re: Editor does not become dirty when i use Same File for model anddiagram [message #228407 is a reply to message #228266] Wed, 29 April 2009 14:56 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ed,

> I do expect the Document root's features to be derived and transient
> because they are derived from the mixed feature map and only the mixed
> feature has is serialized or copied...
Ok. Then we have to modify GMF to work correctly with this code.

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #228415 is a reply to message #228289] Wed, 29 April 2009 15:03 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

For you can register custom ResourceFactory instead of default org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y
inside generated plugin.xml. This fectory should create subclasses of GMFResource
class overriding createModificationTrackingAdapter() method with the original
code from XMIResourceImpl.


-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #228628 is a reply to message #228415] Fri, 01 May 2009 05:54 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Hello Alex,

I tried creating a custom ResourceFactory and overriding GMFResource
#createModificationTrackingAdapter() without the transient check. But this
is causing another issue. Whenever I open a diagram, it always opens in a
dirty state. I figured out the problem, the transient check in GMFResource
handles the call when the notifier is DiagramImpl. But since I ignored
that check my editor becomes dirty everytime I open the file.

Am I missing something?

Lavanya.
Re: Editor does not become dirty when i use Same File for model and diagram [message #229768 is a reply to message #228628] Tue, 12 May 2009 15:43 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

Then try skipping this particular notification in custom Resource produced
by this ResoruceFactory or (instead) preserve the logic from GMFResource
with an addition - not skipping notifications you need to make this editor
dirty.

-----------------
Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #229915 is a reply to message #229768] Wed, 13 May 2009 08:35 Go to previous messageGo to next message
Lavanya K C is currently offline Lavanya K CFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Alex,

I tried doing a transient check in my custom Resource for the
notifications from org.eclipse.gmf.runtime.notation.impl.ViewImpl and
org.eclipse.gmf.runtime.notation.impl.NotationEObjectImpl and skipping the
transient check for all others (notifications from my model elements).
This is working fine.
I just want to make sure if this approach is okay or am I missing any
other cases by that check?

Thanks for the help once again,

Lavanya.


Alex Shatalin wrote:

> Hello Lavanya,

> Then try skipping this particular notification in custom Resource produced
> by this ResoruceFactory or (instead) preserve the logic from GMFResource
> with an addition - not skipping notifications you need to make this editor
> dirty.

> -----------------
> Alex Shatalin
Re: Editor does not become dirty when i use Same File for model and diagram [message #230055 is a reply to message #229915] Wed, 13 May 2009 12:42 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Lavanya,

I think it should be ok for your diagram and in GMf we have to develop some
generic solution.

-----------------
Alex Shatalin
Previous Topic:Loading GMF from DB
Next Topic:Overlapping connections
Goto Forum:
  


Current Time: Thu Apr 25 12:56:46 GMT 2024

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

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

Back to the top