Community
Participate
Working Groups
Hi All, I am unable to refresh my Grpahiti editor inpsite of the underlying resource getting refreshed.I suspect the issue in the NPE i am getting in DomainModelWorkspaceSynchronizerDelegate. Please note my file system is not local hence the local root is not formed and the time stamp comparison in the DomainModelWorkspaceSynchronizerDelegate fails and eventually it fails to set the resourcechanged flag to true. For more details and discussions please check. http://www.eclipse.org/forums/index.php/t/243237/ Let me know if i need to provide any further details or if any help in testing is required. cheers, Saurav
As I pointed out in the linked discussion, the point is not only to avoid a potential NPE. First, I'm not clear whether it's really correct to check all resources for timestamp changes in that method (we're being notified of a change in particular resource, I think we'd check that one only). Further, it's not clear either what you we do in case we can't check timestamps (eg. because it's not actually a file). In my proposed patch a took a middle approach (consider it changed if it's the resource notified), but I doubt this is the right way: DomainModelWorkspaceSynchronizerDelegate.handleResourceChanged() Proposal 1: (check all, setResourceChanged if NPE with notified resource) 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; } } Proposal 2: (check only notified resource, setResourceChanged if NPE ) IFile file = WorkspaceSynchronizer.getFile(resource); try { if (file != null && (!file.exists() || file.getLocation().toFile().lastModified() != resource.getTimeStamp())) { deb.setResourceChanged(true); return true; } } catch(Exception e) { deb.setResourceChanged(true); return true; } Proposal 3: (check all resources, setResourceChanged if NPE ) 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) { deb.setResourceChanged(true); return true; } I'd vote for 2. (Actually, I'd vote to factor this logic out of here, to some user-provided/hoookable method, but that's other discussion)
Hernan, thanks for your hints! I agree that it is not necessary to check all files in the resource set, since the change is not reported resource specific. I did the following changes: - remove iteration over all resources in resource set - getUnderlying File instead of getFile (also takes into account archives, seems to be more flexible) - if the file is null we inform the diagram editor behavior that something changed - otherwise we stick to general eclipse IFile interface and ask getLocalTimeStamp, if there is no local time stamp this method returns a NULL_TIMESTAMP and we notify for changes Saurav, does it work now for your use case?
The fix looks good to me and should solve the issues mentioned here. Saurav: please just let us know in case this does not help.
(In reply to comment #3) > The fix looks good to me and should solve the issues mentioned here. Saurav: > please just let us know in case this does not help. Hi Michael/ Tim, Thanks for the quick reply. Fix looks good Would it mean if the time stamp comparison fails, the resource changed flag is set to true ? and on editor activation the new resource is loaded ? Can you please provide me the patch or is it submitted ?,I would do testing and let you know. cheers, Saurav
(In reply to comment #4) > Would it mean if the time stamp comparison fails, the resource changed flag is > set to true ? and on editor activation the new resource is loaded ? Yes, that would mean it. > > Can you please provide me the patch or is it submitted ?,I would do testing and > let you know. The fix has been checked in to head and will be part of our Juno M3 shipment. For now it can be installed from our nightly build update site at http://download.eclipse.org/graphiti/updates/nightly/ Michael
(In reply to comment #5) > (In reply to comment #4) > > Would it mean if the time stamp comparison fails, the resource changed flag is > > set to true ? and on editor activation the new resource is loaded ? > Yes, that would mean it. > > > > Can you please provide me the patch or is it submitted ?,I would do testing and > > let you know. > The fix has been checked in to head and will be part of our Juno M3 shipment. > For now it can be installed from our nightly build update site at > http://download.eclipse.org/graphiti/updates/nightly/ > Michael Any chances of getting it submitted in 0.8.0 ,our development is on Indigo. ? cheers, Saurav
(In reply to comment #6) > Any chances of getting it submitted in 0.8.0 ,our development is on Indigo. ? Our Juno M3 version (Graphiti 0.9.0 for now) will be compatible with Indigo. So you can test the fix in that version. In parallel we will check if a downport to 0.8.2 (part of Indigo SR2) is possible. Michael
(In reply to comment #6) > Any chances of getting it submitted in 0.8.0 ,our development is on Indigo. ? > cheers, > Saurav I have downported the fix to our 0_8_x codeline; it will be part of our Indigo SR2 shipment
Hi Michael, Thanks for the info. The NPE from DomainModelWorkspaceSynchronizer is not coming now and the flag is also set to true. Then from my editor refresh i call DiagramEditor.setFocus() to reload the model. But while doing it i get org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference from my diagram file. It was thrown during the refreshContent of DiagramEditorInternal DiagramEditorInput diagramEditorInput = (DiagramEditorInput) getEditorInput(); Diagram diagram = diagramEditorInput.getDiagram(); Let me know if you can provide me any hints. cheers, Saurav
(In reply to comment #9) > Hi Michael, > Thanks for the info. > The NPE from DomainModelWorkspaceSynchronizer is not coming now and the flag is > also set to true. > Then from my editor refresh i call DiagramEditor.setFocus() to reload the > model. > But while doing it i get > org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference > from my diagram file. > It was thrown during the refreshContent of DiagramEditorInternal > DiagramEditorInput diagramEditorInput = (DiagramEditorInput) getEditorInput(); > Diagram diagram = diagramEditorInput.getDiagram(); > Let me know if you can provide me any hints. > cheers, > Saurav Hi Saurav, thanks for letting me know that the fix works. The other thing you mentioned seems to be a different issue, so I would recommend to deal with that in a different topic e.g. in the forum to not mix things here. Nevertheless, it seems as if your resource(s) are not consistent, so there is a reference to an object that cannot be found. Michael
Hi Michael, You are quite right.I would open a different thread in the forum to discuss the issue if required :). cheers, Saurav
Bookkeeping: Set target release
Part of Graphiti 0.9.0 (Eclipse Juno)