PTP
Release 7.0

org.eclipse.ptp.rdt.sync.core
Class SyncConfigManager

java.lang.Object
  extended by org.eclipse.ptp.rdt.sync.core.SyncConfigManager

public class SyncConfigManager
extends java.lang.Object

Main class for managing sync configurations

Since:
3.0

Method Summary
static void addConfig(IProject project, SyncConfig config)
          Add a new sync configuration to the project
static void addSyncConfigListener(java.lang.String natureId, ISyncConfigListener listener)
          Register to receive sync configuration events.
static SyncConfig getActive(IProject project)
          Get the active configuration for the project.
static java.net.URI getActiveSyncLocationURI(IResource resource)
          Get the synchronize location URI of the resource associated with the active sync configuration.
static SyncConfig getConfig(IProject project, java.lang.String name)
          Find a configuration by name
static SyncConfig[] getConfigs(IProject project)
          Get the sync configurations associated with the project
static SyncConfig getLocalConfig(ISynchronizeService syncService)
          Get a local sync config, really a config that does no sync'ing, for when the user wants to just work locally.
static java.net.URI getSyncLocationURI(SyncConfig config, IResource resource)
          Get the synchronize location URI of the resource associated with the sync configuration.
static boolean isActive(IProject project, SyncConfig config)
          Check if this config is active for the project.
static boolean isLocal(SyncConfig config)
          Return whether the config is local (no sync'ing is done) This definition must agree with how local configs are created in #getLocalConfig().
static boolean isRemote(SyncConfig config)
          Return whether the config is remote (sync'ing is done)
static SyncConfig newConfig(java.lang.String name, java.lang.String providerId, IRemoteConnection conn, java.lang.String location)
           
static SyncConfig newConfig(java.lang.String name, java.lang.String providerId, java.lang.String remoteServicesId, java.lang.String connName, java.lang.String location)
           
static void removeConfig(IProject project, SyncConfig config)
          Remove the sync configuration from the project.
static void removeSyncConfigListener(java.lang.String natureId, ISyncConfigListener listener)
          Remove the listener for sync config events
static void saveConfigs(IProject project)
          Save the current configurations for the project.
static void setActive(IProject project, SyncConfig config)
          Set the active sync configuration for the project.
static void updateConfigs(IProject project, SyncConfig[] addedConfigs, SyncConfig[] removedConfigs)
          Batch update configurations for the project
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addConfig

public static void addConfig(IProject project,
                             SyncConfig config)
Add a new sync configuration to the project

Parameters:
project - project
config - sync configuration to add to the project

addSyncConfigListener

public static void addSyncConfigListener(java.lang.String natureId,
                                         ISyncConfigListener listener)
Register to receive sync configuration events.

Parameters:
natureId - project nature ID of projects to notify of changes
listener - listener to receive events

getActive

public static SyncConfig getActive(IProject project)
Get the active configuration for the project. There is always at least one active configuration for every project. Returns null if the project is not a synchronized project.

Parameters:
project -
Returns:
active configuration

getActiveSyncLocationURI

public static java.net.URI getActiveSyncLocationURI(IResource resource)
                                             throws CoreException
Get the synchronize location URI of the resource associated with the active sync configuration. Returns null if the project containing the resource is not a synchronized project.

Parameters:
resource - target resource - cannot be null
Returns:
URI or null if not a sync project
Throws:
CoreException

getConfig

public static SyncConfig getConfig(IProject project,
                                   java.lang.String name)
Find a configuration by name

Parameters:
project - project containing configuration
name - name of configuration
Returns:
configuration or null if no configuration with supplied name found

getConfigs

public static SyncConfig[] getConfigs(IProject project)
Get the sync configurations associated with the project

Parameters:
project -
Returns:
sync configurations for the project

getLocalConfig

public static SyncConfig getLocalConfig(ISynchronizeService syncService)
                                 throws CoreException
Get a local sync config, really a config that does no sync'ing, for when the user wants to just work locally. This method must agree with isLocal(SyncConfig).

Returns:
a local config
Throws:
CoreException - on problems retrieving local service elements

getSyncLocationURI

public static java.net.URI getSyncLocationURI(SyncConfig config,
                                              IResource resource)
                                       throws CoreException
Get the synchronize location URI of the resource associated with the sync configuration. Returns null if the sync configuration has not been configured correctly.

Parameters:
config - sync configuration
resource - target resource
Returns:
URI or null if not correctly configured
Throws:
CoreException

isActive

public static boolean isActive(IProject project,
                               SyncConfig config)
Check if this config is active for the project.

Parameters:
project -
config -
Returns:
true if this config is the active config for the project

isLocal

public static boolean isLocal(SyncConfig config)
Return whether the config is local (no sync'ing is done) This definition must agree with how local configs are created in #getLocalConfig().

Parameters:
config -
Returns:
whether config is local

isRemote

public static boolean isRemote(SyncConfig config)
Return whether the config is remote (sync'ing is done)

Parameters:
config -
Returns:
whether config is remote

newConfig

public static SyncConfig newConfig(java.lang.String name,
                                   java.lang.String providerId,
                                   IRemoteConnection conn,
                                   java.lang.String location)
Parameters:
name -
providerId -
conn -
location -
Returns:

newConfig

public static SyncConfig newConfig(java.lang.String name,
                                   java.lang.String providerId,
                                   java.lang.String remoteServicesId,
                                   java.lang.String connName,
                                   java.lang.String location)
Parameters:
name -
providerId -
remoteServicesId -
connName -
location -
Returns:

removeConfig

public static void removeConfig(IProject project,
                                SyncConfig config)
Remove the sync configuration from the project. Note that this methods allows an active configuration to be removed. Clients should check the active status of the configuration and call setActive(IProject, SyncConfig) if necessary. Clients will not be allowed to remove all configurations from the project. There must always be at least one configuration for each project.

Parameters:
project - project
config - configuration to remove

removeSyncConfigListener

public static void removeSyncConfigListener(java.lang.String natureId,
                                            ISyncConfigListener listener)
Remove the listener for sync config events

Parameters:
natureId -
listener -

saveConfigs

public static void saveConfigs(IProject project)
                        throws CoreException
Save the current configurations for the project. This method should be called prior to workbench shutdown if any modifications have been made to the configurations

Parameters:
project -
Throws:
CoreException

setActive

public static void setActive(IProject project,
                             SyncConfig config)
Set the active sync configuration for the project. Automatically deselects the current active configuration.

Parameters:
project -
config -

updateConfigs

public static void updateConfigs(IProject project,
                                 SyncConfig[] addedConfigs,
                                 SyncConfig[] removedConfigs)
Batch update configurations for the project

Parameters:
project - project to update
addedConfigs - configs to be added
removedConfigs - configs to be removed

PTP
Release 7.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.