}
private void openFile(Display display, final String path) {
display.asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return;
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
IFileInfo fetchInfo = fileStore.fetchInfo();
if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
IWorkbenchPage page = window.getActivePage();
if (page == null) {
String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_noWindow, path);
MessageDialog.open(MessageDialog.ERROR, window.getShell(),
IDEWorkbenchMessages.OpenDelayedFileAction_title,
msg, SWT.SHEET);
}
try {
IDE.openInternalEditorOnFileStore(page, fileStore);
Shell shell = window.getShell();
if (shell != null) {
if (shell.getMinimized())
shell.setMinimized(false);
shell.forceActive();
}
} catch (PartInitException e) {
String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_errorOnOpen,
fileStore.getName());
CoreException eLog = new PartInitException(e.getMessage());
IDEWorkbenchPlugin.log(msg, new Status(IStatus.ERROR, IDEApplication.PLUGIN_ID, msg, eLog));
MessageDialog.open(MessageDialog.ERROR, window.getShell(),
IDEWorkbenchMessages.OpenDelayedFileAction_title,
msg, SWT.SHEET);
}
} else {
String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_fileNotFound, path);
MessageDialog.open(MessageDialog.ERROR, window.getShell(),
IDEWorkbenchMessages.OpenDelayedFileAction_title,
msg, SWT.SHEET);
}
}
});