Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-10-20 19:55:38 +0000
committerMichael Valenta2003-10-20 19:55:38 +0000
commita2a169b8a23d6cad0ac857387dcacf4099493389 (patch)
tree19f3c98932ed1aa4892f985a4b6d8ba436bdcaaf
parentfa4d066e7036b86610bebf162c3b829c6ccd49ee (diff)
downloadeclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.tar.gz
eclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.tar.xz
eclipse.platform.team-a2a169b8a23d6cad0ac857387dcacf4099493389.zip
Extracted Target code from team plugins and placed it
in the team.webdav plugin
-rw-r--r--bundles/org.eclipse.team.core/plugin.xml1
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java4
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java82
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/BaseIdentifierNotInitializedException.java31
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/IRemoteTargetResource.java120
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteFactory.java42
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteListener.java16
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITargetRunnable.java18
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITeamStatusConstants.java79
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java98
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java201
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java826
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/Site.java145
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java228
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetManager.java274
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetProvider.java218
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/UrlUtil.java81
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/messages.properties21
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/site_element.gifbin0 -> 147 bytes
-rw-r--r--bundles/org.eclipse.team.ui/plugin.properties16
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml87
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java33
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/AuthenticatedTargetSitePropertiesPage.java104
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java399
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java147
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/DiscardSiteAction.java190
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ExportTargetSiteMainPage.java206
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAction.java177
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java198
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsProjectAction.java161
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetSyncAction.java149
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ImportTargetSiteMainPage.java149
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java197
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ProjectTargetMappingPropertiesPage.java126
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutAction.java78
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutSyncAction.java149
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java181
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java92
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java574
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java54
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteLazyContentProvider.java25
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java68
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java189
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteViewSorter.java40
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java51
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java102
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java61
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java59
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteContentHandler.java89
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteExportWizard.java191
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteImportWizard.java158
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java235
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java95
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetWizardPage.java199
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java110
-rw-r--r--tests/org.eclipse.team.tests.core/build.properties2
-rw-r--r--tests/org.eclipse.team.tests.core/ftp.properties17
-rw-r--r--tests/org.eclipse.team.tests.core/plugin.xml10
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java41
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java3
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java100
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java707
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java237
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java108
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java62
-rw-r--r--tests/org.eclipse.team.tests.core/test.xml32
-rw-r--r--tests/org.eclipse.team.tests.core/webdav.properties17
68 files changed, 5 insertions, 8956 deletions
diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml
index 4cbef5874..0e8fd5c76 100644
--- a/bundles/org.eclipse.team.core/plugin.xml
+++ b/bundles/org.eclipse.team.core/plugin.xml
@@ -22,7 +22,6 @@
<extension-point id="ignore" name="%GlobalIgnoreRegistry" schema="schema/ignore.exsd"/>
<extension-point id="projectSets" name="%TeamProjectSets" schema="schema/projectSets.exsd"/>
<extension-point id="repository" name="%Repository" schema="schema/repository.exsd"/>
- <extension-point id="targets" name="%Targets"/>
<extension-point id="subscriber" name="%Subscriber"/>
<!-- Define common known file types -->
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
index c6de5c808..5b5d9140f 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.TargetManager;
/**
* <code>TeamPlugin</code> is the plug-in runtime class for the Team
@@ -46,8 +45,6 @@ final public class TeamPlugin extends Plugin {
public static final String PROJECT_SET_EXTENSION = "projectSets"; //$NON-NLS-1$
// The id of the targets extension point
public static final String REPOSITORY_EXTENSION = "repository"; //$NON-NLS-1$
- // The id of the targets extension point
- public static final String TARGETS_EXTENSION = "targets"; //$NON-NLS-1$
// The one and only plug-in instance
@@ -67,7 +64,6 @@ final public class TeamPlugin extends Plugin {
public void startup() throws CoreException {
Policy.localize("org.eclipse.team.internal.core.messages"); //$NON-NLS-1$
Team.startup();
- TargetManager.startup();
}
/**
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java
deleted file mode 100644
index 3e1b5f8ea..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.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.internal.core.target;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-/**
- * This is a layer that contains anything which a Target Site implementation that uses authentication would need to have.
- */
-public abstract class AuthenticatedSite extends Site {
-
- protected String username;
- protected String password;
-
- /**
- * @see org.eclipse.team.internal.core.target.Site#dispose()
- */
- public void dispose() throws TeamException {
- try {
- Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException e) {
- throw new TeamException(e.getStatus());
- }
- }
-
- /**
- * Gets the username.
- * @return Returns a String
- */
- public String getUsername() {
- return username;
- }
-
- /**
- * Gets the password.
- * @return Returns a String
- */
- public String getPassword() {
- return password;
- }
-
- public void setUsername(String name) throws TeamException {
- Map authInfo=Platform.getAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- if (authInfo==null) authInfo=new HashMap(2);
- authInfo.put("name", name); //$NON-NLS-1$
- try {
- Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- Platform.addAuthorizationInfo(getURL(), "", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$
- this.username=name;
- } catch (CoreException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
- public void setPassword(String password) throws TeamException {
- Map authInfo=Platform.getAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- if (authInfo==null) authInfo=new HashMap(2);
- authInfo.put("password", password); //$NON-NLS-1$
- try {
- Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
- Platform.addAuthorizationInfo(getURL(), "", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$
- this.password=password;
- } catch (CoreException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/BaseIdentifierNotInitializedException.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/BaseIdentifierNotInitializedException.java
deleted file mode 100644
index e592b65b5..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/BaseIdentifierNotInitializedException.java
+++ /dev/null
@@ -1,31 +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.internal.core.target;
-
-public class BaseIdentifierNotInitializedException extends Exception {
- /**
- * Default constructor for a <code>TeamProviderException</code>.
- */
- public BaseIdentifierNotInitializedException() {
- super();
- }
-
- /**
- * Constructor for a <code>TeamProviderException</code> that takes
- * a string description of the cause of the exception.
- *
- * @param message a message describing the cause of the exception.
- */
- public BaseIdentifierNotInitializedException(String message) {
- super(message);
- }
-}
-
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/IRemoteTargetResource.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/IRemoteTargetResource.java
deleted file mode 100644
index 9395cc77d..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/IRemoteTargetResource.java
+++ /dev/null
@@ -1,120 +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.internal.core.target;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-
-/**
- * Interface for target resources that are not local. This is a handle to a
- * clients-side 'proxy' for the server resource. There are no guarantees that
- * the handle is not stale or invalid.
- * <p>
- * Use <code>exists()</code> to verify is the associated server resource
- * exists.</p>
- * <p>
- * Methods that take progress monitors are expected to be long running and
- * may contact the server. Progress and cancellation will be provided. Clients
- * can assume that methods that don't take progress monitors are responsive
- * and won't contact the server.
- * </p>
- *
- * @see IRemoteResource
- */
-public interface IRemoteTargetResource extends IRemoteResource {
- /**
- * Returns the URL of this remote resource.
- */
- public URL getURL();
-
- /**
- * Returns the size of the resource.
- */
- public int getSize(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Returns the last modified time
- */
- public String getLastModified(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Return a boolean value indicating whether or not this resource exists on the
- * remote server.
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Creates the directory named by this URL, including any necessary but non-existant
- * parent directories.
- */
- public void mkdirs(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Returns a handle to the remote file identified by the given path in this
- * folder.
- * <p>
- * This is a remote resource handle operation; neither the resource nor
- * the result need exist on the server.</p>
- * <p>
- * The supplied path may be absolute or relative; in either case, it is
- * interpreted as relative to this resource and is appended
- * to this container's full path to form the full path of the resultant resource.
- * A trailing separator is ignored.
- * </p>
- *
- * @param name the path of the remote member file
- * @return the (handle of the) remote file
- * @see #getFolder
- */
- public IRemoteTargetResource getFile(String name);
-
- /**
- * Returns a handle to the remote folder identified by the given path in this
- * folder.
- * <p>
- * This is a remote resource handle operation; neither the resource nor
- * the result need exist on the server.</p>
- * <p>
- * The supplied path may be absolute or relative; in either case, it is
- * interpreted as relative to this resource and is appended
- * to this container's full path to form the full path of the resultant resource.
- * A trailing separator is ignored.
- * </p>
- *
- * @param path the path of the remote member file
- * @return the (handle of the) remote file
- * @see #getFolder
- */
- public IRemoteTargetResource getFolder(String name);
-
- /**
- * Return the site where this remote resource exists
- */
- public Site getSite();
-
- /**
- * Return true if this can be reached (in some fashion).
- * This method is not guaranteed to catch all connection failure cases but is used
- * to at least test the waters.
- * @param monitor
- * @return boolean
- */
- boolean canBeReached(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Delete the remote resource.
- */
- public void delete(IProgressMonitor monitor) throws TeamException;
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteFactory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteFactory.java
deleted file mode 100644
index 972c1592b..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteFactory.java
+++ /dev/null
@@ -1,42 +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.internal.core.target;
-
-import java.io.ObjectInputStream;
-import java.util.Properties;
-
-/**
- * The <code>ISiteFactory</code> interface must be implemented by any plug-in
- * that is providing target management. It provides mechanisms for creating
- * concrete <code>Site</code> instances for it's target type.
- *
- * @see Site
- */
-public interface ISiteFactory {
- /**
- * Responsible for reading from the stream and restoring the classes fields
- * then returning a new <code>Site</code> instance. The <code>Site</code>
- * instances are written using the <code>Site#writeObject</code> method.
- *
- * @param is the input stream that contains the output of Site#writeObject
- * @return a new target site
- */
- public Site newSite(ObjectInputStream is);
-
- /**
- * Returns a new target site for the given target specific properties. This
- * is mainly used for testing purposes.
- *
- * @param properties the target specific location encoded in properties
- * @return a new target site
- */
- public Site newSite(Properties properties);
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteListener.java
deleted file mode 100644
index 39820348a..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ISiteListener.java
+++ /dev/null
@@ -1,16 +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.internal.core.target;
-
-public interface ISiteListener {
- public void siteAdded(Site site);
- public void siteRemoved(Site site);
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITargetRunnable.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITargetRunnable.java
deleted file mode 100644
index e78f7b5ff..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITargetRunnable.java
+++ /dev/null
@@ -1,18 +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.internal.core.target;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-
-public interface ITargetRunnable {
- public void run(IProgressMonitor monitor) throws TeamException;
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITeamStatusConstants.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITeamStatusConstants.java
deleted file mode 100644
index 97fde4d33..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ITeamStatusConstants.java
+++ /dev/null
@@ -1,79 +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.internal.core.target;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-public interface ITeamStatusConstants {
-
- public static final IStatus OK_STATUS = Team.OK_STATUS;
-
- public static final IStatus NOT_CHECKED_OUT_STATUS =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- TeamException.NOT_CHECKED_OUT,
- Policy.bind("teamStatus.notCheckedOut"), //$NON-NLS-1$
- null);
-
- public static final IStatus NOT_CHECKED_IN_STATUS =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- TeamException.NOT_CHECKED_IN,
- Policy.bind("teamStatus.notCheckedIn"), //$NON-NLS-1$
- null);
-
- public static final IStatus NO_REMOTE_RESOURCE_STATUS =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- TeamException.NO_REMOTE_RESOURCE,
- Policy.bind("teamStatus.noRemoteResource"), //$NON-NLS-1$
- null);
-
- public static final IStatus IO_FAILED_STATUS =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- TeamException.IO_FAILED,
- Policy.bind("teamStatus.ioFailed"), //$NON-NLS-1$
- null);
-
- public static final IStatus CONFLICT_STATUS =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- TeamException.CONFLICT,
- Policy.bind("teamStatus.conflict"), //$NON-NLS-1$
- null);
-
- public static final IStatus REQUIRED_CONFIGURATION_MISSING =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- -100,
- Policy.bind("provider.configuration.missing"), //$NON-NLS-1$
- null);
-
- public static final IStatus INVALID_CONFIGURATION =
- new Status(
- IStatus.ERROR,
- TeamPlugin.ID,
- -101,
- Policy.bind("provider.configuration.invalid"), //$NON-NLS-1$
- null);
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java
deleted file mode 100644
index 0aeb4f483..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java
+++ /dev/null
@@ -1,98 +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.internal.core.target;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class LocationMapping {
-
- private final long SERIAL_ID = 1;
-
- private String type;
- private URL url;
- private IPath path;
-
- public LocationMapping(Site site, IPath path) {
- this.type = site.getType();
- this.url = site.getURL();
- this.path = path;
- }
-
- public LocationMapping(String type, URL url, IPath path) {
- this.type = type;
- this.url = url;
- this.path = path;
- }
-
- public LocationMapping(byte[] bytes) throws IOException {
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- DataInputStream is = new DataInputStream(bis);
- long id = is.readLong();
- this.type = is.readUTF();
- this.url = new URL(is.readUTF());
- this.path = new Path(is.readUTF());
- }
-
-
- /**
- * Gets the type.
- * @return Returns a String
- */
- public String getType() {
- return type;
- }
-
- /**
- * Gets the locationId.
- * @return Returns a String
- */
- public URL getURL() {
- return url;
- }
-
- /**
- * @see Object#equals(Object)
- */
- public boolean equals(Object other) {
- if(this == other) return true;
- if(! (other instanceof LocationMapping)) return false;
- LocationMapping location = (LocationMapping)other;
- return getType().equals(location.getType()) &&
- getURL().equals(location.getURL()) &&
- getPath().equals(location.getPath());
- }
- /**
- * Gets the path.
- * @return Returns a IPath
- */
- public IPath getPath() {
- return path;
- }
-
-
- public byte[] encode() throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- DataOutputStream os = new DataOutputStream(bos);
- os.writeLong(SERIAL_ID);
- os.writeUTF(getType());
- os.writeUTF(getURL().toExternalForm());
- os.writeUTF(getPath().toString());
- return bos.toByteArray();
- }
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java
deleted file mode 100644
index 5ee713aa0..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.core.target;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.ILocalSyncElement;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.core.sync.RemoteSyncElement;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-/**
- * Is a synchronization element that can calculate three-way sync
- * states based on timestamps. This is useful for synchronizing between
- * repositories without revision history and thus the base contents is
- * not available (e.g. non-versioning DAV, FTP...)
- *
- * @see IRemoteSyncElement
- */
-public class RemoteTargetSyncElement extends RemoteSyncElement {
-
- private IRemoteTargetResource remote;
- private IResource local;
- private TargetProvider provider;
-
- public RemoteTargetSyncElement(TargetProvider provider, IResource local, IRemoteTargetResource remote) {
- this.local = local;
- this.remote = remote;
- this.provider = provider;
- }
-
- /**
- * @see RemoteSyncElement#create(boolean, IResource, IRemoteResource, IRemoteResource, Object)
- */
- public IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data) {
- return new RemoteTargetSyncElement(provider, local, (IRemoteTargetResource)remote);
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IResource, IRemoteResource)
- */
- protected boolean timestampEquals(IResource e1, IRemoteResource e2) {
- return false;
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IRemoteResource, IRemoteResource)
- */
- protected boolean timestampEquals(IRemoteResource e1, IRemoteResource e2) {
- return false;
- }
-
- /**
- * @see LocalSyncElement#create(IResource, IRemoteResource, Object)
- */
- public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
- return new RemoteTargetSyncElement(provider, local, (IRemoteTargetResource)base);
- }
-
- /**
- * @see LocalSyncElement#getData()
- */
- protected Object getData() {
- return null;
- }
-
- /**
- * @see LocalSyncElement#isIgnored(IResource)
- */
- protected boolean isIgnored(IResource resource) {
- return false;
- }
-
- /**
- * @see IRemoteSyncElement#getRemote()
- */
- public IRemoteResource getRemote() {
- return remote;
- }
-
- /**
- * @see IRemoteSyncElement#isThreeWay()
- */
- public boolean isThreeWay() {
- return true;
- }
-
- /**
- * @see ILocalSyncElement#getLocal()
- */
- public IResource getLocal() {
- return local;
- }
-
- /**
- * @see ILocalSyncElement#getBase()
- */
- public IRemoteResource getBase() {
- return null;
- }
-
- /**
- * @see ILocalSyncElement#getSyncKind(int, IProgressMonitor)
- */
- public int getSyncKind(int granularity, IProgressMonitor progress) {
- progress.beginTask(null, 100);
- int description = IN_SYNC;
- IResource local = getLocal();
- boolean localExists = local.exists();
- boolean hasBase = provider.hasBase(local);
- boolean isOutgoing;
- boolean isIncoming;
- if (hasBase) {
- isOutgoing = provider.isDirty(local);
- isIncoming = isOutOfDate(Policy.subMonitorFor(progress, 10));
- } else {
- // if there's no base, use existance to determine direction
- isOutgoing = localExists;
- isIncoming = remote != null;
- }
-
- if (remote == null) {
- if (!localExists) {
- // this should never happen
- // Assert.isTrue(false);
- } else {
- // no remote but a local
- if (!isOutgoing && isIncoming) {
- description = INCOMING | DELETION;
- } else if (isOutgoing && isIncoming) {
- description = CONFLICTING | CHANGE;
- } else if (!isOutgoing && !isIncoming) {
- description = OUTGOING | ADDITION;
- } else if (isOutgoing && !isIncoming) {
- description = OUTGOING | ADDITION;
- }
- }
- } else {
- if (!localExists) {
- // a remote but no local
- if (!isOutgoing /* and both out of date and not out of date */) {
- description = INCOMING | ADDITION;
- } else if (isOutgoing && !isIncoming) {
- description = OUTGOING | DELETION;
- } else if (isOutgoing && isIncoming) {
- description = CONFLICTING | CHANGE;
- }
- } else {
- // have a local and a remote
- if (!isOutgoing && !isIncoming) {
- // ignore, there is no change;
- } else if (!isOutgoing && isIncoming) {
- description = INCOMING | CHANGE;
- } else if (isOutgoing && !isIncoming) {
- description = OUTGOING | CHANGE;
- } else {
- description = CONFLICTING | CHANGE;
- }
- // if contents are the same, then mark as pseudo change
- if (description != IN_SYNC && compare(granularity, false, local, remote, Policy.subMonitorFor(progress, 90)))
- description |= PSEUDO_CONFLICT;
- }
- }
- return description;
- }
- /**
- * Returns the provider.
- * @return TargetProvider
- */
- protected TargetProvider getProvider() {
- return provider;
- }
-
- /**
- * Return true if the resource associated with the receiver is out-of-date
- */
- protected boolean isOutOfDate(IProgressMonitor monitor) {
- IResource local = getLocal();
- if (provider.hasBase(local)) {
- try{
- return provider.isOutOfDate(local, monitor);
- } catch(TeamException e) {
- TeamPlugin.log(e);
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
deleted file mode 100644
index e8033b1b2..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
+++ /dev/null
@@ -1,826 +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.internal.core.target;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.Assert;
-import org.eclipse.team.internal.core.NullSubProgressMonitor;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-/**
- * This abstract class implements the state of a local and corresponding remote resource,
- * and behavior of those resources.
- * <p>
- * Common state for all 'managed' resources includes:
- * <ul>
- * <li>the local resource and corresponding remote resource objects</li>
- * <li>the timestamp of the local resource as it was last in synch with the provider</li>
- * <li>an identifier for the remote resource as it was last in synch with the provider</li>
- */
-public abstract class ResourceState {
-
- /*
- * Serialization format identifier.
- * see toBytes() and fromBytes()
- */
- private static final int BYTES_FORMAT = 0;
-
- /*
- * These constants are used to indicate uninitialized values for the local
- * base timestamp and remote base identifier.
- */
- protected static final long EMPTY_LOCALBASETS = -1L;
- protected static final String EMPTY_REMOTEBASEID = "Undefined:"; //$NON-NLS-1$
-
- /*
- * The base state of the resource. The 'base' is the state of the resource
- * state that was fetched from (or put in) the provider.
- */
- protected long localBaseTimestamp = EMPTY_LOCALBASETS;
- protected String remoteBaseIdentifier = EMPTY_REMOTEBASEID;
-
- protected boolean checkedOut = true;
-
- /*
- * This is the local resource that the receiver represents. It is initialized by
- * the constructor. (The remote resource is maintained by specific subclasses
- * as it is type-dependent.)
- */
- protected IResource localResource;
-
- protected QualifiedName stateKey = new QualifiedName("org.eclipse.team.target", "state_info"); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected URL rootUrl;
-
- /**
- * Constructor for a resource state given a local resource.
- * Remember which local resource this state represents.
- *
- * @param localResource the local part of a synchronized pair of resources.
- */
- public ResourceState(IResource localResource, URL rootUrl) {
- super();
- this.rootUrl = rootUrl;
- SynchronizedTargetProvider.getSynchronizer().add(stateKey);
- this.localResource = localResource;
- }
-
- /**
- * Get the timestamp that represents the base state of the local resource, that is
- * the state that the local resource had when it was initially fetched from the repository.
- *
- * @return the timestamp of the local state of the resource (as reported by
- * java.io.File.getLastModified()) at the point the resource was downloaded to the
- * workspace.
- * @throws BaseIdentifierNotInitializedException if the resource has not yet been
- * downloaded.
- */
- public long getLocalBaseTimestamp()
- throws BaseIdentifierNotInitializedException {
- if (localBaseTimestamp == EMPTY_LOCALBASETS)
- throw new BaseIdentifierNotInitializedException();
- return localBaseTimestamp;
- }
-
-
- /**
- * Get the identifier that represents the base state of the remote resource, that is
- * the state of the remote resource when it was fetched as the base state of the
- * local resource.
- * <p>
- * In general, repositories have arbitrary ways to distinguish resource states.
- * The result should only be used for equality comparison, there should be no
- * ordering or other information implied from the value returned. For example,
- * the value may be a version identifier, timestamp, ETag, etc. To ensure
- * schemes do not inadvertantly test equal it is recommended that the identifier
- * be a URI where the scheme denotes the value type,
- * e.g., date-rfc1123:Fri, 16 Nov 2001 06:25:24 GMT</p>
- *
- * @return an opaque identifier to the base state of the resource in the provider.
- * @throws BaseIdentifierNotInitializedException if the resource has not yet been
- * downloaded.
- */
- public String getRemoteBaseIdentifier()
- throws BaseIdentifierNotInitializedException {
- if (remoteBaseIdentifier.equals(EMPTY_REMOTEBASEID))
- throw new BaseIdentifierNotInitializedException();
- return remoteBaseIdentifier;
- }
-
-
- /**
- * Get the identifier that represents the released state of the resource,
- * that is the state that it currently has in the repository.
- * <p>
- * In general, repositories have arbitrary ways to distinguish resource states.
- * The result should only be used for equality comparison, there should be no
- * ordering or other information implied from the value returned. For example,
- * the value may be a version identifier, timestamp, ETag, etc. To ensure
- * schemes do not inadvertantly test equal it is recommended that the identifier
- * be a URI where the scheme denotes the value type,
- * e.g., date-rfc1123:Fri, 16 Nov 2001 06:25:24 GMT</p>
- *
- * @param progress a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- * @return an opaque identifier to the current released state of the resource in
- * the provider.
- * @throws TeamException if there is a problem getting the released state
- * identifier from the provider. Valid exception status codes include:
- * <ul>
- * <li>IO_FAILED</li>
- * <li>NO_REMOTE_RESOURCE</li>
- * </ul></p>
- */
- public abstract String getReleasedIdentifier(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Check out the receiver. Return a status if the receiver is in the wrong state for the operation to be performed.
- *
- * @throws TeamException if there is a error communicating with the resource from the server.
- */
- public void checkout(IProgressMonitor progress) throws TeamException {
- progress.beginTask(null, 100);
- try {
- // Not going to allow branching.
- if (isOutOfDate(Policy.subMonitorFor(progress, 50)))
- throw new TeamException(ITeamStatusConstants.CONFLICT_STATUS);
-
- // Sanity check.
- if (!hasRemote(Policy.subMonitorFor(progress, 50)))
- throw new TeamException(ITeamStatusConstants.NO_REMOTE_RESOURCE_STATUS);
-
- // Legally, the resource must be checked in before it can be checked out.
- if (isCheckedOut())
- throw new TeamException(ITeamStatusConstants.NOT_CHECKED_IN_STATUS);
-
- // Do the provider specific action for check-out.
- basicCheckout(progress);
- } finally {
- progress.done();
- }
- }
-
- /**
- * A basic checkout is provider specific.
- * Unless overridden, work in an optimistic mode.
- */
- protected void basicCheckout(IProgressMonitor progress) throws TeamException {
- checkedOut = true;
- }
-
-
- /**
- * Check in the receiver.
- *
- * @throws TeamException if there is a error communicating with the resource from the server.
- */
- public void checkin(IProgressMonitor progress) throws TeamException {
- progress = Policy.monitorFor(progress);
- progress.beginTask(null, 100);
- try {
- // The resource must be checked out before it can be checked in.
- if (!isCheckedOut())
- throw new TeamException(ITeamStatusConstants.NOT_CHECKED_OUT_STATUS);
-
- if (!hasLocal()) {
- if (hasRemote(Policy.subMonitorFor(progress, 10))) {
- delete(Policy.subMonitorFor(progress, 80));
- }
- } else {
- // Ensure the necessary remote direcotories exist
- mkRemoteDirs(Policy.subMonitorFor(progress, 10));
- // Copy from the local resource to the repository.
- if (getLocal().getType() == IResource.FILE) {
- upload(Policy.subMonitorFor(progress, 80));
- }
- }
- //if we got to here the upload succeeded (didn't throw)
- checkedOut = false;
- } finally {
- progress.done();
- }
- }
-
- /**
- * Uncheckout the receiver.
- */
- public void uncheckout(IProgressMonitor progress) throws TeamException {
- // Has to be checked-out before it can be reversed.
- if (!isCheckedOut())
- throw new TeamException(ITeamStatusConstants.NOT_CHECKED_OUT_STATUS);
-
- // Nothing interesting to do since the API spec. requires that we do not reverse
- // any local changes.
- checkedOut = false;
- }
-
- /**
- * Answer whether the receiver is checked out or not.
- * <p>
- * Note that this is a quick operation that will be called from the UI, so providers are required
- * to cache information that is expensive to compute. Where the cache may get stale users
- * have the opportunity to force a refresh using ITeamProvider.refreshState().
- *
- * @return <code>true</code> if the receiver is checked in, and <code>false</code>
- * if it is not.
- * @see ITeamProvider#isCheckedOut(IResource)
- * @see ITeamProvider#refreshState(IResource[], int, IProgressMonitor)
- */
- public boolean isCheckedOut() {
- return checkedOut;
- }
-
- /**
- * Answer if the local resource currently has a different timestamp to the
- * base timestamp for this resource.
- *
- * @return <code>true</code> if the resource has a different modification
- * timestamp, and <code>false</code> otherwise.
- * @see ITeamProvider#isDirty(IResource)
- */
- public boolean isDirty() {
- if (!hasPhantom()) return false;
- if (!hasLocal()) return true;
- if (localBaseTimestamp == EMPTY_LOCALBASETS)
- return localResource.getType() == IResource.FILE;
- return localBaseTimestamp != localResource.getModificationStamp();
- }
-
- /**
- * Answers true if the base identifier of the given resource is different to the
- * current released state of the resource.
- */
- public boolean isOutOfDate(IProgressMonitor monitor) throws TeamException {
- if (!hasPhantom()) return false;
- if (remoteBaseIdentifier.equals(EMPTY_REMOTEBASEID)) return false;
- String releasedIdentifier = getReleasedIdentifier(monitor);
- return !remoteBaseIdentifier.equals(releasedIdentifier);
- }
-
- /**
- * Download the remote resource represented by the receiver state to the location
- * represented by the local resource (i.e., resource.getLocation().toFile()).
- * This copies from the provider to the workspace, <em>and</em> sets the local
- * base timestamp and remote base identifier.
- * The provider may (and should wherever possible) optimize the case where it
- * knows the local resource is identical to the remote resource.
- */
- public abstract void download(IProgressMonitor progress) throws TeamException;
-
- /**
- * Upload the resource represented by the local resource to the remote
- * resource represented by the receiver. This copies from the workspace to
- * the provider <em>and</em> sets the local base timestamp and remote base
- * identifier.
- */
- public abstract void upload(IProgressMonitor progress) throws TeamException;
-
- /**
- * Delete the remote resource.
- */
- public abstract void delete(IProgressMonitor progress) throws TeamException;
-
- /**
- * Answer if the remote resource exists.
- */
- public abstract boolean hasRemote(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Answer the type of the remote resource (if it exists).
- * The type should correspond to the IResource enumerated types.
- */
- public abstract int getRemoteType();
-
- /**
- * Answer the array of resource states for each member of the receiver.
- * If the receiver has no members (or is incapable of having members)
- * answer an empty array.
- */
- public abstract ResourceState[] getRemoteChildren(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Create the necessary remote directories corresponding to the local resource.
- * That is, if the resource is a folder, create it and its parents if they don't
- * already exist. If the resource is a file, create its parents if they don't
- * already exist.
- */
- protected abstract void mkRemoteDirs(IProgressMonitor monitor) throws TeamException;
-
- /**
- */
- public IResource getLocal() {
- return localResource;
- }
-
- /**
- * Get the file underlying the local resource.
- */
- protected File getLocalFile() {
- return localResource.getLocation().toFile();
- }
-
- /**
- * Answer if the local resource exists.
- */
- protected boolean hasLocal() {
- return localResource.exists();
- }
-
- /**
- * Answer if the local resource has a phantom, which indicates that the respource had both a local
- * and remote version at one time.
- */
- protected boolean hasPhantom() {
- try {
- return SynchronizedTargetProvider.getSynchronizer().getSyncInfo(stateKey, localResource) != null;
- } catch (CoreException e) {
- TeamPlugin.log(e);
- return false;
- }
- }
-
- /**
- * Initializes the resource state instance from the given serialized state.
- * The format of the serialized state is that produced by <code>toBytes()</code>.
- *
- * @param bytes the serialized resource state.
- */
- public final void loadState() throws TeamException {
- try {
- byte[] storedState =
- SynchronizedTargetProvider.getSynchronizer().getSyncInfo(stateKey, localResource);
- if (storedState != null)
- fromBytes(storedState);
- } catch (CoreException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
- /**
- * Initializes the resource state instance from the given serialized state.
- * The format of the serialized state is that produced by <code>toBytes()</code>.
- *
- * @param bytes the serialized resource state.
- */
- protected void fromBytes(byte[] bytes) throws TeamException{
- try {
- DataInputStream dataStream =
- new DataInputStream(new ByteArrayInputStream(bytes));
- if (BYTES_FORMAT != dataStream.readByte())
- return;
-
- // Restore common resource state values.
- remoteBaseIdentifier = dataStream.readUTF();
- localBaseTimestamp = dataStream.readLong();
-
- } catch (IOException e) {
- throw TeamPlugin.wrapException(e);
- }
- };
-
- public final void storeState() throws TeamException {
- try {
- SynchronizedTargetProvider.getSynchronizer().setSyncInfo(
- stateKey,
- localResource,
- toBytes());
- // Ensure that the parent has base info recorded (otherwise deleting the parent will cause the lose of sync info)
- if (localResource.getType() == IResource.PROJECT) return;
- IContainer parent = localResource.getParent();
- if (parent != null && parent.getType() != IResource.PROJECT &&
- SynchronizedTargetProvider.getSynchronizer().getSyncInfo(stateKey, parent) == null) {
- getParent().storeState();
- } else {
- ResourcesPlugin.getWorkspace().save(false, null);
- }
- } catch (CoreException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
- /**
- * Answer the resource state as a sequence of bytes, in a format that can be used to
- * reconstruct an equivalent resource state using the <code>fromBytes(byte[])</code>
- * method.
- * <p>
- * Subclasses should implement <code>storeState(DataOutputStream)</code> to
- * store provider specific state information.</p>
- *
- * @return the resource state as a byte array.
- * @see #storeState(DataOutputStream)
- * @see fromBytes(byte[])
- */
- protected byte[] toBytes() throws TeamException {
- try {
- // Create a stream to store the byte representation of the receiver's state.
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream(32);
- // Guess ~32 bytes
- DataOutputStream dataStream = new DataOutputStream(byteStream);
- dataStream.writeByte(BYTES_FORMAT);
-
- // Store data common to all resource states.
- dataStream.writeUTF(remoteBaseIdentifier);
- dataStream.writeLong(localBaseTimestamp);
-
- dataStream.close();
- return byteStream.toByteArray();
- } catch (IOException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
- final public void removeState() throws TeamException {
- try {
- if (localResource.exists() || localResource.isPhantom()) {
- SynchronizedTargetProvider.getSynchronizer().flushSyncInfo(
- stateKey,
- localResource,
- IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e) {
- throw TeamPlugin.wrapException(e);
- }
- }
-
- /**
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /**
- * Method getRoot.
- * @return URL of this resource's parent
- */
- public URL getRoot() {
- return rootUrl;
- }
-
- private ResourceState getParent() throws TeamException {
- return getResourceStateFor(localResource.getParent());
- }
-
- private ResourceState getResourceStateFor(IResource resource) throws TeamException {
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- return ((SynchronizedTargetProvider)provider).getState(resource);
- }
-
- /**
- * Get the resource corresponding to the receiver to the specified depth.
- */
- protected final void get(int depth, IProgressMonitor progress) throws TeamException {
-
- progress = Policy.monitorFor(progress);
-
- // the no progress monitor is used to control the progress given to
- // other methods and ensures that the progress monitor is not overloaded
- // with subtask messages and work. The null monitor does propagate
- // cancellation.
- IProgressMonitor noProgress = new NullSubProgressMonitor(progress);
- try {
- progress.beginTask(null, 100);
- Policy.checkCanceled(progress);
-
- // If remote does not exist then simply ensure no local resource exists.
- if (!hasRemote(noProgress)) {
- if (hasLocal())
- deleteLocal(noProgress);
- return;
- }
-
- // Ensure that the required local folders exist
- if (!hasLocal()) {
- mkLocalDirs(noProgress);
- }
-
- // If the remote resource is a file, download the remote contents
- if (getRemoteType() == IResource.FILE) {
- download(Policy.subMonitorFor(progress, 100));
- return;
- }
-
- // The remote resource is a container.
-
- // If the local resource is a file, we must remove it first.
- if (getLocal().getType() == IResource.FILE) {
- if (hasLocal()) {
- deleteLocal(noProgress); // May not exist.
- }
- // change the local resource to a folder and create it
- localResource = localResource.getParent().getFolder(new Path(localResource.getName()));
- mkLocalDirs(noProgress);
- }
-
- // Finally, resolve the collection membership based upon the depth parameter.
- switch (depth) {
- case IResource.DEPTH_ZERO :
- // If we are not considering members of the collection then we are done.
- return;
- case IResource.DEPTH_ONE :
- // If we are considering only the immediate members of the collection
- getFolderShallow(Policy.subMonitorFor(progress, 100));
- return;
- case IResource.DEPTH_INFINITE :
- // We are going in deep.
- getFolderDeep(Policy.subMonitorFor(progress, 100));
- return;
- default :
- // We have covered all the legal cases.
- Assert.isLegal(false);
- return; // Never reached.
- } // end switch
- } finally {
- progress.done();
- }
- }
-
- /**
- * Get the folder resource represented by the receiver deeply.
- */
- protected final void getFolderDeep(IProgressMonitor progress) throws TeamException {
- progress = Policy.monitorFor(progress);
- try {
- progress.beginTask(null, 10);
- // Could throw if problem getting the folder at this level.
- ResourceState[] childFolders = getFolderShallow(Policy.subMonitorFor(progress, 7));
-
- // If there are no further children then we are done.
- if (childFolders.length == 0)
- return;
-
- IProgressMonitor subProgress = Policy.subMonitorFor(progress, 3);
- // Collect the responses in the multistatus.
- try {
- subProgress.beginTask(null, childFolders.length);
- for (int i = 0; i < childFolders.length; i++) {
- childFolders[i].get(IResource.DEPTH_INFINITE, Policy.subMonitorFor(subProgress, 1));
- }
- } finally {
- subProgress.done();
- }
-
- return;
- } finally {
- progress.done();
- }
- }
-
- /**
- * Synchronize from the remote provider to the workspace.
- * Assume that the 'remote' folder is correct, and change the local
- * folder to look like the remote folder.
- *
- * returns an array of children of the remote resource that are themselves
- * collections.
- */
- protected final ResourceState[] getFolderShallow(IProgressMonitor progress) throws TeamException {
- progress = Policy.monitorFor(progress);
- IProgressMonitor noProgress = new NullProgressMonitor();
- try {
- // We are assuming that the resource is a container.
- Assert.isLegal(getLocal() instanceof IContainer);
- IContainer localContainer = (IContainer)getLocal();
-
- // Get list of all _remote_ children.
- ResourceState[] remoteChildren = getRemoteChildren(noProgress);
-
- // This will be the list of remote children that are themselves containers.
- Set remoteChildFolders = new HashSet();
-
- // Make a list of _local_ children that have not yet been processed,
- IResource[] localChildren = getLocalChildren();
- Set surplusLocalChildren = new HashSet(localChildren.length);
- surplusLocalChildren.addAll(Arrays.asList(localChildren));
-
- progress.beginTask(null, remoteChildren.length * 100);
- // For each remote child that is a file, make the local file content equivalent.
- for (int i = 0; i < remoteChildren.length; i++) {
- Policy.checkCanceled(progress);
- ResourceState remoteChildState = remoteChildren[i];
- // If the remote child is a container add it to the list, and ensure that the local child
- // is a folder if it exists.
- if (remoteChildState.getRemoteType() == IResource.FILE) {
- // The remote resource is a file. Copy the content of the remote file
- // to the local file, overwriting any existing content that may exist, and
- // creating the file if it doesn't.
- remoteChildState.download(Policy.subMonitorFor(progress, 100));
- // Remember that we have processed this child.
- surplusLocalChildren.remove(remoteChildState.getLocal());
- } else {
- // The remote resource is a container.
- remoteChildFolders.add(remoteChildState);
- // If the local child is not a container then it must be deleted.
- IResource localChild = remoteChildState.getLocal();
- if (localChild.exists() && (!(localChild instanceof IContainer)))
- remoteChildState.deleteLocal(noProgress);
- } // end if
- } // end for
-
- // Remove each local child that does not have a corresponding remote resource.
- TargetProvider provider = TargetManager.getProvider(localContainer.getProject());
- Iterator childrenItr = surplusLocalChildren.iterator();
- while (childrenItr.hasNext()) {
- IResource unseenChild = (IResource) childrenItr.next();
- ((SynchronizedTargetProvider)provider).newState(unseenChild).deleteLocal(noProgress);
- } // end-while
-
- // Answer the array of children seen on the remote collection that are
- // themselves collections (to support depth operations).
- return (ResourceState[]) remoteChildFolders.toArray(
- new ResourceState[remoteChildFolders.size()]);
- } finally {
- progress.done();
- }
- }
-
- /**
- * Delete the local resource represented by the resource state. Do not complain if the resource does not exist.
- */
- protected final void deleteLocal(IProgressMonitor progress) throws TeamException {
- try {
- getLocal().delete(IResource.KEEP_HISTORY, progress);
- removeState();
- } catch (CoreException exception) {
- throw TeamPlugin.wrapException(exception);
- }
- }
-
- /**
- * Make the local directories matching the description of the local resource state.
- */
- protected final void mkLocalDirs(IProgressMonitor progress) throws TeamException {
- try {
- IResource resource = getLocal();
- if (resource.getType() == IResource.FILE) {
- resource = resource.getParent();
- }
- if (resource.getType() == IResource.FOLDER && ! resource.exists()) {
- if (!resource.getParent().exists()) {
- ResourceState parent=getResourceStateFor(resource.getParent());
- parent.mkLocalDirs(progress);
- }
- ((IFolder)resource).create(false /* force */, true /* make local */, progress);
- // Mark the folders as having a base
- storeState();
- }
- } catch (CoreException exception) {
- // The creation failed.
- throw TeamPlugin.wrapException(exception);
- }
- }
-
- /**
- * Get an array of local children of the given container, or an empty array if the
- * container does not exist or has no children.
- */
- protected final IResource[] getLocalChildren() throws TeamException {
- // We are assuming that the resource is a container.
- Assert.isLegal(getLocal() instanceof IContainer);
- IContainer container = (IContainer)getLocal();
- if (container.exists())
- try {
- return container.members();
- } catch (CoreException exception) {
- throw TeamPlugin.wrapException(exception);
- }
- return new IResource[0];
- }
-
- /**
- * Put the resource from the workspace to the remote provider.
- * Assume that the 'local' resource is correct, and change the remote
- * resource to look like the local resource. This includes removing any
- * child resources that exist remotely but do not exist locally.
- */
- protected final void put(IProgressMonitor progress) throws TeamException {
-
- progress = Policy.monitorFor(progress);
-
- // the no progress monitor is used to control the progress given to
- // other methods and ensures that the progress monitor is not overloaded
- // with subtask messages and work. The null monitor does propagate
- // cancellation.
- IProgressMonitor noProgress = new NullSubProgressMonitor(progress);
- try {
- // Check cancellation
- progress.beginTask(null, 100);
- Policy.checkCanceled(progress);
-
- // This operation is inefficient
-// // Ensure that the remote type matches the local type
-// boolean hasRemote = hasRemote(noProgress);
-// if ((getRemoteType() != localResource.getType() && localResource.getType() != IResource.PROJECT)) {
-// if (hasRemote) delete(noProgress);
-// hasRemote = false;
-// }
-
- // Upload the resource (this is a shallow operation for folders)
- checkin(Policy.subMonitorFor(progress, 75));
-
- // If we're putting a file, we're done
- if (localResource.getType() == IResource.FILE) return;
-
- // If the local doesn't exist then we just deleted the remote so we're done
- if (!hasLocal()) return;
-
- // Make a list of _remote_ children that have not yet been processed,
- Map surplusRemoteChildren = new HashMap();
- boolean hasRemote = hasRemote(noProgress); // XXX is this needed?
- if (hasRemote) {
- ResourceState[] remoteChildren = remoteChildren = getRemoteChildren(progress);
- for (int i = 0; i < remoteChildren.length; i++) {
- ResourceState resourceState = remoteChildren[i];
- surplusRemoteChildren.put(resourceState.getLocal(), resourceState);
- }
- }
-
- // For each local child that is a file, make the remote file content equivalent.
- IResource[] localChildren = getLocalChildren();
- IProgressMonitor subMonitor = Policy.subMonitorFor(progress, 25);
- try {
- subMonitor.beginTask(null, localChildren.length * 100);
- for (int i = 0; i < localChildren.length; i++) {
- IResource localChild = localChildren[i];
- // Get the resource state corresponding to the local resource
- ResourceState state = (ResourceState)surplusRemoteChildren.get(localChild);
- if (state == null) {
- // There is no remote corresponding to the local
- state = getResourceStateFor(localChild);
- } else {
- // There is a remote. Remember that we have processed this child.
- surplusRemoteChildren.remove(localChild);
- }
- // Put the child (this is a deep operation for folders)
- state.put(Policy.subMonitorFor(subMonitor, 100));
- }
- } finally {
- subMonitor.done();
- }
-
- // Remove each remote child that does not have a corresponding local resource.
- Iterator childrenItr = surplusRemoteChildren.values().iterator();
- while (childrenItr.hasNext()) {
- ResourceState unseenChild = (ResourceState) childrenItr.next();
- unseenChild.delete(noProgress);
- }
- } finally {
- progress.done();
-
- }
- }
-
- /**
- * Method to be used only by subclasses to set the remoteBaseIdentifier after
- * an upload or download.
- *
- * @param remoteBaseIdentifier The remoteBaseIdentifier to set
- */
- protected void setRemoteBaseIdentifier(String remoteBaseIdentifier) {
- this.remoteBaseIdentifier = remoteBaseIdentifier;
- }
-
- /**
- * Method to be used only by subclasses to set the localBaseTimestamp after
- * an upload or download.
- *
- * @param localBaseTimestamp The localBaseTimestamp to set
- */
- public void setLocalBaseTimestamp(long localBaseTimestamp) {
- this.localBaseTimestamp = localBaseTimestamp;
- }
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/Site.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/Site.java
deleted file mode 100644
index ff4c6ab2b..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/Site.java
+++ /dev/null
@@ -1,145 +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.internal.core.target;
-
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-
-/**
- * A <code>Site</code> is a place where resources can be deployed and
- * retrieved via a target provider.
- *
- * @see ISiteFactory
- */
-public abstract class Site {
-
- //The location of the site's resources:
- private URL rootUrl;
-
- /**
- * Answers a <code>TargetProvider</code> instance for the given path at
- * this site.
- */
- public abstract TargetProvider newProvider(IPath intrasitePath)
- throws TeamException;
-
- /**
- * Answers the type identifier for this site. For example:
- * <blockquote><pre>
- * org.eclipse.team.target.webdav
- * </pre></blockquote>
- *
- * @return string identifier for this site
- */
- public abstract String getType();
-
- /**
- * Answers a string that can be displayed to the user that represents
- * this site. For example:
- * <blockquote><pre>
- * http://usename@www.mysite.com/dav (WebDav)
- * </pre></blockquote>
- */
- public String getDisplayName() {
- return getURL().toExternalForm();
- }
-
- /**
- * Writes the state of this site such that the corresponding concrete
- * <code>ISiteFactory</code> class can restore the site.
- *
- * @param os the object stream into which to write it's state
- */
- public abstract void writeObject(ObjectOutputStream os);
-
- /**
- * Returns a handle to the remote resource that represents this site
- * on the server.
- *
- * @return a remote handle to this site that may or may not exist
- */
- public IRemoteTargetResource getRemoteResource() throws TeamException {
- return newProvider(Path.EMPTY).getRemoteResource();
- }
-
- /**
- * Compares two Sites. The result is <code>true</code> if and only if
- * the argument is not <code>null</code> and is a Site object that
- * represents the same Site as this object. Two Site objects are equal
- * if they have the same types and URLs.
- *
- * @param other the Site to compare with
- *
- * @return <code>true</code> if the Sites are the same; <code>false</code>
- * otherwise
- *
- * @see Object#equals(Object)
- */
- public boolean equals(Object other) {
- if (this == other) return true;
- if (!(other instanceof Site)) return false;
- Site location = (Site)other;
- if (!getType().equals(location.getType())) return false;
- URL url = getURL();
- if (url == null) return super.equals(other);
- return url.equals(location.getURL());
- }
-
- public int hashCode() {
- URL url = getURL();
- if (url == null) return super.hashCode();
- return url.hashCode();
- }
-
- /**
- * Debugging helper
- *
- * @see Object#toString()
- */
- public String toString() {
- return getDisplayName();
- }
-
- /**
- * Should be called whenever a site is being deleted from the workspace.
- * This method removes the encrypted login info stored for the site.
- * @throws TeamException
- */
- public abstract void dispose() throws TeamException;
-
- /**
- * Answers the location of this site as a URL. For example:
- * <blockquote><pre>
- * http://www.mysite.com:14356/dav
- * </pre></blockquote>
- *
- * @return URL location of this site
- */
- public URL getURL() {
- return rootUrl;
- }
-
- /**
- * Sets the rootUrl.
- * @param rootUrl The rootUrl to set
- */
- protected void setURL(URL rootUrl) {
- this.rootUrl = rootUrl;
- }
-
- public abstract Properties getConfiguration();
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java
deleted file mode 100644
index 8f5a7a137..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java
+++ /dev/null
@@ -1,228 +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.internal.core.target;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ISynchronizer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-public abstract class SynchronizedTargetProvider extends TargetProvider {
-
- private static final int CONFIG_FORMAT_VERSION = 2;
-
- // The location where the target reads/writes against
- protected Site site;
- // The path relative to the site where the target reads/writes against
- protected IPath intrasitePath;
- // The URL which combines the site and relative path
- protected URL targetURL;
-
- /*
- * Answers the synchronizer.
- */
- final protected static ISynchronizer getSynchronizer() {
- return ResourcesPlugin.getWorkspace().getSynchronizer();
- }
-
- public SynchronizedTargetProvider(Site site, IPath intrasitePath) throws TeamException {
- this.intrasitePath = intrasitePath;
- this.site = site;
- // Create the combined URL here so we know it's good
- String root = getSite().getURL().toExternalForm();
- try {
- targetURL = UrlUtil.concat(root, intrasitePath);
- } catch (MalformedURLException e) {
- throw new TeamException(Policy.bind(Policy.bind("SynchronizedTargetProvider.invalidURLCombination"), root, intrasitePath.toString()), e); //$NON-NLS-1$
- }
- }
-
- /*
- * Answers a new state based on an existing local resource.
- */
- abstract public ResourceState newState(IResource resource);
-
- /*
- * Answers a new state based on an existing local resource and
- * an associated existing remote resource.
- */
- abstract public ResourceState newState(IResource resource, IRemoteTargetResource remote);
-
- /**
- * @see TargetProvider#getSite()
- */
- public Site getSite() {
- return site;
- }
-
- /**
- * @see TargetProvider#getURL()
- */
- public URL getURL() {
- return targetURL;
- }
-
- /*
- * Get the state descriptor for a given resource.
- */
- public ResourceState getState(IResource resource) throws TeamException {
- // Create a new resource state with default values.
- ResourceState state = newState(resource);
- state.loadState();
- return state;
- }
-
- /*
- * Get the state descriptor for a given resource.
- */
- public ResourceState getState(IResource resource, IRemoteTargetResource remote) throws TeamException {
- // Create a new resource state with default values.
- ResourceState state = newState(resource, remote);
- state.loadState();
- return state;
- }
-
- /**
- * Get the resource from the provider to the workspace, and remember the fetched
- * state as the base state of the resource.
- *
- * @see TargetProvider.get(IResource[], int, IProgressMonitor)
- */
- public void get(final IResource[] resources, IProgressMonitor progress) throws TeamException {
- run(new ITargetRunnable() {
- public void run(IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask(null, resources.length * 100);
- for (int i = 0; i < resources.length; i++) {
- getState(resources[i]).get(IResource.DEPTH_INFINITE, Policy.subMonitorFor(monitor, 100));
- }
- } finally {
- monitor.done();
- }
- }
- }, Policy.monitorFor(progress));
- }
-
- /**
- * Get the resource from the provider to the workspace, and remember the fetched
- * state as the base state of the resource.
- *
- * @see TargetProvider.get(IResource, IRemoteTargetResource, IProgressMonitor)
- */
- public void get(final IResource resource, final IRemoteTargetResource remote, IProgressMonitor progress) throws TeamException {
- run(new ITargetRunnable() {
- public void run(IProgressMonitor monitor) throws TeamException {
- getState(resource, remote).get(IResource.DEPTH_INFINITE, monitor);
- }
- }, Policy.monitorFor(progress));
- }
-
-
- /**
- * Put the resources to the remote.
- *
- * @see TargetProvider.put(IResource[], IProgressMonitor)
- */
- public void put(final IResource[] resources, IProgressMonitor progress) throws TeamException {
- run(new ITargetRunnable() {
- public void run(IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask(null, resources.length * 100);
- for (int i = 0; i < resources.length; i++) {
- getState(resources[i]).put(Policy.subMonitorFor(monitor, 100));
- }
- } finally {
- monitor.done();
- }
- }
- }, Policy.monitorFor(progress));
- }
-
- /**
- * Answer if the local resource currently has a different timestamp to the
- * base timestamp for this resource.
- *
- * @param resource the resource to test.
- * @return <code>true</code> if the resource has a different modification
- * timestamp, and <code>false</code> otherwise.
- *
- * @see TargetProvider#isDirty(IResource)
- */
- public boolean isDirty(IResource resource) {
- try {
- return getState(resource).isDirty();
- } catch (TeamException e) {
- TeamPlugin.log(e);
- return true;
- }
- }
-
- /**
- * Answers true if the base identifier of the given resource is different to the
- * current released state of the resource.
- *
- * @param resource the resource state to test.
- * @return <code>true</code> if the resource base identifier is different to the
- * current released state of the resource, and <code>false</code> otherwise.
- *
- * @see TargetProvider#isOutOfDate(IResource, IProgressMonitor)
- */
- public boolean isOutOfDate(IResource resource, IProgressMonitor monitor) throws TeamException {
- ResourceState state = getState(resource);
- return state.isOutOfDate(monitor);
- }
-
- /**
- * @see TargetProvider#deregister(IProject)
- */
- public void deregister(IProject project) {
- try {
- newState(project).removeState();
- } catch (TeamException e) {
- TeamPlugin.log(e);
- }
- }
-
- /**
- * @see TargetProvider#getRemoteSyncElement(IResource)
- */
- public IRemoteSyncElement getRemoteSyncElement(IResource resource) {
- return new RemoteTargetSyncElement(this, resource, getRemoteResourceFor(resource));
- }
-
-
- /**
- * @see TargetProvider#hasBase(IResource)
- */
- public boolean hasBase(IResource resource) {
- // the project always has a base
- if (resource.getType() == IResource.PROJECT) return true;
- try {
- return getState(resource).hasPhantom();
- } catch (TeamException e) {
- TeamPlugin.log(e);
- return true;
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetManager.java
deleted file mode 100644
index 6b5902aba..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetManager.java
+++ /dev/null
@@ -1,274 +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.internal.core.target;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ISynchronizer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-public class TargetManager {
- private static final String TARGET_SITES_FILE = ".targetSites"; //$NON-NLS-1$
-
- private static final QualifiedName TARGET_MAPPINGS =
- new QualifiedName("org.eclipse.team.core.target", "mappings"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private static Map factories = new Hashtable();
- private static List sites = new ArrayList();
- private static List listeners = new ArrayList();
-
- //Key for persistent property to denote the project as having target management
- private static final QualifiedName PROP_KEY =
- new QualifiedName("org.eclipse.team", "target"); //$NON-NLS-1$ //$NON-NLS-2$
-
- //Key to signify the kind of target. We only have one at the moment
- private static final String BASIC_TARGET_KEY = "basic"; //$NON-NLS-1$
-
- public static void startup() {
- ResourcesPlugin.getWorkspace().getSynchronizer().add(TARGET_MAPPINGS);
- readLocations();
- }
-
- public static Site[] getSites() {
- return (Site[]) sites.toArray(
- new Site[sites.size()]);
- }
-
- public static void addSite(Site site) {
- sites.add(site);
- save();
- for (Iterator it = listeners.iterator(); it.hasNext();) {
- ISiteListener element = (ISiteListener) it.next();
- element.siteAdded(site);
- }
- }
-
- public static void removeSite(Site site) {
- sites.remove(site);
- save();
- for (Iterator it = listeners.iterator(); it.hasNext();) {
- ISiteListener element = (ISiteListener) it.next();
- element.siteRemoved(site);
- }
- }
-
- /**
- * @see TargetProvider#map(IProject)
- */
- public static void map(IProject project, Site site, IPath path) throws TeamException {
- try {
- ISynchronizer s = ResourcesPlugin.getWorkspace().getSynchronizer();
- byte[] mappingBytes = s.getSyncInfo(TARGET_MAPPINGS, project);
- if (mappingBytes != null) {
- throw new TeamException(Policy.bind("TargetManager.Problems_mapping_project._Project_is_already_mapped._4")); //$NON-NLS-1$
- }
- LocationMapping mapping = new LocationMapping(site, path);
- s.setSyncInfo(
- TARGET_MAPPINGS,
- project,
- mapping.encode());
- project.setPersistentProperty(PROP_KEY, BASIC_TARGET_KEY);
- } catch (CoreException e) {
- throw new TeamException(Policy.bind("TargetManager.Problems_mapping_project", project.getName()), e); //$NON-NLS-1$
- } catch (IOException e) {
- throw new TeamException(Policy.bind("TargetManager.Problems_mapping_project", project.getName()), e); //$NON-NLS-1$
- }
- }
-
- /**
- * @see TargetProvider#unmap(IProject)
- */
- public static void unmap(IProject project) throws TeamException {
- try {
- ISynchronizer s = ResourcesPlugin.getWorkspace().getSynchronizer();
- byte[] mappingBytes = s.getSyncInfo(TARGET_MAPPINGS, project);
- if (mappingBytes == null) {
- throw new TeamException(Policy.bind("TargetManager.unableToUnmap", project.getName())); //$NON-NLS-1$
- } else {
- TargetProvider provider = getProvider(project);
- provider.deregister(project);
- s.flushSyncInfo(TARGET_MAPPINGS, project, IResource.DEPTH_ZERO);
- }
- project.setPersistentProperty(PROP_KEY, null); // null arg removes
- } catch (CoreException e) {
- throw new TeamException(Policy.bind("TargetManager.problemsUnmapping", project.getName()), e); //$NON-NLS-1$
- }
- }
-
- public static TargetProvider getProvider(IProject project) throws TeamException {
- try {
- ISynchronizer s = ResourcesPlugin.getWorkspace().getSynchronizer();
- byte[] mappingBytes = s.getSyncInfo(TARGET_MAPPINGS, project);
- if (mappingBytes == null) {
- return null;
- } else {
- LocationMapping mapping = new LocationMapping(mappingBytes);
- Site site =
- getSite(mapping.getType(), mapping.getURL());
- if (site != null) {
- return site.newProvider(mapping.getPath());
- }
- }
- return null;
- } catch (CoreException e) {
- throw new TeamException(Policy.bind("TargetManager.problemsGettingProvider", project.getName()), e); //$NON-NLS-1$
- } catch (IOException e) {
- throw new TeamException(Policy.bind("TargetManager.problemsGettingProvider", project.getName()), e); //$NON-NLS-1$
- }
- }
-
- public static Site getSite(String type, URL url) {
- return getSite(type, url.toExternalForm());
- }
-
- public static Site getSite(String type, String urlID) {
- for (Iterator it = sites.iterator(); it.hasNext();) {
- Site element = (Site) it.next();
- if (element.getType().equals(type)
- && element.getURL().toExternalForm().equals(urlID)) {
- return element;
- }
- }
- return null;
- }
-
- public static void addSiteListener(ISiteListener listener) {
- listeners.add(listener);
- }
-
- public static void removeSiteListener(ISiteListener listener) {
- listeners.remove(listener);
- }
-
- private static void readLocations() {
- // read saved locations list from disk, only if the file exists
- IPath pluginStateLocation =
- TeamPlugin.getPlugin().getStateLocation().append(
- TARGET_SITES_FILE);
- File f = pluginStateLocation.toFile();
- if (f.exists()) {
- try {
- DataInputStream dis =
- new DataInputStream(new FileInputStream(f));
- readLocations(dis);
- } catch (IOException e) {
- TeamPlugin.log(Status.ERROR, Policy.bind("Config.error"), e); //$NON-NLS-1$
- }
- }
- }
-
- private static void writeLocations() {
- // save repositories to disk
- IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation();
- File tempFile = pluginStateLocation.append(TARGET_SITES_FILE + ".tmp").toFile(); //$NON-NLS-1$
- File stateFile =
- pluginStateLocation.append(TARGET_SITES_FILE).toFile();
- try {
- DataOutputStream dos =
- new DataOutputStream(new FileOutputStream(tempFile));
- writeLocations(dos);
- dos.close();
- if (stateFile.exists())
- stateFile.delete();
- boolean renamed = tempFile.renameTo(stateFile);
- if (!renamed) {
- //todo: log the error
- }
- } catch (IOException e) {
- TeamPlugin.log(Status.ERROR, Policy.bind("Config.error"), e); //$NON-NLS-1$
- }
- }
-
- private static void save() {
- writeLocations();
- }
-
- private static void readLocations(DataInputStream dis) throws IOException {
- int repoCount = dis.readInt();
- for (int i = 0; i < repoCount; i++) {
- String id = dis.readUTF();
- ISiteFactory factory =
- (ISiteFactory) getSiteFactory(id);
- if (factory == null) {
- //todo: log error
- return;
- }
- Site site = factory.newSite(new ObjectInputStream(dis));
- sites.add(site);
- }
- }
-
- private static void writeLocations(DataOutputStream dos)
- throws IOException {
- dos.writeInt(sites.size());
- Iterator iter = sites.iterator();
- while (iter.hasNext()) {
- Site site = (Site) iter.next();
- dos.writeUTF(site.getType());
- site.writeObject(new ObjectOutputStream(dos));
- }
- dos.flush();
- dos.close();
- }
-
- public static ISiteFactory getSiteFactory(String id) {
- TeamPlugin plugin = TeamPlugin.getPlugin();
- if (plugin != null) {
- IExtensionPoint extension =
- plugin.getDescriptor().getExtensionPoint(
- TeamPlugin.TARGETS_EXTENSION);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] configElements =
- extensions[i].getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$
- if (extensionId != null && extensionId.equals(id)) {
- try {
- return (ISiteFactory) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- TeamPlugin.log(e);
- return null;
- }
- }
- }
- }
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetProvider.java
deleted file mode 100644
index 4658623b3..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/TargetProvider.java
+++ /dev/null
@@ -1,218 +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.internal.core.target;
-
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-
-public abstract class TargetProvider {
- /**
- * Answers the site which this target is associated with
- * @return a printable string
- */
- public abstract Site getSite();
-
- /**
- * Answers the full path where the provider stores/retrieves to/from.
- * @return a printable string
- */
- public abstract URL getURL();
-
- /**
- * Updates the local resource to have the same content as the corresponding remote
- * resource. Where the local resource does not exist, this method will create it.
- * Where, the remote resource does not exist and the local does, this method will delete
- * the local resource.
- * <p>
- * If the remote resource is a container (e.g. folder or project) this operation is equivalent
- * to getting each member of the remote resource, thereby updating the
- * content of existing local members, creating local members to receive new remote resources,
- * and deleting local members that no longer have a corresponding remote resource.</p>
- * <p>
- * Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.</p>
- *
- * @param resources an array of local resources to update from the corresponding remote
- * resources.
- * @param progress a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- * @throws TeamException if there is a problem getting one or more of the resources. The
- * exception will contain multiple statuses, one for each resource in the <code>resources</code>
- * array.
- */
- public abstract void get(IResource[] resources, IProgressMonitor progress) throws TeamException;
-
- /**
- * Updates the local resource to have the same content as the given remote
- * resource. Where the local resource does not exist, this method will create it.
- * <p>
- * If the remote resource is a container (e.g. folder or project) this operation is equivalent
- * to getting each non-container member of the remote resource, thereby updating the
- * content of existing local members, creating local members to receive new remote resources,
- * and deleting local members that no longer have a corresponding remote resource.</p>
- * <p>
- * Interrupting the method (via the progress monitor) may lead to partial, but consistent, results.</p>
- *
- * @param resources an array of local resources to update from the corresponding remote
- * resources.
- * @param progress a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- * @throws TeamException if there is a problem getting one or more of the resources. The
- * exception will contain multiple statuses, one for each resource in the <code>resources</code>
- * array.
- */
- public abstract void get(IResource resource, IRemoteTargetResource remote, IProgressMonitor progress) throws TeamException;
-
- /**
- * Transfers the content of the local resource to the corresponding remote resource.
- * <p>
- * If a remote resource does not exist this method creates a new remote resource with the same content
- * as the given local resource. The local resource is said to <i>correspond</i> to the new remote resource.
- * If the local resource doesn't exist and a remote does, the remote resource will be deleted.
- * </p>
- * <p>
- * If the local resource is a container (e.g. folder or project) this operation is equivalent
- * to putting each member of the local resource, thereby updating the
- * content of existing remote members, creating remote members to receive new local resources,
- * and deleting remote members that no longer have a corresponding local resource.</p>
- * <p>
- * @param resources an array of local resources to be put.
- * @param progress a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- * @throws TeamException if there is a problem put'ing one or more of the resources.
- * The exception will contain multiple status', one for each resource in the <code>resources</code>
- * array.
- */
- public abstract void put(IResource[] resources, IProgressMonitor progress) throws TeamException;
-
- /**
- * Returns a remote resource handle at the path of the given local resource.
- *
- * @param resource local resource path to be used to construct the remote handle's path
- * @return a handle to a remote resource that may or may not exist
- */
- public abstract IRemoteTargetResource getRemoteResourceFor(IResource resource);
-
- /**
- * Returns a remote resource handle at the path of this target provider's URL.
- * @return a handle to a remote resource that may or may not exist
- */
- public abstract IRemoteTargetResource getRemoteResource();
-
- /**
- * Replies true if its believed possible to get the given resource.
- * This intended to be a relatively quick operation, presumably based on local state of the provider
- * or it may be used to indicate that the provider only supports data transfer in one direction.
- * It is not intended to indicate the existance of a remote resource. Hence, this method may return true
- * even if there is no remote resource.
- */
- public boolean canGet(IResource resource) {
- return true;
- }
-
- /**
- * Replies true if its believed possible to put the given resource.
- * This intended to be a relatively quick operation, presumably based on local state of the provider
- * or it may be used to indicate that the provider only supports data transfer in one direction.
- */
- public boolean canPut(IResource resource) {
- return true;
- }
-
- /**
- * Answers true if the base identifier of the given resource is different to the
- * current released state of the resource. Answer false if there is no correspondence
- * between the local and remote resources (i.e. hasBase(resource) returns false).
- *
- * @param resource the resource to test
- * @param monitor a progress monitor
- *
- * @throws TeamException if there is a problem getting this information from the server.
- */
- public abstract boolean isOutOfDate(IResource resource, IProgressMonitor monitor) throws TeamException;
-
- /**
- * Answer true if the local resource currently has a different timestamp to the
- * base timestamp for this resource. Answer true for local resources that no longer exist
- * (i.e. the local resource did exist and corresponded to a remote resource) and false if the
- * local resource does not exist and was never mapped to a remote resource.
- *
- * @param resource the resource to test
- */
- public abstract boolean isDirty(IResource resource);
-
- /**
- * Answer true if the given resource at one time had a remote counterpart and still does
- * to the knowledge of the provider.
- *
- * @param resource the resource to test
- */
- public abstract boolean hasBase(IResource resource);
-
- public abstract void deregister(IProject project);
-
- /**
- * This method provides a mechanism for allowing a target provider to optimize connections
- * over a set of operations. The default behavior of the method is to run the provided runnable
- * and to supply it with the provided progress monitor. Specific target providers may override this
- * method in order to ensure that the number of connections made to a remote server is minimized.
- * Calls to this method are nestable and it is up to the target provider to ensure that this is
- * supported.
- */
- public void run(final ITargetRunnable runnable, IProgressMonitor monitor) throws TeamException {
- try {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- runnable.run(monitor);
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
- }
- }
- }, monitor);
- } catch (CoreException e) {
- throw new TeamException(e.getStatus());
- }
- }
-
- /**
- * Return an IRemoteSyncElement for the given resource. This element is used to
- * compare the state of the local and remote resources.
- */
- public abstract IRemoteSyncElement getRemoteSyncElement(IResource resource);
-
- /**
- * @see java.lang.Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj.getClass().equals(this.getClass())) {
- return this.getURL().toExternalForm().equals(((TargetProvider)obj).getURL().toExternalForm());
- }
- return super.equals(obj);
- }
-
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return getURL().toExternalForm().hashCode();
- }
-
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/UrlUtil.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/UrlUtil.java
deleted file mode 100644
index 79dd18fa1..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/UrlUtil.java
+++ /dev/null
@@ -1,81 +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.internal.core.target;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class UrlUtil {
-
- public static IPath getTrailingPath(URL fullURL, URL startingURL) {
- IPath fullPath = new Path(fullURL.getPath());
- IPath startingPath = new Path(startingURL.getPath());
- int matchingCount = fullPath.matchingFirstSegments(startingPath);
- return fullPath.removeFirstSegments(matchingCount);
- }
-
- public static URL concat(String root, IPath end) throws MalformedURLException {
- return new URL(concatString(root, end));
- }
-
- public static String concatString(String root, IPath end) {
- if(end.isEmpty())
- return root;
- if(root.length() == 0)
- return end.toString();
- boolean rootHasTrailing = root.charAt(root.length() - 1) == Path.SEPARATOR; //has trailing '/'
- boolean endHasLeading = end.isAbsolute(); // has leading '/'
-
- if(rootHasTrailing && endHasLeading) //http://mysite/ + /myFolder
- return root + end.toString().substring(1); // we have two seperators, drop one
-
- if(!rootHasTrailing && !endHasLeading) //http://mysite + myFolder
- return root + Path.SEPARATOR + end.toString();
-
- return root + end.toString(); //have one separator between the two, just concat end
- }
-
- /*
- * Return a string that is like url but guaranteed to end with a '/'
- */
- public static String makeAbsolute(String url) {
- boolean hasTrailing = url.charAt(url.length() - 1) == Path.SEPARATOR; //has trailing '/'
- if(hasTrailing)
- return url;
- return url + Path.SEPARATOR;
- }
-
- /*
- * @see toTruncatedPath(URL, int)
- */
- public static String toTruncatedPath(URL url, int split) {
- return toTruncatedPath(url.getPath(), split);
- }
-
- /*
- * If the number of segments in the url path is greater than <code>split</code> then
- * the returned path is truncated to <code>split</code> number of segments and '...'
- * is shown as the first segment of the path.
- */
- public static String toTruncatedPath(String url, int split) {
- IPath path = new Path(url);
- path = path.setDevice(null); // clear the device id, in this case the http:
- int segments = path.segmentCount();
- if(segments>split) {
- IPath last = path.removeFirstSegments(segments - split);
- return "..." + IPath.SEPARATOR + last.toString(); //$NON-NLS-1$
- }
- return path.toString();
- }
-}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/messages.properties b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/messages.properties
deleted file mode 100644
index d398d21b5..000000000
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/messages.properties
+++ /dev/null
@@ -1,21 +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
-###############################################################################
-
-teamStatus.notCheckedOut=Not checked out.
-teamStatus.notCheckedIn=Not checked in.
-teamStatus.unmanagedResource=Unmanaged resource.
-teamStatus.noRemoteResource=Remote resource does not exist.
-teamStatus.ioFailed=An IO error occurred.
-teamStatus.conflict=A conflict occurred.
-provider.configuration.missing=Required configuration value missing.
-provider.configuration.invalid=Configuration value is invalid.
-filetransfer.monitor={0} ({1}K of {2}K bytes)
-multiStatus.errorsOccurred=Errors occurred \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/site_element.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/site_element.gif
new file mode 100644
index 000000000..9dd4d8300
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/site_element.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/plugin.properties b/bundles/org.eclipse.team.ui/plugin.properties
index b88f2545c..6027e2820 100644
--- a/bundles/org.eclipse.team.ui/plugin.properties
+++ b/bundles/org.eclipse.team.ui/plugin.properties
@@ -36,22 +36,6 @@ ProjectSetImportWizard.name=Team Project Set
ProjectSetImportWizard.description=A wizard that imports a Team Project Set
ProjectSetExportWizard.name=Team Project Set
ProjectSetExportWizard.description=A wizard that exports a Team Project Set
-TargetSiteImportWizard.name=Target Site
-TargetSiteImportWizard.description=A wizard that imports a Target site
-TargetSiteExportWizard.name=Target Site
-TargetSiteExportWizard.description=A wizard that exports a Target site
-
-Deployment.group=Depl&oy
-Deployment.getAction=&Target
-Deployment.uploadAction=Upl&oad
-Deployment.synchronize=Synchroni&ze with Target...
-
-SiteExplorerGetAs.label=Download &As...
-SiteExplorerGetAs.tooltip=Download the selected remote folder with a user specified project type and name.
-SiteExplorerGetAsProject.label=&Download As Project
-SiteExplorerGetAsProject.tooltip=Download the selected remote folder and create a project with the same name.
-SiteExplorerDiscardSite.label=D&iscard Site
-SiteExplorerDiscardSite.tooltip=Discard the site
Command.category.name=Team
Command.category.description=Actions that apply when working with a Team
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index ed1b0d5f9..0b1982837 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -21,7 +21,6 @@
<extension-point id="configurationWizards" name="%configurationWizards" schema="schema/configurationWizards.exsd"/>
- <extension-point id="targetConfigWizards" name="%targetWizards"/>
<extension-point id="subscriberMenus" name="%subscriberMenus"/>
<!-- **************** PREFERENCES ******************* -->
@@ -45,26 +44,6 @@
id="org.eclipse.team.ui.IgnorePreferences">
</page>
</extension>
-<!-- ************** Property Pages *************** -->
- <extension
- point="org.eclipse.ui.propertyPages">
- <page
- objectClass="org.eclipse.team.internal.ui.target.SiteElement"
- name="%loginDetails"
- class="org.eclipse.team.internal.ui.target.AuthenticatedTargetSitePropertiesPage"
- id="org.eclipse.team.target.ui.propertyPages.AuthenticatedTargetSitePropertiesPage">
- </page>
- <page
- objectClass="org.eclipse.core.resources.IProject"
- name="%targetSite"
- class="org.eclipse.team.internal.ui.target.ProjectTargetMappingPropertiesPage"
- id="org.eclipse.team.internal.ui.target.ProjectTargetMappingPropertiesPage">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.target=basic">
- </filter>
- </page>
- </extension>
<!-- ****************** POPUP ACTIONS *************** -->
<extension
point="org.eclipse.ui.popupMenus">
@@ -127,66 +106,6 @@
id="org.eclipse.team.ui.ConfigureProject">
</action>
</objectContribution>
-<!-- ****************** Target Management Popup Actions *************** -->
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
- adaptable="true"
- id="org.eclipse.team.ui.targetResourceContributionsActions">
- <filter
- name="projectPersistentProperty"
- value="org.eclipse.team.target=basic">
- </filter>
- <action
- label="%Deployment.getAction"
- helpContextId="org.eclipse.team.ui.target_get_action_context"
- class="org.eclipse.team.internal.ui.target.GetAction"
- menubarPath="replaceWithMenu/replaceWithGroup"
- id="org.eclipse.team.target.getAction">
- </action>
- <action
- label="%Deployment.uploadAction"
- helpContextId="org.eclipse.team.ui.target_put_action_context"
- class="org.eclipse.team.internal.ui.target.UploadAction"
- menubarPath="team.main/targetGroup"
- id="org.eclipse.team.target.uploadAction">
- </action>
- <action
- label="%Deployment.synchronize"
- helpContextId="org.eclipse.team.ui.target_synchronize_action_context"
- class="org.eclipse.team.internal.ui.target.SyncAction"
- menubarPath="team.main/targetGroup"
- id="org.eclipse.team.target.SyncAction">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.team.internal.ui.target.RemoteResourceElement"
- id="org.eclipse.team.internal.ui.target.RemoteResourceElement">
- <action
- label="%SiteExplorerGetAs.label"
- helpContextId="org.eclipse.team.ui.target_getas_action_context"
- tooltip="%SiteExplorerGetAs.tooltip"
- class="org.eclipse.team.internal.ui.target.GetAsAction"
- id="org.eclipse.team.internal.ui.target.GetAsAction">
- </action>
- <action
- label="%SiteExplorerGetAsProject.label"
- helpContextId="org.eclipse.team.ui.target_getasproject_action_context"
- tooltip="%SiteExplorerGetAsProject.tooltip"
- class="org.eclipse.team.internal.ui.target.GetAsProjectAction"
- id="org.eclipse.team.internal.ui.target.GetAsProjectAction">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.team.internal.ui.target.SiteElement"
- id="org.eclipse.team.internal.ui.target.SiteElement">
- <action
- label="%SiteExplorerDiscardSite.label"
- helpContextId="org.eclipse.team.ui.target_disconnect_action_context"
- tooltip="%SiteExplorerDiscardSite.tooltip"
- class="org.eclipse.team.internal.ui.target.DiscardSiteAction"
- id="org.eclipse.team.internal.ui.target.DiscardSiteAction">
- </action>
- </objectContribution>
</extension>
<!-- ************** Views ********************** -->
<extension
@@ -278,12 +197,6 @@
relationship="stack"
id="org.eclipse.team.ui.sync.SyncView">
</view>
- <view
- relative="org.eclipse.ui.views.ResourceNavigator"
- visible="false"
- relationship="stack"
- id="org.eclipse.team.ui.target.SiteExplorerView">
- </view>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.team.internal.ui.sync.views.TeamSynchronizingPerspective">
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
index b77845db3..0453708f2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
@@ -58,7 +58,6 @@ public class TeamUIPlugin extends AbstractUIPlugin implements IPropertyChangeLis
// extension points
public static final String PT_CONFIGURATION ="configurationWizards"; //$NON-NLS-1$
- public static final String PT_TARGETCONFIG ="targetConfigWizards"; //$NON-NLS-1$
public static final String PT_DECORATORS = "decorators"; //$NON-NLS-1$
private static List propertyChangeListeners = new ArrayList(5);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
index 5201a1461..4af0dfbd5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
@@ -34,8 +34,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.TeamPlugin;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.IObjectActionDelegate;
@@ -322,37 +320,6 @@ public abstract class TeamAction extends ActionDelegate implements IObjectAction
}
/**
- * Convenience method that maps the selected resources to their target providers.
- * The returned Hashtable has keys which are TargetProviders, and values
- * which are Lists of IResources that are shared with that provider.
- *
- * @return a hashtable mapping providers to their selected resources
- */
- protected Hashtable getTargetProviderMapping() throws TeamException {
- return getTargetProviderMapping(getSelectedResources());
- }
- /**
- * Convenience method that maps the given resources to their target providers.
- * The returned Hashtable has keys which are TargetProviders, and values
- * which are Lists of IResources that are shared with that provider.
- *
- * @return a hashtable mapping providers to their resources
- */
- protected Hashtable getTargetProviderMapping(IResource[] resources) throws TeamException {
- Hashtable result = new Hashtable();
- for (int i = 0; i < resources.length; i++) {
- TargetProvider provider = TargetManager.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;
- }
-
- /**
* @return IWorkbenchPart
*/
protected IWorkbenchPart getTargetPart() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/AuthenticatedTargetSitePropertiesPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/AuthenticatedTargetSitePropertiesPage.java
deleted file mode 100644
index eff28731e..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/AuthenticatedTargetSitePropertiesPage.java
+++ /dev/null
@@ -1,104 +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.internal.ui.target;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.ErrorDialog;
-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.swt.widgets.Text;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.AuthenticatedSite;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class AuthenticatedTargetSitePropertiesPage extends PropertyPage {
- public static final int WIDTH_HINT = 250;
-
- private Site site;
- private Text nameText, passwordText;
-
- /**
- * Initializes the page
- */
- private void initialize() {
- IAdaptable element = getElement();
- if (element instanceof SiteElement) {
- site = ((SiteElement)element).getSite();
- } else {
- SiteElement adapter = (SiteElement)element.getAdapter(SiteElement.class);
- if (adapter != null) {
- site = adapter.getSite();
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- initialize();
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new GridLayout(2, false));
-
- Label serverLabel = new Label(container, SWT.NONE);
- serverLabel.setText(Policy.bind("AuthenticatedTargetSitePropertiesPage.Server")); //$NON-NLS-1$
- serverLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- Label serverText = new Label(container, SWT.NONE);
- serverText.setText(site.getURL().getHost());
- GridData data = new GridData();
- data.widthHint = WIDTH_HINT;
- serverText.setLayoutData(data);
-
- Label nameLabel = new Label(container, SWT.NONE);
- nameLabel.setText(Policy.bind("AuthenticatedTargetSitePropertiesPage.User")); //$NON-NLS-1$
- nameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- nameText = new Text(container, SWT.SINGLE | SWT.BORDER);
- data = new GridData();
- data.widthHint = WIDTH_HINT;
- nameText.setLayoutData(data);
- String name=((AuthenticatedSite)site).getUsername();
- if (name!=null) nameText.setText(name);
-
- Label passwordLabel = new Label(container, SWT.NONE);
- passwordLabel.setText(Policy.bind("AuthenticatedTargetSitePropertiesPage.Password")); //$NON-NLS-1$
- passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- passwordText = new Text(container, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
- passwordText.setText(""); //$NON-NLS-1$
- data = new GridData();
- data.widthHint = WIDTH_HINT;
- passwordText.setLayoutData(data);
-
- return container;
- }
-
- /**
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- String name = nameText.getText();
- String password = passwordText.getText();
- try {
- if (name!=null && name.length()>0) ((AuthenticatedSite)site).setUsername(name);
- if (password!=null && password.length()>0) ((AuthenticatedSite)site).setPassword(password);
- return true;
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), Policy.bind("AuthenticatedTargetSitePropertiesPage.Error"), null, e.getStatus()); //$NON-NLS-1$
- return false;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java
deleted file mode 100644
index 909f35126..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java
+++ /dev/null
@@ -1,399 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.wizards.ConfigurationWizardElement;
-import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizardMainPage;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.team.ui.ISharedImages;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.internal.model.AdaptableList;
-
-public class ConfigureTargetWizard extends Wizard implements IConfigurationWizard {
- protected IWorkbench workbench;
- protected IProject project;
- protected IConfigurationWizard wizard;
-
- protected ConfigureProjectWizardMainPage mainPage;
- protected static MappingSelectionPage mappingPage;
-
- private String pluginId = TeamUIPlugin.PLUGIN_ID;
-
- protected final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
- protected final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
- protected final static String ATT_NAME = "name"; //$NON-NLS-1$
- protected final static String ATT_CLASS = "class"; //$NON-NLS-1$
- protected final static String ATT_ICON = "icon"; //$NON-NLS-1$
- protected final static String ATT_ID = "id"; //$NON-NLS-1$
-
- public ConfigureTargetWizard() {
- setNeedsProgressMonitor(true);
- setWindowTitle(getWizardWindowTitle()); //$NON-NLS-1$
- }
-
- public static final String MAPPING_PAGE_NAME = "mapping-page"; //$NON-NLS-1$
-
- protected SiteSelectionPage siteSelectionPage = null;
- /**
- * @see ConfigureProjectWizard#getExtensionPoint()
- */
- protected String getExtensionPoint() {
- return TeamUIPlugin.PT_TARGETCONFIG;
- }
-
- /**
- * @see ConfigureProjectWizard#getWizardDescription()
- */
- protected String getWizardDescription() {
- return Policy.bind("TargetSiteCreationWizard.description"); //$NON-NLS-1$
- }
-
- /**
- * @see ConfigureProjectWizard#getWizardLabel()
- */
- protected String getWizardLabel() {
- return Policy.bind("TargetSiteCreationWizard.label"); //$NON-NLS-1$
- }
-
- /**
- * @see ConfigureProjectWizard#getWizardWindowTitle()
- */
- protected String getWizardWindowTitle() {
- if(project != null) {
- return Policy.bind("TargetSiteCreationWizard.windowTitleProject"); //$NON-NLS-1$
- } else {
- return Policy.bind("TargetSiteCreationWizard.windowTitleNoProject"); //$NON-NLS-1$
- }
- }
-
- /*
- * @see Wizard#addPages
- */
- public void addPages() {
- Site[] sites = TargetManager.getSites();
- AdaptableList wizards = getAvailableWizards();
-
- if(sites.length > 0 && project != null) {
- TargetProvider provider = null;
- try {
- provider = TargetManager.getProvider(project);
- } catch (TeamException e) {
- TeamUIPlugin.log(e);
- }
- siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE), provider); //$NON-NLS-1$ //$NON-NLS-2$
- addPage(siteSelectionPage);
- }
-
- if(project != null) {
- mappingPage = new MappingSelectionPage(ConfigureTargetWizard.MAPPING_PAGE_NAME, Policy.bind("MappingSelectionPage.mappingTitle"), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE)); //$NON-NLS-1$
- mappingPage.setWizard(this);
- }
-
- try {
- if(wizards.size() == 1) {
- ConfigurationWizardElement element = (ConfigurationWizardElement)wizards.getChildren()[0];
- this.wizard = (IConfigurationWizard)element.createExecutableExtension();
- wizard.init(workbench, project);
- wizard.addPages();
- if (wizard.getPageCount() > 0) {
- wizard.setContainer(getContainer());
- IWizardPage[] pages = wizard.getPages();
- for (int i = 0; i < pages.length; i++) {
- addPage(pages[i]);
- }
- }
- } else {
- mainPage = new ConfigureProjectWizardMainPage("target-selection-page", getWizardLabel(), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WIZBAN_SHARE), wizards, Policy.bind("ConfigureProjectWizardMainPage.selectTarget")); //$NON-NLS-1$ //$NON-NLS-2$
- mainPage.setDescription(getWizardDescription());
- mainPage.setProject(project);
- mainPage.setWorkbench(workbench);
- addPage(mainPage);
- }
- } catch (CoreException e) {
- TeamUIPlugin.log(e);
- return;
- }
- }
-
- public IWizardPage getNextPage(IWizardPage page) {
- if(page == siteSelectionPage) {
- if(siteSelectionPage.isDisconnect()) {
- return null;
- }
- if(siteSelectionPage.getSite() != null) {
- mappingPage.setSite(siteSelectionPage.getSite());
- mappingPage.setPreviousPage(page);
- return mappingPage;
- } else if(mainPage != null) {
- return mainPage;
- } else if(wizard != null) {
- return wizard.getStartingPage();
- }
- }
- if(wizard != null) {
- return wizard.getNextPage(page);
- }
- return super.getNextPage(page);
- }
-
- public static MappingSelectionPage getMappingPage() {
- return mappingPage;
- }
-
- public boolean canFinish() {
- // If we are on the first page, never allow finish unless the selected wizard has no pages.
- IWizardPage currentPage = getContainer().getCurrentPage();
- if (currentPage == mainPage) {
- if (mainPage.getSelectedWizard() != null && mainPage.getNextPage() == null) {
- return true;
- }
- return false;
- } else if(currentPage == siteSelectionPage) {
- if(siteSelectionPage.getSite() != null || siteSelectionPage.isDisconnect()) {
- return true;
- } else {
- return false;
- }
- }
-
- MappingSelectionPage mappingPage = getMappingPage();
- if(mappingPage != null && currentPage == mappingPage) {
- return mappingPage.isPageComplete();
- }
- if(wizard != null) {
- return wizard.canFinish();
- }
- return super.canFinish();
- }
-
- /*
- * @see Wizard#performFinish
- */
- public boolean performFinish() {
- // handles finish on site selection page and on mapping page
- IWizardPage currentPage = getContainer().getCurrentPage();
- if(currentPage == siteSelectionPage || currentPage == getMappingPage()) {
- Site site;
- if(currentPage == siteSelectionPage) {
- // if the user selected the disconnect option then disconnect
- // this project from the target
- if(siteSelectionPage.isDisconnect()) {
- try {
- TargetManager.unmap(project);
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), Policy.bind("Error"), Policy.bind("ConfigureTargetWizard.errorUnmappingProject"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- return true;
- }
- site = siteSelectionPage.getSite();
- } else {
- site = getMappingPage().getSite();
- }
- // a site has been selected on either the site selection page or the
- // mapping page. Use this site information to map the project to the
- // target.
- IPath path = Path.EMPTY;
- if(getMappingPage() != null) {
- path = getMappingPage().getMapping();
- }
- if(! setMapping(getContainer(), project, site, path))
- return false; //mapping failed so fail finish
- }
-
- // allow target wizard to finish
- if (wizard != null) {
- return wizard.performFinish();
- }
- return true;
- }
-
- public static boolean setMapping(IWizardContainer container, IProject project, Site site, IPath path) {
- if(validateSite(site, container)) {
- if(TargetManager.getSite(site.getType(), site.getURL()) == null) {
- TargetManager.addSite(site);
- }
- try {
- TargetProvider provider = TargetManager.getProvider(project);
- if(provider != null) {
- if(!provider.getSite().equals(site) && !MessageDialog.openQuestion(container.getShell(),
- Policy.bind("ConfigureTargetWizardQuestion_2"), //$NON-NLS-1$
- Policy.bind("ConfigureTargetWizard.alreadyMapped", project.getName(), provider.getURL().toExternalForm()))) { //$NON-NLS-1$
- return false;
- }
- TargetManager.unmap(project);
- }
- TargetManager.map(project, site, path);
- return true;
- } catch (TeamException e) {
- ErrorDialog.openError(container.getShell(), Policy.bind("ConfigureTargetWizardError_6"), Policy.bind("ConfigureTargetWizardError_mapping_the_project_with_this_site_7"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- } else {
- return false;
- }
- }
-
- public static boolean validateSite(final Site site, final IWizardContainer container) {
- final boolean[] valid = new boolean[] {true};
- final String[] message = new String[] {Policy.bind("ConfigureTargetWizardURL_doesn__t_exist_on_the_server_8")}; //$NON-NLS-1$
- final int[] code = new int[] {-1};
- try {
- container.run(true, false, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask(Policy.bind("ConfigureTargetWizardValidating_connection_to_Site..._9"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- IRemoteTargetResource remote = site.getRemoteResource();
- valid[0] = remote.canBeReached(monitor);
- } catch(TeamException e) {
- message[0] = e.getStatus().getMessage();
- code[0] = e.getStatus().getCode();
- valid[0] = false;
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- valid[0] = false;
- message[0] = e.getTargetException().getMessage();
- } catch (InterruptedException e) {
- return false;
- }
- if(! valid[0]) {
- if(! MessageDialog.openQuestion(container.getShell(),
- Policy.bind("ConfigureTargetWizardConnection_Error_10"), //$NON-NLS-1$
- Policy.bind("ConfigureTargetWizard.errorOccurred", new Object[] {site.getURL().toExternalForm(), new Integer(code[0]), message[0]}))) { //$NON-NLS-1$
- return false;
- }
- }
- return true;
- }
-
- /**
- * Returns the configuration wizards that are available for invocation.
- *
- * @return the available wizards
- */
- protected AdaptableList getAvailableWizards() {
- AdaptableList result = new AdaptableList();
- IPluginRegistry registry = Platform.getPluginRegistry();
- IExtensionPoint point = registry.getExtensionPoint(pluginId, getExtensionPoint());
- if (point != null) {
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- IConfigurationElement element = elements[j];
- if (element.getName().equals(TAG_WIZARD)) {
- ConfigurationWizardElement wizard = createWizardElement(element);
- if (wizard != null) {
- result.add(wizard);
- }
- }
- }
- }
- }
-
- return result;
- }
- /**
- * Returns a new ConfigurationWizardElement configured according to the parameters
- * contained in the passed Registry.
- *
- * May answer null if there was not enough information in the Extension to create
- * an adequate wizard
- *
- * @param element the element for which to create a wizard element
- * @return the wizard element for the given element
- */
- protected ConfigurationWizardElement createWizardElement(IConfigurationElement element) {
- // WizardElements must have a name attribute
- String nameString = element.getAttribute(ATT_NAME);
- if (nameString == null) {
- // Missing attribute
- return null;
- }
- ConfigurationWizardElement result = new ConfigurationWizardElement(nameString);
- if (initializeWizard(result, element)) {
- // initialization was successful
- return result;
- }
- return null;
- }
- /**
- * Initialize the passed element's properties based on the contents of
- * the passed registry. Answer a boolean indicating whether the element
- * was able to be adequately initialized.
- *
- * @param element the element to initialize the properties for
- * @param extension the registry to get properties from
- * @return whether initialization was successful
- */
- protected boolean initializeWizard(ConfigurationWizardElement element, IConfigurationElement config) {
- element.setID(config.getAttribute(ATT_ID));
- String description = ""; //$NON-NLS-1$
- IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
- if (children.length >= 1) {
- description = children[0].getValue();
- }
-
- element.setDescription(description);
-
- // apply CLASS and ICON properties
- element.setConfigurationElement(config);
- String iconName = config.getAttribute(ATT_ICON);
- if (iconName != null) {
- IExtension extension = config.getDeclaringExtension();
- element.setImageDescriptor(TeamUIPlugin.getImageDescriptorFromExtension(extension, iconName));
- }
- // ensure that a class was specified
- if (element.getConfigurationElement() == null) {
- // Missing attribute
- return false;
- }
- setForcePreviousAndNextButtons(true);
- return true;
- }
- /*
- * Method declared on IConfigurationWizard
- */
- public void init(IWorkbench workbench, IProject project) {
- this.workbench = workbench;
- this.project = project;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java
deleted file mode 100644
index e6ae4bcb0..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java
+++ /dev/null
@@ -1,147 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.Utils;
-
-/**
- * Action to create a new remote folder.
- */
-public class CreateNewFolderAction extends TargetAction {
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- return getSelectedRemoteFolders().length == 1;
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- try {
- Utils.runWithProgressDialog(getShell(), true /* cancelable */, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- try {
- createDir(getShell(), getSelectedRemoteFolders()[0], new String());
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- });
- } catch (InvocationTargetException e) {
- handle(e, Policy.bind("Error"), Policy.bind("CreateNewFolderAction.errorCreatingFolder")); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (InterruptedException e) {
- }
- }
-
- /**
- * Throws a TeamException if one occured.
- * Returns null if the operation was cancelled or an exception occured
- */
- public static IRemoteTargetResource createDir(final Shell shell, final IRemoteTargetResource parent, final String defaultName) throws TeamException {
- final IRemoteTargetResource[] newFolder = new IRemoteTargetResource[] {null};
- try {
- Utils.runWithProgressDialog(shell, true, new IRunnableWithProgress() {
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask(Policy.bind("CreateNewFolderAction.creatingFolder"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- final String[] folderName = new String[] {null};
- final String suggestedName = getSuggestedFolderName(parent, Policy.subMonitorFor(monitor, 0), defaultName);
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- InputDialog dialog = new InputDialog(shell,
- Policy.bind("CreateNewFolderAction.title"), //$NON-NLS-1$
- Policy.bind("CreateNewFolderAction.message"), //$NON-NLS-1$
- suggestedName,
- null);
- Policy.checkCanceled(monitor);
- if(dialog.open() == InputDialog.OK) {
- folderName[0] = dialog.getValue();
- }
- }
- });
- if(folderName[0] != null) {
- newFolder[0] = parent.getFolder(folderName[0]);
- newFolder[0].mkdirs(Policy.subMonitorFor(monitor, 0));
- }
- } catch(TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- } catch(InvocationTargetException e) {
- if (e.getTargetException() instanceof TeamException) {
- throw (TeamException)e.getTargetException();
- }
- Utils.handle(e);
- } catch(InterruptedException e) {
- }
- return newFolder[0];
- }
-
- protected static String getSuggestedFolderName(IRemoteTargetResource parent, IProgressMonitor monitor, String defaultName) throws TeamException {
- IRemoteResource[] members;
- monitor.subTask(Policy.bind("CreateNewFolderAction.suggestedNameProgress")); //$NON-NLS-1$
- members = parent.members(monitor);
- ArrayList names = new ArrayList();
-
- String suggestedFolderName = defaultName;
-
- boolean nameUsed = false;
-
- for (int i = 0; i < members.length; i++) {
- String existingName = members[i].getName();
- names.add(existingName); // cache them for next round since faster
- if(existingName.equals(suggestedFolderName)) {
- nameUsed = true;
- }
- }
-
- if(!nameUsed)
- return suggestedFolderName;
-
- //Otherwise, keep proposing new names by incrementing a postfix name index until we find one not used
- int postfix = 1;
-
- String baseName = suggestedFolderName;
-
- do {
- nameUsed = false;
- for (int i = 0; i < members.length && !nameUsed; i++) {
- suggestedFolderName = Policy.bind("CreateNewFolderAction.suggestedNameConcat", baseName, String.valueOf(postfix)); //$NON-NLS-1$
- String existingName = (String) names.get(i);
-
- if(existingName.equals(suggestedFolderName)) {
- postfix = postfix + 1;
- nameUsed = true;
- }
- }
- } while(nameUsed);
- return suggestedFolderName;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/DiscardSiteAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/DiscardSiteAction.java
deleted file mode 100644
index 573f4bc18..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/DiscardSiteAction.java
+++ /dev/null
@@ -1,190 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-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.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
-
-/**
- * Discards a remembered Site from Target Management. Before a Site can be
- * discarded all resources using this site must be deconfigured. This action will
- * prompt the user if a Site cannot be discarded because of existing connections.
- */
-public class DiscardSiteAction extends TargetAction {
-
- private class AlreadyMappedDialog extends DetailsDialog {
- private IProject[] projects;
- private org.eclipse.swt.widgets.List detailsList;
- private Button unmap;
-
- public AlreadyMappedDialog(Shell shell, IProject[] projects) {
- super(shell, Policy.bind("SiteExplorerView.unmapDialogTitle")); //$NON-NLS-1$
- setImageKey(DLG_IMG_WARNING);
- this.projects = projects;
- }
-
- protected Composite createDropDownDialogArea(Composite parent) {
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setFont(parent.getFont());
-
- detailsList = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- GridData data = new GridData ();
- data.heightHint = 75;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- detailsList.setLayoutData(data);
-
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- TargetProvider target;
- try {
- target = TargetManager.getProvider(project);
- } catch (TeamException e) {
- continue;
- }
- detailsList.add(Policy.bind("SiteExplorerView.mappedProjects", project.getName(), target.getURL().toExternalForm())); //$NON-NLS-1$
- }
- return composite;
- }
-
- protected void createMainDialogArea(Composite composite) {
- Label label = new Label(composite, SWT.WRAP);
- label.setText(Policy.bind("SiteExplorerView.projectsAlreadyMapped")); //$NON-NLS-1$
- GridData data = new GridData(
- GridData.GRAB_HORIZONTAL |
- GridData.GRAB_VERTICAL |
- GridData.HORIZONTAL_ALIGN_FILL |
- GridData.VERTICAL_ALIGN_CENTER);
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- label.setLayoutData(data);
- label.setFont(composite.getFont());
-
- unmap = new Button(composite, SWT.CHECK);
- unmap.setText(Policy.bind("SiteExplorerView.unmapProjectsAndDisconnect")); //$NON-NLS-1$
- unmap.setSelection(false);
- unmap.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- updateEnablements();
- }
- });
- setPageComplete(false);
- updateEnablements();
- }
-
- protected void updateEnablements() {
- setPageComplete(unmap.getSelection());
- }
- }
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- return getSelectedSites().length > 0;
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- deletedSelected();
- }
-
- private void deletedSelected() {
- try {
- Site[] sites = getSelectedSites();
- if(sites.length > 0) {
-
- // sites are already mapped, ask if they want to unmap projects first
- IProject[] mappedProjects = projectsMappedToSite(sites);
- if( mappedProjects.length > 0 ) {
- AlreadyMappedDialog dialog = new AlreadyMappedDialog(getShell(), mappedProjects);
- if(dialog.open() == AlreadyMappedDialog.OK) {
- for (int i = 0; i < mappedProjects.length; i++) {
- TargetManager.unmap(mappedProjects[i]);
- }
- } else {
- // nothing to do
- return;
- }
- } else {
- MessageDialog d = new MessageDialog(getShell(),
- Policy.bind("SiteExplorerView.promptForDeletingSitesTitle"), //$NON-NLS-1$
- null,
- Policy.bind("SiteExplorerView.promptForDeletingSites", new Integer(sites.length).toString()), //$NON-NLS-1$
- MessageDialog.QUESTION,
- new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0);
- if( d.open() != MessageDialog.OK ) {
- return;
- }
- }
- // sites aren't mapped, just ask then delete them form the view
- // and from the target manager.
- for (int i = 0; i < sites.length; i++) {
- TargetManager.removeSite(sites[i]);
- sites[i].dispose();
- }
- }
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(),
- Policy.bind("Error"), //$NON-NLS-1$
- Policy.bind("CreateNewFolderAction.errorDeletingSites"), //$NON-NLS-1$
- e.getStatus());
- }
- }
-
- private IProject[] projectsMappedToSite(Site[] sites) throws TeamException {
- List mappedProjects = new ArrayList();
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- TargetProvider target = TargetManager.getProvider(project);
- for (int j = 0; j < sites.length; j++) {
- if(target != null && target.getSite().equals(sites[j])) {
- mappedProjects.add(project);
- }
- }
- }
- return (IProject[]) mappedProjects.toArray(new IProject[mappedProjects.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ExportTargetSiteMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ExportTargetSiteMainPage.java
deleted file mode 100644
index 03f33e02f..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ExportTargetSiteMainPage.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.internal.ui.target;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.TableLayout;
-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.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.wizards.TeamWizardPage;
-
-/**
- * This page allows the user to save the settings used by Target sites to a file.
- */
-public class ExportTargetSiteMainPage extends TeamWizardPage {
- private List selectedSites = new ArrayList();
- private Text fileText;
- private String fileName = ""; //$NON-NLS-1$
- private Table table;
- private Button browseButton;
-
- /**
- * Constructor for ExportTargetSiteMainPage.
- * @param pageName The name of the page.
- */
- public ExportTargetSiteMainPage(String pageName) {
- super(pageName);
- }
-
- /**
- * Constructor for ExportTargetSiteMainPage.
- * @param pageName The name of the page
- * @param title The title of the page
- * @param titleImage The image for the page
- */
- public ExportTargetSiteMainPage(String pageName, String title, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = createComposite(parent, 1);
- initializeDialogUnits(composite);
- createLabel(composite, Policy.bind("ExportTargetSiteMainPage.Select_Sites")); //$NON-NLS-1$
-
- //TODO: add F1 help.
-
- table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- table.setLayout(new TableLayout());
- GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = 300;
- table.setLayoutData(data);
- table.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- if (event.detail == SWT.CHECK) {
- TableItem item = (TableItem) event.item;
- if (item.getChecked()) {
- selectedSites.add(item.getData());
- } else {
- selectedSites.remove(item.getData());
- }
- updateEnablement();
- }
- }
- });
- createLabel(composite, Policy.bind("ExportTargetSiteMainPage.Target_Site_Filename")); //$NON-NLS-1$
-
- Composite inner = new Composite(composite, SWT.NULL);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- inner.setLayout(layout);
-
- createLabel(inner, Policy.bind("ExportTargetSiteMainPage.File_name")); //$NON-NLS-1$
- fileText = createTextField(inner);
- if (fileName != null)
- fileText.setText(fileName);
- fileText.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event event) {
- fileName = fileText.getText();
- updateEnablement();
- }
- });
-
- browseButton = new Button(inner, SWT.PUSH);
- browseButton.setText(Policy.bind("ExportTargetSiteMainPage.Browse")); //$NON-NLS-1$
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- browseButton.setLayoutData(data);
- browseButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- FileDialog d = new FileDialog(getShell(), SWT.SAVE);
- d.setFilterExtensions(new String[] { "*.tsf" }); //$NON-NLS-1$
- d.setFilterNames(new String[] { Policy.bind("ExportTargetSiteMainPage.Target_Site_Files")}); //$NON-NLS-1$
- d.setFileName(Policy.bind("ExportTargetSiteMainPage.default")); //$NON-NLS-1$
- d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$
- String f = d.open();
- if (f != null) {
- fileText.setText(f);
- fileName = f;
- }
- }
- });
-
- initializeSites();
- setControl(composite);
- updateEnablement();
- Dialog.applyDialogFont(parent);
- }
-
- public void setSelectedSites(Site[] selectedSites) {
- this.selectedSites.addAll(Arrays.asList(selectedSites));
- }
-
- public void setFileName(String file) {
- if (file != null) {
- this.fileName = file;
- }
- }
-
- private void initializeSites() {
- List siteList = new ArrayList();
- Site[] workspaceSites = TargetManager.getSites();
- for (int i = 0; i < workspaceSites.length; i++) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setData(workspaceSites[i]);
- item.setText(workspaceSites[i].getDisplayName());
- }
- }
-
- /**
- * Returns the fileName.
- * @return String
- */
- public String getFileName() {
- return fileName;
- }
-
- public Site[] getSelectedSites() {
- return (Site[]) selectedSites.toArray(new Site[selectedSites.size()]);
- }
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- fileText.setFocus();
- }
- }
-
- private void updateEnablement() {
- boolean complete;
- if (selectedSites.size() == 0) {
- setMessage(null);
- complete = false;
- } else if (fileName.length() == 0) {
- setMessage(null);
- complete = false;
- } else {
- File f = new File(fileName);
- if (f.isDirectory()) {
- setMessage(Policy.bind("ExportTargetSiteMainPage.folder_specified"), ERROR); //$NON-NLS-1$
- complete = false;
- } else {
- complete = true;
- }
- }
- if (complete) {
- setMessage(null);
- }
- setPageComplete(complete);
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAction.java
deleted file mode 100644
index fe907b12e..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAction.java
+++ /dev/null
@@ -1,177 +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.internal.ui.target;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * Action for getting the contents of the selected resources
- */
-public class GetAction extends TargetAction {
-
- private class OutgoingChangesDialog extends DetailsDialog {
- private IResource[] outgoingChanges;
- private org.eclipse.swt.widgets.List detailsList;
-
- public OutgoingChangesDialog(Shell shell, IResource[] outgoingChanges) {
- super(shell, Policy.bind("GetAction.confirmFileOverwriteTitle")); //$NON-NLS-1$
- setImageKey(DLG_IMG_QUESTION);
- this.outgoingChanges = outgoingChanges;
- }
-
- protected Composite createDropDownDialogArea(Composite parent) {
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setFont(parent.getFont());
-
- detailsList = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- GridData data = new GridData ();
- data.heightHint = 75;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- detailsList.setLayoutData(data);
-
- for (int i = 0; i < outgoingChanges.length; i++) {
- detailsList.add(outgoingChanges[i].getFullPath().toString()); //$NON-NLS-1$
- }
- return composite;
- }
-
- protected void createMainDialogArea(Composite parent) {
- Label label = new Label(parent, SWT.WRAP);
- label.setText(Policy.bind("GetAction.confirmFileOverwrite")); //$NON-NLS-1$
- GridData data = new GridData(
- GridData.GRAB_HORIZONTAL |
- GridData.GRAB_VERTICAL |
- GridData.HORIZONTAL_ALIGN_FILL |
- GridData.VERTICAL_ALIGN_CENTER);
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- label.setLayoutData(data);
- label.setFont(parent.getFont());
- setPageComplete(true);
- }
-
- protected void updateEnablements() {
- }
- }
-
- public void run(IAction action) {
- if(promptForOutgoingChanges()) {
- run(new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- Hashtable table = getTargetProviderMapping();
- Set keySet = table.keySet();
- monitor.beginTask(null, keySet.size() * 1000);
-
- // perform the get on each provider
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- TargetProvider provider = (TargetProvider)iterator.next();
- monitor.setTaskName(Policy.bind("GetAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- provider.get(providerResources, Policy.subInfiniteMonitorFor(monitor, 1000));
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("GetAction.title"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
- }
-
- private boolean promptForOutgoingChanges() {
- try {
- // find any outgoing changes that will be overwritten and prompt
- Hashtable table = getTargetProviderMapping();
- Set keySet = table.keySet();
-
- Iterator iterator = keySet.iterator();
- List outgoingChanges = new ArrayList();
- while (iterator.hasNext()) {
- TargetProvider provider = (TargetProvider)iterator.next();
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- outgoingChanges.addAll(Arrays.asList(findResourcesWithOutgoingChanges(providerResources)));
- }
- if(! outgoingChanges.isEmpty()) {
- final OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(),
- (IResource[]) outgoingChanges.toArray(new IResource[outgoingChanges.size()]));
- final boolean okToContinue[] = {true};
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- if(dialog.open() != OutgoingChangesDialog.OK) {
- okToContinue[0] = false;
- }
- }
- });
- return okToContinue[0];
- }
- return true;
- } catch(CoreException e) {
- Utils.handle(e);
- }
- return false;
- }
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- if (resources.length == 0) return false;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- if(provider == null)
- return false;
- if(! provider.canPut(resource))
- return false; //if one can't don't allow for any
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java
deleted file mode 100644
index fc90d0c81..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java
+++ /dev/null
@@ -1,198 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.dialogs.PromptingDialog;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.NewProjectAction;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.ProjectLocationSelectionDialog;
-
-/**
- * Action to transfer a remote folder and it's contents into the workspace. If
- * the remote folder doesn't have a .project then the project creation wizard
- * is shown to configure a new project, otherwise the a prompt is shown to choose
- * the project name and location.
- *
- * @see GetAsProjectAction
- */
-public class GetAsAction extends GetAsProjectAction {
- public void run(IAction action) {
-
- final IRemoteTargetResource[] folders = getSelectedRemoteFolders();
- if (folders.length != 1) return;
- final IRemoteTargetResource remoteFolder = folders[0];
- final String remoteName = remoteFolder.getName();
-
- // Fetch the members of the folder to see if they contain a .project file.
- final boolean[] hasProjectMetaFile = new boolean[] { false };
- final boolean[] errorOccured = new boolean[] { false };
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- hasProjectMetaFile[0] = hasProjectMetaFile(remoteFolder, monitor);
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- }, Policy.bind("GetAs.checkoutFailed"), PROGRESS_DIALOG); //$NON-NLS-1$
- if (errorOccured[0]) return;
-
- // Prompt outside a workspace runnable so that the project creation delta can be heard
- IProject newProject = null;
- if ( ! hasProjectMetaFile[0]) {
- newProject = getNewProject(remoteFolder.getName());
- if (newProject == null) return;
- }
-
- final IProject createdProject = newProject;
- run(new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- IProject project;
- if (hasProjectMetaFile[0]) {
- // Prompt for name
- final Shell shell = getShell();
- final int[] result = new int[] { Dialog.OK };
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(remoteName);
- final ProjectLocationSelectionDialog dialog = new ProjectLocationSelectionDialog(shell, project);
- dialog.setTitle(Policy.bind("GetAs.enterProjectTitle", remoteName)); //$NON-NLS-1$
-
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0] = dialog.open();
- }
- });
- if (result[0] != Dialog.OK) return;
-
- Object[] destinationPaths = dialog.getResult();
- if (destinationPaths == null) return;
- String newName = (String) destinationPaths[0];
- IPath newLocation = new Path((String) destinationPaths[1]);
-
- // prompt if the project exists locally
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(newName);
- PromptingDialog prompt = new PromptingDialog(getShell(), new IResource[] { project },
- getOverwriteLocalAndFileSystemPrompt(), Policy.bind("GetAsProject.confirmOverwrite"));//$NON-NLS-1$
- if (prompt.promptForMultiple().length == 0) return;
-
- monitor.beginTask(null, 100);
- monitor.setTaskName(Policy.bind("GetAs.taskname", remoteFolder.getName(), newName)); //$NON-NLS-1$
-
- // create the project
- try {
- if (newLocation.equals(Platform.getLocation())) {
- // create in default location
- project.create(Policy.subMonitorFor(monitor, 3));
- } else {
- // create in some other location
- IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName());
- desc.setLocation(newLocation);
- project.create(desc, Policy.subMonitorFor(monitor, 3));
- }
- project.open(Policy.subMonitorFor(monitor, 2));
- } catch (CoreException e) {
- throw new TeamException(e.getStatus());
- }
- } else {
- project = createdProject;
- monitor.beginTask(null, 95);
- monitor.setTaskName(Policy.bind("GetAs.taskname", remoteFolder.getName(), createdProject.getName())); //$NON-NLS-1$
- }
-
- get(project, remoteFolder, Policy.subInfiniteMonitorFor(monitor, 95));
-
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("GetAs.checkoutFailed"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
-
- /*
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- return getSelectedRemoteFolders().length == 1;
- }
-
- /**
- * Get a new project.
- *
- * The suggestedName is not currently used but is a desired capability.
- */
- private IProject getNewProject(String suggestedName) {
- NewProjectListener listener = new NewProjectListener();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
- (new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow())).run();
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
- return listener.getNewProject();
- }
-
- protected boolean hasProjectMetaFile(IRemoteTargetResource remote, IProgressMonitor monitor) throws TeamException {
- IRemoteResource[] children = remote.members(monitor);
- for (int i = 0; i < children.length; i++) {
- if(children[i].getName().equals(".project")) { //$NON-NLS-1$
- return true;
- }
- }
- return false;
- }
-
- class NewProjectListener implements IResourceChangeListener {
- private IProject newProject = null;
- /**
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta root = event.getDelta();
- IResourceDelta[] projectDeltas = root.getAffectedChildren();
- for (int i = 0; i < projectDeltas.length; i++) {
- IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
- if (delta.getKind() == IResourceDelta.ADDED) {
- newProject = (IProject)resource;
- }
- }
- }
- /**
- * Gets the newProject.
- * @return Returns a IProject
- */
- public IProject getNewProject() {
- return newProject;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsProjectAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsProjectAction.java
deleted file mode 100644
index ca48f090b..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsProjectAction.java
+++ /dev/null
@@ -1,161 +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.internal.ui.target;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.internal.ui.dialogs.IPromptCondition;
-import org.eclipse.team.internal.ui.dialogs.PromptingDialog;
-
-/**
- * Action to transfer a remote folder and it's contents into the workspace. The
- * resulting project is named with the remote folder name and the kind of project
- * is determined by the remote .project file. If the remote folder doesn't not
- * contain a .project, then the project default simple type is used.
- *
- * @see GetAsAction
- */
-public class GetAsProjectAction extends TargetAction {
-
- public void run(IAction action) {
-
- final IRemoteTargetResource[] remoteFolders = getSelectedRemoteFolders();
-
- Set targetProjects = new HashSet();
- for (int i = 0; i < remoteFolders.length; i++) {
- String projectName = remoteFolders[i].getName();
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- targetProjects.add(project);
- }
- final IResource[] projects = (IResource[]) targetProjects.toArray(new IResource[targetProjects.size()]);
- PromptingDialog prompt = new PromptingDialog(getShell(), projects,
- getOverwriteLocalAndFileSystemPrompt(),
- Policy.bind("GetAsProject.confirmOverwrite"));//$NON-NLS-1$
-
- try {
- if (prompt.promptForMultiple().length != projects.length) return;
- } catch (InterruptedException e) {
- return;
- }
-
- try {
- Utils.runWithProgressDialog(getShell(), true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask(getTaskName(remoteFolders), remoteFolders.length * 100);
- monitor.setTaskName(getTaskName(remoteFolders));
- for (int i = 0; i < remoteFolders.length; i++) {
- IProject project = (IProject)projects[i];
- IRemoteTargetResource remote = remoteFolders[i];
- IProgressMonitor subMonitor = Policy.subInfiniteMonitorFor(monitor, 100);
- get(project, remote, subMonitor);
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- handle(e, Policy.bind("Error"), Policy.bind("GetAsProject.errorGettingResources")); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (InterruptedException e) {
- return;
- }
- }
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- return getSelectedRemoteFolders().length > 0;
- }
-
- protected void get(IProject project, IRemoteTargetResource remote, IProgressMonitor monitor) throws TeamException {
- try {
- monitor.beginTask(null, 100);
- try {
- if(!project.exists()) {
- project.create(Policy.subMonitorFor(monitor, 5));
- }
- if(!project.isOpen()) {
- project.open(Policy.subMonitorFor(monitor, 5));
- }
- } catch (CoreException e) {
- ErrorDialog.openError(getShell(), Policy.bind("Error"), Policy.bind("GetAsProject.errorCreatingProject"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
- Site site = remote.getSite();
- TargetProvider provider = TargetManager.getProvider(project);
- if(provider != null) {
- TargetManager.unmap(project);
- }
- TargetManager.map(project, site, UrlUtil.getTrailingPath(remote.getURL(), site.getURL()));
- provider = TargetManager.getProvider(project);
- provider.get(project, remote, Policy.subMonitorFor(monitor, 90));
- } finally {
- monitor.done();
- }
- }
-
- protected static String getTaskName(IRemoteTargetResource[] remoteFolders) {
- if (remoteFolders.length == 1) {
- IRemoteTargetResource folder = remoteFolders[0];
- return Policy.bind("GetAsProject.taskName1", folder.getURL().toExternalForm()); //$NON-NLS-1$
- }
- else {
- return Policy.bind("GetAsProject.taskNameN", new Integer(remoteFolders.length).toString()); //$NON-NLS-1$
- }
- }
-
- protected IPromptCondition getOverwriteLocalAndFileSystemPrompt() {
- return new IPromptCondition() {
- // prompt if resource in workspace exists or exists in local file system
- public boolean needsPrompt(IResource resource) {
- File localLocation = getFileLocation(resource);
- if(resource.exists() || localLocation.exists()) {
- return true;
- }
- return false;
- }
- public String promptMessage(IResource resource) {
- File localLocation = getFileLocation(resource);
- if(resource.exists()) {
- return Policy.bind("GetAsProject.thisResourceExists", resource.getName());//$NON-NLS-1$
- } else {
- return Policy.bind("GetAsProject.thisExternalFileExists", resource.getName());//$NON-NLS-1$
- }//$NON-NLS-1$
- }
- private File getFileLocation(IResource resource) {
- return new File(resource.getParent().getLocation().toFile(), resource.getName());
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetSyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetSyncAction.java
deleted file mode 100644
index f2129f36a..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetSyncAction.java
+++ /dev/null
@@ -1,149 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.sync.ITeamNode;
-import org.eclipse.team.internal.ui.sync.SyncSet;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class GetSyncAction extends TargetSyncAction {
-
- public GetSyncAction(TargetSyncCompareInput model, ISelectionProvider sp, String label, Shell shell) {
- super(model, sp, label, shell);
- WorkbenchHelp.setHelp(this, IHelpContextIds.SYNC_GET_ACTION);
- }
-
- /**
- * @see TargetSyncAction#isEnabled(ITeamNode)
- */
- protected boolean isEnabled(ITeamNode node) {
- // Get action is enabled for any changed nodes.
- SyncSet set = new SyncSet(new StructuredSelection(node));
- return set.hasIncomingChanges() || set.hasConflicts();
- }
-
- /**
- * @see TargetSyncAction#removeNonApplicableNodes(SyncSet, int)
- */
- protected void removeNonApplicableNodes(SyncSet set, int syncMode) {
- set.removeOutgoingNodes();
- }
-
- /**
- * @see TargetSyncAction#run(SyncSet, IProgressMonitor)
- */
- protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
- try {
- ITeamNode[] changed = syncSet.getChangedNodes();
- if (changed.length == 0) {
- return syncSet;
- }
- List fileResources = new ArrayList();
- List folderDeletions = new ArrayList();
- List folderAdditions = new ArrayList();
- //Find the incoming file changes the potential incoming folder deletions:
- for (int i = 0; i < changed.length; i++) {
- if (changed[i].getChangeDirection()==ITeamNode.INCOMING || changed[i].getChangeDirection()==ITeamNode.CONFLICTING) {
- if (changed[i].getResource().getType()==IResource.FILE) fileResources.add(changed[i].getResource());
- else if (changed[i].getChangeType()==Differencer.DELETION
- && /*don't delete nonexistant folders*/changed[i].getResource().exists())
- folderDeletions.add(changed[i].getResource());
- else {
- //If the new remote folders have no children then we'd better explicitly create them locally:
- IResource resource=changed[i].getResource();
- if (getRemoteResourceFor(resource).members(monitor).length==0)
- folderAdditions.add(changed[i].getResource());
- }
- }
- }
- get((IResource[])fileResources.toArray(new IResource[fileResources.size()]), monitor);
- get((IResource[])folderAdditions.toArray(new IResource[folderDeletions.size()]), monitor);
- if (folderDeletions.size()>0) {
- //Prune the list of potential incoming folder deletions, retaining only those that don't have local content:
- boolean delete;
- Iterator iter=folderDeletions.iterator();
- for (IContainer container=(IContainer)iter.next(); iter.hasNext(); container=(IContainer)iter.next()) {
- delete=true;
- IResource[] children=container.members();
- for (int j = 0; j < children.length; j++) {
- if (!folderDeletions.contains(children[j])) {
- delete=false;
- break;
- }
- }
- if (!delete) iter.remove();
- }
- get((IResource[])folderDeletions.toArray(new IResource[folderDeletions.size()]), monitor);
- }
- } catch (final TeamException e) {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- }
- });
- return null;
- } catch (final CoreException e) {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- }
- });
- return null;
- }
- return syncSet;
- }
-
- /**
- * Put the given resources to their associated providers.
- *
- * @param resources the resources to commit
- * @param monitor the progress monitor
- */
- public void get(IResource[] resources, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- try {
- Hashtable table = getTargetProviderMapping(resources);
- Set keySet = table.keySet();
- monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
- TargetProvider provider = (TargetProvider)iterator.next();
- monitor.setTaskName(Policy.bind("GetAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- provider.get(providerResources, subMonitor);
- }
- } finally {
- monitor.done();
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ImportTargetSiteMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ImportTargetSiteMainPage.java
deleted file mode 100644
index c3c2ccefb..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ImportTargetSiteMainPage.java
+++ /dev/null
@@ -1,149 +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.internal.ui.target;
-
-import java.io.File;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.ImageDescriptor;
-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.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.wizards.TeamWizardPage;
-
-public class ImportTargetSiteMainPage extends TeamWizardPage {
- private Text fileText;
- private String file = ""; //$NON-NLS-1$
- private Button browseButton;
-
- /**
- * @see org.eclipse.jface.wizard.WizardPage#WizardPage(String, String, ImageDescriptor)
- */
- public ImportTargetSiteMainPage(String pageName, String title, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- }
-
- private void updateEnablement() {
- boolean complete;
-
- if (file.length() == 0) {
- setMessage(null);
- complete = false;
- } else {
- // See if the file exists
- File f = new File(file);
- if (!f.exists()) {
- setMessage(Policy.bind("ImportTargetSiteMainPage.nonexistent_file"), ERROR); //$NON-NLS-1$
- complete = false;
- } else if (f.isDirectory()) {
- setMessage(Policy.bind("ImportTargetSiteMainPage.folder_specified"), ERROR); //$NON-NLS-1$
- complete = false;
- } else {
- complete = true;
- }
- }
- if (complete) {
- setMessage(null);
- }
- setPageComplete(complete);
- }
-
- /**
- * single-use mutator
- * @param file The name to use for the file.
- */
- public void setFileName(String file) {
- if (file != null) {
- this.file = file;
- }
- }
-
- /**
- * Method getFileName.
- * @return String
- */
- public String getFileName() {
- return file;
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- fileText.setFocus();
- }
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = createComposite(parent, 1);
- initializeDialogUnits(composite);
-
- //TODO: add F1 help.
-
- Composite inner = new Composite(composite, SWT.NULL);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- inner.setLayout(layout);
-
- createLabel(inner, Policy.bind("ImportTargetSiteMainPage.File_name")); //$NON-NLS-1$
- fileText = createTextField(inner);
- if (file != null) fileText.setText(file);
- fileText.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event event) {
- file = fileText.getText();
- updateEnablement();
- }
- });
-
- browseButton = new Button(inner, SWT.PUSH);
- browseButton.setText(Policy.bind("ImportTargetSiteMainPage.Browse")); //$NON-NLS-1$
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- browseButton.setLayoutData(data);
- browseButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- FileDialog d = new FileDialog(getShell());
- d.setFilterExtensions(new String[] {"*.tsf", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
- d.setFilterNames(new String[] {Policy.bind("ImportTargetSiteMainPage.Target_Site_Files"), Policy.bind("ImportTargetSiteMainPage.allFiles")}); //$NON-NLS-1$ //$NON-NLS-2$
- d.setFilterPath(new File(".").getAbsolutePath()); //$NON-NLS-1$
- String f = d.open();
- if (f != null) {
- fileText.setText(f);
- file = f;
- }
- }
- });
-
- setControl(composite);
- updateEnablement();
- Dialog.applyDialogFont(parent);
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
deleted file mode 100644
index 5ba6a9f55..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
+++ /dev/null
@@ -1,197 +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.internal.ui.target;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.UrlUtil;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-public class MappingSelectionPage extends TargetWizardPage {
- private IPath path = Path.EMPTY;
- private Site site;
- private TreeViewer viewer;
- private Text textPath;
-
- public MappingSelectionPage(String pageName, String title, ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- setDescription(Policy.bind("MappingSelectionPage.description")); //$NON-NLS-1$
- }
-
- public void setSite(Site site) {
- this.site = site;
- }
-
- public Site getSite() {
- return site;
- }
-
- public void createControl(Composite p) {
- Composite composite = createComposite(p, 1);
- // set F1 help
- WorkbenchHelp.setHelp(composite, IHelpContextIds.TARGET_MAPPING_SELECTION_PAGE);
-
- createLabel(composite, Policy.bind("MappingSelectionPage.label")); //$NON-NLS-1$
-
- viewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE);
-
- GridData data = new GridData (GridData.FILL_BOTH);
- viewer.getTree().setLayoutData(data);
- viewer.setContentProvider(new SiteLazyContentProvider());
- viewer.setLabelProvider(new WorkbenchLabelProvider());
- viewer.setSorter(new SiteViewSorter());
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateTextPath();
- }
- });
-
- // include only folders in view
- viewer.addFilter(new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getRemoteResource().isContainer();
- }
- return false;
- }
- });
-
- Button newFolderButton = new Button(composite, SWT.PUSH);
- newFolderButton.setText(Policy.bind("MappingSelectionPage.newFolderLabel")); //$NON-NLS-1$
- newFolderButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent (Event event) {
- Shell shell = getShell();
- try {
- // assume that only one folder is selected in the folder tree
- IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- Object currentSelection = selection.getFirstElement();
- final IRemoteTargetResource selectedFolder = getSelectedRemoteFolder(selection);
- String defaultName = ((ConfigureTargetWizard) getWizard()).project.getName();
-
- IRemoteTargetResource newFolder = CreateNewFolderAction.createDir(getShell(), selectedFolder, defaultName);
- if (newFolder == null)
- return;
-
- RemoteResourceElement newFolderUIElement = new RemoteResourceElement(newFolder);
-
- ((RemoteResourceElement)currentSelection).setCachedChildren(null);
- viewer.refresh(currentSelection);
- viewer.setExpandedState(currentSelection, true);
- viewer.setSelection(new StructuredSelection(newFolderUIElement));
- } catch (TeamException e) {
- Utils.handle(e);
- return;
- }
- }
- });
- setViewerInput();
- setControl(composite);
- setPageComplete(true);
- Dialog.applyDialogFont(p);
- }
-
- private IRemoteTargetResource getSelectedRemoteFolder(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- final List filesSelection = new ArrayList();
- Iterator it = selection.iterator();
- while(it.hasNext()) {
- Object o = it.next();
- if(o instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)o).getRemoteResource();
- } else if(o instanceof SiteElement) {
- try {
- return ((SiteElement)o).getSite().getRemoteResource();
- } catch (TeamException e) {
- return null;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Method updateTextPath.
- */
- private void updateTextPath() {
- IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- if (!selection.isEmpty()) {
- final List filesSelection = new ArrayList();
- Iterator it = selection.iterator();
- while(it.hasNext()) {
- Object o = it.next();
- if(o instanceof RemoteResourceElement) {
- RemoteResourceElement element = (RemoteResourceElement) o;
- URL remoteResourceURL;
- remoteResourceURL = element.getRemoteResource().getURL();
- this.path = UrlUtil.getTrailingPath(
- remoteResourceURL,
- this.site.getURL());
- return;
- }
- }
- }
- }
-
- public IPath getMapping() {
- return this.path;
- }
-
- /**
- * Attempt to set the viewer input.
- * Do nothing if we don't have enough info yet to set it.
- */
- private void setViewerInput() {
- if(this.site == null || viewer == null)
- return;
- viewer.setInput(new SiteRootsElement(new Site[] {site}, getContainer()));
- }
-
- /**
- * @see IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- if(visible) {
- setViewerInput();
- viewer.setSelection(new StructuredSelection(new SiteElement(site)));
- }
- super.setVisible(visible);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ProjectTargetMappingPropertiesPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ProjectTargetMappingPropertiesPage.java
deleted file mode 100644
index a18000996..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ProjectTargetMappingPropertiesPage.java
+++ /dev/null
@@ -1,126 +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.internal.ui.target;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.wizard.WizardDialog;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class ProjectTargetMappingPropertiesPage extends PropertyPage {
- public static final int WIDTH_HINT = 250;
-
- private IProject proj;
- private Site site = null;
- private IPath mapping;
- private TargetProvider origProvider=null;
-
- private Label serverText,folderText;
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- initialize();
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new GridLayout(2, false));
-
- Label serverLabel = new Label(container, SWT.NONE);
- serverLabel.setText(Policy.bind("ProjectTargetMappingPropertiesPage.URL")); //$NON-NLS-1$
- serverText = new Label(container, SWT.NONE);
- serverText.setText(site.getURL().toString());
- GridData data = new GridData();
- data.widthHint = WIDTH_HINT;
- serverText.setLayoutData(data);
-
- Label folderLabel = new Label(container, SWT.NONE);
- folderLabel.setText(Policy.bind("ProjectTargetMappingPropertiesPage.FolderName")); //$NON-NLS-1$
- folderText = new Label(container, SWT.NONE);
- folderText.setText(mapping.toString());
- data = new GridData();
- data.widthHint = WIDTH_HINT;
- folderText.setLayoutData(data);
-
- Button change = new Button(container, SWT.PUSH);
- change.setText(Policy.bind("ProjectTargetMappingPropertiesPage.ChangeBtn")); //$NON-NLS-1$
- change.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- ConfigureTargetWizard wizard = new ConfigureTargetWizard();
- wizard.init(null, proj);
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- dialog.open();
- refreshInfo();
- }
- });
- Dialog.applyDialogFont(parent);
- return container;
- }
-
- private void initialize() {
- IAdaptable element = getElement();
- if (element instanceof IProject) {
- proj = ((IProject) element).getProject();
- } else {
- IProject adapter = (IProject) element.getAdapter(IProject.class);
- if (adapter != null) {
- proj = adapter.getProject();
- }
- }
- try {
- TargetProvider provider = TargetManager.getProvider(proj);
- if (origProvider==null) origProvider=provider;
- site = provider.getSite();
- mapping = UrlUtil.getTrailingPath(provider.getURL(), site.getURL());
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), Policy.bind("ProjectTargetMappingPropertiesPage.Error"), null, e.getStatus()); //$NON-NLS-1$
- }
- }
-
- private void refreshInfo() {
- initialize();
- serverText.setText(site.getURL().toString());
- folderText.setText(mapping.toString());
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- IPath oldMapping = UrlUtil.getTrailingPath(origProvider.getURL(), origProvider.getSite().getURL());
- try {
- TargetManager.unmap(proj);
- TargetManager.map(proj, origProvider.getSite(), oldMapping);
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), Policy.bind("ProjectTargetMappingPropertiesPage.Error"), null, e.getStatus()); //$NON-NLS-1$
- }
- refreshInfo();
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutAction.java
deleted file mode 100644
index 6b81f47b1..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutAction.java
+++ /dev/null
@@ -1,78 +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.internal.ui.target;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-/**
- * Action for checking in the selected resources
- */
-public class PutAction extends TargetAction {
- /*
- * Method declared on IActionDelegate.
- */
- public void run(IAction action) {
- run(new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- Hashtable table = getTargetProviderMapping();
- Set keySet = table.keySet();
- monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
- TargetProvider provider = (TargetProvider)iterator.next();
- monitor.setTaskName(Policy.bind("PutAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
-
- provider.put(providerResources, subMonitor);
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("PutAction.title"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- if (resources.length == 0) return false;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- if(provider == null)
- return false;
- if(! provider.canGet(resource))
- return false; //if one can't don't allow for any
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutSyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutSyncAction.java
deleted file mode 100644
index ab141e082..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/PutSyncAction.java
+++ /dev/null
@@ -1,149 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.sync.ITeamNode;
-import org.eclipse.team.internal.ui.sync.SyncSet;
-import org.eclipse.team.internal.ui.sync.SyncView;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class PutSyncAction extends TargetSyncAction {
-
- public PutSyncAction(TargetSyncCompareInput model, ISelectionProvider sp, String label, Shell shell) {
- super(model, sp, label, shell);
- WorkbenchHelp.setHelp(this, IHelpContextIds.SYNC_PUT_ACTION);
- }
-
- /**
- * @see TargetSyncAction#isEnabled(ITeamNode)
- */
- protected boolean isEnabled(ITeamNode node) {
- // Put action is enabled for any changed nodes.
- return new SyncSet(new StructuredSelection(node)).getChangedNodes().length > 0;
- }
-
- /**
- * @see TargetSyncAction#removeNonApplicableNodes(SyncSet, int)
- */
- protected void removeNonApplicableNodes(SyncSet set, int syncMode) {
- if (syncMode == SyncView.SYNC_OUTGOING) {
- set.removeIncomingNodes();
- }
- }
-
- /**
- * @see TargetSyncAction#run(SyncSet, IProgressMonitor)
- */
- protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
- try {
- ITeamNode[] changed = syncSet.getChangedNodes();
- if (changed.length == 0) {
- return syncSet;
- }
- List fileResources = new ArrayList();
- List folderDeletions = new ArrayList();
- List folderAdditions = new ArrayList();
- //Find the outgoing file changes the potential outgoing folder deletions:
- for (int i = 0; i < changed.length; i++) {
- if (changed[i].getChangeDirection()==ITeamNode.OUTGOING || changed[i].getChangeDirection()==ITeamNode.CONFLICTING) {
- if (changed[i].getResource().getType()==IResource.FILE) fileResources.add(changed[i].getResource());
- else if (changed[i].getChangeType()==Differencer.DELETION)
- folderDeletions.add(changed[i].getResource());
- else if (((IContainer)(changed[i].getResource())).members().length==0)
- ////If the new local folders have no children then we'd better explicitly create them remotely:
- folderAdditions.add(changed[i].getResource());
- }
- }
- put((IResource[])fileResources.toArray(new IResource[fileResources.size()]), monitor);
- if (folderAdditions.size()>0)
- put((IResource[])folderAdditions.toArray(new IResource[folderDeletions.size()]), monitor);
- if (folderDeletions.size()>0) {
- //Prune the list of potential outgoing folder deletions, retaining only those that don't have remote content:
- boolean delete;
- Iterator iter=folderDeletions.iterator();
- for (IContainer i=(IContainer)iter.next(); iter.hasNext(); i=(IContainer)iter.next()) {
- delete=true;
- IRemoteResource[] children=getRemoteResourceFor(i).members(monitor);
- for (int j = 0; j < children.length; j++) {
- if (!folderDeletions.contains(children[j])) {
- delete=false;
- break;
- }
- }
- if (!delete) iter.remove();
- }
- put((IResource[])folderDeletions.toArray(new IResource[folderDeletions.size()]), monitor);
- }
- } catch (final TeamException e) {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- }
- });
- return null;
- } catch (final CoreException e) {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- }
- });
- return null;
- }
- return syncSet;
- }
-
- /**
- * Put the given resources to their associated providers.
- *
- * @param resources the resources to commit
- * @param monitor the progress monitor
- */
- public void put(IResource[] resources, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- try {
- Hashtable table = getTargetProviderMapping(resources);
- Set keySet = table.keySet();
- monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
- TargetProvider provider = (TargetProvider)iterator.next();
- monitor.setTaskName(Policy.bind("PutAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- provider.put(providerResources, subMonitor);
- }
- } finally {
- monitor.done();
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
deleted file mode 100644
index e90242a59..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
+++ /dev/null
@@ -1,181 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * Used to show IRemoteTargetResource instances in the UI. In addition these elements
- * support caching of values returned from IRemoteTargetResource methods, as such these
- * instances aren't as much proxies as the underlying remote handles.
- * <p>
- * Implementation in progress: support for configuring these elements with a custom
- * progress monitor that can be the target of long running operations. This will
- * allow showing progress in wizards and in the SiteExplorerView when navigating
- * remote servers.</p>
- */
-public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
-
- // remote resource this element represents
- private IRemoteTargetResource remote;
-
- // cache for the remote values
- private IRemoteResource[] children = null;
- private int size = 0;
- private String lastModified = null;
-
- // context in which to perform long-running operations
- private IRunnableContext runContext;
-
- public RemoteResourceElement(IRemoteTargetResource remote) {
- this.remote = remote;
- }
-
- public RemoteResourceElement(IRemoteTargetResource remote, IRunnableContext runContext) {
- this(remote);
- this.runContext = runContext;
- }
-
- public IRemoteTargetResource getRemoteResource() {
- return remote;
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class) return this;
- return null;
- }
-
- public Object[] getChildren(Object o) {
- final Object[][] result = new Object[1][];
- try {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- // progress for fetching remote children is always unknown
- // let's not bother even trying to guess.
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- if(children == null) {
- setCachedChildren(remote.members(Policy.subMonitorFor(monitor, 50)));
- }
- List remoteElements = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- IRemoteTargetResource child = (IRemoteTargetResource)children[i];
- RemoteResourceElement element = new RemoteResourceElement(child, runContext);
-
- // cache size and last modified
- element.setLastModified(child.getLastModified(Policy.subMonitorFor(monitor, 25)));
- element.setSize(child.getSize(Policy.subMonitorFor(monitor, 25)));
- remoteElements.add(element);
- }
- result[0] = (RemoteResourceElement[])remoteElements.toArray(new RemoteResourceElement[remoteElements.size()]);
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
-
- if(runContext == null) {
- Utils.runWithProgress(null, true /*cancelable*/, runnable);
- } else {
- runContext.run(true, true, runnable);
- }
- } catch (InterruptedException e) {
- return new Object[0];
- } catch (InvocationTargetException e) {
- Utils.handle(e.getTargetException());
- return new Object[0];
- }
- return result[0];
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- if(remote.isContainer()) {
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
- } else {
- return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(remote.getName());
- }
- }
-
- public String getLabel(Object o) {
- // would be nice to display more than just the name (e.g. timestamp, size...)
- return remote.getName();
- }
-
- public Object getParent(Object o) {
- return null;
- }
-
- public int hashCode() {
- return getRemoteResource().hashCode();
- }
-
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(!(obj instanceof RemoteResourceElement))
- return false;
- return ((RemoteResourceElement)obj).getRemoteResource().equals(getRemoteResource());
- }
-
- public void clearChildren() {
- children = null;
- }
-
- public IRemoteResource[] getCachedChildren() {
- return children;
- }
-
- public void setCachedChildren(IRemoteResource[] children) {
- this.children = children;
- }
-
- protected void setRemoteResource(IRemoteTargetResource remote) {
- this.remote = remote;
- }
-
- public String getLastModified() {
- return lastModified;
- }
-
- public int getSize() {
- return size;
- }
-
- public void setLastModified(String lastModified) {
- this.lastModified = lastModified;
- }
-
- public void setSize(int size) {
- this.size = size;
- }
-
- public String getName() {
- return remote.getName();
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
deleted file mode 100644
index 16fa29dd3..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
+++ /dev/null
@@ -1,92 +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.internal.ui.target;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.ui.ISharedImages;
-
-/**
- * Used to show Site instances in the UI. Sites are really just remote
- * resources but are shown with a different icon and label.
- *
- * @see RemoteResourceElement
- */
-public class SiteElement extends RemoteResourceElement {
- private Site site;
-
- public SiteElement(Site site) {
- super(null);
- this.site = site;
- }
-
- public SiteElement(Site site, IRunnableContext runContext) {
- super(null, runContext);
- this.site = site;
- }
-
- public Site getSite() {
- return site;
- }
-
- public int hashCode() {
- return site.hashCode();
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT);
- }
-
- public String getLabel(Object o) {
- return getSite().getDisplayName();
- }
-
- public Object getParent(Object o) {
- return null;
- }
-
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(!(obj instanceof SiteElement))
- return false;
- Site otherSite = ((SiteElement)obj).getSite();
- return getSite().equals(otherSite);
- }
- /**
- * @see IWorkbenchAdapter#getChildren(Object)
- */
- public Object[] getChildren(Object o) {
- try {
- setRemoteResource(site.getRemoteResource());
- } catch (TeamException e) {
- Utils.handle(e);
- return new Object[0];
- }
- return super.getChildren(this);
- }
- /**
- * @see RemoteResourceElement#getRemoteResource()
- */
- public IRemoteTargetResource getRemoteResource() {
- try {
- return site.getRemoteResource();
- } catch (TeamException e) {
- Utils.handle(e);
- return null;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
deleted file mode 100644
index 512058279..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
+++ /dev/null
@@ -1,574 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.ISiteListener;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.ui.ISharedImages;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.internal.WorkbenchImages;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Is a view that allows browsing remote target sites. It is modeled after
- * a file explorer: a tree of folders is show with a table of the folder's
- * contents.
- * <p>
- * Progress is shown in the main workbench window's status line progress
- * monitor.</p>
- *
- * @see Site
- * @see IRemoteTargetResource
- */
-public class SiteExplorerView extends ViewPart implements ISiteListener {
-
- public static final String VIEW_ID = "org.eclipse.team.ui.target.SiteExplorerView"; //$NON-NLS-1$
-
- // The tree viewer showing the folders and sites
- private TreeViewer folderTree;
-
- // The table view that shows the resources in the currently selected folder
- // from the folders tree.
- private TableViewer folderContentsTable;
-
- // The root
- private SiteRootsElement root;
-
- // Embedded progress monitor part used to display progress when contacting the server
- // Note: this feature is not enabled yet and is still under construction
- private IProgressMonitor progressMonitorPart;
-
- // The view's actions
- private Action addSiteAction;
- private Action newFolderAction;
- private PropertyDialogAction propertiesAction;
-
- /**
- * Sorter for the folderContents table
- */
- class FolderListingSorter extends ViewerSorter {
- private boolean reversed = false;
- private int columnNumber;
-
- public static final int NAME = 0;
- public static final int SIZE = 1;
- public static final int MODIFIED = 2;
-
- // column headings: "Name" "Size" "Modified"
- private int[][] SORT_ORDERS_BY_COLUMN = {
- {NAME}, /* name */
- {SIZE, NAME}, /* size */
- {MODIFIED, NAME, SIZE}, /* modified */
- };
-
- public FolderListingSorter(int columnNumber) {
- this.columnNumber = columnNumber;
- }
-
- public int compare(Viewer viewer, Object o1, Object o2) {
- RemoteResourceElement e1 = (RemoteResourceElement)o1;
- RemoteResourceElement e2 = (RemoteResourceElement)o2;
- int[] columnSortOrder = SORT_ORDERS_BY_COLUMN[columnNumber];
- int result = 0;
- for (int i = 0; i < columnSortOrder.length; ++i) {
- result = compareColumnValue(columnSortOrder[i], e1, e2);
- if (result != 0)
- break;
- }
- if (reversed)
- result = -result;
- return result;
- }
-
- int compareColumnValue(int columnNumber, RemoteResourceElement e1, RemoteResourceElement e2) {
- IRemoteTargetResource r1 = e1.getRemoteResource();
- IRemoteTargetResource r2 = e2.getRemoteResource();
- switch (columnNumber) {
- case NAME:
- if (r1.isContainer() && r2.isContainer())
- return compareNames(r1, r2);
- else if (r1.isContainer())
- return -1;
- else if (r2.isContainer())
- return 1;
- return compareNames(r1, r2);
- case SIZE:
- return new Integer(e1.getSize()).compareTo(new Integer(e2.getSize()));
- case MODIFIED:
- return getCollator().compare(e1.getLastModified(), e2.getLastModified());
- default:
- return 0;
- }
- }
-
- protected int compareNames(IRemoteTargetResource resource1, IRemoteTargetResource resource2) {
- return resource1.getName().compareTo(resource2.getName());
- }
-
- /**
- * Returns the number of the column by which this is sorting.
- */
- public int getColumnNumber() {
- return columnNumber;
- }
-
- /**
- * Returns true for descending, or false
- * for ascending sorting order.
- */
- public boolean isReversed() {
- return reversed;
- }
-
- /**
- * Sets the sorting order.
- */
- public void setReversed(boolean newReversed) {
- reversed = newReversed;
- }
- }
-
- /**
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite top) {
- Composite p = new Composite(top, SWT.NULL);
- GridData data = new GridData (GridData.FILL_BOTH);
- p.setLayoutData(data);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- p.setLayout (gridLayout);
-
- SashForm sash = new SashForm(p, SWT.HORIZONTAL);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 3;
- sash.setLayoutData(data);
-
- folderTree = new TreeViewer(sash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- folderTree.setContentProvider(new SiteLazyContentProvider());
- folderTree.setLabelProvider(new WorkbenchLabelProvider());
-
- folderTree.setSorter(new SiteViewSorter());
- folderTree.getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent event) {
- if (event.keyCode == SWT.F5) {
- RemoteResourceElement[] selectedFolders = getSelectedRemoteFolder((IStructuredSelection)folderTree.getSelection());
- if(selectedFolders.length == 1) {
- selectedFolders[0].setCachedChildren(null);
- folderTree.refresh(selectedFolders[0]);
- updateFileTable(selectedFolders[0]);
- }
- }
- }
- });
-
- folderTree.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection)folderTree.getSelection();
- final RemoteResourceElement[] remoteFolders = getSelectedRemoteFolder(selection);
- if(remoteFolders.length == 1) {
- updateFileTable(remoteFolders[0]);
- }
- }
- });
-
- folderTree.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent e) {
- IStructuredSelection selection = (IStructuredSelection)folderTree.getSelection();
- if(selection.size() == 1) {
- expandInTreeCurrentSelection(selection, true /*toggle expanded*/);
- }
- }
- });
-
- folderTree.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object e1, Object e2) {
- String name1 = ""; //$NON-NLS-1$
- String name2 = ""; //$NON-NLS-1$
- if(e1 instanceof RemoteResourceElement) {
- name1 = ((RemoteResourceElement)e1).getRemoteResource().getName();
- } else if(e1 instanceof SiteElement) {
- name1 = ((SiteElement)e1).getSite().getURL().toExternalForm();
- }
- if(e2 instanceof RemoteResourceElement) {
- name2 = ((RemoteResourceElement)e2).getRemoteResource().getName();
- } else if(e2 instanceof SiteElement) {
- name2 = ((SiteElement)e2).getSite().getURL().toExternalForm();
- }
-
- return getCollator().compare(name1, name2);
- }
- });
-
- // show only folders in tree
- folderTree.addFilter(new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getRemoteResource().isContainer();
- }
- return false;
- }
- });
-
- Table table = new Table(sash, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- TableLayout layout = new TableLayout();
- table.setLayout(layout);
- table.setHeaderVisible(true);
-
- TableColumn tableColumn = new TableColumn(table, SWT.NULL);
- tableColumn.setText(Policy.bind("SiteExplorerView.Name_1")); //$NON-NLS-1$
- tableColumn.addSelectionListener(getColumnListener());
- layout.addColumnData(new ColumnWeightData(30, true));
-
- tableColumn = new TableColumn(table, SWT.NULL);
- tableColumn.setText(Policy.bind("SiteExplorerView.Size_2")); //$NON-NLS-1$
- tableColumn.setAlignment(SWT.RIGHT);
- tableColumn.addSelectionListener(getColumnListener());
- layout.addColumnData(new ColumnWeightData(10, true));
-
- tableColumn = new TableColumn(table, SWT.NULL);
- tableColumn.setText(Policy.bind("SiteExplorerView.Modified_3")); //$NON-NLS-1$
- tableColumn.addSelectionListener(getColumnListener());
- layout.addColumnData(new ColumnWeightData(30, true));
-
- tableColumn = new TableColumn(table, SWT.NULL);
- tableColumn.setText(Policy.bind("SiteExplorerView.URL_4")); //$NON-NLS-1$
- layout.addColumnData(new ColumnWeightData(30, true));
-
- folderContentsTable = new TableViewer(table);
- folderContentsTable.setContentProvider(new SiteLazyContentProvider());
- folderContentsTable.setLabelProvider(new SiteExplorerViewLabelProvider());
-
- folderContentsTable.getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent event) {
- if (event.keyCode == SWT.F5) {
- RemoteResourceElement folder = (RemoteResourceElement)folderContentsTable.getInput();
- if(folder != null) {
- folder.setCachedChildren(null);
- folderContentsTable.refresh();
- }
- }
- }
- });
-
- folderContentsTable.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent e) {
- IStructuredSelection selection = (IStructuredSelection)folderContentsTable.getSelection();
- if(selection.size() == 1) {
- final RemoteResourceElement[] remoteFolders = getSelectedRemoteFolder(selection);
- if(remoteFolders.length == 1) {
- IStructuredSelection treeSelection = (IStructuredSelection)folderTree.getSelection();
- expandInTreeCurrentSelection(treeSelection, false /*don't toggle*/);
- folderTree.setSelection(new StructuredSelection(remoteFolders[0]));
- }
- }
- }
- });
- FolderListingSorter sorter = new FolderListingSorter(FolderListingSorter.NAME);
- sorter.setReversed(false);
- folderContentsTable.setSorter(sorter);
-
- sash.setWeights(new int[] {33, 67});
-
- TargetManager.addSiteListener(this);
-
- root = new SiteRootsElement(getViewSite().getWorkbenchWindow());
- initalizeActions();
- folderTree.setInput(root);
-
- // F1 Help
- WorkbenchHelp.setHelp(folderTree.getControl(), IHelpContextIds.SITE_EXPLORER_VIEW);
- }
-
- private Shell getShell() {
- return folderTree.getTree().getShell();
- }
-
- private RemoteResourceElement[] getSelectedRemoteFolder(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- final List folders = new ArrayList();
- Iterator it = selection.iterator();
- while(it.hasNext()) {
- Object o = it.next();
- if(o instanceof RemoteResourceElement) {
- folders.add(o);
- }
- }
- return (RemoteResourceElement[]) folders.toArray(new RemoteResourceElement[folders.size()]);
- }
- return new RemoteResourceElement[0];
- }
-
- private void expandInTreeCurrentSelection(IStructuredSelection selection, boolean toggle) {
- if (!selection.isEmpty()) {
- Iterator it = selection.iterator();
- while(it.hasNext()) {
- Object element = it.next();
- if(toggle) {
- folderTree.setExpandedState(element, !folderTree.getExpandedState(element));
- } else {
- folderTree.setExpandedState(element, true);
- }
- }
- }
- }
-
- /**
- * Method updateFileTable.
- */
- private void updateFileTable(RemoteResourceElement remoteFolder) {
- if(remoteFolder != null && !remoteFolder.equals(folderContentsTable.getInput())) {
- folderContentsTable.setInput(remoteFolder);
- }
- }
-
- private void initalizeActions() {
- final Shell shell = folderContentsTable.getTable().getShell();
- // Create actions
-
- // Refresh (toolbar)
- addSiteAction = new Action(Policy.bind("SiteExplorerView.addSiteAction"), TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT)) { //$NON-NLS-1$
- public void run() {
- ConfigureTargetWizard wizard = new ConfigureTargetWizard();
- wizard.init(null, null);
- WizardDialog dialog = new WizardDialog(shell, wizard);
- dialog.open();
- }
- };
- addSiteAction.setToolTipText(Policy.bind("SiteExplorerView.addSiteActionTooltip")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(addSiteAction, IHelpContextIds.ADD_SITE_ACTION);
-
- newFolderAction = new Action(Policy.bind("SiteExplorerView.newFolderAction"), WorkbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
- public void run() {
- final Shell shell = folderTree.getTree().getShell();
- try {
- // assume that only one folder is selected in the folder tree, this
- // is enforced by isEnable() method for this action
- IStructuredSelection selection = (IStructuredSelection)folderTree.getSelection();
- Object currentSelection = selection.getFirstElement();
-
- RemoteResourceElement selectedFolder;
- if(!selection.isEmpty()) {
- selectedFolder = getSelectedRemoteFolder(selection)[0];
- } else {
- selectedFolder = (RemoteResourceElement)folderContentsTable.getInput();
- }
-
- IRemoteTargetResource newFolder = CreateNewFolderAction.createDir(shell, selectedFolder.getRemoteResource(), Policy.bind("CreateNewFolderAction.newFolderName")); //$NON-NLS-1$
- if (newFolder == null)
- return;
-
- // force a refresh
- selectedFolder.setCachedChildren(null);
-
- // select the newly added folder
- RemoteResourceElement newFolderUIElement = new RemoteResourceElement(newFolder);
- folderTree.refresh(currentSelection);
- expandInTreeCurrentSelection(new StructuredSelection(currentSelection), false);
- folderTree.setSelection(new StructuredSelection(newFolderUIElement));
- } catch (TeamException e) {
- Utils.handle(e);
- return;
- }
- }
- public boolean isEnabled() {
- return folderContentsTable.getInput() != null ||
- getSelectedRemoteFolder((IStructuredSelection)folderTree.getSelection()).length == 1;
- }
- };
- WorkbenchHelp.setHelp(newFolderAction, IHelpContextIds.NEW_FOLDER_ACTION);
-
- IActionBars bars = getViewSite().getActionBars();
- IToolBarManager tbm = bars.getToolBarManager();
- tbm.add(addSiteAction);
- tbm.update(false);
-
- // Properties
- propertiesAction = new PropertyDialogAction(shell, folderTree);
- getViewSite().getActionBars().setGlobalActionHandler(IWorkbenchActionConstants.PROPERTIES, propertiesAction);
- IStructuredSelection selection = (IStructuredSelection)folderTree.getSelection();
- if (selection.size() == 1 && selection.getFirstElement() instanceof SiteElement) {
- propertiesAction.setEnabled(true);
- } else {
- propertiesAction.setEnabled(false);
- }
- folderTree.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection ss = (IStructuredSelection)event.getSelection();
- boolean enabled = ss.size() == 1 && ss.getFirstElement() instanceof SiteElement;
- propertiesAction.setEnabled(enabled);
- }
- });
-
- MenuManager treeMgr = new MenuManager();
- MenuManager tableMgr = new MenuManager();
- Tree tree = folderTree.getTree();
- Table table = folderContentsTable.getTable();
- Menu treeMenu = treeMgr.createContextMenu(tree);
- Menu tableMenu = tableMgr.createContextMenu(table);
- IMenuListener menuListener = new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- // Misc additions
- MenuManager sub = new MenuManager(Policy.bind("SiteExplorerView.newMenu"), IWorkbenchActionConstants.GROUP_ADD); //$NON-NLS-1$
- sub.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- manager.add(sub);
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- sub.add(addSiteAction);
- sub.add(newFolderAction);
- manager.add(propertiesAction);
- }
- };
- treeMgr.addMenuListener(menuListener);
- treeMgr.setRemoveAllWhenShown(true);
- tableMgr.addMenuListener(menuListener);
- tableMgr.setRemoveAllWhenShown(true);
- tree.setMenu(treeMenu);
- table.setMenu(tableMenu);
- getSite().registerContextMenu(tableMgr, folderContentsTable);
- getSite().registerContextMenu(treeMgr, folderTree);
- }
-
- /**
- * Add the new site to the viewer and make it the current selection.
- *
- * @see ISiteListener#siteAdded(Site)
- */
- public void siteAdded(Site site) {
- SiteElement element = new SiteElement(site, getViewSite().getWorkbenchWindow());
- folderTree.add(root, element);
- folderTree.setSelection(new StructuredSelection(element));
- }
-
- /**
- * Remote the site from the viewer and select the next site in the
- * tree.
- *
- * @see ISiteListener#siteRemoved(Site)
- */
- public void siteRemoved(Site site) {
- folderTree.remove(new SiteElement(site));
- selectNextObjectInTreeViewer();
- }
-
- private void selectNextObjectInTreeViewer() {
- Object[] items = folderTree.getVisibleExpandedElements();
- if(items.length > 0) {
- folderTree.setSelection(new StructuredSelection(items[0]));
- } else {
- folderContentsTable.setInput(null);
- }
- }
-
- /**
- * Adds the listener that sets the sorter.
- */
- private SelectionListener getColumnListener() {
- /**
- * This class handles selections of the column headers.
- * Selection of the column header will cause resorting
- * of the shown tasks using that column's sorter.
- * Repeated selection of the header will toggle
- * sorting order (ascending versus descending).
- */
- return new SelectionAdapter() {
- /**
- * Handles the case of user selecting the
- * header area.
- * <p>If the column has not been selected previously,
- * it will set the sorter of that column to be
- * the current tasklist sorter. Repeated
- * presses on the same column header will
- * toggle sorting order (ascending/descending).
- */
- public void widgetSelected(SelectionEvent e) {
- // column selected - need to sort
- // only allow sorting on name for now
- int column = folderContentsTable.getTable().indexOf((TableColumn) e.widget);
- if(column == FolderListingSorter.NAME) {
- FolderListingSorter oldSorter = (FolderListingSorter)folderContentsTable.getSorter();
- if (oldSorter != null && column == oldSorter.getColumnNumber()) {
- oldSorter.setReversed(!oldSorter.isReversed());
- folderContentsTable.refresh();
- } else {
- folderContentsTable.setSorter(new FolderListingSorter(column));
- }
- }
- }
- };
- }
-
- /**
- * @see IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- }
- /**
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- super.dispose();
- TargetManager.removeSiteListener(this);
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java
deleted file mode 100644
index a0f2e0ef9..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java
+++ /dev/null
@@ -1,54 +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.internal.ui.target;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-public class SiteExplorerViewLabelProvider extends WorkbenchLabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0) {
- return super.getImage(element);
- }
- return null;
- }
- public String getColumnText(Object element, int columnIndex) {
- switch (columnIndex) {
- case 0 :
- return super.getText(element);
- case 1 :
- if(element instanceof RemoteResourceElement) {
- RemoteResourceElement remote = ((RemoteResourceElement)element);
- if(remote.getRemoteResource().isContainer()) {
- return ""; //$NON-NLS-1$
- }
- int size = remote.getSize();
- int sizeKb = size / 1000;
- if(sizeKb == 0 && size % 1000 > 0) {
- sizeKb = 1;
- }
- return Policy.bind("SiteExplorerViewLabelProvider.fileSize", new Integer(sizeKb).toString()); //$NON-NLS-1$
- }
- case 2 :
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getLastModified();
- }
- case 3 :
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getRemoteResource().getURL().toExternalForm();
- }
- }
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteLazyContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteLazyContentProvider.java
deleted file mode 100644
index 0bdf305f0..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteLazyContentProvider.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.internal.ui.target;
-
-import org.eclipse.ui.model.WorkbenchContentProvider;
-
-public class SiteLazyContentProvider extends WorkbenchContentProvider {
-
- public boolean hasChildren(Object element) {
- if (element == null) {
- return false;
- }
- // the + box will always appear, but then disappear
- // if not needed after you first click on it.
- return true; // just always return true to avoid going to server
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
deleted file mode 100644
index d7022f3a4..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
+++ /dev/null
@@ -1,68 +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.internal.ui.target;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * Used to show all Sites defined in the workbench.
- */
-public class SiteRootsElement implements IWorkbenchAdapter, IAdaptable {
- private Site[] sites = null;
-
- // progress monitoring support
- private IRunnableContext runContext;
-
- public SiteRootsElement(Site[] sites, IRunnableContext runContext) {
- this.sites = sites;
- this.runContext = runContext;
- }
-
- public SiteRootsElement(IRunnableContext runContext) {
- this(null, runContext);
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
-
- public Object[] getChildren(Object o) {
- Site[] childSites;
- if(sites == null) {
- childSites = TargetManager.getSites();
- } else {
- childSites = sites;
- }
- SiteElement[] siteElements = new SiteElement[childSites.length];
- for (int i = 0; i < childSites.length; i++) {
- siteElements[i] = new SiteElement(childSites[i], runContext);
- }
- return siteElements;
- }
-
- public String getLabel(Object o) {
- return null;
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class) return this;
- return null;
- }
-
- public Object getParent(Object o) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java
deleted file mode 100644
index b5fb921b4..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java
+++ /dev/null
@@ -1,189 +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.internal.ui.target;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-/**
- * Wizard page that allows selecting an existing target provider site
- * or to create a new site.
- */
-public class SiteSelectionPage extends TargetWizardPage {
- private TableViewer table;
- private Button useExistingRepo;
- private Button useNewRepo;
- private Button disconnectTarget;
- private Site site;
- private TargetProvider currentProvider;
-
- private boolean disconnect = false;
-
- public SiteSelectionPage(String pageName, String title, ImageDescriptor titleImage, TargetProvider currentProvider) {
- super(pageName, title, titleImage);
- setDescription(Policy.bind("SiteSelectionPage.description")); //$NON-NLS-1$
- this.currentProvider = currentProvider;
- }
-
- protected TableViewer createTable(Composite parent) {
- Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- TableLayout layout = new TableLayout();
- layout.addColumnData(new ColumnWeightData(100, true));
- table.setLayout(layout);
- TableColumn col = new TableColumn(table, SWT.NONE);
- col.setResizable(true);
-
- return new TableViewer(table);
- }
-
- public void createControl(Composite parent) {
- Composite composite = createComposite(parent, 2);
- // set F1 help
- WorkbenchHelp.setHelp(composite, IHelpContextIds.TARGET_NEW_SITE_PAGE);
-
- Label description = new Label(composite, SWT.WRAP);
- GridData data = new GridData();
- data.horizontalSpan = 2;
- data.widthHint = 350;
- description.setLayoutData(data);
- description.setText(Policy.bind("SiteSelectionPage.label")); //$NON-NLS-1$
-
- useExistingRepo = createRadioButton(composite, Policy.bind("SiteSelectionPage.useExisting"), 2); //$NON-NLS-1$
- table = createTable(composite);
- table.setContentProvider(new WorkbenchContentProvider());
- table.setLabelProvider(new WorkbenchLabelProvider() {
- protected String decorateText(String input, Object element) {
- if(currentProvider != null && element.equals(new SiteElement(currentProvider.getSite()))) {
- IPath mapping = UrlUtil.getTrailingPath(currentProvider.getURL(), currentProvider.getSite().getURL());
- if(mapping.isEmpty()) {
- return Policy.bind("SiteSelectionPage.siteLabelCurrent", super.decorateText(input, element)); //$NON-NLS-1$
- } else {
- return Policy.bind("SiteSelectionPage.siteLabelCurrentWithMapping", super.decorateText(input, element), mapping.toString()); //$NON-NLS-1$
- }
- }
- return super.decorateText(input, element);
- }
- });
-
- table.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- SiteElement siteElement = (SiteElement)((IStructuredSelection)table.getSelection()).getFirstElement();
- if(siteElement != null) {
- site = siteElement.getSite();
- setPageComplete(true);
- } else {
- setPageComplete(false);
- }
- }
- });
- useNewRepo = createRadioButton(composite, Policy.bind("SiteSelectionPage.createNew"), 2); //$NON-NLS-1$
-
- useExistingRepo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- if (!useExistingRepo.getSelection()) {
- table.getTable().setEnabled(false);
- site = null;
- } else {
- table.getTable().setEnabled(true);
- SiteElement siteElement = (SiteElement)((IStructuredSelection)table.getSelection()).getFirstElement();
- if(siteElement != null) {
- site = siteElement.getSite();
- }
- }
- }
- });
-
- useNewRepo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- SiteSelectionPage.this.setPageComplete(! useNewRepo.getSelection());
- }
- });
-
-
- if(currentProvider != null ) {
- disconnectTarget = createRadioButton(composite, Policy.bind("SiteSelectionPage.disconnectTarget"), 2); //$NON-NLS-1$
- disconnectTarget.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- disconnect = disconnectTarget.getSelection();
- SiteSelectionPage.this.setPageComplete(true);
- }
- });
- }
-
- setControl(composite);
- initializeValues();
- Dialog.applyDialogFont(parent);
- }
-
- /**
- * Initializes states of the controls.
- */
- private void initializeValues() {
- Site[] sites = TargetManager.getSites();
- table.setInput(new SiteRootsElement(null /* no progress monitoring required */));
- if (sites.length == 0) {
- useNewRepo.setSelection(true);
- } else {
- useExistingRepo.setSelection(true);
- if(currentProvider != null) {
- table.setSelection(new StructuredSelection(new SiteElement(currentProvider.getSite())));
- } else {
- table.setSelection(new StructuredSelection(new SiteElement(sites[0])));
- }
- }
- }
-
- public Site getSite() {
- return site;
- }
-
- public boolean isDisconnect() {
- return disconnect;
- }
-
- /**
- * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
- */
- public boolean canFlipToNextPage() {
- if(isDisconnect()) {
- return false;
- } else {
- return true;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteViewSorter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteViewSorter.java
deleted file mode 100644
index c0e12ee71..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteViewSorter.java
+++ /dev/null
@@ -1,40 +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.internal.ui.target;
-
-import java.net.URL;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.team.internal.core.target.Site;
-
-public class SiteViewSorter extends ViewerSorter {
-
- public int category(Object element) {
- if (element instanceof Site) {
- return ((Site)element).getType().hashCode();
- }
- return 0;
- }
-
- public int compare(Viewer viewer, Object o1, Object o2) {
- int cat1 = category(o1);
- int cat2 = category(o2);
- if (cat1 != cat2) return cat1 - cat2;
-
- if (o1 instanceof Site && o2 instanceof Site) {
- URL site1 = ((Site)o1).getURL();
- URL site2 = ((Site)o2).getURL();
- return site1.toExternalForm().compareTo(site2.toExternalForm());
- }
- return super.compare(viewer, o1, o2);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
deleted file mode 100644
index e4be4c143..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
+++ /dev/null
@@ -1,51 +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.internal.ui.target;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-import org.eclipse.team.internal.ui.sync.SyncCompareInput;
-import org.eclipse.team.internal.ui.sync.SyncView;
-
-/**
- * Action for catchup/release in popup menus.
- */
-public class SyncAction extends TeamAction {
-
- public void run(IAction action) {
- IResource[] resources = getSelectedResources();
- SyncView view = SyncView.findViewInActivePage(getTargetPage());
- if (view != null) {
- view.showSync(getCompareInput(resources), getTargetPage());
- }
- }
-
- protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (!resource.isAccessible()) return false;
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- if(provider == null) return false;
- }
- return true;
- }
-
- protected SyncCompareInput getCompareInput(IResource[] resources) {
- return new TargetSyncCompareInput(resources, IRemoteSyncElement.GRANULARITY_TIMESTAMP);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java
deleted file mode 100644
index 777e087c9..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java
+++ /dev/null
@@ -1,102 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-
-public abstract class TargetAction extends TeamAction {
- /**
- * Get selected remote target folders
- */
- protected IRemoteTargetResource[] getSelectedRemoteFolders() {
- ArrayList resources = null;
- if (!selection.isEmpty()) {
- resources = new ArrayList();
- Iterator elements = ((IStructuredSelection) selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- IRemoteTargetResource remote = null;
- if (next instanceof RemoteResourceElement) {
- remote = ((RemoteResourceElement)next).getRemoteResource();
- } else if(next instanceof SiteElement) {
- try {
- remote = ((SiteElement)next).getSite().getRemoteResource();
- } catch (TeamException e) {
- Utils.handle(e);
- return new IRemoteTargetResource[0];
- }
- }
- if(remote != null && remote.isContainer()) {
- resources.add(remote);
- continue;
- }
- }
- }
- if (resources != null && !resources.isEmpty()) {
- return (IRemoteTargetResource[])resources.toArray(new IRemoteTargetResource[resources.size()]);
- }
- return new IRemoteTargetResource[0];
- }
-
- /**
- * Get selected remote target folders
- */
- protected Site[] getSelectedSites() {
- ArrayList sites = new ArrayList();;
- if (!selection.isEmpty()) {
- Iterator elements = ((IStructuredSelection) selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- IRemoteTargetResource remote = null;
- if (next instanceof SiteElement) {
- sites.add(((SiteElement)next).getSite());
- }
- }
- }
- return (Site[])sites.toArray(new Site[sites.size()]);
- }
-
- protected IResource[] findResourcesWithOutgoingChanges(IResource[] resources) throws TeamException, CoreException {
- // Collect the dirty resource
- final List dirtyResources = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- final TargetProvider provider = TargetManager.getProvider(resource.getProject());
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- if (provider.isDirty(resource) || ! provider.hasBase(resource)) {
- dirtyResources.add(resource);
- }
- } else {
- // Check for outgoing folder deletions?
- }
- return true;
- }
- }, IResource.DEPTH_INFINITE, true /* include phantoms */);
- }
- return (IResource[]) dirtyResources.toArray(new IResource[dirtyResources.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java
deleted file mode 100644
index a2770d958..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java
+++ /dev/null
@@ -1,61 +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.internal.ui.target;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.internal.ui.IHelpContextIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.sync.CatchupReleaseViewer;
-import org.eclipse.team.internal.ui.sync.SyncView;
-import org.eclipse.ui.help.WorkbenchHelp;
-public class TargetCatchupReleaseViewer extends CatchupReleaseViewer {
- private GetSyncAction getAction;
- private PutSyncAction putAction;
-
- public TargetCatchupReleaseViewer(Composite parent, TargetSyncCompareInput input) {
- super(parent, input);
- initializeActions(input);
- // set F1 help
- WorkbenchHelp.setHelp(this.getControl(), IHelpContextIds.TARGET_CATCHUP_RELEASE_VIEWER);
- }
-
- /**
- * Creates the actions for this viewer.
- */
- private void initializeActions(final TargetSyncCompareInput diffModel) {
- Shell shell = getControl().getShell();
- getAction = new GetSyncAction(diffModel, this, Policy.bind("TargetCatchupReleaseViewer.Get_1"), shell); //$NON-NLS-1$
- putAction = new PutSyncAction(diffModel, this, Policy.bind("TargetCatchupReleaseViewer.Put_2"), shell); //$NON-NLS-1$
- }
- protected void fillContextMenu(IMenuManager manager) {
- super.fillContextMenu(manager);
- manager.add(new Separator());
- switch (getSyncMode()) {
- case SyncView.SYNC_INCOMING:
- getAction.update(SyncView.SYNC_INCOMING);
- manager.add(getAction);
- break;
- case SyncView.SYNC_OUTGOING:
- putAction.update(SyncView.SYNC_INCOMING);
- manager.add(putAction);
- break;
- case SyncView.SYNC_BOTH:
- getAction.update(SyncView.SYNC_INCOMING);
- manager.add(getAction);
- putAction.update(SyncView.SYNC_INCOMING);
- manager.add(putAction);
- break;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java
deleted file mode 100644
index 1e3c15bba..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetProjectAction.java
+++ /dev/null
@@ -1,59 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-
-public class TargetProjectAction extends TeamAction {
- /*
- * Method declared on IActionDelegate.
- */
- public void run(IAction action) {
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- IProject project = getSelectedProjects()[0];
- ConfigureTargetWizard wizard = new ConfigureTargetWizard();
- wizard.init(null, project);
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- dialog.open();
- } catch (Exception e) {
- throw new InvocationTargetException(e);
- }
- }
- }, Policy.bind("ConfigureTargetAction.configureProject"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$
- }
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() {
- IProject[] selectedProjects = getSelectedProjects();
- if (selectedProjects.length != 1) return false;
- if (!selectedProjects[0].isAccessible()) return false;
-/* try {
- if (TargetManager.getProvider(selectedProjects[0]) == null) return true;
- } catch (TeamException e) {
- TeamPlugin.log(IStatus.ERROR, "Exception getting provider", e);
- return false;
- }
- return false;
-*/
- return true;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteContentHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteContentHandler.java
deleted file mode 100644
index 9212c6776..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteContentHandler.java
+++ /dev/null
@@ -1,89 +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.internal.ui.target;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class TargetSiteContentHandler extends DefaultHandler implements ContentHandler {
- private StringBuffer buffer;
- private List propList;
- private String target;
-
- /**
- * Constructor for TargetSiteContentHandler.
- */
- public TargetSiteContentHandler() {
- super();
- propList=new LinkedList();
- }
-
- /**
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] ch, int start, int length) throws SAXException {
- if (buffer!=null)
- buffer.append(ch, start, length);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endElement(String, String, String)
- */
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
- if (qName.equals("site")) { //$NON-NLS-1$
- Properties props=new Properties();
- byte[] bytes=buffer.toString().getBytes();
- InputStream iStream=new ByteArrayInputStream(bytes);
- try {
- props.load(iStream);
- props.setProperty("target", target); //$NON-NLS-1$
- propList.add(props);
- } catch (IOException e) {
- //TODO: log an error.
- }
- }
- }
-
- /**
- * Retrieve the property list that has been built up.
- * @return Properties[]
- */
- Properties[] getProperties() {
- return (Properties[]) propList.toArray(new Properties[propList.size()]);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
- */
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
- if (qName.equals("site")) { //$NON-NLS-1$
- buffer = new StringBuffer();
- target=atts.getValue("target"); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- ;
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteExportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteExportWizard.java
deleted file mode 100644
index bfcbb0aab..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteExportWizard.java
+++ /dev/null
@@ -1,191 +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.internal.ui.target;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.wizards.ProjectSetImportWizard;
-import org.eclipse.team.ui.ISharedImages;
-import org.eclipse.ui.IExportWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * This wizard allows the user to save the settings used by Target sites to a file.
- */
-public class TargetSiteExportWizard extends Wizard implements IExportWizard {
- private ExportTargetSiteMainPage mainPage;
- private IStructuredSelection selection;
- /**
- * Constructor for TargetSiteExportWizard.
- */
- public TargetSiteExportWizard() {
- setNeedsProgressMonitor(true);
- setWindowTitle(Policy.bind("TargetSiteExportWizard.Target_Site")); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- final boolean[] result = new boolean[] { false };
- try {
- getContainer().run(false, false, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- String filename = mainPage.getFileName();
- Path path = new Path(filename);
- if (path.getFileExtension() == null) {
- filename = filename + ".tsf"; //$NON-NLS-1$
- }
- ProjectSetImportWizard.lastFile = filename;
- File file = new File(filename);
- File parentFile = file.getParentFile();
- if (parentFile != null && !parentFile.exists()) {
- boolean r = MessageDialog.openQuestion(
- getShell(),
- Policy.bind("TargetSiteExportWizard.Creation_Question"), //$NON-NLS-1$
- Policy.bind("TargetSiteExportWizard.Create_dir")); //$NON-NLS-1$
- if (!r) {
- result[0] = false;
- return;
- }
- r = parentFile.mkdirs();
- if (!r) {
- MessageDialog.openError(getShell(),
- Policy.bind("TargetSiteExportWizard.Export_Problems"), //$NON-NLS-1$
- Policy.bind("TargetSiteExportWizard.Directory_creation_error") //$NON-NLS-1$
- );
- result[0] = false;
- return;
- }
- }
- if (file.exists() && file.isFile()) {
- boolean r = MessageDialog.openQuestion(
- getShell(),
- Policy.bind("TargetSiteExportWizard.Overwrite_Question"), //$NON-NLS-1$
- Policy.bind("TargetSiteExportWizard.Overwrite_file") //$NON-NLS-1$
- );
- if (!r) {
- result[0] = false;
- return;
- }
- }
- BufferedWriter writer = null;
- try {
- OutputStream jout = new FileOutputStream(file);
-
- writer = new BufferedWriter(new OutputStreamWriter(jout, "UTF-8")); //$NON-NLS-1$
- writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
- writer.newLine();
- writer.write("<tsf version=\"2.0\">"); //$NON-NLS-1$
- writer.newLine();
- writer.flush();
-
- Site[] sites = mainPage.getSelectedSites();
- Properties props;
- monitor.beginTask(null, 5 * sites.length);
- String target;
-
- //The 1st one needs to have a unique comment since it only requires an opening tag:
- props = sites[0].getConfiguration();
- monitor.worked(2);
- target=sites[0].getType();
- monitor.worked(1);
- props.store(jout, "<site target=\""+target+"\">"); //$NON-NLS-1$ //$NON-NLS-2$
- monitor.worked(2);
-
- // For each additional site, write the config to disk:
- for (int i = 1; i < sites.length; i++) {
- props = sites[i].getConfiguration();
- monitor.worked(2);
- target=sites[i].getType();
- monitor.worked(1);
- props.store(jout, "</site> <site target=\""+target+"\">"); //$NON-NLS-1$ //$NON-NLS-2$
- monitor.worked(2);
- }
- jout.flush();//This line may not actually be needed but it's not doing any harm either.
-
- writer.write("</site>"); //$NON-NLS-1$
- writer.newLine();
- writer.write("</tsf>"); //$NON-NLS-1$
- writer.newLine();
- result[0] = true;
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- }
- });
- } catch (InterruptedException e) {
- return true;
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
- if (target instanceof TeamException) {
- ErrorDialog.openError(getShell(), null, null, ((TeamException) target).getStatus());
- return false;
- }
- if (target instanceof RuntimeException) {
- throw (RuntimeException) target;
- }
- if (target instanceof Error) {
- throw (Error) target;
- }
- }
- return result[0];
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.selection = selection;
- }
-
- /**
- * @see org.eclipse.jface.wizard.IWizard#addPages()
- */
- public void addPages() {
- mainPage = new ExportTargetSiteMainPage("targetSiteMainPage", //$NON-NLS-1$
- Policy.bind("TargetSiteExportWizard.Export_a_Target_Site"), //$NON-NLS-1$
- TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_PROJECTSET_EXPORT_BANNER) //TODO: We need our own banner...
- );
- Site[] sites = (Site[]) selection.toList().toArray(new Site[0]);
- mainPage.setSelectedSites(sites);
- mainPage.setFileName(ProjectSetImportWizard.lastFile);
- addPage(mainPage);
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteImportWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteImportWizard.java
deleted file mode 100644
index 98f820a7c..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSiteImportWizard.java
+++ /dev/null
@@ -1,158 +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.internal.ui.target;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.Assert;
-import org.eclipse.team.internal.core.target.ISiteFactory;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.ui.ISharedImages;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class TargetSiteImportWizard extends Wizard implements IImportWizard {
- public static String lastFile;
-
- private ImportTargetSiteMainPage mainPage;
-
- /**
- * Retrieves the Site object that the TargetProvider is contained in.
- * @return Site
- */
- Site getSite(Properties properties) {
- try {
- URL url = new URL(properties.getProperty("location")); //$NON-NLS-1$
- return TargetManager.getSite(properties.getProperty("target"), url); //$NON-NLS-1$
- } catch (MalformedURLException e) {
- return null;
- }
- }
-
- public TargetSiteImportWizard() {
- setNeedsProgressMonitor(true);
- setWindowTitle(Policy.bind("TargetSiteImportWizard.Target_Site")); //$NON-NLS-1$
- }
-
- public void addPages() {
- mainPage = new ImportTargetSiteMainPage(
- "targetSiteMainPage", //$NON-NLS-1$
- Policy.bind("TargetSiteImportWizard.Import_Target_Site"), //$NON-NLS-1$
- TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_PROJECTSET_IMPORT_BANNER)
- );
- mainPage.setFileName(lastFile);
- addPage(mainPage);
- }
-
- /**
- * @see org.eclipse.jface.wizard.IWizard#performFinish()
- */
- public boolean performFinish() {
- try {
- getContainer().run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- InputStreamReader reader = null;
- try {
- String filename = mainPage.getFileName();
- lastFile = filename;
- reader = new InputStreamReader(new FileInputStream(filename), "UTF-8"); //$NON-NLS-1$
-
- SAXParserFactory factory = SAXParserFactory.newInstance();
- SAXParser parser;
- parser = factory.newSAXParser();
- TargetSiteContentHandler handler = new TargetSiteContentHandler();
- InputSource source = new InputSource(reader);
- parser.parse(source, handler);
-
- Properties[] propList = handler.getProperties();
- for (int i = 0; i < propList.length; i++) {
- String target = propList[i].getProperty("target"); //$NON-NLS-1$
- ISiteFactory siteFactory = TargetManager.getSiteFactory(target);
- Assert.isNotNull(siteFactory);
-
- final Site newsite = siteFactory.newSite(propList[i]);
- Site[] existingSites = TargetManager.getSites();
- boolean dupe = false;
- for (int j = 0; j < existingSites.length; j++) {
- if (existingSites[j].equals(newsite))
- dupe = true;
- }
- if (!dupe) {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- TargetManager.addSite(newsite);
- }
- });
- }
- }
-
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- } catch (ParserConfigurationException e) {
- throw new InvocationTargetException(e);
- } catch (SAXException e) {
- throw new InvocationTargetException(e);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- }
- });
- } catch (InterruptedException e) {
- return true;
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
- if (target instanceof TeamException) {
- ErrorDialog.openError(getShell(), null, null, ((TeamException) target).getStatus());
- return false;
- }
- if (target instanceof RuntimeException) {
- throw (RuntimeException) target;
- }
- if (target instanceof Error) {
- throw (Error) target;
- }
- }
- return true;
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {}
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java
deleted file mode 100644
index ff99c0a08..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java
+++ /dev/null
@@ -1,235 +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.internal.ui.target;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.team.internal.ui.sync.ChangedTeamContainer;
-import org.eclipse.team.internal.ui.sync.ITeamNode;
-import org.eclipse.team.internal.ui.sync.SyncSet;
-import org.eclipse.team.internal.ui.sync.UnchangedTeamContainer;
-
-public abstract class TargetSyncAction extends Action {
- private TargetSyncCompareInput diffModel;
- private ISelectionProvider selectionProvider;
-
- protected int syncMode;
- private Shell shell;
-
- protected static IRemoteResource getRemoteResourceFor(IResource local) throws TeamException {
- return TargetManager.getProvider(local.getProject()).getRemoteResourceFor(local);
- }
-
- /**
- * Creates a TargetSyncAction which works on selection and doesn't commit changes.
- */
- public TargetSyncAction(TargetSyncCompareInput model, ISelectionProvider sp, String label, Shell shell) {
- super(label);
- this.diffModel = model;
- this.selectionProvider = sp;
- this.shell = shell;
- }
-
- protected Shell getShell() {
- return shell;
- }
-
- protected TargetSyncCompareInput getDiffModel() {
- return diffModel;
- }
-
- /**
- * Returns true if at least one node can perform the specified action.
- */
- private boolean isEnabled(Object[] nodes) {
- for (int i = 0; i < nodes.length; i++) {
- if (nodes[i] instanceof ITeamNode) {
- ITeamNode node = (ITeamNode)nodes[i];
- if (isEnabled(node)) {
- return true;
- }
- } else {
- if (nodes[i] instanceof IDiffContainer)
- if (isEnabled(((IDiffContainer)nodes[i]).getChildren()))
- return true;
- }
- }
- return false;
- }
-
- protected abstract boolean isEnabled(ITeamNode node);
-
- /**
- * Perform the sychronization operation.
- */
- public void run() {
- ISelection s = selectionProvider.getSelection();
- if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
- return;
- }
- final SyncSet set = new SyncSet((IStructuredSelection)s);
- removeNonApplicableNodes(set, syncMode);
- final SyncSet[] result = new SyncSet[1];
- WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- result[0] = TargetSyncAction.this.run(set, monitor);
- }
- };
- try {
- run(op, Policy.bind("TargetSyncAction.errorEncountered")); //$NON-NLS-1$
- } catch (InterruptedException e) {
- }
- if (result[0] != null) {
- // all returned nodes that have a changed sync kind are assumed
- // to have been operated on and will be removed from the diff tree.
- removeNodes(result[0].getChangedNodes());
-
- // any node that claims that it's IN_SYNC will be automatically
- // filtered from the diff tree - see DiffElement.setKind().
- diffModel.updateView();
- }
- }
-
- protected abstract void removeNonApplicableNodes(SyncSet set, int syncMode);
-
- /**
- * The given nodes have been synchronized. Remove them from
- * the sync set.
- *
- * For folders that are outgoing deletions, we may need to leave the
- * folder as is or adjust the sync kind depending on the sync kind of
- * the folder's children.
- *
- * @see CVSSyncCompareInput#collectResourceChanges(IDiffContainer, IRemoteSyncElement, IProgressMonitor)
- */
- private void removeNodes(final ITeamNode[] nodes) {
- // Update the model
- Set outgoingFolderDeletions = new HashSet();
- for (int i = 0; i < nodes.length; i++) {
- if (nodes[i].getClass() == UnchangedTeamContainer.class) {
- // Unchanged containers get removed automatically when all
- // children are removed
- continue;
- }
- if (nodes[i].getClass() == ChangedTeamContainer.class) {
- // If this node still has children, convert to an
- // unchanged container, then it will disappear when
- // all children have been removed.
- ChangedTeamContainer container = (ChangedTeamContainer)nodes[i];
- IDiffElement[] children = container.getChildren();
- if (children.length > 0) {
- IDiffContainer parent = container.getParent();
- UnchangedTeamContainer unchanged = new UnchangedTeamContainer(parent, container.getResource());
- for (int j = 0; j < children.length; j++) {
- unchanged.add(children[j]);
- }
- parent.removeToRoot(container);
- continue;
- }
- // No children, it will get removed below.
- }
- nodes[i].getParent().removeToRoot(nodes[i]);
- }
- }
-
- /**
- * Updates the action with the latest selection, setting enablement
- * as necessary.
- */
- public void update(int syncMode) {
- this.syncMode = syncMode;
- IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
- setEnabled(isEnabled(selection.toArray()));
- }
-
- /**
- * Subclasses must implement this method, which performs action-specific code.
- *
- * It may return the sync set which was passed in, or null.
- */
- protected abstract SyncSet run(SyncSet syncSet, IProgressMonitor monitor);
-
- /**
- * Helper method to run a runnable in a progress monitor dialog, and display any errors.
- */
- protected void run(IRunnableWithProgress op, String problemMessage) throws InterruptedException {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- try {
- dialog.run(true, true, op);
- } catch (InvocationTargetException e) {
- Throwable throwable = e.getTargetException();
- IStatus error = null;
- if (throwable instanceof CoreException) {
- error = ((CoreException)throwable).getStatus();
- } else {
- error = new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("simpleInternal") , throwable); //$NON-NLS-1$
- }
- ErrorDialog.openError(shell, problemMessage, error.getMessage(), error);
- TeamUIPlugin.log(error.getSeverity(), error.getMessage(), throwable);
- }
- }
-
- /**
- * Helper method. Check if a save is necessary. If it is, prompt the user to save.
- * Return true if all necessary saves have been performed, false otherwise.
- */
- protected boolean saveIfNecessary() {
- return getDiffModel().saveIfNecessary();
- }
-
- /**
- * Convenience method that maps the given resources to their target providers.
- * The returned Hashtable has keys which are TargetProviders, and values
- * which are Lists of IResources that are shared with that provider.
- *
- * @return a hashtable mapping providers to their resources
- */
- protected Hashtable getTargetProviderMapping(IResource[] resources) throws TeamException {
- Hashtable result = new Hashtable();
- for (int i = 0; i < resources.length; i++) {
- TargetProvider provider = TargetManager.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/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
deleted file mode 100644
index 55b00b9d5..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
+++ /dev/null
@@ -1,95 +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.internal.ui.target;
-
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.core.target.ITargetRunnable;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.sync.CatchupReleaseViewer;
-import org.eclipse.team.internal.ui.sync.SyncCompareInput;
-
-public class TargetSyncCompareInput extends SyncCompareInput {
-
- private IResource[] resources;
-
- protected TargetSyncCompareInput(IResource[] resources, int granularity) {
- super(granularity);
- this.resources = resources;
- }
-
- /**
- * @see SyncCompareInput#createSyncElements(IProgressMonitor)
- */
- protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask(null, resources.length);
- IRemoteSyncElement[] elements = new IRemoteSyncElement[resources.length];
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- elements[i] = provider.getRemoteSyncElement(resource);
- monitor.worked(1);
- }
- return elements;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * @see CompareEditorInput#createDiffViewer(Composite)
- */
- public Viewer createDiffViewer(Composite parent) {
- CatchupReleaseViewer viewer = new TargetCatchupReleaseViewer(parent, this);
- setViewer(viewer);
- return viewer;
- }
-
- protected void updateView() {
- // Update the view
- if (getDiffRoot().hasChildren()) {
- getViewer().refresh();
- } else {
- getViewer().setInput(null);
- }
-
- // Update the status line
- updateStatusLine();
- }
-
- /**
- * @see SyncCompareInput#collectResourceChanges(IDiffContainer, IRemoteSyncElement, IProgressMonitor)
- */
- protected IDiffElement collectResourceChanges(
- final IDiffContainer parent,
- final IRemoteSyncElement tree,
- IProgressMonitor pm) throws TeamException {
-
- final IDiffElement[] result = new IDiffElement[] {null};
- TargetProvider provider = TargetManager.getProvider(tree.getLocal().getProject());
- provider.run(new ITargetRunnable() {
- public void run(IProgressMonitor monitor) throws TeamException {
- result[0] = TargetSyncCompareInput.super.collectResourceChanges(parent, tree, monitor);
- }
- }, pm);
- return result[0];
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetWizardPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetWizardPage.java
deleted file mode 100644
index 3ee584f3f..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetWizardPage.java
+++ /dev/null
@@ -1,199 +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.internal.ui.target;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.Label;
-import org.eclipse.swt.widgets.Text;
-
-/*
- * Common superclass for wizard pages. Provides convenience methods
- * for widget creation.
- */
-public abstract class TargetWizardPage extends WizardPage {
-
- private static final int COMBO_HISTORY_LENGTH = 5;
-
- /*
- * WizardPage constructor comment.
- * @param pageName the name of the page
- */
- public TargetWizardPage(String pageName) {
- super(pageName);
- }
-
- /*
- * WizardPage constructor comment.
- * @param pageName the name of the page
- * @param title the title of the page
- * @param titleImage the image for the page
- */
- public TargetWizardPage(String pageName, String title, org.eclipse.jface.resource.ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
- }
-
- protected Button createRadioButton(Composite parent, String label, int span) {
- Button button = new Button(parent, SWT.RADIO);
- button.setText(label);
- GridData data = new GridData();
- data.horizontalSpan = span;
- button.setLayoutData(data);
- return button;
- }
-
- /*
- * 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;
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java
deleted file mode 100644
index 6daadc520..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java
+++ /dev/null
@@ -1,110 +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.internal.ui.target;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.dialogs.IPromptCondition;
-import org.eclipse.team.internal.ui.dialogs.PromptingDialog;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-public class UploadAction extends TargetAction {
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- if (resources.length == 0) return false;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- TargetProvider provider = TargetManager.getProvider(resource.getProject());
- if(provider == null)
- return false;
- if(! provider.canPut(resource))
- return false; //if one can't don't allow for any
- // Don't want to go though the resources deeply to see if there are dirty children
- }
- return true;
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
- run(new WorkspaceModifyOperation() {
- public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- Hashtable table = getTargetProviderMapping();
- Set keySet = table.keySet();
- monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
- Iterator iterator = keySet.iterator();
- boolean hasOutgoing = false;
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1024);
- final TargetProvider provider = (TargetProvider)iterator.next();
- subMonitor.setTaskName(Policy.bind("UploadAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
-
- IResource[] providerResources = (IResource[])((List)table.get(provider)).toArray(new IResource[0]);
- IResource[] outgoingChanges = findResourcesWithOutgoingChanges(providerResources);
- if (outgoingChanges.length > 0) {
- // Prompt for any outgoing deletions
- PromptingDialog prompt = new PromptingDialog(
- getShell(),
- outgoingChanges,
- new IPromptCondition() {
- public boolean needsPrompt(IResource resource) {
- return ! resource.exists();
- }
- public String promptMessage(IResource resource) {
- return Policy.bind("UploadAction.confirmFileDeletionMessage", resource.getFullPath().toString()); //$NON-NLS-1$
- }
- },
- Policy.bind("UploadAction.confirmDeletionTitle"));//$NON-NLS-1$
-
- // Put the resources that were selected
- hasOutgoing = true;
- provider.put(prompt.promptForMultiple(), subMonitor);
- }
- }
- if (!hasOutgoing) {
- getShell().getDisplay().syncExec(
- new Runnable() {
- public void run() {
- MessageDialog.openInformation(getShell(),
- Policy.bind("UploadAction.noDirtyTitle"), //$NON-NLS-1$
- Policy.bind("UploadAction.noDirtyMessage")); //$NON-NLS-1$
- }
- });
- };
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- }, Policy.bind("UploadAction.problemMessage"), PROGRESS_DIALOG); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/build.properties b/tests/org.eclipse.team.tests.core/build.properties
index 992cef9f9..926d9a39d 100644
--- a/tests/org.eclipse.team.tests.core/build.properties
+++ b/tests/org.eclipse.team.tests.core/build.properties
@@ -9,4 +9,4 @@
# IBM Corporation - initial API and implementation
###############################################################################
source.teamtests.jar=src/
-bin.includes=about.html,plugin.xml,*.jar,test.xml, ftp.properties, webdav.properties \ No newline at end of file
+bin.includes=about.html,plugin.xml,*.jar,test.xml \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/ftp.properties b/tests/org.eclipse.team.tests.core/ftp.properties
deleted file mode 100644
index 472424eb4..000000000
--- a/tests/org.eclipse.team.tests.core/ftp.properties
+++ /dev/null
@@ -1,17 +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
-###############################################################################
-target=org.eclipse.team.ftp
-test_dir=target
-location=ftp://@host@/path
-username=@user@
-password=@password@
-connectionTimeout=6000
-passive=true \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml
index 67f74ae07..a11a75dcd 100644
--- a/tests/org.eclipse.team.tests.core/plugin.xml
+++ b/tests/org.eclipse.team.tests.core/plugin.xml
@@ -84,15 +84,5 @@
id="org.eclipse.team.tests.core.linking">
</repository>
</extension>
-<!-- *************** Test application **************** -->
- <extension
- id="testapplication"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- class="org.eclipse.team.tests.ftp.TestApplication">
- </run>
- </application>
- </extension>
</plugin>
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
deleted file mode 100644
index dcdd61a43..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
+++ /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
- *******************************************************************************/
-package org.eclipse.team.tests.core;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
-
-public class AllTargetTests extends EclipseWorkspaceTest {
-
- /**
- * Constructor for AllTargetTests.
- */
- public AllTargetTests() {
- super();
- }
-
- /**
- * Constructor for AllTargetTests.
- * @param name
- */
- public AllTargetTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(TargetProviderTests.suite());
- suite.addTest(RemoteResourceTests.suite());
- suite.addTest(SyncElementTest.suite());
- return new TargetTestSetup(suite);
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
index 99d1a4718..1738eead5 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java
@@ -31,9 +31,6 @@ public class AllTeamTests extends EclipseWorkspaceTest {
super(name);
}
- /*
- * ORDER IS IMPORTANT: Run compatibility and resource tests before any other!!!
- */
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(RepositoryProviderTests.suite());
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
deleted file mode 100644
index 8a666baee..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
+++ /dev/null
@@ -1,100 +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.tests.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.TargetProvider;
-
-/**
- * A set of test cases for org.eclipse.team.core.sync.IRemoteResource
- */
-public class RemoteResourceTests extends TeamTest {
- public RemoteResourceTests() {
- super();
- }
- public RemoteResourceTests(String name) {
- super(name);
- }
- public static Test suite() {
- TestSuite suite = new TestSuite(RemoteResourceTests.class);
- return new TargetTestSetup(suite);
- }
-
- protected IProject createAndPut(String projectPrefix, String[] resourceNames) throws CoreException, TeamException {
- IProject project = getUniqueTestProject(projectPrefix);
- IResource[] resources = buildResources(project, resourceNames, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- return project;
- }
-
- public void testGetName() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResource();
- assertEquals(project.getName(), remote.getName());
- }
- public void testIsContainerSuccess() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("iscontainer");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- IRemoteResource remote = target.getRemoteResource();
- assertTrue(remote.isContainer());
- }
- public void testIsContainerFail() throws CoreException, TeamException {
- IProject project = createAndPut("iscontainer", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResourceFor(project.getFile("file1.txt"));
- assertTrue(!remote.isContainer());
- }
- public void testGetContents() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResourceFor(project.getFile("file1.txt"));
- InputStream jin = remote.getContents(DEFAULT_MONITOR);
- try {
- while (jin.available() > 0) {
- jin.read();
- }
- } catch (IOException e) {
- System.out.flush();
- e.printStackTrace(System.err);
- fail("Couldn't read from the input stream.");
- }
- }
- public void testMembers() throws CoreException, TeamException {
- IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
- TargetProvider target = getProvider(project);
- IRemoteResource remote = target.getRemoteResource();
- IRemoteResource[] altResources = remote.members(DEFAULT_MONITOR);
- for (int i = 0; i < altResources.length; i++) {
- assertEquals(altResources[i], project.findMember(altResources[i].getName()));
- }
- }
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties=TargetTestSetup.properties;
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
deleted file mode 100644
index 756159d7a..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
+++ /dev/null
@@ -1,707 +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.tests.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.ILocalSyncElement;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.core.sync.RemoteSyncElement;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-
-public class SyncElementTest extends TeamTest {
- /*
- * Constructor for SyncElementTest.
- */
- public SyncElementTest() {
- super();
- }
-
- /*
- * Constructor for SyncElementTest.
- * @param name
- */
- public SyncElementTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(SyncElementTest.class);
- return new TargetTestSetup(suite);
- //return new CVSTestSetup(new SyncElementTest("testAdditionConflicts"));
- }
- /*
- * Get the child in the sync tree
- */
- protected ILocalSyncElement getChild(ILocalSyncElement tree, IPath path) throws TeamException {
- if (path.segmentCount() == 0)
- return tree;
- ILocalSyncElement[] children = tree.members(DEFAULT_MONITOR);
- for (int i = 0; i < children.length; i++) {
- if (children[i].getName().equals(path.segment(0)))
- return getChild(children[i], path.removeFirstSegments(1));
- }
- assertTrue("Child " + path.toString() + " does not exist", false);
- return null;
- }
-
- /*
- * Assert that the specified resources in the tree have the specified sync kind
- * Ignore conflict types if they are not specified in the assert statement
- */
- public void assertSyncEquals(String message, ILocalSyncElement tree, String[] resources, int[] syncKinds, int granularity)
- throws TeamException {
- assertTrue(resources.length == syncKinds.length);
- for (int i = 0; i < resources.length; i++) {
- int conflictTypeMask = 0x0F; // ignore manual and auto merge sync types for now.
- ILocalSyncElement child = getChild(tree, new Path(resources[i]));
- int kind = child.getSyncKind(granularity, DEFAULT_MONITOR) & conflictTypeMask;
- int kindOther = syncKinds[i] & conflictTypeMask;
- assertTrue(
- message
- + ": improper sync state for "
- + resources[i]
- + " expected "
- + RemoteSyncElement.kindToString(kindOther)
- + " but was "
- + RemoteSyncElement.kindToString(kind),
- kind == kindOther);
- }
- }
-
- public void assertSyncEquals(String message, ILocalSyncElement tree, String[] resources, int[] syncKinds) throws TeamException {
- assertSyncEquals(message, tree, resources, syncKinds, ILocalSyncElement.GRANULARITY_TIMESTAMP);
- }
-
- /*
- * Assert that the named resources have no local resource or sync info
- */
- public void assertDeleted(String message, IRemoteSyncElement tree, String[] resources) throws CoreException, TeamException {
- for (int i = 0; i < resources.length; i++) {
- try {
- getChild(tree, new Path(resources[i]));
- } catch (AssertionFailedError e) {
- break;
- }
- assertTrue(message + ": resource " + resources[i] + " still exists in some form", false);
- }
- }
-
- IRemoteSyncElement getRemoteSyncTree(IProject project, IProgressMonitor monitor) throws TeamException {
- return getProvider(project).getRemoteSyncElement(project);
- }
- protected IProject checkoutCopy(IProject project, String postfix) throws CoreException,TeamException {
- TargetProvider provider = getProvider(project);
- IProject result = getUniqueTestProject(project.getName()+postfix);
- TargetManager.map(result, provider.getSite(), UrlUtil.getTrailingPath(provider.getURL(), provider.getSite().getURL()));
- TargetProvider target = TargetManager.getProvider(result);
- target.get(new IResource[] { result }, null);
- return result;
- }
- protected void getResourcesFromTarget(IProject project, String[] resourceNames)throws TeamException,CoreException {
- TargetProvider provider=getProvider(project);
- IResource[] resources=getResources(project,resourceNames);
- provider.get(resources,null);
- }
- protected void putResourcesOntoTarget(IProject project, String[] resourceNames)throws TeamException,CoreException {
- TargetProvider provider=getProvider(project);
- IResource[] resources=getResources(project,resourceNames);
- provider.put(resources,null);
- }
- /**
- * Add the resources to an existing container and optionally upload them to the remote server
- */
- public IResource[] addResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] newResources = buildResources(container, hierarchy, false);
- if (checkin) getProvider(container).put(newResources, DEFAULT_MONITOR);
- return newResources;
- }
- /**
- * Delete the resources from an existing container and optionally add the changes to the remote server
- */
- public IResource[] deleteResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- for (int i = 0; i < resources.length; i++) {
- resources[0].delete(true, null);
- }
- if (checkin) getProvider(container).put(resources, DEFAULT_MONITOR);
- return resources;
- }
- /*
- * Perform a simple test that checks for the different types of incoming changes
- */
- public void testIncomingChanges() throws TeamException, CoreException, IOException {
- // Create a test project
- IProject project = createAndPut("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("This will be different".getBytes()), false, false, null);
- addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(copy, new String[] { "folder1/b.txt" }, false);
- sleep(1500); // Wait so that timestamp of modified file differs from original
- putResourcesOntoTarget(copy,new String[] { "folder1/a.txt","folder2/folder3/add.txt","folder1/b.txt" });
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingChanges",
- tree,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION });
-
- // Verify that we are in sync (except for "folder1/b.txt", which was deleted)
- getResourcesFromTarget(project,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingChanges",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Ensure "folder1/b.txt" was deleted
- assertDeleted("testIncomingChanges", tree, new String[] { "folder1/b.txt" });
-
- // Verify that the copy equals the original
- assertEquals(project, copy);
- }
-
- /*
- * Perform a simple test that checks for the different types of outgoing changes
- */
- public void testOutgoingChanges() throws TeamException, CoreException {
- // Create a test project (which commits it as well)
- IProject project = createAndPut("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Make some modifications
- IFile file = project.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
- deleteResources(project, new String[] { "folder1/b.txt" }, false);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingChanges",
- tree,
- new String[] {
- "file1.txt",
- "folder1/",
- "folder1/a.txt",
- "folder1/b.txt",
- "folder2/",
- "folder2/folder3/",
- "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
-
- // Commit the changes
- putResourcesOntoTarget(project, new String[] { "folder1/a.txt", "folder1/b.txt", "folder2/folder3/add.txt" });
-
- // Ensure we're in sync
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingChanges",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Ensure deleted resource "folder1/b.txt" no longer exists
- assertDeleted("testOutgoingChanges", tree, new String[] { "folder1/b.txt" });
- }
-
- /*
- * Test simple file conflicts
- */
- public void testFileConflict() throws TeamException, CoreException, IOException {
- // Create a test project (which commits it as well)
- IProject project = createAndPut("testFileConflict", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout a copy and make some modifications
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "prefix\n", true);
- file = copy.getFile("folder1/a.txt");
- file.setContents(new ByteArrayInputStream("Use a custom string to avoid intermitant errors!".getBytes()), false, false, null);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Make the same modifications to the original (We need to test both M and C!!!)
- file = project.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "\npostfix", false); // This will test merges (M)
- file = project.getFile("folder1/a.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null); // This will test conflicts (C)
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE });
-
- // Catch up to the file1.txt conflict using UPDATE with ignoreLocalChanges
- getResourcesFromTarget(project, new String[] { "file1.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE });
-
- // Release the folder1/a.txt conflict uploading
- getProvider(project).put(new IResource[] { project.getFile("folder1/a.txt")}, DEFAULT_MONITOR);
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFileConflict",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test conflicts involving additions
- */
- public void testAdditionConflicts() throws TeamException, CoreException {
- // CASE 1: The user adds (using CVS add) a remotely added file
- // (a) catchup is simply get?
- // (b) release must do a merge
- // CASE 2: The user adds (but not using cvs add) a remotely added file
- // (a) catchup is simply get?
- // (b) release must do a merge
- // CASE 3: The user adds a remotely added then deleted file
- // catchup is not applicable
- // release is normal
-
- // Create a test project (which commits it as well) and add an uncommited resource
- IProject project = createAndPut("testAdditionConflicts", new String[] { "file.txt" });
- addResources(project, new String[] { "add1a.txt", "add1b.txt" }, false);
- addResources(project, new String[] { "add3.txt" }, false);
- buildResources(project, new String[] { "add2a.txt", "add2b.txt" }, false); //useless code!???
-
- // Checkout a copy, add the same resource and commit
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt" }, true);
- deleteResources(copy, new String[] { "add3.txt" }, true);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
-
- getProvider(project).put(
- new IResource[] { project.getFile("add1b.txt"), project.getFile("add2b.txt"), project.getFile("add3.txt")},
- DEFAULT_MONITOR);
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "file.txt", "add1b.txt", "add2b.txt", "add3.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
-
- IFile file = project.getFile("add1a.txt");
- file.delete(false, DEFAULT_MONITOR);
- file = project.getFile("add2a.txt");
- file.delete(false, DEFAULT_MONITOR);
- getResourcesFromTarget(project, new String[] { "add1a.txt","add2a.txt" });//This replaces the chunk commented out below:
- /*getProvider(project).update(
- new IResource[] { project.getFile("add1a.txt"), project.getFile("add2a.txt")},
- new Command.LocalOption[] { Command.DO_NOT_RECURSE },
- null,
- true, //createBackups
- DEFAULT_MONITOR
- );*/
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testAdditionConflicts",
- tree,
- new String[] { "add1a.txt", "add2a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test conflicts involving deletions
- */
- public void testDeletionConflicts() throws TeamException, CoreException {
-
- // CASE 1: The user deletes a remotely modified file
- // (a) catchup must do an update
- // (b) release must do a merge
- // CASE 2: The user deletes (and removes) a remotely modified file
- // (a) catchup must do an unmanage and update
- // (b) release must do a merge
- // CASE 3: The user modified a remotely deleted file
- // (a) catchup must do an unmanage and local delete
- // (b) release must do a merge
- // CASE 4: The user deletes a remotely deleted file
- // (a) catchup can update (or unmanage?)
- // (b) release must unmanage
- // CASE 5: The user deletes (and removes) a remotely deleted file
- // (a) catchup can update (or unmanage?)
- // (b) release must unmanage
-
- // Perform the test case for case A first
-
- // Create a test project (which commits it as well) and delete the resource without committing
- IProject project =
- createAndPut(
- "testDeletionConflictsA",
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" });
- IFile file = project.getFile("delete1.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] { "delete2.txt" }, false);
- file = project.getFile("delete3.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete3.txt".getBytes()), false, false, null);
- file = project.getFile("delete4.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] { "delete5.txt" }, false);
-
- // Checkout a copy and commit the deletion
- IProject copy = checkoutCopy(project, "-copy");
- file = copy.getFile("delete1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete1.txt".getBytes()), false, false, null);
- file = copy.getFile("delete2.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(new ByteArrayInputStream("unique text for delete2.txt".getBytes()), false, false, null);
- deleteResources(copy, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" }, false);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsA",
- tree,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
-
- // Catch up to remote changes.
-
- project.getFile("delete3.txt").delete(false, DEFAULT_MONITOR);
-
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsA",
- tree,
- new String[] { "delete1.txt", "delete2.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
- assertDeleted("testDeletionConflictsA", tree, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" });
-
- // Now redo the test case for case B
-
- // Create a test project (which commits it as well) and delete the resource without committing
- project =
- createAndPut(
- "testDeletionConflictsB",
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" });
- file = project.getFile("delete1.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] { "delete2.txt" }, false);
- file = project.getFile("delete3.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- file = project.getFile("delete4.txt");
- file.delete(false, DEFAULT_MONITOR);
- deleteResources(project, new String[] { "delete5.txt" }, false);
-
- // Checkout a copy and commit the deletion
- copy = checkoutCopy(project, "-copy");
- file = copy.getFile("delete1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- file = copy.getFile("delete2.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- file.setContents(getRandomContents(), false, false, null);
- deleteResources(copy, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" }, false);
- getProvider(copy).put(new IResource[] { copy }, DEFAULT_MONITOR);
-
- // Get the sync tree for the project
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testDeletionConflictsB",
- tree,
- new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
-
- // Release the resources
-
- putResourcesOntoTarget(project, new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt" });
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("testDeletionConflictsB", tree, new String[] { "delete3.txt" }, new int[] { IRemoteSyncElement.IN_SYNC });
- assertDeleted("testDeletionConflictsB", tree, new String[] { "delete1.txt", "delete2.txt", "delete4.txt", "delete5.txt" });
- }
-
- /*
- * Test that a deleted file can still be deleted through the team provider
- */
- public void testOutgoingDeletion() throws TeamException, CoreException {
-
- // Create a test project (which commits it as well)
- IProject project = createAndPut("testOutgoingDeletion", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Delete a file
- IFile file = project.getFile("folder1/b.txt");
- file.delete(true, DEFAULT_MONITOR); // WARNING: As of 2002/03/05, this is equivalent to a cvs remove
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingDeletion",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
-
- // Commit the deletion
- getProvider(file.getProject()).put(new IResource[] { file }, DEFAULT_MONITOR);
-
- // Get the sync tree again for the project and ensure others aren't effected
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testOutgoingDeletion",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
-
- // Assert that deletion no longer appears in remote tree
- assertDeleted("testOutgoingDeletion", tree, new String[] { "folder1/b.txt" });
- }
-
- /*
- * Test catching up to an incoming addition
- */
- public void testIncomingAddition() throws TeamException, CoreException {
- // Create a test project
- IProject project = createAndPut("testIncomingAddition", new String[] { "file1.txt", "folder1/", "folder1/a.txt" });
-
- // Checkout and modify a copy
- IProject copy = checkoutCopy(project, "-copy");
- addResources(copy, new String[] { "folder1/add.txt" }, true);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingAddition",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt" },
- new int[] {
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION });
-
- // Get the resource from the tree
- ILocalSyncElement element = getChild(tree, new Path("folder1/add.txt"));
-
- // Catch up to the addition by updating
- getResourcesFromTarget(project, new String[] { "folder1/add.txt" });
-
- // Get the sync tree again for the project and ensure the added resource is in sync
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testIncomingAddition",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
- }
-
- /*
- * Test changes using a granularity of contents
- */
- public void testGranularityContents() throws TeamException, CoreException, IOException {
- // Create a test project (which commits it as well)
- IProject project =
- createAndPut("testGranularityContents", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt" });
-
- // Checkout a copy and make some modifications
- IProject copy = checkoutCopy(project, "-copy");
- IFile file = copy.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "a", true);
- file = copy.getFile("folder1/a.txt");
- file.setContents(getRandomContents(), false, false, null);
- putResourcesOntoTarget(copy, new String[] { "file1.txt","folder1/a.txt" });
-
- // Make the same modifications to the original
- file = project.getFile("file1.txt");
- sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "a", false);
- file = project.getFile("folder1/a.txt");
- file.setContents(new ByteArrayInputStream("unique text".getBytes()), false, false, null);
-
- // Get the sync tree for the project
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testGranularityContents",
- tree,
- new String[] { "file1.txt", "folder1/", "folder1/a.txt" },
- new int[] {
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE },
- IRemoteSyncElement.GRANULARITY_CONTENTS);
- }
-
- public void testRenameProject() throws TeamException, CoreException, IOException {
- String[] resourceNames = new String[] { "changed.txt", "folder1/", "folder1/a.txt" };
- int[] inSync = new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC };
- IProject project = createAndPut("testRenameProject", new String[] { "changed.txt", "folder1/", "folder1/a.txt" });
-
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("sync should be in sync", tree, resourceNames, inSync);
- IProjectDescription desc = project.getDescription();
- String newName = project.getName() + "_renamed";
- desc.setName(newName);
- project.move(desc, false, null);
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(newName);
- assertTrue(project.exists());
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals("sync should be in sync", tree, resourceNames, inSync);
- }
-
- public void testFolderDeletion() throws TeamException, CoreException {
-
- IProject project =
- createAndPut(
- "testFolderDeletion",
- new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/folder2/file.txt" });
-
- // Delete a folder and ensure that the file is managed but doesn't exist
- project.getFolder("folder1").delete(false, false, null);
-
- // The folders and files should show up as outgoing deletions
- IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFolderDeletion sync check",
- tree,
- new String[] { "folder1", "folder1/a.txt", "folder1/folder2", "folder1/folder2/file.txt" },
- new int[] {
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
-
- // commit folder1/a.txt
- putResourcesOntoTarget(project, new String[] { "folder1/a.txt" });
-
- // Resync and verify that above file is gone and others remain the same
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertSyncEquals(
- "testFolderDeletion sync check",
- tree,
- new String[] { "folder1", "folder1/folder2", "folder1/folder2/file.txt" },
- new int[] {
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION,
- IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION });
- assertDeleted("testFolderDeletion", tree, new String[] { "folder1/a.txt" });
-
- // Commit folder1/folder2/file.txt
- putResourcesOntoTarget(project, new String[] { "folder1/", "folder1/folder2/", "folder1/folder2/file.txt" });
-
- // Resync and verify that all are deleted
- tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
- assertDeleted("testFolderDeletion", tree, new String[] { "folder1", "folder1/folder2", "folder1/folder2/file.txt" });
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
deleted file mode 100644
index a70a8342d..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
+++ /dev/null
@@ -1,237 +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.tests.core;
-
-import java.net.MalformedURLException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.core.target.UrlUtil;
-
-/**
- * A set of test cases for org.eclipse.team.core.target.TargetProvider
- */
-public class TargetProviderTests extends TeamTest {
-
-
- public TargetProviderTests() {
- super();
- }
- public TargetProviderTests(String name) {
- super(name);
- }
- public static Test suite() {
- TestSuite suite = new TestSuite(TargetProviderTests.class);
- return new TargetTestSetup(suite);
- //return new TargetTestSetup(new TargetProviderTests("testPutAndGet"));
- }
- /**
- * Tests the link between the target & the site for consistency.
- * @throws CoreException
- * @throws TeamException
- */
- public void testProjectMapping() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("projectmapping");
- TargetProvider target = createProvider(project);
- assertTrue(getSite().equals(target.getSite()));
- TargetManager.unmap(project);
- assertNull(TargetManager.getProvider(project));
- }
- /**
- * Tests the getURL() method on TargetProvider.
- * @throws CoreException
- * @throws TeamException
- */
- public void testUrlRetrieval() throws CoreException, TeamException, MalformedURLException {
- IProject project = getNamedTestProject("urlretrieval");
- TargetManager.map(project, getSite(), new Path(properties.getProperty("test_dir")));
- TargetProvider target = TargetManager.getProvider(project);
- String goodurl = UrlUtil.concat(properties.getProperty("location"), new Path(properties.getProperty("test_dir"))).toString();
- assertEquals(goodurl, target.getURL().toString());
- }
- /**
- * Verifies that the get() and put() methods on the TargetProvider works as expected.
- * @throws CoreException
- * @throws TeamException
- */
- public void testPutAndGet() throws CoreException, TeamException {
- // test put
- IProject project = getUniqueTestProject("get");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, DEFAULT_MONITOR);
- assertLocalEqualsRemote(project);
- // test get on a new project
- project.delete(true, true, DEFAULT_MONITOR);
- project.create(DEFAULT_MONITOR);
- project.open(DEFAULT_MONITOR);
- target = createProvider(project);
- target.get(new IResource[] { project }, DEFAULT_MONITOR);
- assertLocalEqualsRemote(project);
- }
- /**
- * Verifies that canGet() and canPut() returns accurate values.
- * @throws CoreException
- * @throws TeamException
- */
- public void testCanGetAndCanPut() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("canget");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(target.canPut(resources[i]));
- }
- target.put(resources, DEFAULT_MONITOR);
- project.delete(true, true, DEFAULT_MONITOR);
- project.create(DEFAULT_MONITOR);
- project.open(DEFAULT_MONITOR);
- target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(target.canGet(resources[i]));
- }
- target.get(new IResource[] { project }, null);
- }
- /**
- * Tests bahavior of isOutOfDate() for correctness
- * @throws CoreException
- * @throws TeamException
- */
- public void testIsOutOfDate() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("outdated");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- sleep(1501);
- IProject dupeProject = getUniqueTestProject("outdated");
- IResource[] freshResources = buildResources(dupeProject, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.put(freshResources, null);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType() == IResource.FILE)
- assertTrue(target.isOutOfDate(resources[i], DEFAULT_PROGRESS_MONITOR));
- }
- }
- /**
- * Tests bahavior of isDirty() for correctness
- * @throws CoreException
- * @throws TeamException
- */
- public void testIsDirty() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("dirty");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- sleep(1501);
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType()==IResource.FILE) assertTrue(resources[i].getName(),target.isDirty(resources[i]));
- }
- }
- public void testOverwrite() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("overwrite");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- //Create resources with the same names but different content & upload them in the same spot:
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- target.put(resources, null);
-
- IProject dupeProject = getUniqueTestProject("overwrite");
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- IResource[] freshResources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.get(new IResource[] { dupeProject }, null);
- for (int i = 0; i < resources.length; i++) {
- assertEquals(resources[i],freshResources[i]);
- }
- }
- public void testIsDirtyWhenDeleted() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("dirty");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- sleep(1501);
- resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType()==IResource.FILE) assertTrue(resources[i].getName(),target.isDirty(resources[i]));
- }
- }
- public void testIsOutOfDateWhenDeleted() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("outdated");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- sleep(1501);
- IProject dupeProject = getUniqueTestProject("outdated");
- IResource[] freshResources = buildResources(dupeProject, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetManager.map(dupeProject, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider dupeTarget = TargetManager.getProvider(dupeProject);
- dupeTarget.put(freshResources, null);
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType() == IResource.FILE)
- assertTrue(target.isOutOfDate(resources[i], DEFAULT_PROGRESS_MONITOR));
- }
- }
- public void testPutWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("put");
- IResource[] resources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete(true, null);
- }
- try {
- target.put(resources, null);
- for (int i = 0; i < resources.length; i++) {
- assertTrue(!target.getRemoteResourceFor(resources[i]).exists(null));
- }
- } catch (TeamException e) {} catch (RuntimeException e) {
- fail("Putting files that don't exist locally should delete them remotely");
- }
- }
- public void testGetWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("get");
- String[] testFileNames=new String[] { "file1.txt", "folder1/", "folder1/b.txt" };
- IResource[] resources = buildResources(project, testFileNames, false);
- TargetProvider target = createProvider(project);
- try {
- target.get(new IResource[] { project }, null);
- IResource[] phantoms=getResources(project,testFileNames);
- for (int i = 0; i < phantoms.length; i++) {
- assertTrue(!project.getFile(testFileNames[i]).exists());
- }
- } catch (TeamException e) {
- fail("Getting files that don't exist remotely should delete them locally");
- }
- }
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties=TargetTestSetup.properties;
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java
deleted file mode 100644
index b18dd00cc..000000000
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetTestSetup.java
+++ /dev/null
@@ -1,108 +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.tests.core;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.ISiteFactory;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
-
-/**
- * A set of test cases for org.eclipse.team.core.sync.IRemoteResource
- */
-public class TargetTestSetup extends TestSetup {
-
- public static Properties properties;
- static {
- loadProperties();
- }
-
- public static void loadProperties() {
- properties = new Properties();
- String propertiesFile = System.getProperty("eclipse.target.properties");
- if (propertiesFile == null)
- return;
- File file = new File(propertiesFile);
- if (file.isDirectory())
- file = new File(file, "target.properties");
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
- for (String line;(line = reader.readLine()) != null;) {
- int sep = line.indexOf("=");
- String property = line.substring(0, sep).trim();
- String value = line.substring(sep + 1).trim();
- properties.setProperty(property, value);
- }
- } finally {
- reader.close();
- }
- } catch (Exception e) {
- System.err.println("Could not read repository properties file: " + file.getAbsolutePath());
- }
- }
-
- public TargetTestSetup(Test test) {
- super(test);
- }
- /**
- * Retrieves the Site object that the TargetProvider is contained in.
- * @return Site
- */
- Site getSite() {
- try {
- URL url = new URL(properties.getProperty("location"));
- return TargetManager.getSite(properties.getProperty("target"), url);
- } catch (MalformedURLException e) {
- return null;
- }
- }
- /**
- * This method runs before starting the entire test suite.
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- Site location;
- ISiteFactory factory = TargetManager.getSiteFactory(properties.getProperty("target"));
- assertNotNull(factory);
- Site[] locations = TargetManager.getSites();
-
- if (locations.length == 0) {
- Site l = factory.newSite(properties);
- TargetManager.addSite(l);
- }
- location = getSite();
-
- //clean up the directory:
- IRemoteTargetResource remote=location.getRemoteResource().getFolder(properties.getProperty("test_dir"));
- IRemoteResource[] children=remote.members(null);
- for (int i = 0; i < children.length; i++) {
- ((IRemoteTargetResource)children[i]).delete(null);
- }
-
- TargetProvider target = location.newProvider(new Path(properties.getProperty("test_dir")));
- assertNotNull(target);
- }
-}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
index 5bf347208..3370456bb 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
@@ -14,12 +14,9 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -30,21 +27,15 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.tests.harness.EclipseWorkspaceTest;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.core.target.IRemoteTargetResource;
-import org.eclipse.team.internal.core.target.Site;
-import org.eclipse.team.internal.core.target.TargetManager;
-import org.eclipse.team.internal.core.target.TargetProvider;
public class TeamTest extends EclipseWorkspaceTest {
protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor();
protected static final IProgressMonitor DEFAULT_PROGRESS_MONITOR = new NullProgressMonitor();
- Properties properties;
public TeamTest() {
super();
@@ -52,13 +43,7 @@ public class TeamTest extends EclipseWorkspaceTest {
public TeamTest(String name) {
super(name);
}
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- properties = TargetTestSetup.properties;
- }
+
protected IProject getNamedTestProject(String name) throws CoreException {
IProject target = getWorkspace().getRoot().getProject(name);
if (!target.exists()) {
@@ -77,18 +62,7 @@ public class TeamTest extends EclipseWorkspaceTest {
protected IStatus getTeamTestStatus(int severity) {
return new Status(severity, "org.eclipse.team.tests.core", 0, "team status", null);
}
- /**
- * Retrieves the Site object that the TargetProvider is contained in.
- * @return Site
- */
- Site getSite() {
- try {
- URL url = new URL(properties.getProperty("location"));
- return TargetManager.getSite(properties.getProperty("target"), url);
- } catch (MalformedURLException e) {
- return null;
- }
- }
+
/**
* Creates filesystem 'resources' with the given names and fills them with random text.
* @param container An object that can hold the newly created resources.
@@ -161,21 +135,7 @@ public class TeamTest extends EclipseWorkspaceTest {
return "these are my contents";
}
}
- public TargetProvider createProvider(IProject project) throws TeamException {
- // Ensure the remote folder exists
- IRemoteTargetResource remote = getSite().getRemoteResource().getFolder(
- new Path(properties.getProperty("test_dir")).append(project.getName()).toString());
- if (! remote.exists(null)) {
- remote.mkdirs(null);
- }
- TargetManager.map(project, getSite(), new Path(properties.getProperty("test_dir")).append(project.getName()));
- TargetProvider target = getProvider(project);
- return target;
- }
-
- public TargetProvider getProvider(IProject project) throws TeamException {
- return TargetManager.getProvider(project);
- }
+
public void sleep(int ms) {
try {
@@ -184,14 +144,7 @@ public class TeamTest extends EclipseWorkspaceTest {
System.err.println("Testing was rudely interrupted.");
}
}
- void assertLocalEqualsRemote(IProject project) throws CoreException, TeamException {
- IProject newProject = getNamedTestProject("equals");
- TargetProvider target = TargetManager.getProvider(project);
- IResource[] localResources = project.members();
- for (int i = 0; i < localResources.length; i++) {
- assertEquals(target.getRemoteResourceFor(localResources[i]), localResources[i]);
- }
- }
+
// Assert that the two containers have equal contents
protected void assertEquals(IRemoteResource container1, IResource container2) throws CoreException, TeamException {
if (container2.getType() == IResource.FILE) {
@@ -207,13 +160,6 @@ public class TeamTest extends EclipseWorkspaceTest {
}
}
}
- protected IProject createAndPut(String projectPrefix, String[] resourceNames) throws CoreException, TeamException {
- IProject project = getUniqueTestProject(projectPrefix);
- IResource[] resources = buildResources(project, resourceNames, false);
- TargetProvider target = createProvider(project);
- target.put(resources, DEFAULT_MONITOR);
- return project;
- }
public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException {
IFile file = (IFile) resource;
diff --git a/tests/org.eclipse.team.tests.core/test.xml b/tests/org.eclipse.team.tests.core/test.xml
index bc792fd2a..3418c9378 100644
--- a/tests/org.eclipse.team.tests.core/test.xml
+++ b/tests/org.eclipse.team.tests.core/test.xml
@@ -31,38 +31,6 @@
</target>
- <!-- This target defines the FTP tests that need to be run. -->
- <target name="ftpsuite">
- <property name="location" value="${eclipse-home}/team_test_workspace"/>
- <delete dir="${location}" quiet="true"/>
-
- <!-- Session Test ** FTP ** -->
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.team.tests.core"/>
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <property name="vmargs" value="-Declipse.target.properties=${team-home}/ftp.properties"/>
- </ant>
- <move file="${eclipse-home}/${classname}.xml" tofile="${eclipse-home}/${classname}-ftp.xml"/>
- </target>
-
- <!-- This target defines the WebDAV tests that need to be run. -->
- <target name="webdavsuite">
- <property name="location" value="${eclipse-home}/team_test_workspace"/>
- <delete dir="${location}" quiet="true"/>
-
- <!-- Session Test ** WebDAV ** -->
- <property name="classname" value="org.eclipse.team.tests.core.TargetProviderTests"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="org.eclipse.team.tests.core"/>
- <property name="classname" value="${classname}"/>
- <property name="vmargs" value="-Declipse.target.properties=${team-home}/webdav.properties"/>
- </ant>
- <move file="${eclipse-home}/${classname}.xml" tofile="${eclipse-home}/${classname}-webdav.xml"/>
- </target>
-
<!-- This target holds code to cleanup the testing environment after the tests -->
<!-- have been run. You can use this to delete temporary files that are created. -->
<target name="cleanup">
diff --git a/tests/org.eclipse.team.tests.core/webdav.properties b/tests/org.eclipse.team.tests.core/webdav.properties
deleted file mode 100644
index a81f09182..000000000
--- a/tests/org.eclipse.team.tests.core/webdav.properties
+++ /dev/null
@@ -1,17 +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
-###############################################################################
-target=org.eclipse.team.webdav
-test_dir=target
-location=http://@host@/path
-httpClient.username=@user@
-httpClient.password=@password@
-httpClient.proxyURL=
-httpClient.connectionTimeout=6000 \ No newline at end of file

Back to the top