Skip to content

Instantly share code, notes, and snippets.

@aqubi
Created June 6, 2009 14:49
Show Gist options
  • Save aqubi/124870 to your computer and use it in GitHub Desktop.
Save aqubi/124870 to your computer and use it in GitHub Desktop.
public void resourceChanged(final IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta rootDelta = event.getDelta();
final IEditorInput input = getEditorInput();
IFile file = ((IFileEditorInput) input).getFile();
IPath filePath = file.getFullPath();
IResourceDelta targetDelta = rootDelta.findMember(filePath);
if (targetDelta != null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IFile file = ((IFileEditorInput) input).getFile();
if (!file.exists()) {
// ファイル名が変更されていたら、EditorをCloseする
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.closeEditor(VisualMXMLEditor.this, false);
} else {
if (!getPartName().equals(file.getName())) {
//ファイル名が変わっていたらEditorPartの名前も変更する
setPartName(file.getName());
}
// GraphicalEditorをファイルの情報から読込み直し
refreshGraphicalViewer();
}
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment