Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Diagram update problem related to use of URIEditorInput
Diagram update problem related to use of URIEditorInput [message #233367] Wed, 10 June 2009 23:23 Go to next message
Thomas Spall is currently offline Thomas SpallFriend
Messages: 29
Registered: July 2009
Junior Member
I have a GMF Editor as RCP application which also has the "Project
Explorer" and "Navigator" views visible and contains a workspace
environment like in Eclipse.

Now the problem is:
When I create a new diagram via the gmf auto-generated
new-diagram-wizards, the new diagram's file appears correctly in the
Project Explorer and a new worbench window tab editor for the diagram
opens up correctly. This "parent" diagram is a partitioned diagram, which
means, on double-click on one of the diagram nodes a sub-diagram opens
which shows the "contents" of the diagram node which was double-clicked. I
then do some modifications in the sub-diagram and save it. On this save,
the new contents of the subdiagram are written back into the diagram file.
These modifications should cause the node which was double-clicked in the
"parent" diagram to change it's appearance (more explicitly it should now
be displayed as 'filled' but that's off the point here). But when I close
the sub-diagram editor and go back to the "parent" editor, the "parent"
editor's appearance is not updated. I have to close the "parent" editor
window and open it again via the Project Explorer view to get the updated
appearance displayed.

The strange thing is now that the behaviour described before only happens
for a diagram which has just been freshly created via the new-diagram
wizard. If I open the diagram file via double-clicking the file in the
Project Explorer view and do the same steps to modify the sub-diagram, the
"parent" diagram gets updated automatically (even without displaying that
ususally appearing annoying message "The file contents changed on the file
system. Do you want to reload?")
Re: Diagram update problem related to use of URIEditorInput [message #233378 is a reply to message #233367] Wed, 10 June 2009 23:31 Go to previous messageGo to next message
Thomas Spall is currently offline Thomas SpallFriend
Messages: 29
Registered: July 2009
Junior Member
...I actually found out that the difference between a diagram 'opened' via
the new-diagram-wizard and via Project Explorer is that the EditorInput of
the opened editor in one case is instanceof FileEditorInput (if opened via
the Project Explorer) and in the other it is URIEditorInput (if opened via
the new-diagram-wizard).
It seems that if the EditorInput of the opened editor is of type
FileEditorInput it automatically reacts on the changes that the
sub-diagram does in it's 'doSave' method, so the "parent" diagram elements
automatically learn about the changes which are done by the sub-diagram
editor to the resource. However, this seems to NOT happen when using
URIEditorInput (which is, by the way, what GMF tools generate as per
standard, right!?)
Re: Diagram update problem related to use of URIEditorInput [message #233430 is a reply to message #233367] Thu, 11 June 2009 11:14 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

Can you try saving parent diagram just after openning (actually, creating
new) child one and before modifying it?

-----------------
Alex Shatalin
Re: Diagram update problem related to use of URIEditorInput [message #233438 is a reply to message #233378] Thu, 11 June 2009 11:19 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

You can debug generated ???DocumentProvider to investigate the difference
in handling resource change notifications for both editor inputs.
BTW, if you have resources subsystem in this distribution I recomment you
generating full (non-RCP) gmf diagram. RCP-one is necessary only for pure-RCP
platform (then you do not have eclipse resources subsystem available).

-----------------
Alex Shatalin
Re: Diagram update problem related to use of URIEditorInput [message #233542 is a reply to message #233430] Thu, 11 June 2009 21:33 Go to previous messageGo to next message
Thomas Spall is currently offline Thomas SpallFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Alex,

I tried that (saving "parent" diagram just after opening/creating new
child sub-diagram and before making modifications in the subdiagram) but
the effect is exactly the same as before (see post above).

_______
Thomas
Re: Diagram update problem related to use of URIEditorInput [message #233597 is a reply to message #233438] Mon, 15 June 2009 01:10 Go to previous messageGo to next message
Thomas Spall is currently offline Thomas SpallFriend
Messages: 29
Registered: July 2009
Junior Member
I used the generated ???DocumentProvider of the parent diagram for
debugging. What I can see in there is a 'ResourceSetInfo' and a
'ResourceSetModificationListener' private (respectively protected) class.
Do I guess right that they should be used to provide the refresh
functionality? I.e. the following constructor:

public ResourceSetInfo(IDiagramDocument document,
IEditorInput editorInput) {
super(document);
myDocument = document;
myEditorInput = editorInput;
myResourceSetListener = new
ResourceSetModificationListener(this);
getResourceSet().eAdapters().add(myResourceSetListener);
}

... should take care of installing a new instance of a ResourceSetListener
for every created ResourceSetInfo and subsequently the 'notifyChanged'
method should be called by the framework in case something changed?

However, this mechanism currently does not seem to work.
When opening the parent editor, the ???DocumentProvider's
'createElementInfo()' method is called and a new resourceSet with the
given URIEditorInput is created. Then I open the subdiagram (child) editor
and do the modifications. When saving the child editor the breakpoint I
set in the notifyChanged() method is not triggered. Neither is it
triggered when I close the child editor and return to the parent diagram.
BUT: finally, when closing the parent diagram I get about a dozen
invocations of the notifyChanged() method.

I really don't know what to change or try here. I don't know about the
functionality of the eAdapters() and when they should be called according
to the framework. My only idea currently is to bypass that system
completely and enhance the generated ???DocumentProvider by registering a
'normal' ResourceListener object on the File-Resource which corresponds to
the provided URI...
Re: Diagram update problem related to use of URIEditorInput [message #233605 is a reply to message #233597] Mon, 15 June 2009 01:23 Go to previous messageGo to next message
Thomas Spall is currently offline Thomas SpallFriend
Messages: 29
Registered: July 2009
Junior Member
...by the way, if in ???DiagramEditorUtil.java I change the
'openDiagram(...)' method to use 'FileEditorInput.java' instead of
'URIEditorInput.java' the automatic update of the parent diagram works:

public static boolean openDiagram(Resource diagram) throws
PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench()
getActiveWorkbenchWindow().getActivePage();

URI uri = diagram.getURI();
String platformURI = uri.toPlatformString(true);
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
Path(platformURI));
page.openEditor(new FileEditorInput(file),
CompModellingDiagramEditor.ID);
return true;
}

If I revert to the use of FileEditorInput here, the generated
???DocumentEditor.java does not use the generated ???DocumentProvider.java
but instead generates and uses an instance of
org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.docu ment.FileDiagramDocumentProvider
and this class seems to handle resource changes correctly.

However, this workaround can't work for sub-diagrams of sub-diagrams (as
the input for a sub-diagram can't be a FileEditorInput because you need
the diagram facet functionality which is present in URIs)

Any ideas from anybody about this?
Re: Diagram update problem related to use of URIEditorInput [message #233658 is a reply to message #233597] Mon, 15 June 2009 10:25 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

The problem is: there is no eclipse resources subsystem available in RCP
platform, so it is not possible to listen for any notifications from the
eclipse resources there.
I really suggest you to regenerate your diagram in NON-RCP mode. This will
simplify a situation and you'll have (I hope) synchronization code generated
by GMF for you.
AFAIU you are using RCP+resources platform to run these diagrams and in this
configuration it really make sense to use non-RCP diagrams.

-----------------
Alex Shatalin
Previous Topic:taipan example missing org.eclipse.gmf.examples.taipan.figures
Next Topic:How to integrate "DiagramActionBarContributor" into "MultiPageEditorActionBarContribu
Goto Forum:
  


Current Time: Tue Mar 31 03:12:03 GMT 2020

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

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

Back to the top