public abstract class RepositoryProvider extends Object implements IProjectNature, IAdaptable
RepositoryProvider
is created for each
project that is associated with a repository provider. The lifecycle of these
instances is is similar to that of the platform's 'nature' mechanism.
To create a repository provider and have it registered with the platform, a client must minimally:
RepositoryProvider
plugin.xml
.
Here is an example extension point definition:
<extension point="org.eclipse.team.core.repository">
<repository
class="org.eclipse.myprovider.MyRepositoryProvider"
id="org.eclipse.myprovider.myProviderID">
</repository>
</extension>
Once a repository provider is registered with Team, then you
can associate a repository provider with a project by invoking RepositoryProvider.map()
.
map(IProject, String)
Constructor and Description |
---|
RepositoryProvider()
Default constructor required for the resources plugin to instantiate this class from
the nature extension definition.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canHandleLinkedResources()
Deprecated.
|
boolean |
canHandleLinkedResourceURI()
Return whether this repository provider can handle linked resources that
are located via a URI (i.e. may not be on the local file system) or occur
at an arbitrary depth in the project.
|
void |
configure()
Configures the nature for the given project.
|
abstract void |
configureProject()
Configures the provider for the given project.
|
protected void |
deconfigured()
Method deconfigured is invoked after a provider has been unmaped.
|
Object |
getAdapter(Class adapter)
Returns an object which is an instance of the given class
associated with this object.
|
static String[] |
getAllProviderTypeIds()
Returns all known (registered) RepositoryProvider ids.
|
IFileHistoryProvider |
getFileHistoryProvider()
Returns an
IFileHistoryProvider which can be used to access
file histories. |
IFileModificationValidator |
getFileModificationValidator()
Deprecated.
|
FileModificationValidator |
getFileModificationValidator2()
Returns a
FileModificationValidator for pre-checking operations
that modify the contents of files. |
abstract String |
getID()
Answer the id of this provider instance.
|
IMoveDeleteHook |
getMoveDeleteHook()
Returns an
IMoveDeleteHook for handling moves and deletes
that occur within projects managed by the provider. |
IProject |
getProject()
Returns the project to which this project nature applies.
|
static RepositoryProvider |
getProvider(IProject project)
Returns the provider for a given IProject or
null if a provider is not associated with
the project or if the project is closed or does not exist. |
static RepositoryProvider |
getProvider(IProject project,
String id)
Returns a provider of type with the given id if associated with the given project
or
null if the project is not associated with a provider of that type
or the nature id is that of a non-team repository provider nature. |
IResourceRuleFactory |
getRuleFactory()
Return the resource rule factory for this provider.
|
Subscriber |
getSubscriber()
Return a
Subscriber that describes the synchronization state
of the resources contained in the project associated with this
provider. |
static boolean |
isShared(IProject project)
Returns whether the given project is shared or not.
|
static void |
map(IProject project,
String id)
Instantiate a new RepositoryProvider with concrete class by given providerID
and associate it with project.
|
void |
setProject(IProject project)
Sets the project to which this nature applies.
|
String |
toString()
Returns a brief description of this provider.
|
static void |
unmap(IProject project)
Disassociates project with the repository provider its currently mapped to.
|
IStatus |
validateCreateLink(IResource resource,
int updateFlags,
IPath location)
Deprecated.
see
validateCreateLink(IResource, int, URI) instead |
IStatus |
validateCreateLink(IResource resource,
int updateFlags,
URI location)
Method validateCreateLink is invoked by the Platform Core TeamHook when a
linked resource is about to be added to the provider's project.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deconfigure
public RepositoryProvider()
public static void map(IProject project, String id) throws TeamException
project
- the project to be mappedid
- the ID of the provider to be mapped to the projectTeamException
- if
unmap(IProject)
public static void unmap(IProject project) throws TeamException
project
- TeamException
- The project isn't associated with any repository provider.public abstract void configureProject() throws CoreException
setProject
.
If an exception is generated during configuration
of the project, the provider will not be assigned to the project.CoreException
- if the configuration fails.public final void configure() throws CoreException
RepositoryProvider.map()
the first time a provider is mapped to a project. It is not intended to be called by clients.configure
in interface IProjectNature
CoreException
- if this method fails. If the configuration fails the provider will not be
associated with the project.configureProject()
protected void deconfigured()
public abstract String getID()
public IFileModificationValidator getFileModificationValidator()
getFileModificationValidator2()
IFileModificationValidator
for pre-checking operations
that modify the contents of files.
Returns null
if the provider does not wish to participate in
file modification validation.IFileModificationValidator
for pre-checking operations
that modify the contents of filesIFileModificationValidator
public FileModificationValidator getFileModificationValidator2()
FileModificationValidator
for pre-checking operations
that modify the contents of files. Returns null
if the
provider does not wish to participate in file modification validation. By
default, this method wraps the old validator returned from
getFileModificationValidator()
. Subclasses that which to remain
backwards compatible while providing this new API should override
getFileModificationValidator2()
to return a subclass of
FileModificationValidator
and should return the same
validator from getFileModificationValidator()
.
This method is not intended to be called by clients. Clients should
use the IWorkspace.validateEdit(IFile[], Object)
method instead.
FileModificationValidator
for pre-checking
operations that modify the contents of filesFileModificationValidator
,
IWorkspace.validateEdit(IFile[], Object)
public IFileHistoryProvider getFileHistoryProvider()
IFileHistoryProvider
which can be used to access
file histories. By default, returns null
. Subclasses may override.IFileHistoryProvider
which can be used to access
file histories.public IMoveDeleteHook getMoveDeleteHook()
IMoveDeleteHook
for handling moves and deletes
that occur within projects managed by the provider. This allows providers
to control how moves and deletes occur and includes the ability to prevent them.
Returning null
signals that the default move and delete behavior is desired.
IMoveDeleteHook
for handling moves and deletes
that occur within projects managed by the providerIMoveDeleteHook
public String toString()
public static final String[] getAllProviderTypeIds()
public static final RepositoryProvider getProvider(IProject project)
null
if a provider is not associated with
the project or if the project is closed or does not exist. This method should be called if the caller
is looking for any repository provider. Otherwise call getProvider(project, id)
to look for a specific repository provider type.
project
- the project to query for a providerpublic static final RepositoryProvider getProvider(IProject project, String id)
null
if the project is not associated with a provider of that type
or the nature id is that of a non-team repository provider nature.project
- the project to query for a providerid
- the repository provider idpublic static boolean isShared(IProject project)
getProvider
would) if one is not already instantiated.
Note that IProject.touch() generates a project description delta. This, in combination
with isShared() can be used to be notified of sharing/unsharing of projects.project
- the project being tested.getProvider(IProject)
public IProject getProject()
IProjectNature
getProject
in interface IProjectNature
public void setProject(IProject project)
IProjectNature
IProject.create()
or
IProject.setDescription()
and should not be called directly by clients.setProject
in interface IProjectNature
project
- the project to which this nature appliespublic IStatus validateCreateLink(IResource resource, int updateFlags, IPath location)
validateCreateLink(IResource, int, URI)
insteadcanHandleLinkedResources()
method.resource
- see org.eclipse.core.resources.team.TeamHook
updateFlags
- see org.eclipse.core.resources.team.TeamHook
location
- see org.eclipse.core.resources.team.TeamHook
org.eclipse.core.resources.team.TeamHook
canHandleLinkedResources()
public IStatus validateCreateLink(IResource resource, int updateFlags, URI location)
canHandleLinkedResourcesAtArbitraryDepth()
method.resource
- see org.eclipse.core.resources.team.TeamHook
updateFlags
- see org.eclipse.core.resources.team.TeamHook
location
- see org.eclipse.core.resources.team.TeamHook
org.eclipse.core.resources.team.TeamHook
canHandleLinkedResourceURI()
public boolean canHandleLinkedResources()
canHandleLinkedResourceURI()
IMoveDeleteHook
. This method is
called after the RepositoryProvider is instantiated but before
setProject()
is invoked so it will not have access to any
state determined from the setProject()
method.IMoveDeleteHook
public boolean canHandleLinkedResourceURI()
setProject()
is invoked so it will not have access to any state determined from the
setProject()
method.validateCreateLink(IResource, int, URI)
public Object getAdapter(Class adapter)
IAdaptable
null
if
no such object can be found.getAdapter
in interface IAdaptable
adapter
- the adapter class to look upnull
if this object does not
have an adapter for the given classpublic IResourceRuleFactory getRuleFactory()
By default, the factory returned by this method is pessimistic and
obtains the workspace lock for all operations that could result in a
callback to the provider (either through the IMoveDeleteHook
or IFileModificationValidator
). This is done to ensure that
older providers are not broken. However, providers should override this
method and provide a subclass of ResourceRuleFactory
that provides rules of a more optimistic granularity (e.g. project
or lower).
ResourceRuleFactory
public final Subscriber getSubscriber()
Subscriber
that describes the synchronization state
of the resources contained in the project associated with this
provider. The subscriber is obtained from the RepositoryProviderType
associated with a provider and is thus shared for all providers of the
same type.null
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.