diff options
author | Jean Michel-Lemieux | 2004-02-25 20:34:58 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2004-02-25 20:34:58 +0000 |
commit | 4a1ca77df6f4238416a8715a8c35819611d5992a (patch) | |
tree | 03e4ed09e94442352cb8c3143df59d3b22725627 /examples/org.eclipse.team.examples.filesystem/src | |
parent | a650f9521c18cb3c840475358086bf5f4052a824 (diff) | |
download | eclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.tar.gz eclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.tar.xz eclipse.platform.team-4a1ca77df6f4238416a8715a8c35819611d5992a.zip |
SyncView API released to HEAD.
Diffstat (limited to 'examples/org.eclipse.team.examples.filesystem/src')
10 files changed, 567 insertions, 39 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java index 6020049bd..909e30733 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java @@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations; /** * This class models a sentry that verifies whether resources are available for editing or overwriting. @@ -32,15 +31,13 @@ public final class FileModificationValidator implements IFileModificationValidat //Used to avoid creating multiple copies of the OK status: private static final IStatus OK_STATUS = new Status(Status.OK, FileSystemPlugin.ID, Status.OK, Policy.bind("ok"), null); //$NON-NLS-1$ - private RepositoryProvider provider; private SimpleAccessOperations operations; /** * Constructor for FileModificationValidator. */ public FileModificationValidator(RepositoryProvider provider) { - this.provider = provider; - operations = provider.getSimpleAccess(); + operations = ((FileSystemProvider)provider).getSimpleAccess(); } /** diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java index 2fae985be..60f64c48b 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java @@ -19,7 +19,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations; /** * This example illustrates how to create a concrete implementation of a <code>RepositoryProvider</code> diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java index d8b2db061..5df6b25e6 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java @@ -10,28 +10,18 @@ *******************************************************************************/ package org.eclipse.team.examples.filesystem; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.*; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.sync.IRemoteResource; /** * Class represents a handle to a <code>java.io.File</code> that conforms to - * the <code>org.eclipse.team.core.IRemoteResource</code> interface. + * the <code>org.eclipse.team.core.IResourceVariant</code> interface. */ -public class FileSystemRemoteResource implements IRemoteResource, IStorage { +public class FileSystemRemoteResource implements IAdaptable, IStorage { // the file object in which the data is stored on the disk private File ioFile; @@ -66,7 +56,7 @@ public class FileSystemRemoteResource implements IRemoteResource, IStorage { * Returns an input stream containing the contents of the remote resource. * The remote resource must be a file. * - * @see org.eclipse.team.core.sync.IRemoteResource#getContents(IProgressMonitor) + * @see org.eclipse.team.core.sync.IResourceVariant#getContents(IProgressMonitor) */ public InputStream getContents(IProgressMonitor progress) throws TeamException { if (isContainer()) @@ -88,14 +78,14 @@ public class FileSystemRemoteResource implements IRemoteResource, IStorage { } /** - * @see org.eclipse.team.core.sync.IRemoteResource#getName() + * @see org.eclipse.team.core.sync.IResourceVariant#getName() */ public String getName() { return ioFile.getName(); } /** - * @see org.eclipse.team.core.sync.IRemoteResource#isContainer() + * @see org.eclipse.team.core.sync.IResourceVariant#isContainer() */ public boolean isContainer() { return ioFile.isDirectory(); @@ -105,16 +95,16 @@ public class FileSystemRemoteResource implements IRemoteResource, IStorage { * Fetch the members of the remote resource. The remote resource must be a * container. * - * @see org.eclipse.team.core.sync.IRemoteResource#members(IProgressMonitor) + * @see org.eclipse.team.core.sync.IResourceVariant#members(IProgressMonitor) */ - public IRemoteResource[] members(IProgressMonitor progress) throws TeamException { + public FileSystemRemoteResource[] members(IProgressMonitor progress) throws TeamException { // Make sure we have a container if (!isContainer()) throw new TeamException(Policy.bind("RemoteResource.mustBeFolder", ioFile.getName())); //$NON-NLS-1$ // convert the File children to remote resource children File[] members = ioFile.listFiles(); - IRemoteResource[] result = new IRemoteResource[members.length]; + FileSystemRemoteResource[] result = new FileSystemRemoteResource[members.length]; for (int i = 0; i < members.length; i++) { result[i] = new FileSystemRemoteResource(members[i]); } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java index 87852220a..b80a9d2e5 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java @@ -10,21 +10,11 @@ *******************************************************************************/ package org.eclipse.team.examples.filesystem; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.sync.IRemoteResource; -import org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations; -import org.eclipse.team.examples.filesystem.Policy; /** * SimpleAccessOperations is not part of the Team API. We use it here because it provides @@ -95,7 +85,7 @@ public class FileSystemSimpleAccessOperations implements SimpleAccessOperations } } else if (depth > 0) { //Assume that resources are either files or containers. //If the resource is a container, copy its children over. - IRemoteResource[] estranged = remote.members(progress); + FileSystemRemoteResource[] estranged = remote.members(progress); IResource[] children = new IResource[estranged.length]; if (resources[i].getType() == IResource.PROJECT) { diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSubscriber.java new file mode 100644 index 000000000..50ab30efb --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSubscriber.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.IResourceVariant; +import org.eclipse.team.core.synchronize.IResourceVariantComparator; +import org.eclipse.team.internal.core.subscribers.caches.SyncTreeSubscriber; + + +public class FileSystemSubscriber extends SyncTreeSubscriber { + + /* (non-Javadoc) + * @see org.eclipse.team.internal.core.subscribers.caches.SyncTreeSubscriber#getRemoteResource(org.eclipse.core.resources.IResource) + */ + public IResourceVariant getRemoteResource(IResource resource) throws TeamException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.core.subscribers.caches.SyncTreeSubscriber#getBaseResource(org.eclipse.core.resources.IResource) + */ + public IResourceVariant getBaseResource(IResource resource) throws TeamException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.core.subscribers.caches.SyncTreeSubscriber#hasRemote(org.eclipse.core.resources.IResource) + */ + protected boolean hasRemote(IResource resource) throws TeamException { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.core.subscribers.caches.SyncTreeSubscriber#getResourceComparator() + */ + public IResourceVariantComparator getResourceComparator() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.Subscriber#getName() + */ + public String getName() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.Subscriber#isSupervised(org.eclipse.core.resources.IResource) + */ + public boolean isSupervised(IResource resource) throws TeamException { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.Subscriber#roots() + */ + public IResource[] roots() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.Subscriber#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor) + */ + public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { + // TODO Auto-generated method stub + + } +} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/SimpleAccessOperations.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/SimpleAccessOperations.java new file mode 100644 index 000000000..ce5f0c0d4 --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/SimpleAccessOperations.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; + +/* + * This class represents provisional API. Its here to allow experimentation with 3rd party tools + * calling providers in a repository neutral manner. + * + * A provider is not required to implement this API. + * Implementers, and those who reference it, do so with the awareness that this class may be + * removed or substantially changed at future times without warning. + * + * The <code>SimpleAccessOperations</code> class exposes a basic repository model that + * providers may implement to allow third-party plugins to perform repository operations + * programmatically. For example, a code generation tool may want to get source + * files before generating the code, and check-in the results. If a provider plugin does + * not adhere to the <i>semantics</i> of the <code>SimpleAccessOperations</code> class + * as described, they are free to opt out of implementing it. + * + * @since 2.0 + */ +public interface SimpleAccessOperations { + /* + * Updates the local resource to have the same content as the corresponding remote + * resource. Where the local resource does not exist, this method will create it. + * <p> + * If the remote resource is a container (e.g. folder or project) this operation is equivalent + * to getting each non-container member of the remote resource, thereby updating the + * content of existing local members, creating local members to receive new remote resources, + * and deleting local members that no longer have a corresponding remote resource.</p> + * <p> + * The method is applied to all resources satisfying the depth parameter, described above.</p> + * <p> + * Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.</p> + * + * @param resources an array of local resources to update from the corresponding remote + * resources. + * @param depth the depth to traverse the given resources, taken from <code>IResource</code> + * static constants. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamException if there is a problem getting one or more of the resources. The + * exception will contain multiple statuses, one for each resource in the <code>resources</code> + * array. Possible status codes include: + * <ul> + * <li>NO_REMOTE_RESOURCE</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + */ + public void get(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; + + /* + * Changes the state of the local resource from checked-in to checked-out and transfers the content + * of the remote resource to the local resource. + * <p> + * Where no corresponding local resource exists in the workspace, one is created (including any + * intermediate parent containers) to receive the contents of the remote resource.</p> + * <p> + * Implementations may optimistically only flag the state change locally and rely on resolving conflicts + * during check-in, or they may pessimistically also checkout or lock the remote resource during a + * local resource checkout to avoid conflicts. The provider API does not subscribe to either model + * and supports each equally.</p> + * <p> + * Where checkout is applied to a resource that is already checked-out the method has no + * effect.</p> + * + * @param resources the array of local resources to be checked-out. + * @param depth the depth to traverse the given resources, taken from <code>IResource</code> + * constants. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamProviderException if there is a problem checking-out one or more of the resources. + * The exception will contain multiple statuses, one for each resource in the <code>resources</code> + * array. Possible status codes include: + * <ul> + * <li>NOT_CHECKED_IN</li> + * <li>NO_REMOTE_RESOURCE</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + * @see checkin(IResource[], int, IProgressMonitor) + */ + public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; + + /* + * Transfers the content of the local resource to the corresponding remote resource, and changes the + * state of the local resource from checked-out to checked-in. + * <p> + * If a remote resource does not exist this method creates a new remote resource with the same content + * as the given local resource. The local resource is said to <i>correspond</i> to the new remote resource.</p> + * <p> + * Where providers deal with stores that check-out or lock resources this method is an opportunity + * to transfer the content and make the corresponding remote check-in or unlock. It is envisaged that + * where the server maintains resource versions, checkin creates a new version of the remote resource.</p> + * <p> + * Note that some providers may <em>require</em> that a resource is checked-out before it can be + * checked-in. However, all providers must support the explicit checking out a resource before checking + * it in (e.g., even if the check out is a no-op).</p> + * + * @param resources an array of local resources to be checked-in. + * @param the depth to traverse the given resources, taken from <code>IResource</code> + * constants. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamException if there is a problem checking-in one or more of the resources. + * The exception will contain multiple statuses, one for each resource in the <code>resources</code> + * array. Possible status codes include: + * <ul> + * <li>NOT_CHECKED_OUT</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + * @see checkout(IResource[], int, IProgressMonitor) + */ + public void checkin(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; + + /* + * Changes the state of the local resource from checked-out to checked-in without updating the contents + * of the remote resource. + * <p> + * Note that where the provider is a versioning provider, it is envisaged (though not required) that the + * uncheckout operation does not create a new version.</p> + * <p> + * Note also that <code>uncheckout()</code> does not affect the content of the local resource. The + * caller is required to perform a <code>get()</code> to revert the local resource if that is required + * (otherwise the local resource will be left with the changes that were made while the remote resource + * was checked-out. Furthermore, it is valid to call <code>uncheckout()</code> with an + * <code>IResource</code> that does not exist locally.</p> + * + * @param resources an array of the local resources that are to be unchecked-out. + * @param depth the depth to traverse the given resources, taken from <code>IResource</code> + * constants. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamProviderException if there is a problem undoing the check-out of one or more of + * the resources. The exception will contain multiple statuses, one for each resource in the + * <code>resources</code> array. Possible status codes include: + * <ul> + * <li>NOT_CHECKED_OUT</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + * @see checkin(IResource) + * @see uncheckout(IResource) + */ + public void uncheckout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException; + + /* + * Deletes the remote resource corresponding to the given local resource. + * <p> + * The notion of delete is simply to make the remote resource unavailable. Where the provider + * supports versioning it is not specified whether the delete operation makes the version + * temporarily or forever unavailable, or indeed whether the entire history is made unavailable.</p> + * <p> + * Note that the <code>IResource</code>'s passed as arguments may be non-existant in the + * workbench, the typical case is when such a resource has been received in a core callback.</p> + * <p> + * The resource may be checked-in or checked-out prior to deletion. The local resource is not + * deleted by this method.</p> + * <p> + * Resource deletions are inherently deep.</p> + * + * @param resources the array of resources whose corresponding remote resources are to be deleted. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamProviderException if there is a problem deleting one or more of + * the resources. The exception will contain multiple statuses, one for each resource in the + * <code>resources</code> array. Possible status codes include: + * <ul> + * <li>NO_REMOTE_RESOURCE</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + */ + public void delete(IResource[] resources, IProgressMonitor progress) throws TeamException; + + /* + * Informs the provider that a local resource's name or path has changed. + * <p> + * Some providers, such as versioning providers, may require this information to track the resource + * across name changes.</p> + * <p> + * Note that this method is always called <em>after</em> the local resource has been moved.</p> + * + * @param source the full name of the resource before it was moved. + * @param target the resource that was moved. + * @param progress a progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. + * @throws TeamProviderException if there is a problem recording the move. The exception will + * contain a single status. Possible status codes are: + * <ul> + * <li>NO_REMOTE_RESOURCE</li> + * <li>IO_FAILED</li> + * <li>NOT_AUTHORIZED</li> + * <li>UNABLE</li> + * </ul> + */ + public void moved(IPath source, IResource target, IProgressMonitor progress) throws TeamException; + + /* + * Implementor's Note: + * The following methods are required to return promptly (i.e., they may be used to determine the state of + * a resource in a UI where long delays are unacceptable). Implementations may cache these values + * and update the cache on an explicit call to #refreshState(). + * + * They are currently listed in the provider API, however, they may be moved to a new or different + * interface in the future to better reflect their UI-orientation. + */ + + /* + * Answers if the remote resource state is checked-out. If the resource has never been checked in this + * method will return <code>true</code>. + * <p> + * It is undefined whether this method tests for a resource being checked out to this workspace + * or any workspace.</p> + * + * @param resource the local resource to test. + * @return <code>true</code> if the resource is checked-out and <code>false</code> if it is not. + * @see checkout(IResource[], int, IProgressMonitor) + */ + public boolean isCheckedOut(IResource resource); + + /* + * Answers whether the resource has a corresponding remote resource. + * <p> + * Before a resource is checked-in, the resource will occur locally but not remotely, and calls to this + * method will return <code>false</code>. Once a local resource is checked in (and assuming the local + * local resource is not moved or the remote resource deleted) there will be a corresponding remote + * resource and this method returns <code>true</code>.</p> + * + * @param resource the local resource to test. + * @return <code>true</code> if the local resource has a corresponding remote resource, + * and <code>false</code> otherwise. + * @see checkin(IResource[], int, IProgressMonitor) + * @see refreshState(IResource[], int, IProgressMonitor) + */ + public boolean hasRemote(IResource resource); + + /* + * Answer if the local resource currently has a different timestamp to the base timestamp + * for this resource. + * + * @param resource the resource to test. + * @return <code>true</code> if the resource has a different modification + * timestamp, and <code>false</code> otherwise. + */ + public boolean isDirty(IResource resource); +} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/DeployAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/DeployAction.java new file mode 100644 index 000000000..7fc9c2790 --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/DeployAction.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem.deployment; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.team.core.*; +import org.eclipse.team.internal.ui.actions.TeamAction; +import org.eclipse.ui.IActionDelegate; + +public class DeployAction extends TeamAction implements IActionDelegate { + + public void run(IAction action) { + IContainer container = (IContainer)getSelectedResources()[0]; + IDeploymentProviderManager manager = Team.getDeploymentManager(); + FileSystemDeploymentProvider provider = new FileSystemDeploymentProvider(); + try { + manager.map(container, provider); + } catch (TeamException e) { + ErrorDialog.openError(getShell(), "Error", "Mapping", e.getStatus()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() + */ + protected boolean isEnabled() throws TeamException { + IResource[] resources = getSelectedResources(); + if(resources.length == 1) { + IResource resource = resources[0]; + IDeploymentProviderManager manager = Team.getDeploymentManager(); + if(manager.getMappedTo(resource, FileSystemDeploymentProvider.ID)) { + return false; + } + } + return true; + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/FileSystemDeploymentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/FileSystemDeploymentProvider.java new file mode 100644 index 000000000..19848f476 --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/FileSystemDeploymentProvider.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem.deployment; + +import org.eclipse.team.core.DeploymentProvider; +import org.eclipse.team.internal.core.IMemento; + +public class FileSystemDeploymentProvider extends DeploymentProvider { + + public final static String ID = "org.eclipse.team.examples.filesystem.FileSystemDeploymentProvider"; + + public String getID() { + return ID; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.DeploymentProvider#init() + */ + public void init() { + // TODO Auto-generated method stub + System.out.println("Initialized " + getName()); + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.DeploymentProvider#dispose() + */ + public void dispose() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.DeploymentProvider#saveState(org.eclipse.team.core.IMemento) + */ + public void saveState(IMemento memento) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.DeploymentProvider#restoreState(org.eclipse.team.core.IMemento) + */ + public void restoreState(IMemento memento) { + // TODO Auto-generated method stub + + } +} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/NullAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/NullAction.java new file mode 100644 index 000000000..9216d190a --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/NullAction.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem.deployment; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.team.core.IDeploymentProviderManager; +import org.eclipse.team.core.Team; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ui.actions.TeamAction; +import org.eclipse.ui.IActionDelegate; + +public class NullAction extends TeamAction implements IActionDelegate { + + public void run(IAction action) { + MessageDialog.openQuestion(getShell(), "Action Run", "Action Run"); + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() + */ + protected boolean isEnabled() throws TeamException { + IResource[] resources = getSelectedResources(); + if(resources.length == 1) { + IResource resource = resources[0]; + IDeploymentProviderManager manager = Team.getDeploymentManager(); + if(! manager.getMappedTo(resource, FileSystemDeploymentProvider.ID)) { + return false; + } + } + return true; + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/UnDeployAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/UnDeployAction.java new file mode 100644 index 000000000..5466a25fc --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/deployment/UnDeployAction.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.examples.filesystem.deployment; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.team.core.DeploymentProvider; +import org.eclipse.team.core.IDeploymentProviderManager; +import org.eclipse.team.core.Team; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ui.actions.TeamAction; +import org.eclipse.ui.IActionDelegate; + +public class UnDeployAction extends TeamAction implements IActionDelegate { + + public void run(IAction action) { + IContainer container = (IContainer)getSelectedResources()[0]; + IDeploymentProviderManager manager = Team.getDeploymentManager(); + try { + DeploymentProvider[] providers = manager.getMappings(container, FileSystemDeploymentProvider.ID); + for (int i = 0; i < providers.length; i++) { + DeploymentProvider provider = providers[i]; + manager.unmap(container, provider); + } + } catch (TeamException e) { + ErrorDialog.openError(getShell(), "Error", "Un-Mapping", e.getStatus()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() + */ + protected boolean isEnabled() throws TeamException { + IResource[] resources = getSelectedResources(); + if(resources.length == 1) { + IResource resource = resources[0]; + IDeploymentProviderManager manager = Team.getDeploymentManager(); + if(! manager.getMappedTo(resource, FileSystemDeploymentProvider.ID)) { + return false; + } + } + return true; + } +}
\ No newline at end of file |