Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » IGotoMarker and Editor Reopening
IGotoMarker and Editor Reopening [message #665158] Wed, 13 April 2011 13:39 Go to next message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
I've implemented an IGotoMarker interface for my Graphiti editor. I have gotten it so that I can reference things in the editor from markers and the "Go To" action from the Problems View can select and show the user the PictogramElement that the marker references. But, whenever the "goto" action is executed, Eclipse opens another copy of the Graphiti editor.

The Plugin Development FAQ suggests, here, that custom implementations of IEditorInput should override Object.equals() to prevent this behavior. Graphiti uses a custom IEditorInput implementation, DiagramEditorInput, which provides an implementation of Object.equals(). At first examination, that implementation looks reasonable to me. Experimentally, even if I replace the implementation with code that just returns true, it doesn't stop the new editor from opening.

Has anyone else seen an issue like this?
Re: IGotoMarker and Editor Reopening [message #665178 is a reply to message #665158] Wed, 13 April 2011 14:36 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The Graphiti DiagramEditor registers a matching strategy for checking if an
editor for a given editor input is already open (see the extension of
org.eclipse.ui.editors in org.eclipse.graphiti.ui). At least when opening
the editor from the project explorer this check will be triggered, not sure
if this is also the case when opening from the problems view. Could you
check?

Nevertheless, there seems to be a bug in that implementation (see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=340939), that would explain
why it's not working as expected.

Michael


"Rhett Hudson" wrote in message news:io48l4$18l$1@news.eclipse.org...

I've implemented an IGotoMarker interface for my Graphiti editor. I have
gotten it so that I can reference things in the editor from markers and the
"Go To" action from the Problems View can select and show the user the
PictogramElement that the marker references. But, whenever the "goto" action
is executed, Eclipse opens another copy of the Graphiti editor.

The Plugin Development FAQ suggests,
http://wiki.eclipse.org/Eclipse_Plug-in_Development_FAQ#Why_ does_the_workbench_keep_opening_a_new_editor_every_time_I_op en_a_marker.3F,
that custom implementations of IEditorInput should override Object.equals()
to prevent this behavior. Graphiti uses a custom IEditorInput
implementation, DiagramEditorInput, which provides an implementation of
Object.equals(). At first examination, that implementation looks reasonable
to me. Experimentally, even if I replace the implementation with code that
just returns true, it doesn't stop the new editor from opening.

Has anyone else seen an issue like this?
Re: IGotoMarker and Editor Reopening [message #665187 is a reply to message #665158] Wed, 13 April 2011 15:09 Go to previous messageGo to next message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
After some further investigation, I think the issue may be in DiagramEditorFactory.DiagramEditorMatchingStrategy. The matches() implementation gets called as part of the IDE's determination of whether it can use an existing editor or whether it needs to open a new one.

In my case, at least, it's the first of the cases in matches that gets invoked. The URI from the editor's EditorInput is compared with a URI created based on the IFile that was specified by the marker. But, the code used to created the URI based on the IFile that was passed from the marker, GraphitiUiInternal.getEmfService().getDiagramFromFile(), returns the URI to the Diagram not the Resource. So, it ends up comparing something that looks like 'platform:/resource/test/test.diagram#/' to something like 'platform:/resource/test/test.diagram#/0' and failing.

I've experimented with adding .trimFragment() to both URIs before comparison, and that solves my replicating editor issue. Is this a misunderstanding on my part? Or a bug that I should log?
Re: IGotoMarker and Editor Reopening [message #665188 is a reply to message #665187] Wed, 13 April 2011 15:11 Go to previous message
Rhett Hudson is currently offline Rhett HudsonFriend
Messages: 43
Registered: September 2010
Member
Oops, we crossed in the network there. I'll add my comment to that bug. Thanks.
Previous Topic:Zoom handling in multi-page editors
Next Topic:Resize an Image
Goto Forum:
  


Current Time: Thu Dec 18 18:37:32 GMT 2014

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

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