Created
June 6, 2009 15:49
-
-
Save aqubi/124885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void resourceChanged(final IResourceChangeEvent event) { | |
if (event.getType() != IResourceChangeEvent.POST_CHANGE | |
|| !(getEditorInput() instanceof IFileEditorInput)) { | |
return; | |
} | |
IResourceDelta rootDelta = event.getDelta(); | |
IFile file = ((IFileEditorInput) getEditorInput()).getFile(); | |
IPath filePath = file.getFullPath(); | |
IResourceDelta delta = rootDelta.findMember(filePath); | |
if (delta == null) { | |
return; | |
} | |
Runnable changeRunnable = null; | |
if (delta.getKind() == IResourceDelta.REMOVED) { | |
if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0) { | |
IPath path = delta.getMovedToPath(); | |
final IFile newFile = delta.getResource().getWorkspace().getRoot().getFile(path); | |
if (newFile != null) { | |
changeRunnable = new Runnable() { | |
public void run() { | |
setInput(new FileEditorInput(newFile)); | |
setPartName(getEditorInput().getName()); | |
} | |
}; | |
} | |
} else { | |
changeRunnable = new Runnable() { | |
public void run() { | |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); | |
page.closeEditor(VisualMXMLEditor.this, false); | |
} | |
}; | |
} | |
} else if (delta.getKind() == IResourceDelta.CHANGED) { | |
changeRunnable = new Runnable() { | |
public void run() { | |
refreshGraphicalViewer(); | |
} | |
}; | |
} | |
if (changeRunnable != null) { | |
getSite().getShell().getDisplay().asyncExec(changeRunnable); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment