1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

[189858] delay the creation of the remote systems connections project until needed

This commit is contained in:
David Dykstal 2007-06-04 16:29:25 +00:00
parent d03243be99
commit bcb00d591d
8 changed files with 106 additions and 95 deletions

View file

@ -13,6 +13,10 @@
* Contributors: * Contributors:
* Dave McKnight (IBM) - [177155] Move from rse.ui/systems/org.eclipse.rse.core * Dave McKnight (IBM) - [177155] Move from rse.ui/systems/org.eclipse.rse.core
* Martin Oberhuber (Wind River) - Re-add missing methods for user actions * Martin Oberhuber (Wind River) - Re-add missing methods for user actions
* David Dykstal (IBM) - [189858] delayed the creation of the remote systems project
* removed unneeded first time logic and flags
* renamed createRemoteSystemsProjectInternal to ensureRemoteSystemsProject
* made ensureRemoteSystemsProject private instead of protected
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.core; package org.eclipse.rse.core;
@ -59,8 +63,6 @@ public class SystemResourceManager implements SystemResourceConstants
private static IProject remoteSystemsProject = null; private static IProject remoteSystemsProject = null;
private static IProject remoteSystemsTempFilesProject = null; private static IProject remoteSystemsTempFilesProject = null;
private static boolean initDone = false;
private static boolean firstTime = false;
private static SystemResourceHelpers helpers = null; private static SystemResourceHelpers helpers = null;
private static ISystemResourceListener _listener = null; private static ISystemResourceListener _listener = null;
@ -147,15 +149,27 @@ public class SystemResourceManager implements SystemResourceConstants
/** /**
* Get the default remote systems project. * Get the default remote systems project.
* If found but closed, this will open the project.
* @return IProject handle of the project. Use exists() to test existence. * @return IProject handle of the project. Use exists() to test existence.
*/ */
public static IProject getRemoteSystemsProject() public static IProject getRemoteSystemsProject()
{ {
if (remoteSystemsProject == null) return getRemoteSystemsProject(true);
{ }
/**
* Get the default remote systems project.
* If found but closed, this will open the project.
* @param force if true force the creation of the project if not found.
* In any case, returns handle to the project.
* @return IProject handle of the project. Use exists() to test existence.
*/
public static IProject getRemoteSystemsProject(boolean force) {
if (remoteSystemsProject == null) {
remoteSystemsProject = ResourcesPlugin.getWorkspace().getRoot().getProject(RESOURCE_PROJECT_NAME); remoteSystemsProject = ResourcesPlugin.getWorkspace().getRoot().getProject(RESOURCE_PROJECT_NAME);
if (!initDone || !remoteSystemsProject.isAccessible()) }
remoteSystemsProject = createRemoteSystemsProjectInternal(remoteSystemsProject); if ((!remoteSystemsProject.exists() && force) || (remoteSystemsProject.exists() && !remoteSystemsProject.isOpen())) {
ensureRemoteSystemsProject(remoteSystemsProject);
} }
return remoteSystemsProject; return remoteSystemsProject;
} }
@ -177,7 +191,7 @@ public class SystemResourceManager implements SystemResourceConstants
* @param proj the handle for the remote systems project * @param proj the handle for the remote systems project
* @return the IProject handle of the project (the argument) * @return the IProject handle of the project (the argument)
*/ */
protected static IProject createRemoteSystemsProjectInternal(IProject proj) private static IProject ensureRemoteSystemsProject(IProject proj)
{ {
// Check first for the project to be closed. If yes, try to open it and if this fails, // 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 // try to delete if first before failing here. The case is that the user removed the
@ -189,7 +203,6 @@ public class SystemResourceManager implements SystemResourceConstants
} catch (Exception e) { } catch (Exception e) {
try { try {
proj.delete(false, true, null); proj.delete(false, true, null);
RSECorePlugin.getDefault().getLogger().logWarning("Removed stale remote systems project reference. Re-creating remote system project to recover."); //$NON-NLS-1$ RSECorePlugin.getDefault().getLogger().logWarning("Removed stale remote systems project reference. Re-creating remote system project to recover."); //$NON-NLS-1$
} catch (CoreException exc) { } catch (CoreException exc) {
// If the delete fails, the original opening error will be passed to the error log. // If the delete fails, the original opening error will be passed to the error log.
@ -205,31 +218,13 @@ public class SystemResourceManager implements SystemResourceConstants
String newNatures[] = { RemoteSystemsProject.ID }; String newNatures[] = { RemoteSystemsProject.ID };
description.setNatureIds(newNatures); description.setNatureIds(newNatures);
proj.setDescription(description, null); proj.setDescription(description, null);
firstTime = true;
} catch (Exception e) { } catch (Exception e) {
RSECorePlugin.getDefault().getLogger().logError("error creating remote systems project", e); //$NON-NLS-1$ RSECorePlugin.getDefault().getLogger().logError("error creating remote systems project", e); //$NON-NLS-1$
} }
} }
try {
// create types folder...
// getResourceHelpers().getOrCreateFolder(proj, RESOURCE_TYPE_FILTERS_FOLDER_NAME);
} catch (Exception e) {
RSECorePlugin.getDefault().getLogger().logError("error opening/creating types folder", e); //$NON-NLS-1$
}
initDone = true;
return proj; return proj;
} }
/**
* Return true if we just created the remote systems project for the first time.
* This call has the side effect of resetting the flag to false so it doesn't return
* true more than once, ever.
*/
public static boolean isFirstTime()
{
boolean firsttime = firstTime;
firstTime = false;
return firsttime;
}
// -------------------------------------------- // --------------------------------------------
// GET ALL EXISTING PROFILE NAMES OR FOLDERS... // GET ALL EXISTING PROFILE NAMES OR FOLDERS...
// -------------------------------------------- // --------------------------------------------
@ -397,7 +392,6 @@ public class SystemResourceManager implements SystemResourceConstants
return getResourceHelpers().getOrCreateFolder(parentFolder, factoryId); // Do create it. return getResourceHelpers().getOrCreateFolder(parentFolder, factoryId); // Do create it.
} }
// ------------------- // -------------------
// FOLDER ACTIONS... // FOLDER ACTIONS...
// ------------------- // -------------------

View file

@ -13,6 +13,8 @@
* Contributors: * Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* David Dykstal (IBM) - [189858] made sure that a reference remains broken if the profile
* contained in the reference was not found.
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.core.filters; package org.eclipse.rse.internal.core.filters;
@ -169,11 +171,13 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
String profileName = getReferencedFilterPoolManagerName(); String profileName = getReferencedFilterPoolManagerName();
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile = registry.getSystemProfile(profileName); ISystemProfile profile = registry.getSystemProfile(profileName);
if (profile != null) {
ISubSystem subsystem = (ISubSystem) getProvider(); ISubSystem subsystem = (ISubSystem) getProvider();
ISubSystemConfiguration config = subsystem.getSubSystemConfiguration(); ISubSystemConfiguration config = subsystem.getSubSystemConfiguration();
filterPoolManager = config.getFilterPoolManager(profile); filterPoolManager = config.getFilterPoolManager(profile);
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName); filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
} }
}
if (filterPool != null) { if (filterPool != null) {
setReferenceToFilterPool(filterPool); setReferenceToFilterPool(filterPool);
setReferenceBroken(false); setReferenceBroken(false);

View file

@ -7,6 +7,8 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* David Dykstal (IBM) - [189858] delayed the creation of the remote systems project by
* using handle-only operations.
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.persistence; package org.eclipse.rse.internal.persistence;
@ -36,6 +38,7 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
public String[] getProfileLocationNames() { public String[] getProfileLocationNames() {
List names = new Vector(10); List names = new Vector(10);
IFolder providerFolder = getProviderFolder(); IFolder providerFolder = getProviderFolder();
if (providerFolder.isAccessible()) {
try { try {
IResource[] profileCandidates = providerFolder.members(); IResource[] profileCandidates = providerFolder.members();
for (int i = 0; i < profileCandidates.length; i++) { for (int i = 0; i < profileCandidates.length; i++) {
@ -50,6 +53,7 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
} catch (CoreException e) { } catch (CoreException e) {
logException(e); logException(e);
} }
}
String[] result = new String[names.size()]; String[] result = new String[names.size()];
names.toArray(result); names.toArray(result);
return result; return result;
@ -80,7 +84,8 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
/** /**
* Returns the IFolder in which a profile is stored. * Returns the IFolder in which a profile is stored.
* @return The folder that was created or found. * This is a handle operation, the resulting folder may not exist.
* @return The folder that was found.
*/ */
private IFolder getProfileFolder(String profileLocationName) { private IFolder getProfileFolder(String profileLocationName) {
IFolder providerFolder = getProviderFolder(); IFolder providerFolder = getProviderFolder();
@ -90,36 +95,32 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
/** /**
* Returns the IFolder in which this persistence provider stores its profiles. * Returns the IFolder in which this persistence provider stores its profiles.
* This will create the folder if the folder was not found. * This is a handle operation. It will not create the folder if it is not
* @return The folder that was created or found. * found.
* @return The folder that contains the profiles for this provider.
*/ */
private IFolder getProviderFolder() { private IFolder getProviderFolder() {
IProject project = SystemResourceManager.getRemoteSystemsProject(); IProject project = SystemResourceManager.getRemoteSystemsProject(false);
if (project.isAccessible()) {
try { try {
project.refreshLocal(IResource.DEPTH_INFINITE, null); project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e) { } catch (Exception e) {
} }
}
IFolder providerFolder = getFolder(project, "dom.properties"); //$NON-NLS-1$ IFolder providerFolder = getFolder(project, "dom.properties"); //$NON-NLS-1$
return providerFolder; return providerFolder;
} }
/** /**
* Returns the specified folder of the parent container. If the folder does * Returns the specified folder of the parent container.
* not exist it creates it. * This is a handle operation. The folder may not exist.
* @param parent the parent container - typically a project or folder * @param parent the parent container - typically a project or folder
* @param name the name of the folder to find or create * @param name the name of the folder to find
* @return the found or created folder * @return the found or created folder
*/ */
private IFolder getFolder(IContainer parent, String name) { private IFolder getFolder(IContainer parent, String name) {
IPath path = new Path(name); IPath path = new Path(name);
IFolder folder = parent.getFolder(path); IFolder folder = parent.getFolder(path);
if (!folder.exists()) {
try {
folder.create(IResource.NONE, true, null);
} catch (CoreException e) {
logException(e);
}
}
return folder; return folder;
} }

View file

@ -7,6 +7,9 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* David Dykstal (IBM) - [189858] delayed the creation of the remote systems project by
* using handle-only operations. The project is created only
* if required to exist for writing.
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.persistence; package org.eclipse.rse.internal.persistence;
@ -17,6 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -24,6 +28,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
class PFWorkspaceLocation implements PFPersistenceLocation { class PFWorkspaceLocation implements PFPersistenceLocation {
IFolder baseFolder = null; IFolder baseFolder = null;
@ -37,13 +42,7 @@ class PFWorkspaceLocation implements PFPersistenceLocation {
} }
public void ensure() { public void ensure() {
if (!baseFolder.exists()) { ensure(baseFolder);
try {
baseFolder.create(true, true, null);
} catch (CoreException e) {
logException(e);
}
}
} }
public PFPersistenceLocation getChild(String childName) { public PFPersistenceLocation getChild(String childName) {
@ -134,6 +133,22 @@ class PFWorkspaceLocation implements PFPersistenceLocation {
return result; return result;
} }
private void ensure(IContainer resource) {
if (!resource.isAccessible()) {
if (resource.getType() == IResource.PROJECT) {
SystemResourceManager.getRemoteSystemsProject();
} else {
IFolder folder = (IFolder) resource;
ensure(folder.getParent());
try {
folder.create(true, true, null);
} catch (CoreException e) {
logException(e);
}
}
}
}
private void logException(Exception e) { private void logException(Exception e) {
RSECorePlugin.getDefault().getLogger().logError("unexpected exception", e); //$NON-NLS-1$ RSECorePlugin.getDefault().getLogger().logError("unexpected exception", e); //$NON-NLS-1$
} }

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.view.team; package org.eclipse.rse.internal.ui.view.team;
@ -97,7 +98,8 @@ public class SystemTeamViewContentProvider extends WorkbenchContentProvider
public Object getParent(Object element) public Object getParent(Object element)
{ {
if (element instanceof ISystemProfile) if (element instanceof ISystemProfile)
return SystemResourceManager.getRemoteSystemsProject(); // return SystemResourceManager.getRemoteSystemsProject();
return null;
ISystemViewElementAdapter adapter = getSystemViewAdapter(element); ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
if (adapter != null) if (adapter != null)
return adapter.getParent(element); return adapter.getParent(element);

View file

@ -12,6 +12,7 @@
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.view.team; package org.eclipse.rse.internal.ui.view.team;
@ -19,8 +20,9 @@ package org.eclipse.rse.internal.ui.view.team;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.view.ISystemViewInputProvider; import org.eclipse.rse.ui.view.ISystemViewInputProvider;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -31,7 +33,6 @@ import org.eclipse.swt.widgets.Shell;
*/ */
public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInputProvider public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInputProvider
{ {
private Object[] roots = new Object[1];
private Shell shell; private Shell shell;
private Viewer viewer; private Viewer viewer;
@ -49,8 +50,7 @@ public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInput
*/ */
public Object[] getRoots() public Object[] getRoots()
{ {
if (roots[0] == null) ISystemProfile[] roots = SystemProfileManager.getDefault().getSystemProfiles();
roots[0] = SystemResourceManager.getRemoteSystemsProject();
return roots; return roots;
} }

View file

@ -13,6 +13,7 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.view.team; package org.eclipse.rse.internal.ui.view.team;
@ -1395,7 +1396,7 @@ public class SystemTeamViewPart
case 0: elementType = token; break; case 0: elementType = token; break;
// profile // profile
case 1: case 1:
project = SystemResourceManager.getRemoteSystemsProject(); project = SystemResourceManager.getRemoteSystemsProject(false);
break; break;
case 2: case 2:
profile = sr.getSystemProfile(token); profile = sr.getSystemProfile(token);

View file

@ -23,6 +23,7 @@
* Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point * Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter() * Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
* David Dykstal (IBM) - [189858] Delay the creation of the remote systems project
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.ui; package org.eclipse.rse.ui;
@ -85,7 +86,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
ISystemRegistry registry = getSystemRegistryInternal(); ISystemRegistry registry = getSystemRegistryInternal();
SystemResourceManager.getRemoteSystemsProject(); // create core folder tree // SystemResourceManager.getRemoteSystemsProject(); // create core folder tree
try try
{ {
SystemStartHere.getSystemProfileManager(); // create folders per profile SystemStartHere.getSystemProfileManager(); // create folders per profile
@ -99,13 +100,14 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
// add workspace listener for our project // add workspace listener for our project
IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(); IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false);
SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject); SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject);
SystemResourceManager.startResourceEventListening(listener); SystemResourceManager.startResourceEventListening(listener);
// new support to allow products to not pre-create a local connection // new support to allow products to not pre-create a local connection
if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) { // if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled! if (SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID); IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
if (systemType != null) { if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class)); RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
@ -547,14 +549,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
} }
} }
/**
* Return the project used to hold all the Remote System Framework files
*/
public IProject getRemoteSystemsProject()
{
return SystemResourceManager.getRemoteSystemsProject();
}
/** /**
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/ */