1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 18:35:32 +02:00

[172437] incorporated patch

This commit is contained in:
David Dykstal 2007-02-05 20:43:23 +00:00
parent d6df8489b5
commit 9710d904bf

View file

@ -27,6 +27,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
@ -152,7 +153,7 @@ public class SystemResourceManager implements SystemResourceConstants
if (remoteSystemsProject == null) if (remoteSystemsProject == null)
{ {
remoteSystemsProject = SystemBasePlugin.getWorkspaceRoot().getProject(RESOURCE_PROJECT_NAME); remoteSystemsProject = SystemBasePlugin.getWorkspaceRoot().getProject(RESOURCE_PROJECT_NAME);
if (!initDone) if (!initDone || !remoteSystemsProject.isAccessible())
remoteSystemsProject = createRemoteSystemsProjectInternal(remoteSystemsProject); remoteSystemsProject = createRemoteSystemsProjectInternal(remoteSystemsProject);
} }
return remoteSystemsProject; return remoteSystemsProject;
@ -172,43 +173,45 @@ public class SystemResourceManager implements SystemResourceConstants
} }
/** /**
* Create a remote systems project, plus the core subfolders required. * Create a remote systems project, plus the core subfolders required.
* @return IProject handle of the project. * @param proj the handle for the remote systems project
* @return the IProject handle of the project (the argument)
*/ */
protected static IProject createRemoteSystemsProjectInternal(IProject proj) protected static IProject createRemoteSystemsProjectInternal(IProject proj) {
//throws Exception // Check first for the project to be closed. If yes, try to open it and if this fails,
{ // try to delete if first before failing here. The case is that the user removed the
if (!proj.exists()) // directory in the workspace and we must be able to recover from it.
{ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=172437.
if (!proj.isOpen()) {
try {
proj.open(null);
} catch (Exception e) {
try {
proj.delete(false, true, null);
SystemBasePlugin.logWarning("Removed stale remote systems project reference. Re-creating remote system project to recover."); //$NON-NLS-1$
} catch (CoreException exc) {
// If the delete fails, the original opening error will be passed to the error log.
SystemBasePlugin.logError("error opening remote systems project", e); //$NON-NLS-1$
}
}
}
if (!proj.exists()) {
try { try {
proj.create(null); proj.create(null);
proj.open(null); proj.open(null);
IProjectDescription description = proj.getDescription(); IProjectDescription description = proj.getDescription();
String newNatures[] = {RemoteSystemsProject.ID}; String newNatures[] = { RemoteSystemsProject.ID };
description.setNatureIds(newNatures); description.setNatureIds(newNatures);
proj.setDescription(description, null); proj.setDescription(description, null);
firstTime = true; firstTime = true;
} catch (Exception e) } catch (Exception e) {
{ SystemBasePlugin.logError("error creating remote systems project", e); //$NON-NLS-1$
SystemBasePlugin.logError("error creating remote systems project",e); //$NON-NLS-1$
//throw e;
} }
} }
else if (!proj.isOpen())
{
try { try {
proj.open(null);
} catch (Exception e)
{
SystemBasePlugin.logError("error opening remote systems project",e); //$NON-NLS-1$
//throw e;
}
}
try{
// create types folder... // create types folder...
getResourceHelpers().getOrCreateFolder(proj,RESOURCE_TYPE_FILTERS_FOLDER_NAME); // getResourceHelpers().getOrCreateFolder(proj, RESOURCE_TYPE_FILTERS_FOLDER_NAME);
} catch (Exception e) } catch (Exception e) {
{ SystemBasePlugin.logError("error opening/creating types folder", e); //$NON-NLS-1$
SystemBasePlugin.logError("error opening/creating types folder",e); //$NON-NLS-1$
} }
initDone = true; initDone = true;
return proj; return proj;