Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/rdt
diff options
context:
space:
mode:
authorJohn Eblen2012-05-07 14:07:39 +0000
committerJohn Eblen2012-05-07 14:57:33 +0000
commiteb2583977524973bff844e0db2b55b270b96b4e5 (patch)
tree243b7b3e5698bc8cbda6f24d96b5e5be0dbd7548 /rdt
parent2e3ac737e9d5883ba5848372fe6d4049a51db5b1 (diff)
downloadorg.eclipse.ptp-eb2583977524973bff844e0db2b55b270b96b4e5.tar.gz
org.eclipse.ptp-eb2583977524973bff844e0db2b55b270b96b4e5.tar.xz
org.eclipse.ptp-eb2583977524973bff844e0db2b55b270b96b4e5.zip
Final part of fix for bug 371507 - Projects should be relocatable
To support renaming and copying of sync projects: 1) Simplify BuildConfigurationManager: a) Make sync providers flexible (can sync multiple projects and configurations) b) Thus, remove need for copying and modifying service configurations and having multiple ones per project. c) Save CDT build configuration settings (build scenarios) to CDT (.cproject file) d) Deprecate direct access to service configurations 2) Use macro to support relocation of Workspace build configuration 3) Introduce new sync mode (UNAVAILABLE) to avoid initialization problems
Diffstat (limited to 'rdt')
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildConfigurationManager.java423
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildScenario.java128
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/RemoteContentProvider.java2
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncManager.java71
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncRunner.java38
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/Messages.java16
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/messages.properties8
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/remotemake/SyncCommandLauncher.java8
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/serviceproviders/ISyncServiceProvider.java14
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitRemoteSyncConnection.java7
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java178
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/Messages.java1
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/messages.properties3
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.git.ui/src/org/eclipse/ptp/rdt/sync/git/ui/GitParticipant.java4
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/ResourceChangeListener.java27
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncFileFilterPage.java2
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncMenuOperation.java2
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/Messages.java1
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/messages.properties1
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/properties/BuildRemotePropertiesPage.java3
-rw-r--r--rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/wizards/RemoteSyncWizardPageOperation.java3
21 files changed, 621 insertions, 319 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildConfigurationManager.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildConfigurationManager.java
index 4488f699b..471683ad9 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildConfigurationManager.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildConfigurationManager.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.ptp.rdt.sync.core;
+import java.io.IOException;
import java.net.URI;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@@ -19,6 +19,7 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -48,7 +49,6 @@ import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
import org.eclipse.ptp.services.core.IService;
import org.eclipse.ptp.services.core.IServiceConfiguration;
-import org.eclipse.ptp.services.core.IServiceProvider;
import org.eclipse.ptp.services.core.ServiceModelManager;
import org.eclipse.ptp.services.core.ServiceProvider;
import org.eclipse.ui.XMLMemento;
@@ -64,10 +64,9 @@ import org.osgi.service.prefs.Preferences;
*/
public class BuildConfigurationManager {
private static final String projectScopeSyncNode = "org.eclipse.ptp.rdt.sync.core"; //$NON-NLS-1$
- private static final String CONFIG_NODE_NAME = "config"; //$NON-NLS-1$
- private static final String TEMPLATE_KEY = "template"; //$NON-NLS-1$
- private final Map<String, IServiceConfiguration> fBConfigIdToSConfigMap = Collections
- .synchronizedMap(new HashMap<String, IServiceConfiguration>());
+ private static final String configSyncDataStorageName = "org.eclipse.ptp.rdt.sync.core"; //$NON-NLS-1$
+ private static final String TEMPLATE_KEY = "template-service-configuration"; //$NON-NLS-1$
+ private static final String projectLocationPathVariable = "${project_loc}"; //$NON-NLS-1$
// Setup as a singleton
private BuildConfigurationManager() {
@@ -102,7 +101,7 @@ public class BuildConfigurationManager {
if (localService != null) {
IRemoteConnection localConnection = localService.getConnectionManager().getConnection("Local"); //$NON-NLS-1$
if (localConnection != null) {
- return new BuildScenario(null, localConnection, project.getLocation().toString());
+ return new BuildScenario(null, localConnection, projectLocationPathVariable);
} else {
throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.ptp.rdt.sync.core", //$NON-NLS-1$
Messages.BCM_LocalConnectionError));
@@ -178,25 +177,116 @@ public class BuildConfigurationManager {
*
* @param bconf
* The build configuration - cannot be null
- * @return service configuration for the build configuration
+ * @return service configuration for the build configuration or null on problems retrieving the configuration.
+ * @deprecated This method is inefficient and can easily be used incorrectly. It is inefficient because it requires a copy of
+ * the project's template service configuration. Also, sync'ing with the contained provider precludes optimizations
+ * done by the true provider in the template. Finally, changing data on this copy has no effect, except for the
+ * data stored in the copy. Instead, use {@link #getBuildScenarioForBuildConfiguration} when you need data about
+ * the configuration and use {@link #getSyncRunnerForBuildConfiguration(IConfiguration)} when you need to use the
+ * contained sync provider for sync'ing.
+ *
*/
public IServiceConfiguration getConfigurationForBuildConfiguration(IConfiguration bconf) {
IProject project = bconf.getOwner().getProject();
checkProject(project);
- IServiceConfiguration sconf = fBConfigIdToSConfigMap.get(bconf.getId());
- if (sconf == null) {
- BuildScenario bs = this.getBuildScenarioForBuildConfiguration(bconf);
- // Should never happen, but if it does do not continue. (Function call should have invoked error handling.)
- if (bs == null) {
- return null;
- }
- sconf = copyTemplateServiceConfiguration(project);
- modifyServiceConfigurationForBuildScenario(sconf, bs);
- fBConfigIdToSConfigMap.put(bconf.getId(), sconf);
+
+ BuildScenario bs = this.getBuildScenarioForBuildConfiguration(bconf);
+ // Should never happen, but if it does do not continue. (Function call should have invoked error handling.)
+ if (bs == null) {
+ return null;
}
+ IServiceConfiguration sconf = copyTemplateServiceConfiguration(project);
+ this.modifyServiceConfigurationForBuildScenario(sconf, project, bs);
return sconf;
}
+
+ /**
+ * Get a SyncRunner object that can be used to do sync'ing.
+ *
+ * @param bconf
+ * @return SyncRunner - can be null if this configuration does not require sync'ing, such as a local configuration, or if there
+ * are problems retrieving the sync provider or information.
+ */
+ public SyncRunner getSyncRunnerForBuildConfiguration(IConfiguration bconf) {
+ IProject project = bconf.getOwner().getProject();
+ checkProject(project);
+
+ ISyncServiceProvider provider = this.getProjectSyncServiceProvider(project);
+ if (provider == null) { // Error handled in call
+ return null;
+ }
+
+ BuildScenario buildScenario = this.getBuildScenarioForBuildConfigurationInternal(bconf).bs;
+ if (buildScenario == null) { // Error handled in call
+ return null;
+ }
+
+ if (buildScenario.getSyncProvider() == null) {
+ return null;
+ } else {
+ return new SyncRunner(provider);
+ }
+ }
+
+ // Does the low-level work of creating a copy of a service configuration
+ // Returned configuration is never null.
+ // This method supports deprecated code and can be removed once {@link #getConfigurationForBuildConfiguration} is removed.
+ private IServiceConfiguration copyTemplateServiceConfiguration(IProject project) {
+ IServiceConfiguration newConfig = ServiceModelManager.getInstance().newServiceConfiguration(""); //$NON-NLS-1$
+ if (newConfig == null) {
+ throw new RuntimeException(Messages.BuildConfigurationManager_15);
+ }
+ String oldConfigId = getTemplateServiceConfigurationId(project);
+ IServiceConfiguration oldConfig = ServiceModelManager.getInstance().getConfiguration(oldConfigId);
+ if (oldConfig == null) {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_10 + oldConfigId + Messages.BuildConfigurationManager_11 + project.getName());
+ return null;
+ }
+
+ for (IService service : oldConfig.getServices()) {
+ ServiceProvider oldProvider = (ServiceProvider) oldConfig.getServiceProvider(service);
+ try {
+ // The memento creation methods seem the most robust way to copy state. It is more robust than
+ // getProperties() and setProperties(), which saveState() and restoreState() use by default but which
+ // can be overriden by subclasses.
+ ServiceProvider newProvider = oldProvider.getClass().newInstance();
+ XMLMemento oldProviderState = XMLMemento.createWriteRoot("provider"); //$NON-NLS-1$
+ oldProvider.saveState(oldProviderState);
+ newProvider.restoreState(oldProviderState);
+ newConfig.setServiceProvider(service, newProvider);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(Messages.BCM_ProviderError + oldProvider.getClass());
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(Messages.BCM_ProviderError + oldProvider.getClass());
+ }
+ }
+
+ return newConfig;
+ }
+
+ // Does the low-level work of changing a service configuration for a new build scenario.
+ // This method supports deprecated code and can be removed once {@link #getConfigurationForBuildConfiguration} is removed.
+ private void modifyServiceConfigurationForBuildScenario(IServiceConfiguration sConfig, IProject project, BuildScenario bs) {
+ IService syncService = null; // Only set if sync service should be disabled
+ for (IService service : sConfig.getServices()) {
+ ServiceProvider provider = (ServiceProvider) sConfig.getServiceProvider(service);
+ if (provider instanceof IRemoteExecutionServiceProvider) {
+ // For local configuration, for example, that does not need to sync
+ if (provider instanceof ISyncServiceProvider && bs.getSyncProvider() == null) {
+ syncService = service;
+ } else {
+ ((IRemoteExecutionServiceProvider) provider).setRemoteToolsConnection(bs.getRemoteConnection());
+ ((IRemoteExecutionServiceProvider) provider).setConfigLocation(bs.getLocation(project));
+
+ }
+ }
+ }
+ if (syncService != null) {
+ sConfig.disable(syncService);
+ }
+ }
+
/**
* Return the name of the sync provider for this project, as stored in the project's template service configuration.
@@ -205,6 +295,22 @@ public class BuildConfigurationManager {
* @return sync provider name or null if provider cannot be loaded (should not normally happen)
*/
public String getProjectSyncProvider(IProject project) {
+ ISyncServiceProvider provider = this.getProjectSyncServiceProvider(project);
+ if (provider == null) {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_13 + project.getName());
+ return null;
+ }
+
+ return provider.getName();
+ }
+
+ /**
+ * Return the sync service provider for this project, as stored in the project's template service configuration
+ *
+ * @param project
+ * @return the service provider
+ */
+ private ISyncServiceProvider getProjectSyncServiceProvider(IProject project) {
checkProject(project);
String serviceConfigId = getTemplateServiceConfigurationId(project);
IServiceConfiguration serviceConfig = ServiceModelManager.getInstance().getConfiguration(serviceConfigId);
@@ -219,13 +325,7 @@ public class BuildConfigurationManager {
return null;
}
- IServiceProvider provider = serviceConfig.getServiceProvider(syncService);
- if (provider == null) {
- RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_13 + project.getName());
- return null;
- }
-
- return provider.getName();
+ return (ISyncServiceProvider) serviceConfig.getServiceProvider(syncService);
}
/**
@@ -269,6 +369,15 @@ public class BuildConfigurationManager {
throw new NullPointerException();
}
+ // Store configuration independently of project, which can be useful if the project is deleted.
+ ServiceModelManager smm = ServiceModelManager.getInstance();
+ smm.addConfiguration(sc);
+ try {
+ smm.saveModelConfiguration();
+ } catch (IOException e) {
+ RDTSyncCorePlugin.log(e.toString(), e);
+ }
+
// Cannot call "checkProject" because project not yet initialized
try {
if (!project.hasNature(RemoteSyncNature.NATURE_ID)) {
@@ -296,6 +405,23 @@ public class BuildConfigurationManager {
setBuildScenarioForBuildConfigurationInternal(bs, config);
}
}
+
+ /**
+ * Set the template service configuration for the given project to the given configuration
+ *
+ * @param project
+ * @param sc
+ */
+ public void setTemplateServiceConfiguration(IProject project, IServiceConfiguration sc) {
+ checkProject(project);
+ IScopeContext context = new ProjectScope(project);
+ Preferences node = context.getNode(projectScopeSyncNode);
+ if (node == null) {
+ throw new RuntimeException(Messages.BuildConfigurationManager_0);
+ }
+ node.put(TEMPLATE_KEY, sc.getId());
+ flushNode(node);
+ }
/**
* Indicate if the project has yet been initialized.
@@ -314,40 +440,6 @@ public class BuildConfigurationManager {
}
}
- // Does the low-level work of creating a copy of a service configuration
- // Returned configuration is never null
- private IServiceConfiguration copyTemplateServiceConfiguration(IProject project) {
- IServiceConfiguration newConfig = ServiceModelManager.getInstance().newServiceConfiguration(""); //$NON-NLS-1$
- if (newConfig == null) {
- throw new RuntimeException(Messages.BuildConfigurationManager_15);
- }
- String oldConfigId = getTemplateServiceConfigurationId(project);
- IServiceConfiguration oldConfig = ServiceModelManager.getInstance().getConfiguration(oldConfigId);
- if (oldConfig == null) {
- RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_10 + oldConfigId + Messages.BuildConfigurationManager_11 + project.getName());
- return null;
- }
-
- for (IService service : oldConfig.getServices()) {
- ServiceProvider oldProvider = (ServiceProvider) oldConfig.getServiceProvider(service);
- try {
- // The memento creation methods seem the most robust way to copy state. It is more robust than getProperties() and
- // setProperties(), which saveState() and restoreState() use by default but which can be overriden by subclasses.
- ServiceProvider newProvider = oldProvider.getClass().newInstance();
- XMLMemento oldProviderState = XMLMemento.createWriteRoot("provider"); //$NON-NLS-1$
- oldProvider.saveState(oldProviderState);
- newProvider.restoreState(oldProviderState);
- newConfig.setServiceProvider(service, newProvider);
- } catch (InstantiationException e) {
- throw new RuntimeException(Messages.BCM_ProviderError + oldProvider.getClass());
- } catch (IllegalAccessException e) {
- throw new RuntimeException(Messages.BCM_ProviderError + oldProvider.getClass());
- }
- }
-
- return newConfig;
- }
-
private IConfiguration createConfiguration(IProject project, BuildScenario buildScenario, String configName, String configDesc) {
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
if (buildInfo == null) {
@@ -375,22 +467,12 @@ public class BuildConfigurationManager {
}
if (configDes != null) {
+ configAdded = true;
config.setConfigurationDescription(configDes);
configDes.setName(configName);
configDes.setDescription(configDesc);
- config.getToolChain().getBuilder().setBuildPath(project.getLocation().toString());
- configAdded = true;
- try {
- CoreModel.getDefault().setProjectDescription(project, projectDes, true, null);
- } catch (CoreException e) {
- projectDes.removeConfiguration(configDes);
- configAdded = false;
- creationException = e;
- creationError = Messages.BCM_SetConfigDescriptionError;
- }
- if (configAdded) {
- this.setBuildScenarioForBuildConfigurationInternal(buildScenario, config);
- }
+ setProjectDescription(project, projectDes);
+ this.setBuildScenarioForBuildConfigurationInternal(buildScenario, config);
} else {
creationError = Messages.BCM_CreateConfigError;
}
@@ -431,27 +513,6 @@ public class BuildConfigurationManager {
}
}
}
-
- // Does the low-level work of changing a service configuration for a new build scenario.
- private void modifyServiceConfigurationForBuildScenario(IServiceConfiguration sConfig, BuildScenario bs) {
- IService syncService = null; // Only set if sync service should be disabled
- for (IService service : sConfig.getServices()) {
- ServiceProvider provider = (ServiceProvider) sConfig.getServiceProvider(service);
- if (provider instanceof IRemoteExecutionServiceProvider) {
- // For local configuration, for example, that does not need to sync
- if (provider instanceof ISyncServiceProvider && bs.getSyncProvider() == null) {
- syncService = service;
- } else {
- ((IRemoteExecutionServiceProvider) provider).setRemoteToolsConnection(bs.getRemoteConnection());
- ((IRemoteExecutionServiceProvider) provider).setConfigLocation(bs.getLocation());
-
- }
- }
- }
- if (syncService != null) {
- sConfig.disable(syncService);
- }
- }
// Return ID of the project's template service configuration, or null if not found (project not initialized)
// Returned value is never null
@@ -481,7 +542,6 @@ public class BuildConfigurationManager {
public BuildScenario getBuildScenarioForBuildConfiguration(IConfiguration bconf) {
IProject project = bconf.getOwner().getProject();
checkProject(project);
- updateConfigurations(project);
return this.getBuildScenarioForBuildConfigurationInternal(bconf).bs;
}
@@ -500,26 +560,26 @@ public class BuildConfigurationManager {
// Return null if not found.
private BuildScenarioAndConfiguration getBuildScenarioForBuildConfigurationInternal(IConfiguration bconf) {
IProject project = bconf.getOwner().getProject();
- IScopeContext context = new ProjectScope(project);
- Preferences prefRootNode = context.getNode(projectScopeSyncNode);
- if (prefRootNode == null) {
- RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_0);
- return null;
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ if (buildInfo == null) {
+ throw new RuntimeException(Messages.BCM_BuildInfoError + project.getName());
}
try {
- if (!prefRootNode.nodeExists(CONFIG_NODE_NAME)) {
- throw new RuntimeException(Messages.BuildConfigurationManager_0);
- }
-
- String configId = bconf.getId();
- Preferences prefGeneralConfigNode = prefRootNode.node(CONFIG_NODE_NAME);
- while (configId != null && !prefGeneralConfigNode.nodeExists(configId)) {
+ IConfiguration config = bconf;
+ String configId = config.getId();
+ Map<String, String> scenarioData = this.getConfigData((Configuration) config, configSyncDataStorageName);
+ while (scenarioData == null) {
configId = getParentId(configId);
+ if (configId == null) {
+ break;
+ }
+ config = buildInfo.getManagedProject().getConfiguration(configId);
+ scenarioData = this.getConfigData((Configuration) config, configSyncDataStorageName);
}
if (configId != null) {
- BuildScenario bs = BuildScenario.loadScenario(prefGeneralConfigNode.node(configId));
+ BuildScenario bs = BuildScenario.loadScenario(scenarioData);
if (bs == null) {
RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_14 + configId + Messages.BuildConfigurationManager_11
+ project.getName());
@@ -530,8 +590,8 @@ public class BuildConfigurationManager {
} else {
return null;
}
- } catch (BackingStoreException e) {
- RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_2, e);
+ } catch (CoreException e) {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_19, e);
return null;
}
}
@@ -568,22 +628,70 @@ public class BuildConfigurationManager {
}
private void setBuildScenarioForBuildConfigurationInternal(BuildScenario bs, IConfiguration bconf) {
- IProject project = bconf.getOwner().getProject();
-
- IScopeContext context = new ProjectScope(project);
- Preferences prefRootNode = context.getNode(projectScopeSyncNode);
- if (prefRootNode == null) {
- throw new RuntimeException(Messages.BuildConfigurationManager_0);
+ Map<String, String> map = new HashMap<String, String>();
+ bs.saveScenario(map);
+ try {
+ this.setConfigData((Configuration) bconf, map, configSyncDataStorageName);
+ } catch (CoreException e) {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_20, e);
+ return;
+ }
+ }
+
+ // The below two functions give us an easy mechanism to store build scenario data inside build configurations
+ /**
+ * Get simple java map of configuration data
+ *
+ * @param config
+ * @param storageName - name of storage module
+ *
+ * @return values in named storage location or null if the storage location does not exist.
+ * @throws CoreException on problems retrieving data
+ */
+ private Map<String, String> getConfigData(Configuration config, String storageName) throws CoreException {
+ ICConfigurationDescription configDesc = config.getConfigurationDescription();
+ if (configDesc == null) {
+ // Should never happen
+ throw new RuntimeException(Messages.BuildConfigurationManager_18);
}
-
- Preferences prefConfigNode = prefRootNode.node(CONFIG_NODE_NAME + "/" + bconf.getId()); //$NON-NLS-1$
- bs.saveScenario(prefConfigNode);
- flushNode(prefRootNode);
- IServiceConfiguration sconf = fBConfigIdToSConfigMap.get(bconf.getId());
- if (sconf != null) {
- modifyServiceConfigurationForBuildScenario(sconf, bs);
+ Map<String, String> m = new HashMap<String, String>();
+ ICStorageElement storage = configDesc.getStorage(storageName, false);
+ if (storage == null) {
+ return null;
}
+ for (String attr : storage.getAttributeNames()) {
+ m.put(attr, storage.getAttribute(attr));
+ }
+
+ return m;
+ }
+
+ /**
+ * Store a simple java map as data in a configuration.
+ *
+ * @param config
+ * @param map
+ * @param storageName - name of storage module
+ *
+ * @throws CoreException on problems retrieving data
+ */
+ private void setConfigData(Configuration config, Map<String, String> map, String storageName) throws CoreException {
+ // The commented code gets a read-only description.
+ // ICConfigurationDescription configDesc = config.getConfigurationDescription();
+ ICProjectDescription projectDesc = CoreModel.getDefault().getProjectDescription(config.getOwner().getProject());
+ ICConfigurationDescription configDesc = projectDesc.getConfigurationById(config.getId());
+ if (configDesc == null) {
+ // Should never happen
+ throw new RuntimeException(Messages.BuildConfigurationManager_18);
+ }
+
+ ICStorageElement storage = configDesc.getStorage(storageName, true);
+ for (Map.Entry<String, String> entry : map.entrySet()) {
+ storage.setAttribute(entry.getKey(), entry.getValue());
+ }
+ config.setDirty(true); // Fixes case where "Workspace" configuration does not compile after project rename.
+ setProjectDescription(config.getOwner().getProject(), projectDesc);
}
// Run standard checks on project and throw the appropriate exception if it is not valid
@@ -610,6 +718,7 @@ public class BuildConfigurationManager {
*/
public static void flushNode(final Preferences prefNode) {
+ Throwable firstException = null;
final IWorkspace ws = ResourcesPlugin.getWorkspace();
// Avoid creating a thread if possible.
try {
@@ -619,12 +728,18 @@ public class BuildConfigurationManager {
}
} catch (BackingStoreException e) {
// Proceed to create thread
+ firstException = e;
+ } catch (IllegalStateException e) {
+ // Can occur if the project has been moved or deleted, so the preference node no longer exists.
+ firstException = e;
+ return;
}
+ final Throwable currentException = firstException;
Thread flushThread = new Thread(new Runnable() {
public void run() {
int sleepCount = 0;
- Throwable lastException = null;
+ Throwable lastException = currentException;
while (true) {
try {
Thread.sleep(1000);
@@ -647,10 +762,72 @@ public class BuildConfigurationManager {
} catch (BackingStoreException e) {
// This can happen in the rare case that the lock is locked between the check and the flush.
lastException = e;
+ } catch (IllegalStateException e) {
+ // Can occur if the project has been moved or deleted, so the preference node no longer exists.
+ return;
}
}
}
}, "Flush project data thread"); //$NON-NLS-1$
flushThread.start();
}
+
+ /**
+ * Writing to the .cproject file fails if the workspace is locked. So calling CoreModel.getDefault().setProjectDescription() is
+ * not enough. Instead, spawn a thread that calls this function once the workspace is unlocked.
+ * The overall logic for this function and "nodeFlush" is the same.
+ *
+ * @param project
+ * @param desc
+ */
+ public static void setProjectDescription(final IProject project, final ICProjectDescription desc) {
+ Throwable firstException = null;
+ final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ // Avoid creating a thread if possible.
+ try {
+ if (!ws.isTreeLocked()) {
+ CoreModel.getDefault().setProjectDescription(project, desc, true, null);
+ return;
+ }
+ } catch (CoreException e) {
+ // This can happen in the rare case that the lock is locked between the check and the flush but also for other reasons.
+ // Be optimistic and proceed to create thread.
+ firstException = e;
+ }
+
+ final Throwable currentException = firstException;
+ Thread flushThread = new Thread(new Runnable() {
+ public void run() {
+ int sleepCount = 0;
+ Throwable lastException = currentException;
+ while (true) {
+ try {
+ Thread.sleep(1000);
+ // Give up after 30 sleeps - this should never happen
+ sleepCount++;
+ if (sleepCount > 30) {
+ if (lastException != null) {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_24, lastException);
+ } else {
+ RDTSyncCorePlugin.log(Messages.BuildConfigurationManager_24);
+ }
+ break;
+ }
+ if (!ws.isTreeLocked()) {
+ CoreModel.getDefault().setProjectDescription(project, desc, true, null);
+ break;
+ }
+ } catch(InterruptedException e) {
+ lastException = e;
+ } catch (CoreException e) {
+ // This can happen in the rare case that the lock is locked between the check and the flush but also for
+ // other reasons.
+ // Be optimistic and try again.
+ lastException = e;
+ }
+ }
+ }
+ }, "Save project CDT data thread"); //$NON-NLS-1$
+ flushThread.start();
+ }
} \ No newline at end of file
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildScenario.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildScenario.java
index fc220d9f9..21f7a25d2 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildScenario.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/BuildScenario.java
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.ptp.rdt.sync.core;
+import java.util.Map;
+
+import org.eclipse.core.resources.IPathVariableManager;
+import org.eclipse.core.resources.IProject;
import org.eclipse.ptp.remote.core.IRemoteConnection;
import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
-import org.osgi.service.prefs.Preferences;
/**
* Class for build information that will be mapped to a specific service configuration. Utility methods for reading and writing
@@ -62,39 +65,89 @@ public class BuildScenario {
/**
* Get location (directory)
+ *
* @return location (directory)
+ * @deprecated as of 6.0.0, replaced by {@link #getLocation(IProject)}
+ * The new function supports the use of path variables, such as the project location, useful for project relocation
+ * (see bug 371507). Such support is not possible, though, without project information.
*/
- public String getLocation() {
+ @Deprecated public String getLocation() {
return location;
}
/**
- * Store scenario in a given preference node
+ * Get location (directory), resolved in terms of the passed project
+ *
+ * @param project
+ * @return location
+ */
+ public String getLocation(IProject project) {
+ return resolveString(project, location);
+ }
+
+ /**
+ * Utility function to resolve a string based on path variables for a certain project. Unless string is in the form:
+ * ${path_variable:/remainder}, where "path_variable" is a path variable defined for the project, the original string
+ * is returned unchanged.
+ *
+ * The Eclipse platform should provide a standard mechanism for doing this, but various combinations of URIUtil and
+ * PathVariableManager methods failed.
+ *
+ * @param project
+ * @param path
+ * @return resolved string
+ */
+ public static String resolveString(IProject project, String path) {
+ // Check basic syntax
+ if (!path.startsWith("${") || !path.endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return path;
+ }
+
+ String newPath = path.substring(2, path.length()-1);
+
+ // Extract variable's value
+ String variable = newPath.split(":")[0]; //$NON-NLS-1$
+ IPathVariableManager pvm = project.getPathVariableManager();
+ String value = pvm.getURIValue(variable.toUpperCase()).toString();
+ if (value == null) {
+ return path;
+ }
+
+ // Build and return new path
+ value = value.replaceFirst("file:", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (value.endsWith("/") || value.endsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(0, path.length()-1);
+ }
+ return newPath.replaceFirst(variable + ":*", value); //$NON-NLS-1$
+ }
+
+ /**
+ * Store scenario in the given map
*
- * @param preference node
+ * @param map
*/
- public void saveScenario(Preferences prefRootNode) {
+ public void saveScenario(Map<String, String> map) {
if (syncProvider != null) {
- prefRootNode.put(ATTR_SYNC_PROVIDER, syncProvider);
+ map.put(ATTR_SYNC_PROVIDER, syncProvider);
}
- prefRootNode.put(ATTR_REMOTE_CONNECTION_ID, remoteConnection.getName());
- prefRootNode.put(ATTR_LOCATION, location);
- prefRootNode.put(ATTR_REMOTE_SERVICES_ID, remoteConnection.getRemoteServices().getId());
+ map.put(ATTR_REMOTE_CONNECTION_ID, remoteConnection.getName());
+ map.put(ATTR_LOCATION, location);
+ map.put(ATTR_REMOTE_SERVICES_ID, remoteConnection.getRemoteServices().getId());
}
/**
- * Load data from a preference node into a new build scenario.
+ * Load data from a map into a new build scenario.
*
- * @param preference node
+ * @param map
* @return a new build scenario or null if one of the values is not found or if something goes wrong while trying to find the
* specified IRemoteConnection.
*/
- public static BuildScenario loadScenario(Preferences prefRootNode) {
- String sp = prefRootNode.get(ATTR_SYNC_PROVIDER, null);
- String rc = prefRootNode.get(ATTR_REMOTE_CONNECTION_ID, null);
- String l = prefRootNode.get(ATTR_LOCATION, null);
- String rs = prefRootNode.get(ATTR_REMOTE_SERVICES_ID, null);
- if (rc == null || l == null || rs == null) {
+ public static BuildScenario loadScenario(Map<String, String> map) {
+ String sp = map.get(ATTR_SYNC_PROVIDER);
+ String rc = map.get(ATTR_REMOTE_CONNECTION_ID);
+ String l = map.get(ATTR_LOCATION);
+ String rs = map.get(ATTR_REMOTE_SERVICES_ID);
+ if (rc == null || l == null || rs == null) { // null is okay for sync provider
return null;
}
@@ -110,4 +163,45 @@ public class BuildScenario {
return new BuildScenario(sp, remoteConnection, l);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((location == null) ? 0 : location.hashCode());
+ result = prime
+ * result
+ + ((remoteConnection == null) ? 0 : remoteConnection.hashCode());
+ result = prime * result
+ + ((syncProvider == null) ? 0 : syncProvider.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BuildScenario other = (BuildScenario) obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (remoteConnection == null) {
+ if (other.remoteConnection != null)
+ return false;
+ } else if (!remoteConnection.equals(other.remoteConnection))
+ return false;
+ if (syncProvider == null) {
+ if (other.syncProvider != null)
+ return false;
+ } else if (!syncProvider.equals(other.syncProvider))
+ return false;
+ return true;
+ }
} \ No newline at end of file
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/RemoteContentProvider.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/RemoteContentProvider.java
index 079cbd738..2d6df6330 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/RemoteContentProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/RemoteContentProvider.java
@@ -188,7 +188,7 @@ public class RemoteContentProvider implements ITreeContentProvider {
BuildScenario bs = BuildConfigurationManager.getInstance().getBuildScenarioForBuildConfiguration(bconf);
if (bs != null) {
IRemoteFileManager fileManager = bs.getRemoteConnection().getRemoteServices().getFileManager(bs.getRemoteConnection());
- IPath remotePath = new Path(bs.getLocation()).addTrailingSeparator().append(file.getProjectRelativePath());
+ IPath remotePath = new Path(bs.getLocation(project)).addTrailingSeparator().append(file.getProjectRelativePath());
IFileStore fileStore = fileManager.getResource(remotePath.toString()); // Assumes "/" separator on remote
InputStream fileInput = fileStore.openInputStream(EFS.NONE, null);
if (fileInput != null) {
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncManager.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncManager.java
index 6fa599334..18a7742d7 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncManager.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncManager.java
@@ -26,11 +26,6 @@ import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.ptp.rdt.sync.core.messages.Messages;
import org.eclipse.ptp.rdt.sync.core.serviceproviders.ISyncServiceProvider;
-import org.eclipse.ptp.rdt.sync.core.services.IRemoteSyncServiceConstants;
-import org.eclipse.ptp.services.core.IService;
-import org.eclipse.ptp.services.core.IServiceConfiguration;
-import org.eclipse.ptp.services.core.IServiceModelManager;
-import org.eclipse.ptp.services.core.ServiceModelManager;
import org.osgi.service.prefs.Preferences;
public class SyncManager {
@@ -38,8 +33,12 @@ public class SyncManager {
private SyncManager() {
}
+ // ACTIVE: Sync with current active configuration
+ // ALL: Sync with all configurations
+ // NONE: Do not transfer files but still call sync and do bookkeeping
+ // UNAVAILABLE: Do not call sync. (Used internally during project creation and deletion.)
public static enum SYNC_MODE {
- ACTIVE, ALL, NONE
+ ACTIVE, ALL, NONE, UNAVAILABLE
};
private static final String projectScopeSyncNode = "org.eclipse.ptp.rdt.sync.core"; //$NON-NLS-1$
@@ -48,23 +47,26 @@ public class SyncManager {
private static final String SYNC_AUTO_KEY = "sync-auto"; //$NON-NLS-1$
private static final String SHOW_ERROR_KEY = "show-error"; //$NON-NLS-1$
- private static final SYNC_MODE DEFAULT_SYNC_MODE = SYNC_MODE.ACTIVE;
+ // Sync unavailable by default. Wizards should explicitly set the sync mode once the project is ready.
+ private static final SYNC_MODE DEFAULT_SYNC_MODE = SYNC_MODE.UNAVAILABLE;
private static final boolean DEFAULT_SYNC_AUTO_SETTING = true;
private static final boolean DEFAULT_SHOW_ERROR_SETTING = true;
private static class SynchronizeJob extends Job {
- private final IResourceDelta fDelta;
private final IProject fProject;
- private final ISyncServiceProvider fSyncProvider;
+ private final BuildScenario fBuildScenario;
+ private final IResourceDelta fDelta;
+ private final SyncRunner fSyncRunner;
private final EnumSet<SyncFlag> fSyncFlags;
private final SyncExceptionHandler fSyncExceptionHandler;
- public SynchronizeJob(IResourceDelta delta, IProject project, ISyncServiceProvider provider, EnumSet<SyncFlag> syncFlags,
- SyncExceptionHandler seHandler) {
+ public SynchronizeJob(IProject project, BuildScenario buildScenario, IResourceDelta delta, SyncRunner runner,
+ EnumSet<SyncFlag> syncFlags, SyncExceptionHandler seHandler) {
super(Messages.SyncManager_4);
- fDelta = delta;
fProject = project;
- fSyncProvider = provider;
+ fBuildScenario = buildScenario;
+ fDelta = delta;
+ fSyncRunner = runner;
fSyncFlags = syncFlags;
fSyncExceptionHandler = seHandler;
}
@@ -78,7 +80,8 @@ public class SyncManager {
protected IStatus run(IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 100);
try {
- fSyncProvider.synchronize(fDelta, getFileFilter(fProject), progress.newChild(100), fSyncFlags);
+ fSyncRunner.synchronize(fProject, fBuildScenario, fDelta, getFileFilter(fProject), progress.newChild(100),
+ fSyncFlags);
} catch (CoreException e) {
if (fSyncExceptionHandler == null) {
System.out.println(Messages.SyncManager_8 + e.getLocalizedMessage());
@@ -402,12 +405,14 @@ public class SyncManager {
Job[] syncJobs = new Job[buildConfigurations.length];
for (IConfiguration buildConfig : buildConfigurations) {
SynchronizeJob job = null;
- ISyncServiceProvider provider = (ISyncServiceProvider) SyncManager.getSyncProvider(buildConfig);
- if (provider != null) {
+ BuildConfigurationManager bcm = BuildConfigurationManager.getInstance();
+ BuildScenario buildScenario = bcm.getBuildScenarioForBuildConfiguration(buildConfig);
+ SyncRunner syncRunner = bcm.getSyncRunnerForBuildConfiguration(buildConfig);
+ if (syncRunner != null) {
if (isBlocking) {
- provider.synchronize(delta, getFileFilter(project), monitor, syncFlags);
+ syncRunner.synchronize(project, buildScenario, delta, getFileFilter(project), monitor, syncFlags);
} else {
- job = new SynchronizeJob(delta, project, provider, syncFlags, seHandler);
+ job = new SynchronizeJob(project, buildScenario, delta, syncRunner, syncFlags, seHandler);
job.schedule();
}
}
@@ -419,34 +424,4 @@ public class SyncManager {
return syncJobs;
}
-
- /**
- * Get the sync service provider for the given project's current active configuration.
- *
- * @param project
- * @return sync service provider or null if provider cannot be found. (Logs error message in that case.)
- */
- public static ISyncServiceProvider getSyncProvider(IProject project) {
- IConfiguration config = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
- return SyncManager.getSyncProvider(config);
- }
-
- /**
- * Get the sync service provider for the given build configuration.
- *
- * @param config
- * @return sync service provider or null if provider cannot be found. (Logs error message in that case.)
- */
- public static ISyncServiceProvider getSyncProvider(IConfiguration config) {
- ISyncServiceProvider provider = null;
- BuildConfigurationManager bcm = BuildConfigurationManager.getInstance();
- IServiceConfiguration serviceConfig = bcm.getConfigurationForBuildConfiguration(config);
- if (serviceConfig != null) {
- IServiceModelManager serviceModel = ServiceModelManager.getInstance();
- IService syncService = serviceModel.getService(IRemoteSyncServiceConstants.SERVICE_SYNC);
- provider = (ISyncServiceProvider) serviceConfig.getServiceProvider(syncService);
- }
-
- return provider;
- }
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncRunner.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncRunner.java
new file mode 100644
index 000000000..32940d8d1
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/SyncRunner.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oak Ridge National Laboratory and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * John Eblen - initial implementation
+ *******************************************************************************/
+package org.eclipse.ptp.rdt.sync.core;
+
+import java.util.EnumSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ptp.rdt.sync.core.serviceproviders.ISyncServiceProvider;
+
+/**
+ * Simple class with a single public method for sync'ing. This serves as an adapter for an ISyncServiceProvider so that clients
+ * can use the provider but without the ability to change the provider or read from it. As of 6.0.0, sync providers are dynamic
+ * and may handle multiple projects and build configurations. Thus, clients need a way to use the provider but without creating
+ * a dependency on the provider's internal data.
+ */
+public class SyncRunner {
+ private ISyncServiceProvider provider;
+
+ public SyncRunner(ISyncServiceProvider ssp) {
+ provider = ssp;
+ }
+
+ public void synchronize(IProject project, BuildScenario buildScenario, IResourceDelta delta, SyncFileFilter filter,
+ IProgressMonitor monitor, EnumSet<SyncFlag> syncFlags) throws CoreException {
+ provider.synchronize(project, buildScenario, delta, filter, monitor, syncFlags);
+ }
+} \ No newline at end of file
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/Messages.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/Messages.java
index 7dd6dbae2..3e37b8da0 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/Messages.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/Messages.java
@@ -64,8 +64,22 @@ public class Messages extends NLS {
public static String BuildConfigurationManager_17;
+ public static String BuildConfigurationManager_18;
+
+ public static String BuildConfigurationManager_19;
+
public static String BuildConfigurationManager_2;
+ public static String BuildConfigurationManager_20;
+
+ public static String BuildConfigurationManager_21;
+
+ public static String BuildConfigurationManager_22;
+
+ public static String BuildConfigurationManager_23;
+
+ public static String BuildConfigurationManager_24;
+
public static String BuildConfigurationManager_3;
public static String BuildConfigurationManager_4;
@@ -80,6 +94,8 @@ public class Messages extends NLS {
public static String BuildConfigurationManager_9;
+ public static String BuildScenario_0;
+
public static String BCM_GetBuildInfoError;
public static String PathResourceMatcher_0;
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/messages.properties b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/messages.properties
index 8f2a1d1ec..cc44f4a73 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/messages.properties
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/messages/messages.properties
@@ -35,7 +35,14 @@ BuildConfigurationManager_14=Unable to load build scenario for configuration
BuildConfigurationManager_15=Unable to create new service configuration
BuildConfigurationManager_16=Unmapped build configuration found
BuildConfigurationManager_17=Unable to flush project data
+BuildConfigurationManager_18=Unable to get description for configuration
+BuildConfigurationManager_19=Unable to retrieve sync data from configuration
BuildConfigurationManager_2=Unable to access node for storing configuration settings
+BuildConfigurationManager_20=Unable to store sync data to configuration
+BuildConfigurationManager_21=Project does not contain prior sync data
+BuildConfigurationManager_22=Configuration not found in service model manager
+BuildConfigurationManager_23=Unable to get sync service provider for sync project
+BuildConfigurationManager_24=Unable to save project data to .cproject file
BuildConfigurationManager_3=Unable to access storage node for configuration
BuildConfigurationManager_4=Unable to find sync data for build configuration
BuildConfigurationManager_5=Unable to read sync data from ancestor for
@@ -43,6 +50,7 @@ BuildConfigurationManager_6=Configuration for a non-sync project
BuildConfigurationManager_7=Project not initialized
BuildConfigurationManager_8=Configuration's project not found
BuildConfigurationManager_9=Unable to read template service configuration
+BuildScenario_0=Path variable said to exist but not found.
PathResourceMatcher_0=Path not found in preference node
RegexResourceMatcher_0=Regex pattern not found in preference node
RemoteContentProvider_0=Null argument passed to RemoteContentProvider constructor.
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/remotemake/SyncCommandLauncher.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/remotemake/SyncCommandLauncher.java
index f2263d265..6551b2c38 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/remotemake/SyncCommandLauncher.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/remotemake/SyncCommandLauncher.java
@@ -29,7 +29,6 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -139,11 +138,10 @@ public class SyncCommandLauncher implements ICommandLauncher {
// Set correct directory
// For managed projects and configurations other than workspace, the directory is incorrect and needs to be fixed.
IConfiguration configuration = ManagedBuildManager.getBuildInfo(getProject()).getDefaultConfiguration();
- String projectWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString()
- + getProject().getFullPath().toPortableString();
+ String projectLocalRoot = getProject().getLocation().toPortableString();
String projectActualRoot = BuildConfigurationManager.getInstance().getBuildScenarioForBuildConfiguration(configuration)
- .getLocation();
- changeToDirectory = new Path(changeToDirectory.toString().replaceFirst(projectWorkspaceRoot, projectActualRoot));
+ .getLocation(getProject());
+ changeToDirectory = new Path(changeToDirectory.toString().replaceFirst(projectLocalRoot, projectActualRoot));
fCommandArgs = constructCommandArray(commandPath.toPortableString(), args);
// Determine the service model for this configuration, and use the provider of the build service to execute the build
diff --git a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/serviceproviders/ISyncServiceProvider.java b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/serviceproviders/ISyncServiceProvider.java
index e5e5ce846..0917ebaa8 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/serviceproviders/ISyncServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.core/src/org/eclipse/ptp/rdt/sync/core/serviceproviders/ISyncServiceProvider.java
@@ -12,10 +12,12 @@ package org.eclipse.ptp.rdt.sync.core.serviceproviders;
import java.util.EnumSet;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider;
+import org.eclipse.ptp.rdt.sync.core.BuildScenario;
import org.eclipse.ptp.rdt.sync.core.SyncFileFilter;
import org.eclipse.ptp.rdt.sync.core.SyncFlag;
import org.eclipse.ptp.remote.core.IRemoteConnection;
@@ -40,12 +42,14 @@ public interface ISyncServiceProvider extends IRemoteExecutionServiceProvider {
public IRemoteConnection getRemoteConnection();
/**
- * Performs synchronization.
- *
+ * Perform synchronization
+ *
+ * @param project
+ * project to sync
* @param delta
* resources requiring synchronization
* @param monitor
- * progress monitor for monitoring or canceling synch
+ * progress monitor for monitoring or canceling sync
* @param syncFlags
* Various flags for the sync call. For example, the sync can be
* forced, either to local (from remote) or to remote (from
@@ -54,8 +58,8 @@ public interface ISyncServiceProvider extends IRemoteExecutionServiceProvider {
* @throws CoreException
* if synchronization fails
*/
- public void synchronize(IResourceDelta delta, SyncFileFilter filter, IProgressMonitor monitor, EnumSet<SyncFlag> syncFlags)
- throws CoreException;
+ public void synchronize(IProject project, BuildScenario buildScenario, IResourceDelta delta, SyncFileFilter filter,
+ IProgressMonitor monitor, EnumSet<SyncFlag> syncFlags) throws CoreException;
/**
* Close any resources (files, sockets) that were open by the sync provider. Resources not open by the provider should not be
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitRemoteSyncConnection.java b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitRemoteSyncConnection.java
index 88beaa0bf..a608b0b59 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitRemoteSyncConnection.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitRemoteSyncConnection.java
@@ -643,6 +643,13 @@ public class GitRemoteSyncConnection {
}
/**
+ * @return the project
+ */
+ public IProject getProject() {
+ return project;
+ }
+
+ /**
* @return the connection (IRemoteConnection)
*/
public IRemoteConnection getConnection() {
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java
index 50e5e020d..7c97bedd3 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/GitServiceProvider.java
@@ -11,7 +11,10 @@
package org.eclipse.ptp.rdt.sync.git.core;
import java.io.ByteArrayInputStream;
+import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@@ -21,13 +24,12 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.ptp.rdt.sync.core.RDTSyncCorePlugin;
+import org.eclipse.ptp.rdt.sync.core.BuildScenario;
import org.eclipse.ptp.rdt.sync.core.SyncFileFilter;
import org.eclipse.ptp.rdt.sync.core.SyncFlag;
import org.eclipse.ptp.rdt.sync.core.SyncManager;
@@ -47,19 +49,61 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
private static final String GIT_CONNECTION_NAME = "connectionName"; //$NON-NLS-1$
private static final String GIT_SERVICES_ID = "servicesId"; //$NON-NLS-1$
- private static final String GIT_PROJECT_NAME = "projectName"; //$NON-NLS-1$
- private IProject fProject = null;
private String fLocation = null;
private IRemoteConnection fConnection = null;
- private GitRemoteSyncConnection fSyncConnection = null;
- private boolean syncInfoChanged = false; // Indicates that fSyncConnection needs to be re-initialized
private boolean hasBeenSynced = false;
private static final ReentrantLock syncLock = new ReentrantLock();
- private final ReentrantLock providerLock = new ReentrantLock();
private Integer fWaitingThreadsCount = 0;
private Integer syncTaskId = -1; // ID for most recent synchronization task, functions as a time-stamp
private int finishedSyncTaskId = -1; // all synchronizations up to this ID (including it) have finished
+
+ // Simple pair class for bundling a project and build scenario.
+ // Since we use this as a key, equality testing is important.
+ private static class ProjectAndScenario {
+ private IProject project;
+ private BuildScenario scenario;
+
+ ProjectAndScenario(IProject p, BuildScenario bs) {
+ project = p;
+ scenario = bs;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((project == null) ? 0 : project.hashCode());
+ result = prime * result
+ + ((scenario == null) ? 0 : scenario.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ProjectAndScenario other = (ProjectAndScenario) obj;
+ if (project == null) {
+ if (other.project != null)
+ return false;
+ } else if (!project.equals(other.project))
+ return false;
+ if (scenario == null) {
+ if (other.scenario != null)
+ return false;
+ } else if (!scenario.equals(other.scenario))
+ return false;
+ return true;
+ }
+ }
+ private Map<ProjectAndScenario, GitRemoteSyncConnection> syncConnectionMap = Collections.synchronizedMap(
+ new HashMap<ProjectAndScenario, GitRemoteSyncConnection>());
/**
* Get the remote directory that will be used for synchronization
@@ -74,21 +118,6 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
}
/**
- * Get the project to be synchronized
- *
- * @return project
- */
- public IProject getProject() {
- if (fProject == null) {
- final String name = getString(GIT_PROJECT_NAME, null);
- if (name != null) {
- fProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- }
- }
- return fProject;
- }
-
- /**
* Get the remote connection used for synchronization
*
* @return remote connection
@@ -125,7 +154,7 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
* @see org.eclipse.ptp.services.core.IServiceProvider#isConfigured()
*/
public boolean isConfigured() {
- return getLocation() != null && getRemoteConnection() != null && getProject() != null;
+ return getLocation() != null && getRemoteConnection() != null;
}
/**
@@ -145,20 +174,6 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
}
/**
- * Set the project that will be synchronized
- *
- * @param project
- * project to synchronize
- */
- public void setProject(IProject project) {
- if (fProject != null) {
- throw new RuntimeException(Messages.GSP_ChangeProjectError);
- }
- fProject = project;
- putString(GIT_PROJECT_NAME, project.getName());
- }
-
- /**
* set the remote connection used for synchronization
*
* @param conn
@@ -188,18 +203,15 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
/*
* (non-Javadoc)
- *
- * @see org.eclipse.ptp.rdt.sync.core.serviceproviders.ISyncServiceProvider#
- * synchronize(org.eclipse.core.resources.IResourceDelta, org.eclipse.core.runtime.IProgressMonitor, boolean)
+ * @see org.eclipse.ptp.rdt.sync.core.serviceproviders.ISyncServiceProvider#synchronize(org.eclipse.core.resources.IProject, org.eclipse.core.resources.IResourceDelta, org.eclipse.ptp.rdt.sync.core.SyncFileFilter, org.eclipse.core.runtime.IProgressMonitor, java.util.EnumSet)
*/
- @SuppressWarnings("null")
- public void synchronize(IResourceDelta delta, SyncFileFilter fileFilter, IProgressMonitor monitor,
- EnumSet<SyncFlag> syncFlags) throws CoreException {
+ public void synchronize(final IProject project, BuildScenario buildScenario, IResourceDelta delta, SyncFileFilter fileFilter,
+ IProgressMonitor monitor, EnumSet<SyncFlag> syncFlags) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.GSP_SyncTaskName, 130);
+
// On first sync, place .gitignore in directories. This is useful for folders that are already present and thus are never
// captured by a resource add or change event. (This can happen for projects converted to sync projects.)
if (!hasBeenSynced) {
- final IProject project = getProject();
project.accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
if (irrelevantPath(resource.getFullPath().toString())) {
@@ -240,7 +252,7 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
// Add .gitignore to empty directories
if (delta.getResource().getType() == IResource.FOLDER
&& (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) {
- IFile emptyFile = getProject().getFile(
+ IFile emptyFile = project.getFile(
delta.getResource().getProjectRelativePath().addTrailingSeparator() + ".gitignore"); //$NON-NLS-1$
try {
if (!(emptyFile.exists())) {
@@ -323,42 +335,20 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
return;
}
- // Safely initialize or re-initialize sync connection. Note that only the thread with the sync lock can change the
- // fSyncConnection. To do so, it copies the sync information atomically first and then creates the connection.
- // Copying avoids having to lock the provider lock during the initialization, a rather involved operation that may
- // take other locks, such as the workspace lock.
- boolean initConnection = false;
- IRemoteConnection conn = null;
- IProject project = null;
- String remoteDir = null;
- providerLock.lock();
- try {
- if (fSyncConnection == null || syncInfoChanged) {
- if (fSyncConnection != null) {
- fSyncConnection.close();
- fSyncConnection = null;
- }
- syncInfoChanged = false;
- initConnection = true;
- project = this.getProject();
- conn = this.getRemoteConnection();
- remoteDir = this.getLocation();
- }
- } finally {
- providerLock.unlock();
+ if (buildScenario == null) {
+ throw new RuntimeException(Messages.GitServiceProvider_3 + project.getName());
}
-
- if (initConnection && (project == null || conn == null || remoteDir == null)) {
- RDTSyncCorePlugin.log(Messages.GitServiceProvider_0);
- } else if (initConnection) {
- fSyncConnection = new GitRemoteSyncConnection(project, conn, project.getLocation().toString(), remoteDir, fileFilter, progress);
- } else {
- fSyncConnection.setFileFilter(fileFilter);
+ ProjectAndScenario pas = new ProjectAndScenario(project, buildScenario);
+ if (!syncConnectionMap.containsKey(pas)) {
+ syncConnectionMap.put(pas, new GitRemoteSyncConnection(project, buildScenario.getRemoteConnection(),
+ project.getLocation().toString(), buildScenario.getLocation(project), fileFilter, progress));
}
-
+ GitRemoteSyncConnection fSyncConnection = syncConnectionMap.get(pas);
+ fSyncConnection.setFileFilter(fileFilter);
+
// Open remote connection if necessary
- if (this.getRemoteConnection().isOpen() == false) {
- this.getRemoteConnection().open(progress.newChild(10));
+ if (buildScenario.getRemoteConnection().isOpen() == false) {
+ buildScenario.getRemoteConnection().open(progress.newChild(10));
}
// This synchronization operation will include all tasks up to current syncTaskId
@@ -379,10 +369,10 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
finishedSyncTaskId = willFinishTaskId;
// TODO: Review exception handling
} catch (final RemoteSyncException e) {
- this.handleRemoteSyncException(e, syncFlags);
+ this.handleRemoteSyncException(project, e, syncFlags);
return;
} catch (RemoteConnectionException e) {
- this.handleRemoteSyncException(new RemoteSyncException(e), syncFlags);
+ this.handleRemoteSyncException(project, new RemoteSyncException(e), syncFlags);
return;
} finally {
syncLock.unlock();
@@ -390,12 +380,10 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
// Sync successful - re-enable error messages. This is really UI code, but there is no way at the moment to notify UI
// of a successful sync.
- SyncManager.setShowErrors(getProject(), true);
-
- IProject project = this.getProject();
- if (project != null) {
- project.refreshLocal(IResource.DEPTH_INFINITE, progress.newChild(20));
- }
+ SyncManager.setShowErrors(project, true);
+
+ // Refresh after sync to display changes
+ project.refreshLocal(IResource.DEPTH_INFINITE, progress.newChild(20));
} finally {
if (monitor != null) {
monitor.done();
@@ -413,7 +401,8 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
* @throws RemoteSyncException
* for non-forced syncs
*/
- private void handleRemoteSyncException(RemoteSyncException e, EnumSet<SyncFlag> syncFlags) throws RemoteSyncException {
+ private void handleRemoteSyncException(IProject project, RemoteSyncException e, EnumSet<SyncFlag> syncFlags)
+ throws RemoteSyncException {
if (syncFlags == SyncFlag.NO_FORCE) {
throw e;
}
@@ -423,10 +412,10 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
// RemoteSyncException is generally used by either creating a new exception with a message describing the problem or by
// embedding another type of error. So we need to decide which message to use.
if ((e.getMessage() != null && e.getMessage().length() > 0) || e.getCause() == null) {
- message = Messages.GSP_SyncErrorMessage + this.getProject().getName()
+ message = Messages.GSP_SyncErrorMessage + project.getName()
+ ":" + endOfLineChar + endOfLineChar + e.getMessage(); //$NON-NLS-1$
} else {
- message = Messages.GSP_SyncErrorMessage + this.getProject().getName()
+ message = Messages.GSP_SyncErrorMessage + project.getName()
+ ":" + endOfLineChar + endOfLineChar + e.getCause().getMessage(); //$NON-NLS-1$
}
@@ -473,11 +462,8 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
* @see org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider#setRemoteToolsConnection()
*/
public void setRemoteToolsConnection(IRemoteConnection connection) {
- providerLock.lock();
fConnection = connection;
putString(GIT_CONNECTION_NAME, connection.getName());
- syncInfoChanged = true;
- providerLock.unlock();
}
/*
@@ -486,18 +472,14 @@ public class GitServiceProvider extends ServiceProvider implements ISyncServiceP
* @see org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider#setConfigLocation()
*/
public void setConfigLocation(String configLocation) {
- providerLock.lock();
fLocation = configLocation;
putString(GIT_LOCATION, configLocation);
- syncInfoChanged = true;
- providerLock.unlock();
}
@Override
public void close() {
- if (fSyncConnection != null) {
- fSyncConnection.close();
- fSyncConnection = null; // get reinitialized by next synchronize call
+ for (GitRemoteSyncConnection conn : syncConnectionMap.values()) {
+ conn.close();
}
}
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/Messages.java b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/Messages.java
index a16ca9a15..a5640bfc4 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/Messages.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/Messages.java
@@ -39,6 +39,7 @@ public class Messages extends NLS {
public static String GitServiceProvider_0;
public static String GitServiceProvider_1;
public static String GitServiceProvider_2;
+ public static String GitServiceProvider_3;
static {
// initialize resource bundle
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/messages.properties b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/messages.properties
index ad0455ef0..0932bd448 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/messages.properties
+++ b/rdt/org.eclipse.ptp.rdt.sync.git.core/src/org/eclipse/ptp/rdt/sync/git/core/messages/messages.properties
@@ -32,4 +32,5 @@ GitRemoteSyncConnection_sync_local_to_remote=Sync local to remote...
GitRemoteSyncConnection_sync_remote_to_local=Sync remote to local...
GitServiceProvider_0=Unable to retrieve information needed to create sync connection
GitServiceProvider_1=Synchronization canceled
-GitServiceProvider_2=Synchronization interrupted \ No newline at end of file
+GitServiceProvider_2=Synchronization interrupted
+GitServiceProvider_3=Unable to find build scenario for project:
diff --git a/rdt/org.eclipse.ptp.rdt.sync.git.ui/src/org/eclipse/ptp/rdt/sync/git/ui/GitParticipant.java b/rdt/org.eclipse.ptp.rdt.sync.git.ui/src/org/eclipse/ptp/rdt/sync/git/ui/GitParticipant.java
index 6dc58a363..a5977bf9c 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.git.ui/src/org/eclipse/ptp/rdt/sync/git/ui/GitParticipant.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.git.ui/src/org/eclipse/ptp/rdt/sync/git/ui/GitParticipant.java
@@ -275,8 +275,7 @@ public class GitParticipant implements ISynchronizeParticipant {
* (non-Javadoc)
*
* @see
- * org.eclipse.ptp.rdt.sync.ui.ISynchronizeParticipant#getProvider(org.eclipse
- * .core.resources.IProject)
+ * org.eclipse.ptp.rdt.sync.ui.ISynchronizeParticipant#getProvider(org.eclipse.core.resources.IProject)
*/
public ISyncServiceProvider getProvider(IProject project) {
ServiceModelManager smm = ServiceModelManager.getInstance();
@@ -286,7 +285,6 @@ public class GitParticipant implements ISynchronizeParticipant {
provider.setLocation(fLocationText.getText());
provider.setRemoteConnection(fSelectedConnection);
provider.setRemoteServices(fSelectedProvider);
- provider.setProject(project);
return provider;
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/ResourceChangeListener.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/ResourceChangeListener.java
index af76b4528..63374e37c 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/ResourceChangeListener.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/ResourceChangeListener.java
@@ -19,14 +19,12 @@ import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.ptp.rdt.sync.core.RDTSyncCorePlugin;
import org.eclipse.ptp.rdt.sync.core.SyncExceptionHandler;
import org.eclipse.ptp.rdt.sync.core.SyncFlag;
import org.eclipse.ptp.rdt.sync.core.SyncManager;
import org.eclipse.ptp.rdt.sync.ui.messages.Messages;
import org.eclipse.ptp.rdt.sync.core.SyncManager.SYNC_MODE;
import org.eclipse.ptp.rdt.sync.core.resources.RemoteSyncNature;
-import org.eclipse.ptp.rdt.sync.core.serviceproviders.ISyncServiceProvider;
import org.eclipse.swt.widgets.Display;
public class ResourceChangeListener {
@@ -91,11 +89,7 @@ public class ResourceChangeListener {
if (!RemoteSyncNature.hasNature(project)) {
return;
}
- SyncManager.setSyncMode(project, SYNC_MODE.NONE);
- ISyncServiceProvider provider = SyncManager.getSyncProvider(project);
- if (provider != null) {
- provider.close();
- }
+ SyncManager.setSyncMode(project, SYNC_MODE.UNAVAILABLE);
return;
}
for (IResourceDelta delta : event.getDelta().getAffectedChildren()) {
@@ -105,15 +99,15 @@ public class ResourceChangeListener {
}
if (RemoteSyncNature.hasNature(project)) {
SYNC_MODE syncMode = SyncManager.getSyncMode(project);
- boolean syncEnabled = true;
+ boolean syncOn = true;
if (!(SyncManager.getSyncAuto()) || syncMode == SYNC_MODE.NONE) {
- syncEnabled = false;
+ syncOn = false;
}
try {
// Post-build event
// Force a sync in order to download any new remote files but no need to sync if sync'ing is disabled.
if (event.getType() == IResourceChangeEvent.POST_BUILD ) {
- if (!syncEnabled) {
+ if (!syncOn || syncMode == SYNC_MODE.UNAVAILABLE) {
continue;
} else if (syncMode == SYNC_MODE.ALL) {
SyncManager.syncAll(null, project, SyncFlag.FORCE, new SyncRCLExceptionHandler(project));
@@ -122,10 +116,13 @@ public class ResourceChangeListener {
}
}
// Post-change event
- // Do a non-forced sync to update any changes reported in delta. Sync'ing is necessary even if user has
- // disabled it. This allows for some bookkeeping but no files are transferred.
- else {
- if (!syncEnabled) {
+ // Sync on all CHANGED events
+ else if (delta.getKind() == IResourceDelta.CHANGED) {
+ // Do a non-forced sync to update any changes reported in delta. Sync'ing is necessary even if user has
+ // turned it off. This allows for some bookkeeping but no files are transferred.
+ if (syncMode == SYNC_MODE.UNAVAILABLE) {
+ continue;
+ } else if (!syncOn) {
SyncManager.sync(delta, project, SyncFlag.NO_SYNC, null);
} else if (syncMode == SYNC_MODE.ALL) {
SyncManager.syncAll(delta, project, SyncFlag.NO_FORCE, new SyncRCLExceptionHandler(project));
@@ -135,7 +132,7 @@ public class ResourceChangeListener {
}
} catch (CoreException e){
// This should never happen because only a blocking sync can throw a core exception, and all syncs here are non-blocking.
- RDTSyncCorePlugin.log(Messages.ResourceChangeListener_0);
+ RDTSyncUIPlugin.log(Messages.ResourceChangeListener_0, e);
}
}
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncFileFilterPage.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncFileFilterPage.java
index 349377eeb..f05a445ec 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncFileFilterPage.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncFileFilterPage.java
@@ -622,7 +622,7 @@ public class SyncFileFilterPage extends ApplicationWindow implements IWorkbenchP
// System error handled by BuildConfigurationManager
remoteFiles = null;
} else {
- remoteFiles = new RemoteContentProvider(bs.getRemoteConnection(), new Path(bs.getLocation()), project);
+ remoteFiles = new RemoteContentProvider(bs.getRemoteConnection(), new Path(bs.getLocation(project)), project);
}
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncMenuOperation.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncMenuOperation.java
index b3933f195..c9344ff69 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncMenuOperation.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/SyncMenuOperation.java
@@ -142,7 +142,7 @@ public class SyncMenuOperation extends AbstractHandler implements IElementUpdate
SYNC_MODE syncMode = SyncManager.getSyncMode(project);
if ((command.equals(setActiveCommand) && syncMode == SYNC_MODE.ACTIVE) ||
(command.equals(setAllCommand) && syncMode == SYNC_MODE.ALL) ||
- (command.equals(setNoneCommand) && syncMode == SYNC_MODE.NONE) ||
+ (command.equals(setNoneCommand) && (syncMode == SYNC_MODE.NONE || syncMode == SYNC_MODE.UNAVAILABLE)) ||
(command.equals(syncAutoCommand) && SyncManager.getSyncAuto())) {
element.setChecked(true);
} else {
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/Messages.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/Messages.java
index 2635d8e0c..dfc79dab6 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/Messages.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/Messages.java
@@ -33,6 +33,7 @@ public class Messages extends NLS {
public static String RemoteSyncWizardPage_0;
public static String RemoteSyncWizardPage_description;
public static String ResourceChangeListener_0;
+ public static String ResourceChangeListener_1;
public static String SyncFileFilterPage_0;
public static String SyncFileFilterPage_1;
public static String SyncFileFilterPage_10;
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/messages.properties b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/messages.properties
index 6ba711e47..73fb645df 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/messages.properties
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/messages/messages.properties
@@ -22,6 +22,7 @@ ConvertToSyncProjectWizardPage_convertingToSyncProject=Converting to sync projec
RemoteSyncWizardPage_0=Configure Remote Synchronization
RemoteSyncWizardPage_description=Configure synchronization for the remote project
ResourceChangeListener_0=Unexpected core exception on non-blocking sync call
+ResourceChangeListener_1=Unable to get sync provider for moved project
WizardProjectConversion_windowLabel=Convert Projects
NewRemoteSyncProjectWizard_description=Create synchronized project of the selected type
NewRemoteSyncProjectWizard_title=New Synchronized Project
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/properties/BuildRemotePropertiesPage.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/properties/BuildRemotePropertiesPage.java
index bdaea8e66..b5cb49835 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/properties/BuildRemotePropertiesPage.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/properties/BuildRemotePropertiesPage.java
@@ -443,7 +443,8 @@ public class BuildRemotePropertiesPage extends AbstractSingleBuildPage {
PageSettings settings = new PageSettings();
settings.remoteProvider = buildScenario.getRemoteConnection().getRemoteServices();
settings.connection = buildScenario.getRemoteConnection();
- settings.rootLocation = buildScenario.getLocation();
+ IProject project = config.getOwner().getProject();
+ settings.rootLocation = buildScenario.getLocation(project);
return settings;
}
diff --git a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/wizards/RemoteSyncWizardPageOperation.java b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/wizards/RemoteSyncWizardPageOperation.java
index 16bf7cccf..81e7b9fa2 100644
--- a/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/wizards/RemoteSyncWizardPageOperation.java
+++ b/rdt/org.eclipse.ptp.rdt.sync.ui/src/org/eclipse/ptp/rdt/sync/ui/wizards/RemoteSyncWizardPageOperation.java
@@ -128,6 +128,9 @@ public class RemoteSyncWizardPageOperation implements IRunnableWithProgress {
SyncManager.saveFileFilter(project, customFilter);
}
monitor.done();
+
+ // Enable sync'ing
+ SyncManager.setSyncMode(project, SyncManager.SYNC_MODE.ACTIVE);
}
private static Object getMBSProperty(String propertyId) {

Back to the top