1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 22:55:26 +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:
* Dave McKnight (IBM) - [177155] Move from rse.ui/systems/org.eclipse.rse.core
* 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;
@ -59,8 +63,6 @@ public class SystemResourceManager implements SystemResourceConstants
private static IProject remoteSystemsProject = null;
private static IProject remoteSystemsTempFilesProject = null;
private static boolean initDone = false;
private static boolean firstTime = false;
private static SystemResourceHelpers helpers = null;
private static ISystemResourceListener _listener = null;
@ -146,21 +148,33 @@ public class SystemResourceManager implements SystemResourceConstants
}
/**
* Get the default remote systems project.
* @return IProject handle of the project. Use exists() to test existence.
*/
public static IProject getRemoteSystemsProject()
{
if (remoteSystemsProject == null)
{
remoteSystemsProject = ResourcesPlugin.getWorkspace().getRoot().getProject(RESOURCE_PROJECT_NAME);
if (!initDone || !remoteSystemsProject.isAccessible())
remoteSystemsProject = createRemoteSystemsProjectInternal(remoteSystemsProject);
}
return remoteSystemsProject;
}
* 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.
*/
public static IProject getRemoteSystemsProject()
{
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);
}
if ((!remoteSystemsProject.exists() && force) || (remoteSystemsProject.exists() && !remoteSystemsProject.isOpen())) {
ensureRemoteSystemsProject(remoteSystemsProject);
}
return remoteSystemsProject;
}
/**
* Get the default remote systems temp files project.
* @return IProject handle of the project. Use exists() to test existence.
*/
@ -177,7 +191,7 @@ public class SystemResourceManager implements SystemResourceConstants
* @param proj the handle for the remote systems project
* @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,
// 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) {
try {
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$
} catch (CoreException exc) {
// 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 };
description.setNatureIds(newNatures);
proj.setDescription(description, null);
firstTime = true;
} catch (Exception e) {
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 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...
// --------------------------------------------
@ -385,7 +380,7 @@ public class SystemResourceManager implements SystemResourceConstants
String folderName = getFolderName(ssFactory);
return getResourceHelpers().getOrCreateFolder(parentFolder, folderName); // Do create it.
}
/**
* Get compile commands root folder given a system profile name and subsystem factory Id.
* This is a special-needs method provided for the Import action processing,
@ -396,7 +391,6 @@ public class SystemResourceManager implements SystemResourceConstants
IFolder parentFolder = getCompileCommandsFolder(profileName);
return getResourceHelpers().getOrCreateFolder(parentFolder, factoryId); // Do create it.
}
// -------------------
// FOLDER ACTIONS...

View file

@ -13,6 +13,8 @@
* Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework
* 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;
@ -169,10 +171,12 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
String profileName = getReferencedFilterPoolManagerName();
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile = registry.getSystemProfile(profileName);
ISubSystem subsystem = (ISubSystem) getProvider();
ISubSystemConfiguration config = subsystem.getSubSystemConfiguration();
filterPoolManager = config.getFilterPoolManager(profile);
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
if (profile != null) {
ISubSystem subsystem = (ISubSystem) getProvider();
ISubSystemConfiguration config = subsystem.getSubSystemConfiguration();
filterPoolManager = config.getFilterPoolManager(profile);
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
}
}
if (filterPool != null) {
setReferenceToFilterPool(filterPool);

View file

@ -7,6 +7,8 @@
*
* Contributors:
* 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;
@ -36,19 +38,21 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
public String[] getProfileLocationNames() {
List names = new Vector(10);
IFolder providerFolder = getProviderFolder();
try {
IResource[] profileCandidates = providerFolder.members();
for (int i = 0; i < profileCandidates.length; i++) {
IResource profileCandidate = profileCandidates[i];
if (profileCandidate.getType() == IResource.FOLDER) {
String candidateName = profileCandidate.getName();
if (candidateName.startsWith(PFConstants.AB_PROFILE)) {
names.add(candidateName);
if (providerFolder.isAccessible()) {
try {
IResource[] profileCandidates = providerFolder.members();
for (int i = 0; i < profileCandidates.length; i++) {
IResource profileCandidate = profileCandidates[i];
if (profileCandidate.getType() == IResource.FOLDER) {
String candidateName = profileCandidate.getName();
if (candidateName.startsWith(PFConstants.AB_PROFILE)) {
names.add(candidateName);
}
}
}
} catch (CoreException e) {
logException(e);
}
} catch (CoreException e) {
logException(e);
}
String[] result = new String[names.size()];
names.toArray(result);
@ -80,7 +84,8 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
/**
* 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) {
IFolder providerFolder = getProviderFolder();
@ -90,36 +95,32 @@ class PFWorkspaceAnchor implements PFPersistenceAnchor {
/**
* Returns the IFolder in which this persistence provider stores its profiles.
* This will create the folder if the folder was not found.
* @return The folder that was created or found.
* This is a handle operation. It will not create the folder if it is not
* found.
* @return The folder that contains the profiles for this provider.
*/
private IFolder getProviderFolder() {
IProject project = SystemResourceManager.getRemoteSystemsProject();
try {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e) {
IProject project = SystemResourceManager.getRemoteSystemsProject(false);
if (project.isAccessible()) {
try {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e) {
}
}
IFolder providerFolder = getFolder(project, "dom.properties"); //$NON-NLS-1$
return providerFolder;
}
/**
* Returns the specified folder of the parent container. If the folder does
* not exist it creates it.
* Returns the specified folder of the parent container.
* This is a handle operation. The folder may not exist.
* @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
*/
private IFolder getFolder(IContainer parent, String name) {
IPath path = new Path(name);
IFolder folder = parent.getFolder(path);
if (!folder.exists()) {
try {
folder.create(IResource.NONE, true, null);
} catch (CoreException e) {
logException(e);
}
}
return folder;
}

View file

@ -7,6 +7,9 @@
*
* Contributors:
* 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;
@ -17,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
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.Path;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager;
class PFWorkspaceLocation implements PFPersistenceLocation {
IFolder baseFolder = null;
@ -37,13 +42,7 @@ class PFWorkspaceLocation implements PFPersistenceLocation {
}
public void ensure() {
if (!baseFolder.exists()) {
try {
baseFolder.create(true, true, null);
} catch (CoreException e) {
logException(e);
}
}
ensure(baseFolder);
}
public PFPersistenceLocation getChild(String childName) {
@ -134,6 +133,22 @@ class PFWorkspaceLocation implements PFPersistenceLocation {
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) {
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) - [186773] split ISystemRegistryUI from ISystemRegistry
* 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;
@ -97,7 +98,8 @@ public class SystemTeamViewContentProvider extends WorkbenchContentProvider
public Object getParent(Object element)
{
if (element instanceof ISystemProfile)
return SystemResourceManager.getRemoteSystemsProject();
// return SystemResourceManager.getRemoteSystemsProject();
return null;
ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
if (adapter != null)
return adapter.getParent(element);

View file

@ -12,6 +12,7 @@
*
* Contributors:
* 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;
@ -19,8 +20,9 @@ package org.eclipse.rse.internal.ui.view.team;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
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.ISystemProfile;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
import org.eclipse.swt.widgets.Shell;
@ -31,7 +33,6 @@ import org.eclipse.swt.widgets.Shell;
*/
public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInputProvider
{
private Object[] roots = new Object[1];
private Shell shell;
private Viewer viewer;
@ -49,9 +50,8 @@ public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInput
*/
public Object[] getRoots()
{
if (roots[0] == null)
roots[0] = SystemResourceManager.getRemoteSystemsProject();
return roots;
ISystemProfile[] roots = SystemProfileManager.getDefault().getSystemProfiles();
return roots;
}
/**

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* 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;
@ -1395,7 +1396,7 @@ public class SystemTeamViewPart
case 0: elementType = token; break;
// profile
case 1:
project = SystemResourceManager.getRemoteSystemsProject();
project = SystemResourceManager.getRemoteSystemsProject(false);
break;
case 2:
profile = sr.getSystemProfile(token);

View file

@ -23,6 +23,7 @@
* Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* 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;
@ -85,7 +86,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
ISystemRegistry registry = getSystemRegistryInternal();
SystemResourceManager.getRemoteSystemsProject(); // create core folder tree
// SystemResourceManager.getRemoteSystemsProject(); // create core folder tree
try
{
SystemStartHere.getSystemProfileManager(); // create folders per profile
@ -99,13 +100,14 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
// add workspace listener for our project
IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject();
IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false);
SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject);
SystemResourceManager.startResourceEventListening(listener);
// new support to allow products to not pre-create a local connection
if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled!
// if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) {
if (SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
if (systemType != null) {
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)
*/