IEditorReference[] editorReferences = activePage.
getEditorReferences();
for (int j = 0; !alreadyOpen && j < editorReferences.length;
j++) {
IEditorReference editorReference = editorReferences[j];
// Check to see if the last segment of the file name matches
// the editor's name (which should be the name and extension
// for example, 'chart.mcht'). If it does then check to
// see if the full path matches that of the file path. We
// do this to reduce calls to x.getEditor(true) which restores
// the editor. Looking at how other eclipse editors work,
// see AbstractDocumentProvider#saveDocument(..), an internal
// map is maintained using within a document provider (which
// we don't have). Adopting a similar approach is better
// but not feasible within the current time frame.
// @todo later evaluate/resolve this comment's issue.
if (filename.equals(editorReference.getName())) {
IFileEditorInput fileEditorInput = ((IFileEditorInput)
editorReference.getEditor(true).getEditorInput());
// If the full path matches, then this editor is exists
// and is open, so we cannot save over it.
if (fileEditorInput.getFile().getFullPath().
equals(filePath)) {
alreadyOpen = true;