diff options
Diffstat (limited to 'examples/org.eclipse.team.examples.filesystem')
30 files changed, 0 insertions, 2358 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/.classpath b/examples/org.eclipse.team.examples.filesystem/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/examples/org.eclipse.team.examples.filesystem/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/examples/org.eclipse.team.examples.filesystem/.cvsignore b/examples/org.eclipse.team.examples.filesystem/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/examples/org.eclipse.team.examples.filesystem/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/examples/org.eclipse.team.examples.filesystem/.project b/examples/org.eclipse.team.examples.filesystem/.project deleted file mode 100644 index eee25274a..000000000 --- a/examples/org.eclipse.team.examples.filesystem/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.team.examples.filesystem</name> - <comment></comment> - <projects> - <project>org.eclipse.core.boot</project> - <project>org.eclipse.core.resources</project> - <project>org.eclipse.core.runtime</project> - <project>org.eclipse.core.runtime.compatibility</project> - <project>org.eclipse.jface.text</project> - <project>org.eclipse.team.core</project> - <project>org.eclipse.team.ui</project> - <project>org.eclipse.ui</project> - <project>org.eclipse.ui.editors</project> - <project>org.eclipse.ui.ide</project> - <project>org.eclipse.ui.views</project> - <project>org.eclipse.ui.workbench.texteditor</project> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/examples/org.eclipse.team.examples.filesystem/about.html b/examples/org.eclipse.team.examples.filesystem/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/examples/org.eclipse.team.examples.filesystem/about.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> -<html> -<head> -<title>About</title> -<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>20th June, 2002</p> -<h3>License</h3> -<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>. -For purposes of the CPL, "Program" will mean the Content.</p> - -<h3>Contributions</h3> - -<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise -made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such -Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p> - -<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or -other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the -host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available -to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also -providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of -the CPL.</p> - -</body> -</html>
\ No newline at end of file diff --git a/examples/org.eclipse.team.examples.filesystem/build.properties b/examples/org.eclipse.team.examples.filesystem/build.properties deleted file mode 100644 index fa97e5430..000000000 --- a/examples/org.eclipse.team.examples.filesystem/build.properties +++ /dev/null @@ -1,14 +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 -############################################################################### -# Eclipse build contribution -source.teamfilesystem.jar=src/ -src.includes=about.html -bin.includes=about.html,icons/,doc-html/,plugin.xml,plugin.properties,*.jar
\ No newline at end of file diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm b/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm deleted file mode 100644 index cf2ced352..000000000 --- a/examples/org.eclipse.team.examples.filesystem/doc-html/hglegal.htm +++ /dev/null @@ -1,14 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.73 [en] (Win98; U) [Netscape]">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
-</body>
-</html>
diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif b/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif Binary files differdeleted file mode 100644 index 61cef4852..000000000 --- a/examples/org.eclipse.team.examples.filesystem/doc-html/ngibmcpy.gif +++ /dev/null diff --git a/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html b/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html deleted file mode 100644 index 9604d0d6c..000000000 --- a/examples/org.eclipse.team.examples.filesystem/doc-html/team_filesystem_ex.html +++ /dev/null @@ -1,35 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0//en"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <title>Team - File System Repository Provider Example</title> -</head> -<body> - -<h2>Team - File System Repository Provider Example</h2> - -<h3>Introduction</h3> - -<p> -The File System Repository Provider shows how to define your own repository provider. -It shows how to override the RepositoryProvider class and register this new class as -a repository provider using the Team extension point. It also illustrates how to create -and register a configuration wizard for connecting a local project to a remote location -and how to provide some custom Team and Replace with menu items for simple Get and Put operations. In -addition it also shows how to use the validate save/validate edit mechanism to support -pessimistic providers. - - -<h3>Running the example</h3> - -To start using this example create a project and select Team > Share Project... from the -project's popup menu. In the wizrd that opens, select File System Example and click Next. -Now enter the location in the local file system where you would like to connect the project -to. The Get and Put operations in the Team menu will now transfer to and from the selected -location. - - -<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corp. 2000, 2002. All Rights Reserved." BORDER=0></a> -</body> -</html> - diff --git a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif b/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif Binary files differdeleted file mode 100644 index af038fa69..000000000 --- a/examples/org.eclipse.team.examples.filesystem/icons/full/wizards/fsicon_wiz.gif +++ /dev/null diff --git a/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif b/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif Binary files differdeleted file mode 100644 index 3038a23c0..000000000 --- a/examples/org.eclipse.team.examples.filesystem/icons/full/wizban/newconnect_wizban.gif +++ /dev/null diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.properties b/examples/org.eclipse.team.examples.filesystem/plugin.properties deleted file mode 100644 index 360a2e606..000000000 --- a/examples/org.eclipse.team.examples.filesystem/plugin.properties +++ /dev/null @@ -1,28 +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 -############################################################################### -pluginName = Eclipse Team File System Example -providerName=Eclipse.org - -Put.name=Put -Put.tooltip=Copy resources to the shared file system location -Get.name=Get -Get.tooltip=Copy resources from the shared file system location to the workbench -Unmanage.name=Unmanage -Unmanage.tooltip=Mark resources as not-shared - -Replace.name=File System Contents -Replace.tooltip=Overwrites the local copy of this resource with the one in the repository - - -fspropertypage.name=FileSystem Provider -fspropertypage.tooltip=An example repository provider that uses the filesystem to provide storage. -fswizard.name=File System Example (Non-Versioning) -fswizard.description=Associate a project with a file system location. This location can be used to shared resources with others. diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.xml b/examples/org.eclipse.team.examples.filesystem/plugin.xml deleted file mode 100644 index bda3da5f8..000000000 --- a/examples/org.eclipse.team.examples.filesystem/plugin.xml +++ /dev/null @@ -1,173 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="org.eclipse.team.examples.filesystem" - name="%pluginName" - version="3.0.0" - provider-name="%providerName" - class="org.eclipse.team.examples.filesystem.FileSystemPlugin"> - - <runtime> - <library name="teamfilesystem.jar"> - <export name="*"/> - <packages prefixes="org.eclipse.team.examples.filesystem"/> - </library> - </runtime> - <requires> - <import plugin="org.eclipse.core.runtime.compatibility"/> - <import plugin="org.eclipse.ui.ide" optional="true"/> - <import plugin="org.eclipse.ui.views" optional="true"/> - <import plugin="org.eclipse.jface.text" optional="true"/> - <import plugin="org.eclipse.ui.workbench.texteditor" optional="true"/> - <import plugin="org.eclipse.ui.editors" optional="true"/> - <import plugin="org.eclipse.core.resources"/> - <import plugin="org.eclipse.team.core"/> - <import plugin="org.eclipse.team.ui"/> - <import plugin="org.eclipse.ui"/> - </requires> - - -<!-- *************** Repository Provider **************** --> - <extension - point="org.eclipse.team.core.repository"> - <repository - class="org.eclipse.team.examples.filesystem.FileSystemProvider" - id="org.eclipse.team.examples.filesystem.FileSystemProvider"> - </repository> - </extension> - -<!-- *************** Deployment Provider **************** --> - <extension - point="org.eclipse.team.core.deployment"> - <deployment - class="org.eclipse.team.examples.filesystem.deployment.FileSystemDeploymentProvider" - id="org.eclipse.team.examples.filesystem.FileSystemDeploymentProvider" - name="%nonVersioningProvider"> - </deployment> - </extension> - -<!-- *************** Deployment ObjectContributions **************** --> - <extension - point="org.eclipse.ui.popupMenus"> - <objectContribution - objectClass="org.eclipse.core.resources.IContainer" - adaptable="true" - id="org.eclipse.team.examples.filesystem.ResourceContributions"> - <menu - label="Deployment Example" - path="additions" - id="example.deployment"> - <separator name="group1"/> - <separator name="group2"/> - </menu> - <action - label="Connect..." - tooltip="Deployment Actions" - menubarPath="example.deployment/group2" - class="org.eclipse.team.examples.filesystem.deployment.DeployAction" - id="org.eclipse.team.examples.filesystem.deploy"> - </action> - <action - label="Disconnect..." - tooltip="Deployment Actions" - menubarPath="example.deployment/group2" - class="org.eclipse.team.examples.filesystem.deployment.UnDeployAction" - id="org.eclipse.team.examples.filesystem.undeploy"> - </action> - <action - label="Upload" - tooltip="Deployment Actions" - menubarPath="example.deployment/group1" - class="org.eclipse.team.examples.filesystem.deployment.NullAction" - id="org.eclipse.team.examples.filesystem.undeploy"> - </action> - <action - label="Download" - tooltip="Deployment Actions" - menubarPath="example.deployment/group1" - class="org.eclipse.team.examples.filesystem.deployment.NullAction" - id="org.eclipse.team.examples.filesystem.undeploy"> - </action> - </objectContribution> - </extension> - -<!-- *************** POPUP MENUS **************** --> - <extension - point="org.eclipse.ui.popupMenus"> - <objectContribution - objectClass="org.eclipse.core.resources.IResource" - adaptable="true" - id="org.eclipse.team.examples.filesystem.ResourceContributions"> - <filter - name="projectPersistentProperty" - value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider"> - </filter> - <action - label="%Get.name" - tooltip="%Get.tooltip" - class="org.eclipse.team.examples.filesystem.ui.GetAction" - menubarPath="team.main/group1" - id="org.eclipse.team.examples.filesystem.get"> - </action> - <action - label="%Put.name" - tooltip="%Put.tooltip" - class="org.eclipse.team.examples.filesystem.ui.PutAction" - menubarPath="team.main/group1" - id="org.eclipse.team.examples.filesystem.put"> - </action> - <action - label="%Replace.name" - tooltip="%ReplaceAction.tooltip" - class="org.eclipse.team.examples.filesystem.ui.ReplaceAction" - menubarPath="replaceWithMenu/replaceWithGroup" - id="org.eclipse.team.examples.filesystem.replace"> - </action> - </objectContribution> - <objectContribution - objectClass="org.eclipse.core.resources.IProject" - adaptable="true" - id="org.eclipse.team.examples.filesystem.ProjectContributions"> - <filter - name="projectPersistentProperty" - value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider"> - </filter> - <action - label="%Unmanage.name" - tooltip="%Unmanage.tooltip" - class="org.eclipse.team.examples.filesystem.ui.DisconnectAction" - menubarPath="team.main/group2" - id="org.eclipse.team.examples.filesystem.unmanage"> - </action> - </objectContribution> - </extension> -<!-- *************** CONFIGURATION WIZARD **************** --> - <extension - point="org.eclipse.team.ui.configurationWizards"> - <wizard - name="%fswizard.name" - icon="icons/full/wizards/fsicon_wiz.gif" - category="org.eclipse.team.ui" - class="org.eclipse.team.examples.filesystem.ui.ConfigurationWizard" - id="org.eclipse.team.examples.filesystem.ui.ConfigurationWizard"> - <description> - %fswizard.description - </description> - </wizard> - </extension> -<!-- *************** PROPERTY PAGES **************** --> - <extension - point="org.eclipse.ui.propertyPages"> - <page - objectClass="org.eclipse.core.resources.IResource" - adaptable="true" - name="%fspropertypage.name" - class="org.eclipse.team.examples.filesystem.ui.FileSystemPropertiesPage" - id="org.eclipse.team.examples.filesystem.ui.FileSystemPropertiesPage"> - <filter - name="projectPersistentProperty" - value="org.eclipse.team.core.repository=org.eclipse.team.examples.filesystem.FileSystemProvider"> - </filter> - </page> - </extension> -</plugin> 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 deleted file mode 100644 index 3508b5a72..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java +++ /dev/null @@ -1,87 +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.util.ArrayList; -import java.util.Collection; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileModificationValidator; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; - -/** - * This class models a sentry that verifies whether resources are available for editing or overwriting. - * This has been made a separate clas for illustration purposes. It may have been more apporpriate - * to have FileSystemProvider implement IFileModificationValidator itself since the interface - * only has two methods and their implementation is straight forward. - */ -public final class FileModificationValidator implements IFileModificationValidator { - - private FileSystemOperations operations; - - /** - * Constructor for FileModificationValidator. - */ - public FileModificationValidator(RepositoryProvider provider) { - operations = ((FileSystemProvider)provider).getOperations(); - } - - /** - * This method will convert any exceptions thrown by the SimpleAccessOperations.chechout() to a Status. - * @param resources the resources that are to be checked out - * @return IStatus a status indicator that reports whether the operation went smoothly or not. - * @see org.eclipse.team.internal.core.simpleAccess.SimpleAccessOperations#chechout(IResource[] resources, int depth, IProgressMonitor progress) - */ - private IStatus checkout(IResource[] resources) { - try { - operations.checkout(resources, IResource.DEPTH_INFINITE, null); - } catch (TeamException e) { - return new Status(IStatus.ERROR, FileSystemPlugin.ID, 0, e.getLocalizedMessage(), e); - } - return Status.OK_STATUS; - } - - /** - * This method will be called by the workbench/editor before it tries to edit one or more files. - * The idea is to prevent anyone from accidentally working on a file that they won't be able to check in changes to. - * @see org.eclipse.core.resources.IFileModificationValidator#validateEdit(IFile[], Object) - */ - public IStatus validateEdit(IFile[] files, Object context) { - Collection toBeCheckedOut = new ArrayList(); - - //Make a list of all the files that need to be checked out: - for (int i = 0; i < files.length; i++) { - if (!operations.isCheckedOut(files[i])) { - toBeCheckedOut.add(files[i]); - } - } - - return checkout((IResource[]) toBeCheckedOut.toArray(new IResource[toBeCheckedOut.size()])); - } - - /** - * This method will be called by the workbench before it tries to save a file. - * It should not attempt to save any files that don't recieve an OK status here. - * @see org.eclipse.core.resources.IFileModificationValidator#validateSave(IFile) - */ - public IStatus validateSave(IFile 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 deleted file mode 100644 index bf072be95..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java +++ /dev/null @@ -1,378 +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.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/FileSystemPlugin.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java deleted file mode 100644 index 040f24c3e..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java +++ /dev/null @@ -1,111 +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.IOException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.TeamException; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * This is the plugin class for the file system examples. It provides the following: - * - * <ol> - * <li>public fields for the plugin and provider IDs as defined in the plugin.xml - * <li>initialization on startup of Policy class that provides internationalization of strings - * <li>helper methods for outputing IStatus objects to the log - * <li>helper methods for converting CoreExceptions and IOExceptions to TeamExceptions - * </ol> - */ -public class FileSystemPlugin extends AbstractUIPlugin { - - /** - * This is the ID of the plugin as defined in the plugin.xml - */ - public static final String ID = "org.eclipse.team.examples.filesystem"; //$NON-NLS-1$ - - /** - * This is the provider ID of the plugin as defined in the plugin.xml - */ - public static final String PROVIDER_ID = ID + ".FileSystemProvider"; //$NON-NLS-1$ - - // This static field will hold the singleton instance of the plugin class - private static FileSystemPlugin plugin; - - /** - * Override the standard plugin constructor. - * - * @param descriptor the plugin descriptor - */ - public FileSystemPlugin(IPluginDescriptor descriptor) { - super(descriptor); - // record this instance as the singleton - plugin = this; - } - - /** - * This method will get invoked when the plugin is started. - * Note that this is not necessarily at workbench startup. - * - * @see org.eclipse.core.runtime.Plugin#startup() - */ - public void startup() throws CoreException { - // localize the string bindings used by the plugins (in order to provide NLS support) - Policy.localize("org.eclipse.team.examples.filesystem.messages"); //$NON-NLS-1$ - } - - /** - * Return the singlton instance of the plugin class to allow other - * classes in the plugin access to plugin instance methods such as - * those for logging errors, etc. - */ - public static FileSystemPlugin getPlugin() { - return plugin; - } - - /** - * Helper method to convert a CoreException into a TeamException. - * We do this to maintain the core status and code. This type of - * mapping may not be appropriate in more complicated exception - * handling situations. - * - * @param e the CoreException - */ - public static TeamException wrapException(CoreException e) { - return new TeamException(e.getStatus()); - } - - /** - * Helper method to convert an IOException into a TeamException. - * This type of mapping may not be appropriate in more complicated - * exception handling situations. - * - * @param e the CoreException - */ - public static TeamException wrapException(IOException e) { - return new TeamException(new Status(IStatus.ERROR, FileSystemPlugin.ID, - TeamException.IO_FAILED, e.getMessage(), e)); - } - - /** - * Helper method to log an exception status. - * - * @param status the status to be logged - */ - public static void log(IStatus status) { - plugin.getLog().log(status); - } -} - 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 deleted file mode 100644 index a7596be7f..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java +++ /dev/null @@ -1,206 +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.File; - -import org.eclipse.core.resources.IFileModificationValidator; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -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.core.variants.IResourceVariant; -import org.eclipse.team.examples.filesystem.subscriber.FileSystemResourceVariant; -import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber; - -/** - * This example illustrates how to create a concrete implementation of a <code>RepositoryProvider</code> - * that uses the file system to act as the repository. See the plugin.xml file for the xml required - * to register this provider with the Team extension point <code>org.eclipse.team.core.repository</code>. - * The plugin.xml file also contains examples of how to filter menu items using a repsitory provider's - * ID. - * - * <p> - * This example provider illustrates the following: - * <ol> - * <li>simple working implementation of <code>RepositoyProvider</code> - * <li>storage of a persistant property with the project (which provides the target location for the provider) - * <li>access to an instance of <code>SimpleAccessOperations</code> for performing simple file operations - * </ol> - * - * <p> - * Additional functionality that will be illustrated in the future include: - * <ol> - * <li>Validate Save/Validat Edit - * <li>Move/Delete Hook - * <li>Project Sets - * <li>Use of the workspace synchronizer (ISynchronizer) - * <li>Use of decorators - * <li>combining streams and progress monitors to get responsive UI - * </ol> - * - */ -public class FileSystemProvider extends RepositoryProvider { - - // The location of the folder on file system where the repository is stored. - private IPath root; - - // The QualifiedName that is used to persist the location accross workspace as a persistant property on a resource - private static QualifiedName FILESYSTEM_REPO_LOC = new QualifiedName(FileSystemPlugin.ID, "disk_location"); //$NON-NLS-1$ - - /** - * Create a new FileSystemProvider. - */ - public FileSystemProvider() { - super(); - } - - /** - * This method is invoked when the provider is mapped to a project. - * Although we have access to the project at this point (using - * <code>getProject()</code>, we don't know the root location so - * there is nothing we can do yet. - * - * @see org.eclipse.team.core.RepositoryProvider#configureProject() - */ - public void configureProject() throws CoreException { - FileSystemSubscriber.getInstance().handleRootChanged(getProject(), true /* added */); - } - - /** - * This method is invoked when the provider is unmapped from its - * project. - * - * @see org.eclipse.core.resources.IProjectNature#deconfigure() - */ - public void deconfigure() throws CoreException { - // Clear the persistant property containing the location - getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, null); - FileSystemSubscriber.getInstance().handleRootChanged(getProject(), false /* removed */); - } - - /** - * Return the provider ID as specified in the plugin.xml - * - * @see RepositoryProvider#getID() - */ - public String getID() { - return FileSystemPlugin.PROVIDER_ID; - } - - /** - * Set the file system location for the provider. This mist be invoked after - * the provider is mapped and configured but before the provider is used to - * perform any operations. - * - * @param location the path representing the location where the project contents will be stored. - * @throws TeamException - */ - public void setTargetLocation(String location) throws TeamException { - - // set the instance variable to the provided path - root = new Path(location); - - // ensure that the location is a folder (if it exists) - File file = new File(location); - if (file.exists() && !file.isDirectory()) { - throw new TeamException(Policy.bind("FileSystemProvider.mustBeFolder", location)); //$NON-NLS-1$ - } - - // record the location as a persistant property so it will be remembered across platform invokations - try { - getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, location); - } catch (CoreException e) { - throw FileSystemPlugin.wrapException(e); - } - } - - /** - * Returns the folder in the file system to which the provider is connected. - * Return <code>null</code> if there is no location or there was a problem - * determining it. - * - * @return IPath The path to the root of the repository. - */ - public IPath getRoot() { - if (root == null) { - try { - String location = getProject().getPersistentProperty(FILESYSTEM_REPO_LOC); - if (location == null) { - return null; - } - root = new Path(location); - } catch (CoreException e) { - // log the problem and carry on - FileSystemPlugin.log(e.getStatus()); - return null; - } - } - return root; - } - - /** - * Return an object that provides the operations for transfering data - * to and from the provider's location. - */ - public FileSystemOperations getOperations() { - return new FileSystemOperations(this); - } - /** - * @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator() - */ - public IFileModificationValidator getFileModificationValidator() { - return new FileModificationValidator(this); - } - - /** - * Return the resource variant for the local resource using the bytes to - * identify the variant. - * @param resource the resource - * @param bytes the bytes that identify the resource variant - * @return the resource variant handle - */ - public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) { - File file = getFile(resource); - if (file == null) return null; - return new FileSystemResourceVariant(file, bytes); - } - - /** - * Return the resource variant for the local resource. - * @param resource the resource - * @return the resource variant - */ - public IResourceVariant getResourceVariant(IResource resource) { - File file = getFile(resource); - if (file == null) return null; - return new FileSystemResourceVariant(file); - } - - /** - * Return the <code>java.io.File</code> that the given resource maps to. - * Return <code>null</code> if the resource is not a child of this provider's - * project. - * @param resource the resource - * @return the file that the resource maps to. - */ - public java.io.File getFile(IResource resource) { - if (resource.getProject().equals(getProject())) { - IPath rootdir = getRoot(); - return new File(rootdir.append(resource.getProjectRelativePath()).toOSString()); - } - return null; - } - -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java deleted file mode 100644 index cfb2db53a..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java +++ /dev/null @@ -1,93 +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.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -/** - * This class is a clone of the Polciy classes many Eclipse plugin suse to - * provide NLSing of strings and aid in proper progress monitoring. - */ -public class Policy { - - protected static ResourceBundle bundle = null; - - /** - * Creates a NLS catalog for the given locale. - */ - public static void localize(String bundleName) { - bundle = ResourceBundle.getBundle(bundleName); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given string. - */ - public static String bind(String id, String binding) { - return bind(id, new String[] { binding }); - } - - /** - * Lookup the message with the given ID in this catalog and bind its - * substitution locations with the given strings. - */ - public static String bind(String id, String binding1, String binding2) { - return bind(id, new String[] { binding1, binding2 }); - } - - /** - * Gets a string from the resource bundle. We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String bind(String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Gets a string from the resource bundle and binds it with the given arguments. If the key is - * not found, return the key. - */ - public static String bind(String key, Object[] args) { - try { - return MessageFormat.format(bind(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Progress monitor helpers - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - } - - public static IProgressMonitor monitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java deleted file mode 100644 index f39f21743..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/StreamUtil.java +++ /dev/null @@ -1,58 +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.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IProgressMonitor; - -public class StreamUtil { - - protected final static byte[] COPY_BUFFER = new byte[4096]; - - public static void pipe( - InputStream in, - OutputStream out, - long sizeEstimate, - IProgressMonitor progress, - String title) - throws IOException { - - // Only show progress for files larger than 25Kb. - Long kilobytesEstimate = new Long(sizeEstimate / 1024); - boolean showProgress = (progress != null) && (sizeEstimate > 25000); - long bytesCopied = 0; - - synchronized (COPY_BUFFER) { - // Read the initial chunk. - int read = in.read(COPY_BUFFER, 0, COPY_BUFFER.length); - - while (read != -1) { - out.write(COPY_BUFFER, 0, read); - - // Report progress - if (showProgress) { - bytesCopied = bytesCopied + read; - progress.subTask( - Policy.bind( - "filetransfer.monitor", //$NON-NLS-1$ - new Object[] { title, new Long(bytesCopied / 1024), kilobytesEstimate })); - } - - // Read the next chunk. - read = in.read(COPY_BUFFER, 0, COPY_BUFFER.length); - } // end while - } // end synchronized - } - -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties deleted file mode 100644 index ccb68c1c3..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/messages.properties +++ /dev/null @@ -1,41 +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 -############################################################################### -fileSystem.propertyLocation=Location: - -FileSystemMainPage.location=Location: -FileSystemMainPage.browseDir=&Browse... -FileSystemMainPage.notValidLocation=Location must be an existing directory - -fsMainPage.name=Select a file system location -fsMainPage.description=This location will be used to share resources with a team - -ConfigurationWizard.errorTitle=Error configuring the provider. -ConfigurationWizard.error=File System provider could not be created - -ConfigurationWizard.name=File System Repository -ConfigurationWizard.description=File System Repository Properties - -DisconnectAction.errorTitle=Error Disconnecting - -PutAction.working=Putting resources... -PutAction.problemMessage=A problem occured putting the resources. - -GetAction.working=Getting resources... -GetAction.problemMessage=A problem occured getting the resources. - -ReplaceAction.working=Replacing resources... -ReplaceAction.problemMessage=A problem occured replacing the resources. - -FileSystemProvider.mustBeFolder=Target location ''{0}'' is a file and must be a folder. -RemoteResource.mustBeFolder=Resource ''{0}'' is a file so it cannot have entries -FileSystemRemoteResource.0=This resource is a container so it cannot have data. -FileSystemSimpleAccessOperations.1=Checking resources out... -FileSystemSimpleAccessOperations.3=Re-locking resources... 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 deleted file mode 100644 index 1a5d01b93..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemRemoteTree.java +++ /dev/null @@ -1,53 +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.subscriber; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.ThreeWayRemoteTree; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; -import org.eclipse.team.examples.filesystem.FileSystemProvider; - -/** - * The file sytem three-way remote resource varant tree taht provides - * the ability to traverse the file system for the creation of resource variants. - */ -public class FileSystemRemoteTree extends ThreeWayRemoteTree { - - /** - * Create the file syetm remote resource variant tree - * @param subscriber the file system subscriber - */ - public FileSystemRemoteTree(FileSystemSubscriber subscriber) { - super(subscriber); - } - - /* (non-Javadoc) - * @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 { - return ((FileSystemResourceVariant)variant).members(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchVariant(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IProgressMonitor) - */ - protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID); - if (provider != null) { - return ((FileSystemProvider)provider).getResourceVariant(resource); - } - return null; - } -} 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 deleted file mode 100644 index 5ddd2c7fa..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java +++ /dev/null @@ -1,150 +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.subscriber; - -import java.io.BufferedInputStream; -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; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.CachedResourceVariant; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; - -/** - * A file system resource variant. Although not strictly necessary, this - * class extends <code>CachedResourceVariant</code> which will - * cache the contents of the resource variant. - */ -public class FileSystemResourceVariant extends CachedResourceVariant { - - private java.io.File ioFile; - private byte[] bytes; - - /** - * Create a resource variant for the given file. The bytes will - * be calculated when they are accessed. - * @param file the file - */ - public FileSystemResourceVariant(java.io.File file) { - this.ioFile = file; - } - - /** - * Create a resource variant for the given file and sync bytes. - * @param file the file - * @param bytes the timestamp bytes - */ - public FileSystemResourceVariant(java.io.File file, byte[] bytes) { - this.ioFile = file; - this.bytes = bytes; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.CachedResourceVariant#fetchContents(org.eclipse.core.runtime.IProgressMonitor) - */ - protected void fetchContents(IProgressMonitor monitor) throws TeamException { - setContents(getContents(), monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.CachedResourceVariant#getCachePath() - */ - protected String getCachePath() { - // append the timestamp to the file path to give each variant a unique path - return getFilePath() + " " + ioFile.lastModified(); //$NON-NLS-1$ - } - - private String getFilePath() { - try { - return ioFile.getCanonicalPath(); - } catch (IOException e) { - // Failed for some reason. Try the absolute path. - FileSystemPlugin.log(new Status(IStatus.ERROR, FileSystemPlugin.ID, 0, - "Failed to obtain canonical path for " + ioFile.getAbsolutePath(), e)); - return ioFile.getAbsolutePath(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.CachedResourceVariant#getCacheId() - */ - protected String getCacheId() { - return FileSystemPlugin.ID; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#getName() - */ - public String getName() { - return ioFile.getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#isContainer() - */ - public boolean isContainer() { - return ioFile.isDirectory(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#getContentIdentifier() - */ - public String getContentIdentifier() { - // Use the modification timestamp as the content identifier - return new Date(ioFile.lastModified()).toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariant#asBytes() - */ - public byte[] asBytes() { - if (bytes == null) { - // For simplicity, convert the timestamp to it's string representation. - // A more optimal storage format would be the 8 bytes that make up the long. - bytes = Long.toString(ioFile.lastModified()).getBytes(); - } - return bytes; - } - - /** - * Return the files contained by the file of this resource variant. - * @return the files contained by the file of this resource variant. - */ - 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/subscriber/FileSystemSubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java deleted file mode 100644 index fc0880b46..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java +++ /dev/null @@ -1,115 +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.subscriber; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.variants.IResourceVariant; -import org.eclipse.team.core.variants.ThreeWayRemoteTree; -import org.eclipse.team.core.variants.ThreeWaySubscriber; -import org.eclipse.team.core.variants.ThreeWaySynchronizer; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; -import org.eclipse.team.examples.filesystem.FileSystemProvider; - -/** - * This is an example file system subscriber that overrides - * ThreeWaySubscriber. It uses a repository - * provider (<code>FileSystemProvider</code>) to determine and - * manage the roots and to create resource variants. It also makes - * use of a file system specific remote tree (<code>FileSystemRemoteTree</code>) - * for provided the remote tree access and refresh. - * - * @see ThreeWaySubscriber - * @see ThreeWaySynchronizer - * @see FileSystemProvider - * @see FileSystemRemoteTree - */ -public class FileSystemSubscriber extends ThreeWaySubscriber { - - private static FileSystemSubscriber instance; - - /** - * Return the file system subscriber singleton. - * @return the file system subscriber singleton. - */ - public static synchronized FileSystemSubscriber getInstance() { - if (instance == null) { - instance = new FileSystemSubscriber(); - } - return instance; - } - - /** - * Create the file system subscriber. - */ - private FileSystemSubscriber() { - super(new ThreeWaySynchronizer(new QualifiedName(FileSystemPlugin.ID, "workpsace-sync"))); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ThreeWaySubscriber#getResourceVariant(org.eclipse.core.resources.IResource, byte[]) - */ - public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException { - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID); - if (provider != null) { - return ((FileSystemProvider)provider).getResourceVariant(resource, bytes); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ThreeWaySubscriber#createRemoteTree() - */ - protected ThreeWayRemoteTree createRemoteTree() { - return new FileSystemRemoteTree(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#getName() - */ - public String getName() { - return "File System Example"; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.Subscriber#roots() - */ - public IResource[] roots() { - List result = new ArrayList(); - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - if(project.isAccessible()) { - RepositoryProvider provider = RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID); - if(provider != null) { - result.add(project); - } - } - } - return (IProject[]) result.toArray(new IProject[result.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.ThreeWaySubscriber#handleRootChanged(org.eclipse.core.resources.IResource, boolean) - */ - public void handleRootChanged(IResource resource, boolean added) { - // Override to allow FileSystemProvider to signal the addition and removal of roots - super.handleRootChanged(resource, added); - } - -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java deleted file mode 100644 index bab78242b..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java +++ /dev/null @@ -1,88 +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.ui; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; -import org.eclipse.team.examples.filesystem.FileSystemProvider; -import org.eclipse.team.examples.filesystem.Policy; -import org.eclipse.team.ui.IConfigurationWizard; -import org.eclipse.ui.IWorkbench; - -/** - * The file system configuration wizard used when associating a project - * the the file system provider. It is registered as a Team configuration wizard - * in the plugin.xml and is invoked when a user chooses to create a File System - * Repository Provider. One invoked, this wizard makes use of the <code>FileSystemMainPage</code> - * in order to obtain a target locaton on disk. - */ -public class ConfigurationWizard extends Wizard implements IConfigurationWizard { - - IProject project; - - FileSystemMainPage mainPage; - - public ConfigurationWizard() { - // retrieve the remembered dialog settings - IDialogSettings workbenchSettings = FileSystemPlugin.getPlugin().getDialogSettings(); - IDialogSettings section = workbenchSettings.getSection("ProviderExamplesWizard"); //$NON-NLS-1$ - if (section == null) { - section = workbenchSettings.addNewSection("ProviderExamplesWizard"); //$NON-NLS-1$ - } - setDialogSettings(section); - } - - /** - * Remember the project so we can map it on finish - * - * @see org.eclipse.team.ui.IConfigurationWizard#init(IWorkbench, IProject) - */ - public void init(IWorkbench workbench, IProject project) { - this.project = project; - } - - public void addPages() { - mainPage = new FileSystemMainPage( - "FileSystemMainPage", //$NON-NLS-1$ - Policy.bind("ConfigurationWizard.name"), //$NON-NLS-1$ - Policy.bind("ConfigurationWizard.description"), //$NON-NLS-1$ - null); - addPage(mainPage); - } - - /* - * Using the information entered in the main page set the provider for - * the given project. - */ - public boolean performFinish() { - mainPage.finish(null); - try { - // Map the provider and set the location - RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID); - FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project); - provider.setTargetLocation(mainPage.getLocation()); - } catch (TeamException e) { - ErrorDialog.openError( - getShell(), - Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$ - Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$ - e.getStatus()); - return false; - } - return true; - } - -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java deleted file mode 100644 index 6fc051cdd..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/DisconnectAction.java +++ /dev/null @@ -1,46 +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.ui; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.Policy; -import org.eclipse.team.internal.ui.actions.TeamAction; - -/** - * Action for getting the contents of the selected resources - */ -public class DisconnectAction extends TeamAction { - - /** - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - public void run(IAction action) { - IProject projects[] = getSelectedProjects(); - try { - for (int i = 0; i < projects.length; i++) { - RepositoryProvider.unmap(projects[i]); - } - } catch (TeamException e) { - ErrorDialog.openError(getShell(), Policy.bind("DisconnectAction.errorTitle"), null, e.getStatus()); //$NON-NLS-1$ - } - } - - /** - * @see TeamAction#isEnabled() - */ - protected boolean isEnabled() { - return true; - } -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java deleted file mode 100644 index e3a5da71f..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java +++ /dev/null @@ -1,65 +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.ui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; -import org.eclipse.team.internal.ui.actions.TeamAction; - -/** - * An abstract class that acts as a super class for FileSystemProvider actions. - * It provides some general methods applicable to multipe actions. - */ -public abstract class FileSystemAction extends TeamAction { - - /** - * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() - */ - protected boolean isEnabled() { - IResource[] resources = getSelectedResources(); - if (resources.length == 0) - return false; - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - // we only want to work on resources mapped to a file system provider - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID); - if (provider == null) - return false; - } - return true; - } - - /** - * Split the resources into sets associated with their project/provider - */ - protected Map getRepositoryProviderMapping() throws TeamException { - HashMap result = new HashMap(); - IResource[] resources = getSelectedResources(); - for (int i = 0; i < resources.length; i++) { - RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject()); - List list = (List) result.get(provider); - if (list == null) { - list = new ArrayList(); - result.put(provider, list); - } - list.add(resources[i]); - } - return result; - } - -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java deleted file mode 100644 index 219ac80fc..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.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.ui; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.examples.filesystem.Policy; - -/** - * This class provides the main page of the file system repository configuration wizard. - * It allows the user to select a location on disk. Once the page is finished, the - * location can be accessed using the <code>getLocation()</code> method. - */ -public class FileSystemMainPage extends WizardPage { - - private static final int COMBO_HISTORY_LENGTH = 5; - - String location; - Combo locationCombo; - - /* - * WizardPage constructor comment. - * @param pageName the name of the page - * @param title the title of the page - * @param description the description of the page - * @param titleImage the image for the page - */ - - public FileSystemMainPage(String pageName, String title, String description, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - setDescription(description); - setTitle(title); - } - - /* - * Creates a new checkbox instance and sets the default layout data. - * - * @param group the composite in which to create the checkbox - * @param label the string to set into the checkbox - * @return the new checkbox - */ - protected Button createCheckBox(Composite group, String label) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setText(label); - GridData data = new GridData(); - data.horizontalSpan = 2; - button.setLayoutData(data); - return button; - } - - /* - * Utility method that creates a combo box - * - * @param parent the parent for the new label - * @return the new widget - */ - protected Combo createCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - combo.setLayoutData(data); - return combo; - } - - /* - * Creates composite control and sets the default layout data. - * - * @param parent the parent of the new composite - * @param numColumns the number of columns for the new composite - * @return the newly-created coposite - */ - protected Composite createComposite(Composite parent, int numColumns) { - Composite composite = new Composite(parent, SWT.NULL); - - // GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - composite.setLayout(layout); - - // GridData - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - return composite; - } - - /* - * Utility method that creates a label instance - * and sets the default layout data. - * - * @param parent the parent for the new label - * @param text the text for the new label - * @return the new label - */ - protected Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - label.setText(text); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - /* - * Create a text field specific for this application - * - * @param parent the parent of the new text field - * @return the new text field - */ - protected Text createTextField(Composite parent) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.verticalAlignment = GridData.CENTER; - data.grabExcessVerticalSpace = false; - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - text.setLayoutData(data); - return text; - } - - /* - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length <code>ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH</code>. - * - * @param history the current history - * @param newEntry the entry to add to the history - * @return the history with the new entry appended - */ - protected String[] addToHistory(String[] history, String newEntry) { - ArrayList l = new ArrayList(Arrays.asList(history)); - addToHistory(l, newEntry); - String[] r = new String[l.size()]; - l.toArray(r); - return r; - } - - /* - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length <code>ConfigurationWizardMainPage.COMBO_HISTORY_LENGTH</code>. - * - * @param history the current history - * @param newEntry the entry to add to the history - */ - protected void addToHistory(List history, String newEntry) { - history.remove(newEntry); - history.add(0,newEntry); - - // since only one new item was added, we can be over the limit - // by at most one item - if (history.size() > COMBO_HISTORY_LENGTH) - history.remove(COMBO_HISTORY_LENGTH); - } - - /* - * Utility method to create an editable combo box - * - * @param parent the parent of the combo box - * @return the created combo - */ - protected Combo createEditableCombo(Composite parent) { - Combo combo = new Combo(parent, SWT.NULL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; - combo.setLayoutData(data); - return combo; - } - - // Dialog store id constants - private static final String STORE_LOCATION = - "ExamplesFSWizardMainPage.STORE_LOCATION";//$NON-NLS-1$ - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - setControl(composite); - - Label label = new Label(composite, SWT.NULL); - label.setText(Policy.bind("FileSystemMainPage.location")); //$NON-NLS-1$ - label.setLayoutData(new GridData()); - - locationCombo = createEditableCombo(composite); - locationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - locationCombo.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event e) { - location = ((Combo)e.widget).getText(); - FileSystemMainPage.this.validateFields(); - } - }); - - locationCombo.setFocus(); - - new Label(composite, SWT.NULL); - Button browse = new Button(composite, SWT.NULL); - browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - browse.setText(Policy.bind("FileSystemMainPage.browseDir")); //$NON-NLS-1$ - browse.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - DirectoryDialog d = new DirectoryDialog(getShell()); - String directory = d.open(); - if(directory!=null) { - locationCombo.setText(directory); - } - } - }); - - initializeValues(); - validateFields(); - } - - public String getLocation() { - return location; - } - - public boolean finish(IProgressMonitor monitor) { - saveWidgetValues(); - return true; - } - /** - * Initializes states of the controls. - */ - private void initializeValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] locations = settings.getArray(STORE_LOCATION); - if (locations != null) { - for (int i = 0; i < locations.length; i++) { - locationCombo.add(locations[i]); - } - locationCombo.select(0); - } - } - } - /** - * Saves the widget values - */ - private void saveWidgetValues() { - // Update history - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] locations = settings.getArray(STORE_LOCATION); - if (locations == null) locations = new String[0]; - locations = addToHistory(locations, locationCombo.getText()); - settings.put(STORE_LOCATION, locations); - } - } - - /* - * Validates the contents of the editable fields and set page completion - * and error messages appropriately. - */ - private void validateFields() { - String location = locationCombo.getText(); - if (location.length() == 0) { - setErrorMessage(null); - setPageComplete(false); - return; - } else { - File file = new File(location); - if(!file.exists() || !file.isDirectory()) { - setErrorMessage(Policy.bind("FileSystemMainPage.notValidLocation")); //$NON-NLS-1$ - setPageComplete(false); - return; - } - } - setErrorMessage(null); - setPageComplete(true); - } -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java deleted file mode 100644 index 309f98030..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemPropertiesPage.java +++ /dev/null @@ -1,82 +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.ui; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.ui.dialogs.PropertyPage; -/* - * A property page which displays the file system specific properties - * for the selected resource. - */ -public class FileSystemPropertiesPage extends PropertyPage { - // The resource to show properties for - protected IResource resource; - - /* - * Creates a key-value property pair in the given parent. - * - * @param parent the parent for the labels - * @param left the string for the left label - * @param right the string for the right label - */ - protected void createPair(Composite parent, String left, String right) { - Label label = new Label(parent, SWT.NONE); - label.setText(left); - - label = new Label(parent, SWT.NONE); - label.setText(right); - label.setToolTipText(right); - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - /* - * Returns the element selected when the properties was run - * @return the selected element - */ - protected IResource getSelectedElement() { - // get the resource that is the source of this property page - IResource resource = null; - IAdaptable element = getElement(); - if (element instanceof IResource) { - resource = (IResource)element; - } else { - Object adapter = element.getAdapter(IResource.class); - if (adapter instanceof IResource) { - resource = (IResource)adapter; - } - } - return resource; - } - - /* - * @see PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - IResource resource = getSelectedElement(); - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject()); - return composite; - } -} 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 deleted file mode 100644 index b873400a2..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/GetAction.java +++ /dev/null @@ -1,63 +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.ui; - -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.FileSystemProvider; -import org.eclipse.team.examples.filesystem.Policy; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -/** - * Action for getting the contents of the selected resources - */ -public class GetAction extends FileSystemAction { - - public void run(IAction action) { - run(new WorkspaceModifyOperation(null) { - public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - try { - Map table = getRepositoryProviderMapping(); - monitor.beginTask(null, table.size() * 1000); - monitor.setTaskName(Policy.bind("GetAction.working")); //$NON-NLS-1$ - for (Iterator iter = table.keySet().iterator(); iter.hasNext();) { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); - FileSystemProvider provider = (FileSystemProvider) iter.next(); - List list = (List) table.get(provider); - IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]); - provider.getOperations().get(providerResources, IResource.DEPTH_INFINITE, isOverwriteOutgoing(), subMonitor); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }, 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 deleted file mode 100644 index 1a6304187..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/PutAction.java +++ /dev/null @@ -1,65 +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.ui; - -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.FileSystemProvider; -import org.eclipse.team.examples.filesystem.Policy; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -/** - * Action for checking in the selected resources - */ -public class PutAction extends FileSystemAction { - - /* - * Method declared on IActionDelegate. - */ - public void run(IAction action) { - run(new WorkspaceModifyOperation(null) { - public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - try { - Map table = getRepositoryProviderMapping(); - monitor.beginTask(null, table.size() * 1000); - monitor.setTaskName(Policy.bind("PutAction.working")); //$NON-NLS-1$ - for (Iterator iter = table.keySet().iterator(); iter.hasNext();) { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); - FileSystemProvider provider = (FileSystemProvider) iter.next(); - List list = (List) table.get(provider); - IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]); - provider.getOperations().checkin(providerResources, IResource.DEPTH_INFINITE, isOverrideIncoming(), subMonitor); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }, Policy.bind("PutAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$ - } - - /** - * Indicate whether the put should override incoming changes. - * @return whether the put should override incoming changes. - */ - protected boolean isOverrideIncoming() { - return false; - } -} diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java deleted file mode 100644 index 60a5620a5..000000000 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ReplaceAction.java +++ /dev/null @@ -1,25 +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.ui; - - -/** - * A replace is simply a get that overwrite local changes - */ -public class ReplaceAction extends GetAction { - - /* (non-Javadoc) - * @see org.eclipse.team.examples.filesystem.ui.GetAction#isOverwriteOutgoing() - */ - protected boolean isOverwriteOutgoing() { - return true; - } -} |