use of org.tigris.subversion.subclipse.ui.editor.RemoteFileEditorInput in project subclipse by subclipse.
the class OpenRemoteFileAction method execute.
/*
* @see SVNAction#execute(IAction)
*/
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
IWorkbench workbench = SVNUIPlugin.getPlugin().getWorkbench();
IEditorRegistry registry = workbench.getEditorRegistry();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
ISVNRemoteFile[] files = getSelectedRemoteFiles();
for (int i = 0; i < files.length; i++) {
ISVNRemoteFile file = files[i];
String filename = file.getName();
IEditorDescriptor descriptor = registry.getDefaultEditor(filename);
String id;
if (descriptor == null) {
descriptor = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
}
if (descriptor == null) {
// $NON-NLS-1$
id = "org.eclipse.ui.DefaultTextEditor";
} else {
id = descriptor.getId();
}
try {
try {
if (usePegRevision && files[i] instanceof RemoteResource)
((RemoteResource) files[i]).setPegRevision(files[i].getRevision());
else
((RemoteResource) files[i]).setPegRevision(SVNRevision.HEAD);
RemoteFileEditorInput input = new RemoteFileEditorInput(files[i], monitor);
if (descriptor != null && descriptor.isOpenExternal()) {
input.writeToTempFile();
}
page.openEditor(input, id);
} catch (PartInitException e) {
if (id.equals("org.eclipse.ui.DefaultTextEditor")) {
// $NON-NLS-1$
throw e;
} else {
RemoteFileEditorInput input = new RemoteFileEditorInput(files[i], monitor);
// $NON-NLS-1$
page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
}
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("OpenRemoteFileAction.0"), // $NON-NLS-1$
e.getMessage());
}
}
}
}, false, // $NON-NLS-1$
PROGRESS_BUSYCURSOR);
}
Aggregations