From e3a06a5439d56a4b9f2d32085b04d8ebe2399db0 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 25 Apr 2006 20:24:33 +0000 Subject: [PATCH] avoid use of RSEUIPlugin api to get workbench (since it's got flawed code for detecting headless) --- .../rse/eclipse/filesystem/Activator.java | 1 + .../RSEFileStoreRemoteFileWrapper.java | 28 ++++++++++--------- .../resources/SystemEditableRemoteFile.java | 7 ++++- .../UniversalFileTransferUtility.java | 23 ++++++++++++--- .../ui/view/SystemViewRemoteFileAdapter.java | 2 +- .../dstore/files/DStoreFileService.java | 5 +++- .../eclipse/rse/ui/view/SystemViewPart.java | 5 +++- 7 files changed, 50 insertions(+), 21 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java index d2433581252..81945734091 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java @@ -50,6 +50,7 @@ public class Activator extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); RSECorePlugin.getDefault(); + RSEUIPlugin.getDefault(); } /** diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java index 8fae942c3e0..8105be970b8 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java @@ -142,19 +142,9 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto IFile file = null; if (_remoteFile.isFile() && _subSystem.isConnected()) { - /* - SystemEditableRemoteFile editable = new SystemEditableRemoteFile(_remoteFile); - try - { - editable.download(monitor); - } - catch (Exception e) - { - - } - file = editable.getLocalResource(); - */ - if (_remoteFile.getName().equals(".project")) + + + if (_remoteFile.getName().equals(".project") && _remoteFile.getLength() == 0) { try @@ -344,4 +334,16 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto } return null; } + + public void delete(int options, IProgressMonitor monitor) throws CoreException + { + try + { + _subSystem.delete(_remoteFile, monitor); + } + catch (Exception e) + { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java index 3be65cf618c..8cb40316667 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java @@ -66,6 +66,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.FileEditorInput; @@ -214,7 +215,11 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP protected IEditorRegistry getEditorRegistry() { - return RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry(); + if (PlatformUI.isWorkbenchRunning()) + { + return PlatformUI.getWorkbench().getEditorRegistry(); + } + return null; } protected IEditorDescriptor getDefaultTextEditor() diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java index 213152f4ebc..c20d00731b6 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.internal.resources.Resource; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -103,7 +104,7 @@ public class UniversalFileTransferUtility IFile tempFile = (IFile) tempResource; // before we make the transfer to the temp file check whether a temp file already exists - if (tempFile.exists()) + if (tempFile.exists() && ((Resource)tempFile).getPropertyManager() != null) { SystemIFileProperties properties = new SystemIFileProperties(tempFile); @@ -330,7 +331,14 @@ public class UniversalFileTransferUtility } if (tempResource instanceof IFile) { - setIFileProperties((IFile)tempResource, rmtFile, srcFS); + try + { + setIFileProperties((IFile)tempResource, rmtFile, srcFS); + } + catch (Exception e) + { + e.printStackTrace(); + } } /* else @@ -398,9 +406,16 @@ public class UniversalFileTransferUtility } tempFile = (IFile) getTempFileFor(srcFileOrFolder); - if (tempFile.exists()) + if (tempFile.exists() && ((Resource)tempFile).getPropertyManager() != null) { - setIFileProperties(tempFile, srcFileOrFolder, srcFS); + try + { + setIFileProperties(tempFile, srcFileOrFolder, srcFS); + } + catch (Exception e) + { + e.printStackTrace(); + } } return tempFile; diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java index 75ff2465a34..e3f4abb82a7 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java @@ -213,7 +213,7 @@ public class SystemViewRemoteFileAdapter { if (registry == null) { - IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench(); + IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) registry = workbench.getEditorRegistry(); } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java index f0322705cea..32fb721beed 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java @@ -657,12 +657,15 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // now wait till we have all the bytes local long localBytes = localFile.length(); - while (localBytes < fileLength && (monitor == null || !monitor.isCanceled())) + long lastLocalBytes = 0; + while (localBytes < fileLength && (monitor == null || !monitor.isCanceled()) && lastLocalBytes != localBytes) { try { + lastLocalBytes= localBytes; Thread.sleep(100); localBytes = localFile.length(); + } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java index 673161c490c..01f804834df 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java @@ -95,10 +95,12 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPersistableElement; import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.part.CellEditorActionHandler; import org.eclipse.ui.part.FileEditorInput; @@ -503,7 +505,8 @@ public class SystemViewPart public void setFocus() { //System.out.println("INSIDE SETFOCUS FOR SYSTEMVIEWPART. SYSTEMVIEW NULL? " + (systemView==null)); - RSEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell().setFocus(); + IWorkbench wb = PlatformUI.getWorkbench(); + wb.getActiveWorkbenchWindow().getShell().setFocus(); systemView.getControl().setFocus(); /* the following was an attempt to fix problem with scrollbar needing two clicks to activate. didn't help. if (!SystemPreferencesGlobal.getGlobalSystemPreferences().getRememberState())