Skip to main content



      Home
Home » Modeling » Graphiti » How do I override equals() of diagram editor input
How do I override equals() of diagram editor input [message #875456] Tue, 22 May 2012 15:30 Go to next message
Eclipse UserFriend
Hello everyone,

I am trying to figure out how to let diagram editor know whether user is opening a new diagram file or a already-opened one. In other words, when a diagram file is opened, double-click on the same file in Project Explorer should highlight the opened editor instead of creating a new editor instance.

Apparently init() of Graphiti's DiagramEditor sets a FileInput instance when user tries to open a diagram file, it then converts the FileInput object to DiagramEditorInput. For multiple FileInput instances of the same file, we get multiple DiagramEditorInput instances. Surprisingly, when debug the equals() in DiagramEditorInput,
if (getClass() != obj.getClass()) {
			return false;
		}

returns false because getClass() returns DiagramEditorInput but obj.getClass() gives FileInput. Any ideas?

@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		DiagramEditorInput other = (DiagramEditorInput) obj;
		if (uri == null) {
			if (other.uri != null) {
				return false;
			}
		} else if (!uri.equals(other.uri)) {
			return false;
		}
		if (providerId == null) {
			if (other.providerId != null) {
				return false;
			}
		} else if (!providerId.equals(other.providerId)) {
			return false;
		}
		return true;
	}


Thanks,
Johnny

[Updated on: Tue, 22 May 2012 15:52] by Moderator

Re: How do I override equals() of diagram editor input [message #875720 is a reply to message #875456] Wed, 23 May 2012 04:21 Go to previous messageGo to next message
Eclipse UserFriend
Do you have your own editor (a DiagramEditor subclass)? In case yes, the
reason for this might be that the
org.eclipse.graphiti.ui.editor.DiagramEditorMatchingStrategy (or your own
subclass of it) is not set as the editor's matching strategy (done in
plugin.xml).

Michael
Re: How do I override equals() of diagram editor input [message #875885 is a reply to message #875720] Wed, 23 May 2012 09:54 Go to previous message
Eclipse UserFriend
Thanks Michael, this works perfectly.
Previous Topic:deletePictogramElement Performance
Next Topic:Ability to get visible size of diagram?
Goto Forum:
  


Current Time: Mon Jul 07 10:02:35 EDT 2025

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

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

Back to the top