Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Grahical editor refresh on underlying resource changed
Grahical editor refresh on underlying resource changed [message #730820] Thu, 29 September 2011 09:10 Go to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi All,

I am extremely new to Graphiti, rather working on an exsisting code.

We have a graphical editor.The underlying resource gets changed externally and the DomainWorkspaceSynchronizer get the event.
Our graphical editor does not get refreshed with the content.

We do unloading and loading of resource before calling the graphical editor refresh method to reload the graphical contents.
My question is how important DomainWorkspaceSynchronizer is to refresh the graphical contents ? because there is an exception thrown in handleResourceChanged method.

Reason for that is that the resource does not appear to be local(its a semantic file system based resource) , so file.getLocation() returns null.Hence NPE and DomainEditorBehaviour.setResourceChanged() is not called.

I may appear to be not talking sense as i have not still got hang of the internals of the Graphiti Smile.Please let me know if i need to provide any further details.

cheers,
Saurav


Re: Grahical editor refresh on underlying resource changed [message #730907 is a reply to message #730820] Thu, 29 September 2011 13:55 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
saurav wrote on Thu, 29 September 2011 06:10
Hi All,

Reason for that is that the resource does not appear to be local(its a semantic file system based resource) , so file.getLocation() returns null.Hence NPE and DomainEditorBehaviour.setResourceChanged() is not called.



Sounds like a bug in DomainModelWorkspaceSynchronizerDelegate.handleResourceChanged() to me.


	
 IFile file = WorkspaceSynchronizer.getFile(r);
 if (file != null && (!file.exists() || 
    file.getLocation().toFile().lastModified() != r.getTimeStamp())) {
	deb.setResourceChanged(true);
	return true;
 }



I'm also new to Graphiti (and EMF) but I think that are two issues here:
1. The test should test that file.getLocation() != null
2. (More conceptually important) What to do when it can't do the timestamp comparison ?

I think that it should rather set the changed flag in this case, deb.setResourceChanged(true); , at least if the resource in question is the one that was notified (the argument to the method).
Come to think of it, I wonder why all the resources in the resourceSet are tested, instead of simply the one notified...
Re: Grahical editor refresh on underlying resource changed [message #730920 is a reply to message #730907] Thu, 29 September 2011 14:13 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi,

we check all files in the resource set, since the business objects might
have been stored in a different file.
The diagram needs to be notified if business objects in a seperate resource
in the same resource set
are modified from the outside.

Best, Tim
Re: Grahical editor refresh on underlying resource changed [message #730926 is a reply to message #730920] Thu, 29 September 2011 14:46 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Tim Kaiser wrote on Thu, 29 September 2011 11:13
Hi,

we check all files in the resource set, since the business objects might
have been stored in a different file.
The diagram needs to be notified if business objects in a seperate resource
in the same resource set
are modified from the outside.



But in that method we are supposedly reacting to a notification for a change in a specific resource. Say I have my diagram with file/uri "x.diag" , and the model in file "x.model", then the resourceset will have two resource with those distinct uris. If I modify from the ouside(say, with the eclipse text editor) the "x.model" file, won't this handleResourceChanged() method will be invoked with the "x.model" resource?

Anyway, I (still) think that, for the particular resource that is reported as method argument, if we can't check the timestamp, the most secure decision is to assume it changed.
Re: Grahical editor refresh on underlying resource changed [message #731034 is a reply to message #730926] Thu, 29 September 2011 18:32 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi Guyz,

Thanks for your inputs.
So my remaining concenrs are following.

As my resource is changed externally the DomainModelWorkspaceSynchronizerDelegate.handleResourceChanged() becomes imperative i guess.
This method will set the resource changed flag to true and while activation the editor will refresh.

As i mentioned my file system does not respond to the timestamp comparison , is there any other way the resource changed flag could be set
or any other better approaches ?

If not from Graphiti side i look for the Semantic File system implementation and try to do something there.

cheers,
Saurav


[Updated on: Thu, 29 September 2011 18:33]

Report message to a moderator

Re: Grahical editor refresh on underlying resource changed [message #731052 is a reply to message #731034] Thu, 29 September 2011 19:01 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
I'd try changing the above to
  Resource r = iterator.next();
  IFile file = WorkspaceSynchronizer.getFile(r);
  try {
    if (file != null && (!file.exists() || file.getLocation().toFile().lastModified() != r.getTimeStamp())) {
       deb.setResourceChanged(true);
       return true;
      }
  } catch(Exception e) {
   if(r == resource) {
      deb.setResourceChanged(true);
      return true;
   }
 }
  

Re: Grahical editor refresh on underlying resource changed [message #731142 is a reply to message #731052] Fri, 30 September 2011 05:49 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hernan wrote on Thu, 29 September 2011 15:01
I'd try changing the above to
  Resource r = iterator.next();
  IFile file = WorkspaceSynchronizer.getFile(r);
  try {
    if (file != null && (!file.exists() || file.getLocation().toFile().lastModified() != r.getTimeStamp())) {
       deb.setResourceChanged(true);
       return true;
      }
  } catch(Exception e) {
   if(r == resource) {
      deb.setResourceChanged(true);
      return true;
   }
 }
  



Hi,

Do you all think the above approach suggested by Hernan can be implemented ?.If yes i can raise a bugzilla.

cheers,
Saurav


Re: Grahical editor refresh on underlying resource changed [message #731165 is a reply to message #731142] Fri, 30 September 2011 07:30 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
There's definitely a bug in here, the NPE must not occur. So yes, please
open a bugzilla for that.

Michael


"saurav" schrieb im Newsbeitrag news:j63kj2$m5g$1@news.eclipse.org...

Hernan wrote on Thu, 29 September 2011 15:01
> I'd try changing the above to
>
> Resource r = iterator.next();
> IFile file = WorkspaceSynchronizer.getFile(r);
> try {
> if (file != null && (!file.exists() ||
> file.getLocation().toFile().lastModified() != r.getTimeStamp())) {
> deb.setResourceChanged(true);
> return true;
> }
> } catch(Exception e) {
> if(r == resource) {
> deb.setResourceChanged(true);
> return true;
> }
> }


Hi,

Do you all think the above approach suggested by Hernan can be implemented
?.If yes i can raise a bugzilla.

cheers,
Saurav
--
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
Re: Grahical editor refresh on underlying resource changed [message #731181 is a reply to message #731165] Fri, 30 September 2011 08:04 Go to previous message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi Michael,

The bug is raised here

https://bugs.eclipse.org/bugs/show_bug.cgi?id=359526

cheers,
Saurav


Previous Topic:How to invoke direct editing programatically?
Next Topic:Difference between Diagram Type and Diagram Type Provider
Goto Forum:
  


Current Time: Tue Apr 16 06:00:23 GMT 2024

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

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

Back to the top