How do I override equals() of diagram editor input [message #875456] |
Tue, 22 May 2012 19:30 |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
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 19:52] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02750 seconds