mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-08 17:45:24 +02:00
cannot assume workbench is loaded
This commit is contained in:
parent
74f177f0f7
commit
97fcc0a5e9
8 changed files with 62 additions and 13 deletions
|
@ -17,10 +17,12 @@
|
||||||
package org.eclipse.rse.eclipse.filesystem;
|
package org.eclipse.rse.eclipse.filesystem;
|
||||||
|
|
||||||
import org.eclipse.core.filesystem.provider.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.core.runtime.dynamichelpers.IExtensionTracker;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
|
import org.eclipse.ui.actions.WorkspaceAction;
|
||||||
import org.eclipse.ui.internal.Workbench;
|
import org.eclipse.ui.internal.Workbench;
|
||||||
import org.eclipse.ui.internal.ide.filesystem.FileSystemSupportRegistry;
|
import org.eclipse.ui.internal.ide.filesystem.FileSystemSupportRegistry;
|
||||||
import org.eclipse.ui.internal.registry.UIExtensionTracker;
|
import org.eclipse.ui.internal.registry.UIExtensionTracker;
|
||||||
|
|
|
@ -143,7 +143,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto
|
||||||
if (file == null || !file.exists())
|
if (file == null || !file.exists())
|
||||||
{
|
{
|
||||||
file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor);
|
file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor);
|
||||||
file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
if (file != null)
|
||||||
|
{
|
||||||
|
file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -152,7 +155,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto
|
||||||
}
|
}
|
||||||
// if (!file.isSynchronized(IFile.DEPTH_ZERO))
|
// if (!file.isSynchronized(IFile.DEPTH_ZERO))
|
||||||
// file.refreshLocal(IFile.DEPTH_ZERO, monitor);
|
// file.refreshLocal(IFile.DEPTH_ZERO, monitor);
|
||||||
return file.getContents();
|
if (file != null)
|
||||||
|
{
|
||||||
|
return file.getContents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -281,9 +287,10 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto
|
||||||
|
|
||||||
public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException
|
public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException
|
||||||
{
|
{
|
||||||
|
IResource file = null;
|
||||||
if (_remoteFile.exists())
|
if (_remoteFile.exists())
|
||||||
{
|
{
|
||||||
IResource file = null;
|
|
||||||
if (_remoteFile.isFile() && _remoteFile.getParentRemoteFileSubSystem().isConnected())
|
if (_remoteFile.isFile() && _remoteFile.getParentRemoteFileSubSystem().isConnected())
|
||||||
{
|
{
|
||||||
file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor);
|
file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor);
|
||||||
|
@ -296,6 +303,14 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto
|
||||||
// file.refreshLocal(IFile.DEPTH_ZERO, monitor);
|
// file.refreshLocal(IFile.DEPTH_ZERO, monitor);
|
||||||
return file.getLocation().toFile();
|
return file.getLocation().toFile();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_remoteFile.getName().equals(".project"))
|
||||||
|
{
|
||||||
|
file = UniversalFileTransferUtility.getTempFileFor(_remoteFile);
|
||||||
|
return file.getLocation().toFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.internal.Workbench;
|
import org.eclipse.ui.internal.Workbench;
|
||||||
|
|
||||||
public class RSEFileSystem extends FileSystem
|
public class RSEFileSystem extends FileSystem
|
||||||
|
@ -107,7 +108,8 @@ public class RSEFileSystem extends FileSystem
|
||||||
Shell shell = null;
|
Shell shell = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shell = RSEUIPlugin.getActiveWorkbenchShell();
|
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||||
|
//shell = RSEUIPlugin.getActiveWorkbenchShell();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.rse.core.SystemBasePlugin;
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
|
import org.eclipse.rse.core.SystemResourceManager;
|
||||||
import org.eclipse.rse.eclipse.filesystem.RSEFileSystem;
|
import org.eclipse.rse.eclipse.filesystem.RSEFileSystem;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
@ -69,17 +70,30 @@ public class CreateRemoteProjectActionDelegate implements IActionDelegate {
|
||||||
URI location = RSEFileSystem.getInstance().getURIFor(directory);
|
URI location = RSEFileSystem.getInstance().getURIFor(directory);
|
||||||
description.setLocationURI(location);
|
description.setLocationURI(location);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//description.setReferencedProjects(new IProject[]{SystemResourceManager.getRemoteSystemsTempFilesProject()});
|
||||||
editProject.create(description, monitor);
|
editProject.create(description, monitor);
|
||||||
|
|
||||||
|
|
||||||
editProject.open(monitor);
|
editProject.open(monitor);
|
||||||
|
|
||||||
editProject.refreshLocal(IResource.DEPTH_INFINITE, 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)
|
catch (CoreException e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
SystemBasePlugin.logError("Error creating temp project", e);
|
SystemBasePlugin.logError("Error creating temp project", e);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return editProject;
|
return editProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,8 @@ public class UniversalFileTransferUtility
|
||||||
|
|
||||||
if (!tempFile.exists() && !tempFile.isSynchronized(IResource.DEPTH_ZERO))
|
if (!tempFile.exists() && !tempFile.isSynchronized(IResource.DEPTH_ZERO))
|
||||||
{
|
{
|
||||||
tempFile.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
//tempFile.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
//tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/);
|
tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/);
|
||||||
}
|
}
|
||||||
if (tempFile.exists())
|
if (tempFile.exists())
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.subsystems.files.dstore.subsystem.RemoteFilePropertyChangeListener;
|
||||||
import org.eclipse.rse.ui.ISystemPreferencesConstants;
|
import org.eclipse.rse.ui.ISystemPreferencesConstants;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import org.eclipse.dstore.core.model.DataElement;
|
import org.eclipse.dstore.core.model.DataElement;
|
||||||
|
|
||||||
|
@ -43,7 +45,8 @@ public class DStoreFileAdapter implements IHostFileToRemoteFileAdapter
|
||||||
if (_listener == null)
|
if (_listener == null)
|
||||||
{
|
{
|
||||||
DStoreConnectorService connectorService = (DStoreConnectorService)ss.getConnectorService();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.dialogs.PropertyPage;
|
import org.eclipse.ui.dialogs.PropertyPage;
|
||||||
import org.eclipse.ui.progress.UIJob;
|
import org.eclipse.ui.progress.UIJob;
|
||||||
import org.eclipse.ui.progress.WorkbenchJob;
|
import org.eclipse.ui.progress.WorkbenchJob;
|
||||||
|
@ -3122,9 +3123,17 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
||||||
public static Shell getActiveWorkbenchShell()
|
public static Shell getActiveWorkbenchShell()
|
||||||
{
|
{
|
||||||
Shell result = null;
|
Shell result = null;
|
||||||
IWorkbenchWindow window = getActiveWorkbenchWindow();
|
if (PlatformUI.isWorkbenchRunning())
|
||||||
if (window != null) {
|
{
|
||||||
result = window.getShell();
|
IWorkbenchWindow window = getActiveWorkbenchWindow();
|
||||||
|
if (window != null)
|
||||||
|
{
|
||||||
|
result = window.getShell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // workbench has not been loaded yet!
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,12 +249,14 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
|
||||||
if (headlessSet && headless) // already been here?
|
if (headlessSet && headless) // already been here?
|
||||||
return wb;
|
return wb;
|
||||||
try {
|
try {
|
||||||
|
wb = PlatformUI.getWorkbench();
|
||||||
|
|
||||||
|
//wb = super.getWorkbench();
|
||||||
wb = super.getWorkbench();
|
|
||||||
headless = false;
|
headless = false;
|
||||||
} catch (Exception exc)
|
}
|
||||||
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
IDEWorkbenchAdvisor advisor = new IDEWorkbenchAdvisor();
|
IDEWorkbenchAdvisor advisor = new IDEWorkbenchAdvisor();
|
||||||
PlatformUI.createAndRunWorkbench(Display.getDefault(), advisor);
|
PlatformUI.createAndRunWorkbench(Display.getDefault(), advisor);
|
||||||
try
|
try
|
||||||
|
@ -265,6 +267,8 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
|
||||||
{
|
{
|
||||||
headless = true;
|
headless = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
headless = true;
|
||||||
}
|
}
|
||||||
headlessSet = true;
|
headlessSet = true;
|
||||||
return wb;
|
return wb;
|
||||||
|
|
Loading…
Add table
Reference in a new issue