Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-03-04 12:30:21 -0500
committerMichael Valenta2004-03-04 12:30:21 -0500
commit8cfc475d0236c757df4d30d076813e3357a5b3c8 (patch)
treeddfc41e0370bbfd7ce115126a72e4327a3e5a8f9 /examples
parentd91bdf8213f1b4c1e36d59fb63e9b696cde197b3 (diff)
downloadeclipse.platform.team-8cfc475d0236c757df4d30d076813e3357a5b3c8.tar.gz
eclipse.platform.team-8cfc475d0236c757df4d30d076813e3357a5b3c8.tar.xz
eclipse.platform.team-8cfc475d0236c757df4d30d076813e3357a5b3c8.zip
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java18
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java378
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java12
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java201
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java301
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/SimpleAccessOperations.java267
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java11
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java34
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java11
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java10
10 files changed, 437 insertions, 806 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 909e30733..3508b5a72 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
@@ -28,16 +28,14 @@ import org.eclipse.team.core.TeamException;
* only has two methods and their implementation is straight forward.
*/
public final class FileModificationValidator implements IFileModificationValidator {
- //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 SimpleAccessOperations operations;
+
+ private FileSystemOperations operations;
/**
* Constructor for FileModificationValidator.
*/
public FileModificationValidator(RepositoryProvider provider) {
- operations = ((FileSystemProvider)provider).getSimpleAccess();
+ operations = ((FileSystemProvider)provider).getOperations();
}
/**
@@ -50,9 +48,9 @@ public final class FileModificationValidator implements IFileModificationValidat
try {
operations.checkout(resources, IResource.DEPTH_INFINITE, null);
} catch (TeamException e) {
- return new Status(Status.ERROR, FileSystemPlugin.ID, Status.ERROR, e.getLocalizedMessage(), e);
+ return new Status(IStatus.ERROR, FileSystemPlugin.ID, 0, e.getLocalizedMessage(), e);
}
- return OK_STATUS;
+ return Status.OK_STATUS;
}
/**
@@ -79,7 +77,11 @@ public final class FileModificationValidator implements IFileModificationValidat
* @see org.eclipse.core.resources.IFileModificationValidator#validateSave(IFile)
*/
public IStatus validateSave(IFile file) {
- return checkout(new IResource[] { file });
+ if (file.isReadOnly()) {
+ return checkout(new IResource[] { file });
+ } else {
+ return Status.OK_STATUS;
+ }
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
new file mode 100644
index 000000000..bf072be95
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
@@ -0,0 +1,378 @@
+/*******************************************************************************
+ * 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 java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.IResourceVariantComparator;
+import org.eclipse.team.core.variants.ThreeWaySynchronizer;
+import org.eclipse.team.examples.filesystem.subscriber.FileSystemResourceVariant;
+import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber;
+
+/**
+ * The get and put operations for the file system provider.
+ */
+public class FileSystemOperations {
+
+ // A reference to the provider
+ private FileSystemProvider provider;
+
+ FileSystemOperations(FileSystemProvider provider) {
+ this.provider = provider;
+ }
+
+ /**
+ * Make the local state of the project match the remote state by getting any out-of-sync
+ * resources. The overrideOutgoing flag is used to indicate whether locally modified
+ * files should also be replaced or left alone.
+ * @param resources the resources to get
+ * @param depth the depth of the operation
+ * @param overrideOutgoing whether locally modified resources should be replaced
+ * @param progress a progress monitor
+ * @throws TeamException
+ */
+ public void get(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ try {
+ // ensure the progress monitor is not null
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("GetAction.working"), 100); //$NON-NLS-1$
+ // Refresh the subscriber so we have the latest remote state
+ FileSystemSubscriber.getInstance().refresh(resources, depth, new SubProgressMonitor(progress, 30));
+ internalGet(resources, depth, overrideOutgoing, new SubProgressMonitor(progress, 70));
+ } finally {
+ progress.done();
+ }
+ }
+
+ /**
+ * Checkout the given resources to the given depth by setting any files
+ * to writtable (i.e set read-only to <coce>false</code>.
+ * @param resources the resources to be checked out
+ * @param depth the depth of the checkout
+ * @param progress a progress monitor
+ * @throws TeamException
+ */
+ public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
+ try {
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.1"), resources.length); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ resources[i].accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource.getType() == IResource.FILE) {
+ //TODO: lock the file on the 'server'.
+ resource.setReadOnly(false);
+ }
+ return true;
+ }
+ }, depth, false /* include phantoms */);
+ progress.worked(1);
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ } finally {
+ progress.done();
+ }
+ }
+
+ /**
+ * Checkin the given resources to the given depth by replacing the remote (i.e. file system)
+ * contents with the local workspace contents.
+ * @param resources the resources
+ * @param depth the depth of the operation
+ * @param overrideIncoming indicate whether incoming remote changes should be replaced
+ * @param progress a progress monitor
+ * @throws TeamException
+ */
+ public void checkin(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ try {
+ // ensure the progress monitor is not null
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("PutAction.working"), 100); //$NON-NLS-1$
+ // Refresh the subscriber so we have the latest remote state
+ FileSystemSubscriber.getInstance().refresh(resources, depth, new SubProgressMonitor(progress, 30));
+ internalPut(resources, depth, overrideIncoming, new SubProgressMonitor(progress, 70));
+ } finally {
+ progress.done();
+ }
+ }
+
+ /**
+ * Return whether the local resource is checked out. A resource
+ * is checked out if it is a file that is not read-only. Folders
+ * are always checked out.
+ * @param resource the resource
+ * @return whether the resource is checked out and can be modified
+ */
+ public boolean isCheckedOut(IResource resource) {
+ if (resource.getType() != IResource.FILE) return true;
+ return !resource.isReadOnly();
+ }
+
+ /*
+ * Get the resource variant for the given resource.
+ */
+ private FileSystemResourceVariant getResourceVariant(IResource resource) {
+ return (FileSystemResourceVariant)provider.getResourceVariant(resource);
+ }
+
+ private void internalGet(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ // Traverse the resources and get any that are out-of-sync
+ progress.beginTask(Policy.bind("GetAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ if (resources[i].getType() == IResource.FILE) {
+ internalGet((IFile) resources[i], overrideOutgoing, progress);
+ } else if (depth != IResource.DEPTH_ZERO) {
+ internalGet((IContainer)resources[i], depth, overrideOutgoing, progress);
+ }
+ progress.worked(1);
+ }
+ }
+
+ /*
+ * Get the folder and its children to the depth specified.
+ */
+ private void internalGet(IContainer container, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ try {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ // Make the local folder state match the remote folder state
+ List toDelete = new ArrayList();
+ if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder)container;
+ FileSystemResourceVariant remote = getResourceVariant(container);
+ if (!folder.exists() && remote != null) {
+ // Create the local folder
+ folder.create(false, true, progress);
+ synchronizer.setBaseBytes(folder, remote.asBytes());
+ } else if (folder.exists() && remote == null) {
+ // Schedule the folder for removal but delay in
+ // case the folder contains outgoing changes
+ toDelete.add(folder);
+ }
+ }
+
+ // Get the children
+ IResource[] children = synchronizer.members(container);
+ if (children.length > 0) {
+ internalGet(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideOutgoing, progress);
+ }
+
+ // Remove any empty folders
+ for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
+ IFolder folder = (IFolder) iter.next();
+ if (folder.members().length == 0) {
+ folder.delete(false, true, progress);
+ synchronizer.flush(folder, IResource.DEPTH_INFINITE);
+ }
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+
+ /*
+ * Get the file if it is out-of-sync.
+ */
+ private void internalGet(IFile localFile, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
+ FileSystemResourceVariant remote = getResourceVariant(localFile);
+ byte[] baseBytes = synchronizer.getBaseBytes(localFile);
+ IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
+ if (!synchronizer.hasSyncBytes(localFile) || (
+ synchronizer.isLocallyModified(localFile) && !overrideOutgoing)) {
+ // Do not overwrite the local modification
+ return;
+ }
+ if (base != null && remote == null) {
+ // The remote no longer exists so remove the local
+ try {
+ localFile.delete(false, true, progress);
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+ if (!synchronizer.isLocallyModified(localFile) && comparator.compare(base, remote)) {
+ // The base and remote are the same and there's no local changes
+ // so nothing needs to be done
+ }
+ try {
+ //Copy from the local file to the remote file:
+ InputStream source = null;
+ try {
+ // Get the remote file content.
+ source = remote.getContents();
+ // Set the local file content to be the same as the remote file.
+ if (localFile.exists())
+ localFile.setContents(source, false, false, progress);
+ else
+ localFile.create(source, false, progress);
+ } finally {
+ if (source != null)
+ source.close();
+ }
+ // Mark as read-only to force a checkout before editing
+ localFile.setReadOnly(true);
+ } catch (IOException e) {
+ throw FileSystemPlugin.wrapException(e);
+ } catch (CoreException e) {
+ throw FileSystemPlugin.wrapException(e);
+ }
+ }
+
+ private void internalPut(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ // ensure the progress monitor is not null
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("PutAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ if (resources[i].getType() == IResource.FILE) {
+ internalPut((IFile)resources[i], overrideIncoming, progress);
+ } else if (depth > 0) { //Assume that resources are either files or containers.
+ internalPut((IContainer)resources[i], depth, overrideIncoming, progress);
+ }
+ progress.worked(1);
+ }
+ progress.done();
+ }
+
+ /*
+ * Get the file if it is out-of-sync.
+ */
+ private void internalPut(IFile localFile, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
+ FileSystemResourceVariant remote = getResourceVariant(localFile);
+ byte[] baseBytes = synchronizer.getBaseBytes(localFile);
+ IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
+
+ // Check whether we are overriding a remote change
+ if (base == null && remote != null && !overrideIncoming) {
+ // The remote is an incoming (or conflicting) addition.
+ // Do not replace unless we are overriding
+ return;
+ } else if (base != null && remote == null) {
+ // The remote is an incoming deletion
+ if (!localFile.exists()) {
+ // Conflicting deletion. Clear the synchronizer.
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ } else if (!overrideIncoming) {
+ // Do not override the incoming deletion
+ return;
+ }
+ } else if (base != null && remote != null) {
+ boolean same = comparator.compare(base, remote);
+ if (!synchronizer.isLocallyModified(localFile) && same) {
+ // The base and remote are the same and there's no local changes
+ // so nothing needs to be done
+ return;
+ }
+ if (!same && !overrideIncoming) {
+ // The remote has changed. Only override if specified
+ return;
+ }
+ }
+
+ // Handle an outgoing deletion
+ File diskFile = provider.getFile(localFile);
+ if (!localFile.exists()) {
+ diskFile.delete();
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ } else {
+ // Otherwise, upload the contents
+ try {
+ //Copy from the local file to the remote file:
+ InputStream in = null;
+ FileOutputStream out = null;
+ try {
+ in = localFile.getContents();
+ out = new FileOutputStream(diskFile);
+ //Copy the contents of the local file to the remote file:
+ StreamUtil.pipe(in, out, diskFile.length(), progress, diskFile.getName());
+ // Mark the file as read-only to require another checkout
+ localFile.setReadOnly(true);
+ } finally {
+ if (in != null)
+ in.close();
+ if (out != null)
+ out.close();
+ }
+ // Update the synchronizer base bytes
+ remote = getResourceVariant(localFile);
+ synchronizer.setBaseBytes(localFile, remote.asBytes());
+ } catch (IOException e) {
+ throw FileSystemPlugin.wrapException(e);
+ } catch (CoreException e) {
+ throw FileSystemPlugin.wrapException(e);
+ }
+ }
+ }
+
+ /*
+ * Get the folder and its children to the depth specified.
+ */
+ private void internalPut(IContainer container, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ try {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ // Make the local folder state match the remote folder state
+ List toDelete = new ArrayList();
+ if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder)container;
+ File diskFile = provider.getFile(container);
+ FileSystemResourceVariant remote = getResourceVariant(container);
+ if (!folder.exists() && remote != null) {
+ // Schedule the folder for removal but delay in
+ // case the folder contains incoming changes
+ toDelete.add(diskFile);
+ } else if (folder.exists() && remote == null) {
+ // Create the remote directory and sync up the local
+ diskFile.mkdir();
+ synchronizer.setBaseBytes(folder, provider.getResourceVariant(folder).asBytes());
+ }
+ }
+
+ // Get the children
+ IResource[] children = synchronizer.members(container);
+ if (children.length > 0) {
+ internalPut(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideIncoming, progress);
+ }
+
+ // Remove any empty folders
+ for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
+ File diskFile = (File) iter.next();
+ if (diskFile.listFiles().length == 0) {
+ diskFile.delete();
+ synchronizer.flush(container, IResource.DEPTH_INFINITE);
+ }
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+}
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 597776599..a7596be7f 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
@@ -151,15 +151,11 @@ public class FileSystemProvider extends RepositoryProvider {
}
/**
- * Return an instance of <code>SimpleAccessOperations</code> that provides the
- * operations for transfering data to and from the provider's location.
- * Note: The interface <code>SimpleAccessOperations</code> is not part of the official
- * Team API. We use it here for convenience.
- *
- * @see org.eclipse.team.core.RepositoryProvider#getSimpleAccess()
+ * Return an object that provides the operations for transfering data
+ * to and from the provider's location.
*/
- public SimpleAccessOperations getSimpleAccess() {
- return new FileSystemSimpleAccessOperations(this);
+ public FileSystemOperations getOperations() {
+ return new FileSystemOperations(this);
}
/**
* @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator()
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
deleted file mode 100644
index 5df6b25e6..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemRemoteResource.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * 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 java.io.*;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-
-/**
- * Class represents a handle to a <code>java.io.File</code> that conforms to
- * the <code>org.eclipse.team.core.IResourceVariant</code> interface.
- */
-public class FileSystemRemoteResource implements IAdaptable, IStorage {
-
- // the file object in which the data is stored on the disk
- private File ioFile;
-
- /**
- * The constructor.
- * @param path the full path of the resource on disk
- */
- public FileSystemRemoteResource(IPath path) {
- this(new File(path.toOSString()));
- }
-
- /**
- * Create a remote resource handle from the given java.io.file
- *
- * @param ioFile the file
- */
- FileSystemRemoteResource(File ioFile) {
- this.ioFile = ioFile;
- }
-
- /**
- * Adapters are used to ensure that the right menus will appear in differnet views.
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /**
- * Returns an input stream containing the contents of the remote resource.
- * The remote resource must be a file.
- *
- * @see org.eclipse.team.core.sync.IResourceVariant#getContents(IProgressMonitor)
- */
- public InputStream getContents(IProgressMonitor progress) throws TeamException {
- if (isContainer())
- throw new TeamException(Policy.bind("FileSystemRemoteResource.0")); //$NON-NLS-1$
- try {
- return new FileInputStream(ioFile);
- } catch (FileNotFoundException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
-
- /**
- * Return the modification timestamp of the remote resource.
- *
- * @return long The date and time (in milliseconds) when the file was last changed on disk.
- */
- public long getLastModified() {
- return ioFile.lastModified();
- }
-
- /**
- * @see org.eclipse.team.core.sync.IResourceVariant#getName()
- */
- public String getName() {
- return ioFile.getName();
- }
-
- /**
- * @see org.eclipse.team.core.sync.IResourceVariant#isContainer()
- */
- public boolean isContainer() {
- return ioFile.isDirectory();
- }
-
- /**
- * Fetch the members of the remote resource. The remote resource must be a
- * container.
- *
- * @see org.eclipse.team.core.sync.IResourceVariant#members(IProgressMonitor)
- */
- 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();
- FileSystemRemoteResource[] result = new FileSystemRemoteResource[members.length];
- for (int i = 0; i < members.length; i++) {
- result[i] = new FileSystemRemoteResource(members[i]);
- }
- return result;
- }
-
- /**
- * copies a single specified file to a specified location on the filesystem.
- * @param dest The location on the filesystem to which the file is to be copied
- * @param src The source file
- */
- static void copyFile(IPath dest, File src) {
- File target = new File(dest.append(src.getName()).toOSString());
- try {
- InputStream in = ((IFile) src).getContents();
- java.io.FileOutputStream out = new java.io.FileOutputStream(target);
- StreamUtil.pipe(in, out, target.length(), null, target.getName());
- } catch (FileNotFoundException e) {} catch (IOException e) {} catch (CoreException e) {}
- }
- /**
- * Recursively copies an entire directory structure to a specified location on the filesystem
- * @param dest The location on the filssystem to which the directory structure is to be written
- * @param src The directory structure that is to be duplicated
- */
- static void copyFolder(IPath dest, File src) {
- String children[] = src.list();
- File current;
- for (int i = 0; i < children.length; i++) {
- current = new File(children[i]);
- if (current.isFile())
- copyFile(dest.append(src.getName()), current);
- else if (current.isDirectory())
- copyFolder(dest.append(src.getName()), current);
- }
- }
-
- /**
- * Creates a copy of the remote resource in the location specified
- * @param location The destination for the copy of the remote resource
- */
- public void copyOver(IPath location) {
- copyFolder(location, ioFile);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getComment()
- */
- public String getComment() throws TeamException {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getContentIdentifier()
- */
- public String getContentIdentifier() throws TeamException {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getCreatorDisplayName()
- */
- public String getCreatorDisplayName() throws TeamException {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getBufferedStorage(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStorage getBufferedStorage(IProgressMonitor monitor) throws TeamException {
- // The contents are local so no caching is required
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#getContents()
- */
- public InputStream getContents() throws CoreException {
- return getContents(new NullProgressMonitor());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#getFullPath()
- */
- public IPath getFullPath() {
- return new Path(ioFile.getAbsolutePath());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#isReadOnly()
- */
- public boolean isReadOnly() {
- return true;
- }
-}
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
deleted file mode 100644
index b80a9d2e5..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemSimpleAccessOperations.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * 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 java.io.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-
-/**
- * SimpleAccessOperations is not part of the Team API. We use it here because it provides
- * a reasonable set of operation commonly implemented by repository providers.
- * Note: This class is not to be interpreted as an example of how a repository
- * provider is to do its work. It is only here because we needed to have some operations
- * to perform. In the future, we may update this class to illustrate the use of the workspace
- * synchronizer (<code>ISynchronizer</code>).
- */
-public class FileSystemSimpleAccessOperations implements SimpleAccessOperations {
-
- // A reference to the provider
- private FileSystemProvider provider;
-
- /**
- * Constructor
- * @param provider
- */
- FileSystemSimpleAccessOperations(FileSystemProvider provider) {
- this.provider = provider;
- }
-
- /**
- * Given a local resource, finds the remote counterpart.
- * @param resource The local resource to lookup
- * @return FileSystemRemoteResource The remote counterpart to the given local resource
- */
- public FileSystemRemoteResource getRemoteResourceFor(IResource resource) {
- return new FileSystemRemoteResource(provider.getRoot().append(resource.getProjectRelativePath()));
- }
-
- /**
- * @see SimpleAccessOperations#get(IResource[], int, IProgressMonitor)
- */
- public void get(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- // ensure the progress monitor is not null
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("GetAction.working"), resources.length); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
- IPath rootdir = provider.getRoot();
- FileSystemRemoteResource remote = getRemoteResourceFor(resources[i]);
- if (resources[i].getType() == IResource.FILE) {
- //Copy the resource over to the other side:
- IFile localFile = (IFile) resources[i]; //since we know the local resource is a file.
- if (localFile.getModificationStamp() != remote.getLastModified()) {
- //Only do this if the timestamps are different
- try {
- //Copy from the local file to the remote file:
- InputStream source = null;
- try {
- // Get the remote file content.
- source = remote.getContents(progress);
- // Set the local file content to be the same as the remote file.
- if (localFile.exists())
- localFile.setContents(source, false, false, progress);
- else
- localFile.create(source, false, progress);
- } finally {
- if (source != null)
- source.close();
- }
- } catch (IOException e) {
- throw FileSystemPlugin.wrapException(e);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- } else if (depth > 0) { //Assume that resources are either files or containers.
- //If the resource is a container, copy its children over.
- FileSystemRemoteResource[] estranged = remote.members(progress);
- IResource[] children = new IResource[estranged.length];
-
- if (resources[i].getType() == IResource.PROJECT) {
- for (int j = 0; j < estranged.length; j++) {
- if (estranged[j].isContainer())
- children[j] = provider.getProject().getFolder(estranged[j].getName());
- else
- children[j] = provider.getProject().getFile(estranged[j].getName());
- }
- } else if (resources[i].getType() == IResource.FOLDER) {
- //Make sure that the folder exists before trying to put anything into it:
- IFolder localFolder = (IFolder) resources[i];
- if (!localFolder.exists()) {
- try {
- localFolder.create(false, true, progress);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
-
- //Create placeholder local resources to place data into:
- for (int j = 0; j < estranged.length; j++) {
- if (estranged[j].isContainer())
- children[j] = provider.getProject().getFolder(resources[i].getProjectRelativePath().append(estranged[j].getName()));
- else
- children[j] = provider.getProject().getFile(resources[i].getProjectRelativePath().append(estranged[j].getName()));
- }
- }
-
- //Recurse into children:
- if (children.length > 0)
- get(children, depth - 1, null);
- }
- progress.worked(1);
- }
- progress.done();
- }
-
- /**
- * Simply make sure that the local resource is not read only.
- *
- * @see SimpleAccessOperations#checkout(IResource[], int, IProgressMonitor)
- */
- public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.1"), resources.length); //$NON-NLS-1$
- IPath rootdir = provider.getRoot();
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
-
- //Do the actual file locking:
- FileSystemRemoteResource remote = getRemoteResourceFor(resources[i]);
- File diskFile = new File(rootdir.append(resources[i].getProjectRelativePath()).toOSString());
- if (resources[i].getType() == IResource.FILE) {
- //TODO: lock the file on the 'server'.
- resources[i].setReadOnly(false);
- } else if (depth > 0) {
- diskFile.mkdirs();
- //Recursively checkout children too:
- try {
- IResource[] children;
- if (resources[i].getType() == IResource.PROJECT)
- children = provider.getProject().members();
- else
- children = provider.getProject().getFolder(resources[i].getName()).members();
- if (children.length > 0)
- checkout(children, depth - 1, null);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- progress.worked(1);
- }
- progress.done();
- }
-
- /**
- * Checkin the resources to the given depth. Mark all checked in resources as read only.
- *
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#checkin(IResource[], int, IProgressMonitor)
- */
- public void checkin(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- // ensure the progress monitor is not null
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("PutAction.working"), resources.length); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
- IPath rootdir = provider.getRoot();
- // Verify that the resources are checked out:
- if (!isCheckedOut(resources[i]))
- return;
-
- File diskFile = new File(rootdir.append(resources[i].getProjectRelativePath()).toOSString());
- if (resources[i].getType() == IResource.FILE) {
- //Copy the resource over to the other side:
- IFile localFile = (IFile) resources[i]; //since we know the local resource is a file.
- if (localFile.getModificationStamp() != diskFile.lastModified()) {
- //Only do this if the timestamps are different
- try {
- diskFile.getParentFile().mkdirs();
- //Copy from the local file to the remote file:
- InputStream in = null;
- FileOutputStream out = null;
- try {
- in = localFile.getContents();
- out = new FileOutputStream(diskFile);
- //Copy the contents of the local file to the remote file:
- StreamUtil.pipe(in, out, diskFile.length(), progress, diskFile.getName());
- } finally {
- if (in != null)
- in.close();
- if (out != null)
- out.close();
- }
- } catch (IOException e) {
- throw FileSystemPlugin.wrapException(e);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- } else if (depth > 0) { //Assume that resources are either files or containers.
- diskFile.mkdirs();
- //Recursively copy children, if any, over as well:
- try {
- IResource[] children;
- if (resources[i].getType() == IResource.PROJECT)
- children = provider.getProject().members();
- else
- children = provider.getProject().getFolder(resources[i].getName()).members();
- if (children.length > 0)
- checkin(children, depth - 1, null);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- progress.worked(1);
- }
- uncheckout(resources, depth, progress);
- progress.done();
- }
-
- /**
- * Mark all checked in resources as read only.
- *
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#uncheckout(IResource[], int, IProgressMonitor)
- */
- public void uncheckout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- progress = Policy.monitorFor(progress);
- progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.3"), resources.length); //$NON-NLS-1$
- IPath rootdir = provider.getRoot();
- for (int i = 0; i < resources.length; i++) {
- Policy.checkCanceled(progress);
-
- //Do the actual file unlocking:
- FileSystemRemoteResource remote = getRemoteResourceFor(resources[i]);
- File diskFile = new File(rootdir.append(resources[i].getProjectRelativePath()).toOSString());
- if (resources[i].getType() == IResource.FILE) {
- //TODO: unlock the file on the 'server'.
- resources[i].setReadOnly(true);
- } else if (depth > 0) {
- diskFile.mkdirs();
- //Recursively uncheckout children too:
- try {
- IResource[] children;
- if (resources[i].getType() == IResource.PROJECT)
- children = provider.getProject().members();
- else
- children = provider.getProject().getFolder(resources[i].getName()).members();
- if (children.length > 0)
- uncheckout(children, depth - 1, null);
- } catch (CoreException e) {
- throw FileSystemPlugin.wrapException(e);
- }
- }
- progress.worked(1);
- }
- progress.done();
- }
-
- /**
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#delete(IResource[], IProgressMonitor)
- */
- public void delete(IResource[] resources, IProgressMonitor progress) throws TeamException {}
-
- /**
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#moved(IPath, IResource, IProgressMonitor)
- */
- public void moved(IPath source, IResource target, IProgressMonitor progress) throws TeamException {}
-
- /**
- * A resource is checked out if it is not read only.
- *
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#isCheckedOut(IResource)
- */
- public boolean isCheckedOut(IResource resource) {
- return !resource.isReadOnly();
- }
-
- /**
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#hasRemote(IResource)
- */
- public boolean hasRemote(IResource resource) {
- return false;
- }
-
- /**
- * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#isDirty(IResource)
- */
- public boolean isDirty(IResource resource) {
- return false;
- }
-
-}
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
deleted file mode 100644
index ce5f0c0d4..000000000
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/SimpleAccessOperations.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * 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/subscriber/FileSystemRemoteTree.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java
index 65f87d805..1a5d01b93 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java
@@ -37,16 +37,7 @@ public class FileSystemRemoteTree extends ThreeWayRemoteTree {
* @see org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchMembers(org.eclipse.team.core.variants.IResourceVariant, org.eclipse.core.runtime.IProgressMonitor)
*/
protected IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException {
- if (variant.isContainer()) {
- java.io.File[] members = ((FileSystemResourceVariant)variant).members();
- FileSystemResourceVariant[] result = new FileSystemResourceVariant[members.length];
- for (int i = 0; i < members.length; i++) {
- result[i] = new FileSystemResourceVariant(members[i]);
- }
- return result;
- } else {
- return new IResourceVariant[0];
- }
+ return ((FileSystemResourceVariant)variant).members();
}
/* (non-Javadoc)
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java
index 630b73ee5..5ddd2c7fa 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java
@@ -11,10 +11,10 @@
package org.eclipse.team.examples.filesystem.subscriber;
import java.io.BufferedInputStream;
-import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -57,11 +57,7 @@ public class FileSystemResourceVariant extends CachedResourceVariant {
* @see org.eclipse.team.core.variants.CachedResourceVariant#fetchContents(org.eclipse.core.runtime.IProgressMonitor)
*/
protected void fetchContents(IProgressMonitor monitor) throws TeamException {
- try {
- setContents(new BufferedInputStream(new FileInputStream(ioFile)), monitor);
- } catch (FileNotFoundException e) {
- throw new TeamException("Failed to fetch contents for " + getFilePath(), e);
- }
+ setContents(getContents(), monitor);
}
/* (non-Javadoc)
@@ -69,7 +65,7 @@ public class FileSystemResourceVariant extends CachedResourceVariant {
*/
protected String getCachePath() {
// append the timestamp to the file path to give each variant a unique path
- return getFilePath() + " " + ioFile.lastModified();
+ return getFilePath() + " " + ioFile.lastModified(); //$NON-NLS-1$
}
private String getFilePath() {
@@ -128,7 +124,27 @@ public class FileSystemResourceVariant extends CachedResourceVariant {
* Return the files contained by the file of this resource variant.
* @return the files contained by the file of this resource variant.
*/
- public File[] members() {
- return ioFile.listFiles();
+ public FileSystemResourceVariant[] members() {
+ if (isContainer()) {
+ java.io.File[] members = ioFile.listFiles();
+ FileSystemResourceVariant[] result = new FileSystemResourceVariant[members.length];
+ for (int i = 0; i < members.length; i++) {
+ result[i] = new FileSystemResourceVariant(members[i]);
+ }
+ return result;
+ } else {
+ return new FileSystemResourceVariant[0];
+ }
+ }
+
+ /**
+ * @return
+ */
+ public InputStream getContents() throws TeamException {
+ try {
+ return new BufferedInputStream(new FileInputStream(ioFile));
+ } catch (FileNotFoundException e) {
+ throw new TeamException("Failed to fetch contents for " + getFilePath(), e);
+ }
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java
index 1c4ce852e..30e99102f 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java
@@ -41,7 +41,7 @@ public class GetAction extends FileSystemAction {
FileSystemProvider provider = (FileSystemProvider) iter.next();
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
- provider.getSimpleAccess().get(providerResources, IResource.DEPTH_INFINITE, subMonitor);
+ provider.getOperations().get(providerResources, IResource.DEPTH_INFINITE, isOverwriteOutgoing(), subMonitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
@@ -51,4 +51,13 @@ public class GetAction extends FileSystemAction {
}
}, Policy.bind("GetAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$
}
+
+ /**
+ * Indicate whether the action should overwrite outgoing changes.
+ * By default, the get action does not override local modifications.
+ * @return whether the action should overwrite outgoing changes.
+ */
+ protected boolean isOverwriteOutgoing() {
+ return false;
+ }
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java
index 004b86517..dde27b1a2 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java
@@ -44,7 +44,7 @@ public class PutAction extends FileSystemAction {
FileSystemProvider provider = (FileSystemProvider) iter.next();
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
- provider.getSimpleAccess().checkin(providerResources, IResource.DEPTH_INFINITE, subMonitor);
+ provider.getOperations().checkin(providerResources, IResource.DEPTH_INFINITE, isOverrideIncoming(), subMonitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
@@ -54,4 +54,12 @@ public class PutAction extends FileSystemAction {
}
}, Policy.bind("PutAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$
}
+
+ /**
+ * Indicate whether the put shoudl override incoming changes.
+ * @return whether the put shoudl override incoming changes.
+ */
+ protected boolean isOverrideIncoming() {
+ return false;
+ }
}

Back to the top