From 97fcc0a5e93ce5e3821dc95263ae7e7c51ee234c Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 24 Apr 2006 14:43:48 +0000 Subject: [PATCH] cannot assume workbench is loaded --- .../rse/eclipse/filesystem/Activator.java | 2 ++ .../RSEFileStoreRemoteFileWrapper.java | 21 ++++++++++++++++--- .../rse/eclipse/filesystem/RSEFileSystem.java | 4 +++- .../CreateRemoteProjectActionDelegate.java | 14 +++++++++++++ .../UniversalFileTransferUtility.java | 4 ++-- .../files/dstore/model/DStoreFileAdapter.java | 5 ++++- .../rse/core/subsystems/SubSystem.java | 15 ++++++++++--- .../eclipse/rse/core/SystemBasePlugin.java | 10 ++++++--- 8 files changed, 62 insertions(+), 13 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 6654923a107..d2433581252 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 @@ -17,10 +17,12 @@ package org.eclipse.rse.eclipse.filesystem; import org.eclipse.core.filesystem.provider.FileSystem; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.ui.actions.WorkspaceAction; import org.eclipse.ui.internal.Workbench; import org.eclipse.ui.internal.ide.filesystem.FileSystemSupportRegistry; import org.eclipse.ui.internal.registry.UIExtensionTracker; 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 88ff43e3734..5d68f9641c9 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 @@ -143,7 +143,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto if (file == null || !file.exists()) { file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor); - file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); + if (file != null) + { + file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); + } } } else @@ -152,7 +155,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto } // if (!file.isSynchronized(IFile.DEPTH_ZERO)) // file.refreshLocal(IFile.DEPTH_ZERO, monitor); - return file.getContents(); + if (file != null) + { + return file.getContents(); + } } return null; } @@ -281,9 +287,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException { + IResource file = null; if (_remoteFile.exists()) { - IResource file = null; + if (_remoteFile.isFile() && _remoteFile.getParentRemoteFileSubSystem().isConnected()) { file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor); @@ -296,6 +303,14 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto // file.refreshLocal(IFile.DEPTH_ZERO, monitor); return file.getLocation().toFile(); } + else + { + if (_remoteFile.getName().equals(".project")) + { + file = UniversalFileTransferUtility.getTempFileFor(_remoteFile); + return file.getLocation().toFile(); + } + } return null; } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java index d8e0e012b17..50c2ddc5410 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java @@ -29,6 +29,7 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.Workbench; public class RSEFileSystem extends FileSystem @@ -107,7 +108,8 @@ public class RSEFileSystem extends FileSystem Shell shell = null; try { - shell = RSEUIPlugin.getActiveWorkbenchShell(); + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + //shell = RSEUIPlugin.getActiveWorkbenchShell(); } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java index d7cb478df5b..f2221d11846 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java @@ -17,6 +17,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.eclipse.filesystem.RSEFileSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.swt.widgets.Display; @@ -68,18 +69,31 @@ public class CreateRemoteProjectActionDelegate implements IActionDelegate { IProjectDescription description = root.getWorkspace().newProjectDescription(directory.getName()); URI location = RSEFileSystem.getInstance().getURIFor(directory); description.setLocationURI(location); + + + //description.setReferencedProjects(new IProject[]{SystemResourceManager.getRemoteSystemsTempFilesProject()}); editProject.create(description, monitor); + editProject.open(monitor); editProject.refreshLocal(IResource.DEPTH_INFINITE, monitor); + IProject tempFilesProject = SystemResourceManager.getRemoteSystemsTempFilesProject(); + IProjectDescription tempFilesDescription = tempFilesProject.getDescription(); + tempFilesDescription.setReferencedProjects(new IProject[]{editProject}); + tempFilesProject.setDescription(tempFilesDescription, monitor); } catch (CoreException e) { + e.printStackTrace(); SystemBasePlugin.logError("Error creating temp project", e); } + catch (Exception e) + { + e.printStackTrace(); + } return editProject; } 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 34a445140d6..9991a288c07 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 @@ -138,8 +138,8 @@ public class UniversalFileTransferUtility if (!tempFile.exists() && !tempFile.isSynchronized(IResource.DEPTH_ZERO)) { - tempFile.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor); - //tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/); + //tempFile.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor); + tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/); } if (tempFile.exists()) { diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/model/DStoreFileAdapter.java b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/model/DStoreFileAdapter.java index 877db971ed2..9247cfc280a 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/model/DStoreFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/model/DStoreFileAdapter.java @@ -31,6 +31,8 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; import org.eclipse.rse.subsystems.files.dstore.subsystem.RemoteFilePropertyChangeListener; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import org.eclipse.dstore.core.model.DataElement; @@ -43,7 +45,8 @@ public class DStoreFileAdapter implements IHostFileToRemoteFileAdapter if (_listener == null) { DStoreConnectorService connectorService = (DStoreConnectorService)ss.getConnectorService(); - _listener = new RemoteFilePropertyChangeListener(SystemBasePlugin.getActiveWorkbenchShell(), connectorService, connectorService.getDataStore(), ss); + Shell shell = FileServiceSubSystem.getActiveWorkbenchShell(); + _listener = new RemoteFilePropertyChangeListener(shell, connectorService, connectorService.getDataStore(), ss); } } diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index 65b8769e474..b850138447c 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -59,6 +59,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.WorkbenchJob; @@ -3122,9 +3123,17 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS public static Shell getActiveWorkbenchShell() { Shell result = null; - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window != null) { - result = window.getShell(); + if (PlatformUI.isWorkbenchRunning()) + { + IWorkbenchWindow window = getActiveWorkbenchWindow(); + if (window != null) + { + result = window.getShell(); + } + } + else // workbench has not been loaded yet! + { + return null; } return result; } diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java index 9d0f8294a19..39404762a87 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java +++ b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java @@ -249,12 +249,14 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin if (headlessSet && headless) // already been here? return wb; try { + wb = PlatformUI.getWorkbench(); - - wb = super.getWorkbench(); + //wb = super.getWorkbench(); headless = false; - } catch (Exception exc) + } + catch (Exception exc) { + /* IDEWorkbenchAdvisor advisor = new IDEWorkbenchAdvisor(); PlatformUI.createAndRunWorkbench(Display.getDefault(), advisor); try @@ -265,6 +267,8 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin { headless = true; } + */ + headless = true; } headlessSet = true; return wb;