Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-20 10:44:53 -0400
committerJean Michel-Lemieux2002-05-20 10:44:53 -0400
commitaabb8e9469be3002a37c5aa26fb8c18049c33a5a (patch)
treebd2a0f80dcf7af1a900a411f29010e69eb7cb7de
parent8b24f3768b8af38c7de8d34a7f34bcfc859ecd37 (diff)
downloadeclipse.platform.team-aabb8e9469be3002a37c5aa26fb8c18049c33a5a.tar.gz
eclipse.platform.team-aabb8e9469be3002a37c5aa26fb8c18049c33a5a.tar.xz
eclipse.platform.team-aabb8e9469be3002a37c5aa26fb8c18049c33a5a.zip
Added:
- API to create remote folders - config wizard support for multiple target providers - remote browsing improvements - mapping changes
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/IRemoteTargetResource.java52
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java29
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java16
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java10
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml34
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPromptCondition.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java)4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java)16
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java19
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties44
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/ConfigureTargetWizard.java18
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java90
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAction.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java197
-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/MappingSelectionPage.java56
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java21
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java160
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteSelectionPage.java46
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java54
27 files changed, 979 insertions, 124 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/IRemoteTargetResource.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/IRemoteTargetResource.java
index a8495b7b7..be83cefae 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/IRemoteTargetResource.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/IRemoteTargetResource.java
@@ -12,6 +12,7 @@ package org.eclipse.team.core.target;
import java.net.URL;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
@@ -30,7 +31,7 @@ public interface IRemoteTargetResource extends IRemoteResource {
/**
* Returns the URL of this remote resource.
*/
- public URL getURL() throws TeamException;
+ public URL getURL();
/**
* Returns the size of the resource.
@@ -47,4 +48,53 @@ public interface IRemoteTargetResource extends IRemoteResource {
* remote server.
*/
public boolean exists() throws TeamException;
+
+ /**
+ * Creates the directory named by this URL, including any necessary but non-existant
+ * parent directories.
+ */
+ public void mkdirs() 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();
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
index 7f4aa453b..2248aee6b 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
@@ -51,6 +51,27 @@ public abstract class TargetProvider {
* 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.
@@ -68,11 +89,7 @@ public abstract class TargetProvider {
public abstract void put(IResource[] resources, IProgressMonitor progress) throws TeamException;
/**
- * Returns a remote resource handle at the path of the given local resource. The remote
- * resource handles URL will be:
- * <blockquote><pre>
- * getURL() + resource.getProjectRelativePath()
- * </pre></blockquote>
+ * 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
@@ -80,7 +97,7 @@ public abstract class TargetProvider {
public abstract IRemoteTargetResource getRemoteResourceFor(IResource resource);
/**
- *Returns a remote resource handle at the path of this target provider's URL.
+ * 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();
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
index 5cac0628e..03b90c466 100644
--- 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
@@ -69,6 +69,12 @@ public abstract class SynchronizedTargetProvider extends TargetProvider {
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);
+
+ /**
* Get the state descriptor for a given resource.
*/
public ResourceState getState(IResource resource) {
@@ -77,6 +83,16 @@ public abstract class SynchronizedTargetProvider extends TargetProvider {
state.loadState();
return state;
}
+
+ /**
+ * Get the state descriptor for a given resource.
+ */
+ public ResourceState getState(IResource resource, IRemoteTargetResource remote) {
+ // 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
@@ -93,6 +109,22 @@ public abstract class SynchronizedTargetProvider extends TargetProvider {
}
}, resources, depth, progress);
}
+
+ /**
+ * Get the resource from the provider to the workspace, and remember the fetched
+ * state as the base state of the resource.
+ *
+ * @see ITeamProvider.get(IResource[], int, IProgressMonitor)
+ */
+ public void get(IResource resource, final IRemoteTargetResource remote, IProgressMonitor progress)
+ throws TeamException {
+ execute(new IIterativeOperation() {
+ public IStatus visit(IResource resource, int depth, IProgressMonitor progress) {
+ ResourceState state = getState(resource, remote);
+ return new Symmetria().get(state, IResource.DEPTH_INFINITE, progress);
+ }
+ }, new IResource[] {resource}, IResource.DEPTH_ZERO, progress);
+ }
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
index 49bbf9e77..dc694e96a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
@@ -5,30 +5,24 @@ package org.eclipse.team.internal.ccvs.ui.actions;
* All Rights Reserved.
*/
-import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
-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.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.client.Checkout;
-import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
-import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.team.internal.ui.PromptingDialog;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
index 46adb7536..a16d02825 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
@@ -39,9 +39,11 @@ import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.AvoidableMessageDialog;
+import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ui.IPromptCondition;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -312,6 +314,20 @@ abstract public class CVSAction extends TeamAction {
}
return new ICVSRemoteFolder[0];
}
+
+ /**
+ * A helper prompt condition for prompting for CVS dirty state.
+ */
+ public static IPromptCondition getOverwriteLocalChangesPrompt() {
+ return new IPromptCondition() {
+ public boolean needsPrompt(IResource resource) {
+ return CVSDecorator.isDirty(resource);
+ }
+ public String promptMessage(IResource resource) {
+ return Policy.bind("ReplaceWithAction.localChanges", resource.getName());//$NON-NLS-1$
+ }
+ };
+ }
/**
* Checks if a the resources' parent's tags are different then the given tag.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java
index 13d581da6..dee456fbb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java
@@ -27,9 +27,9 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.IPromptCondition;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
+import org.eclipse.team.internal.ui.IPromptCondition;
+import org.eclipse.team.internal.ui.PromptingDialog;
/**
* The purpose of the CheckoutAction is to allow the checkout of module aliases into the
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
index ef6e107cb..af0db5ab0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
@@ -27,7 +27,7 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
+import org.eclipse.team.internal.ui.PromptingDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.NewProjectAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
index 005bbc238..181a0d0c3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
@@ -19,9 +19,9 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.ui.IPromptCondition;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
+import org.eclipse.team.internal.ui.IPromptCondition;
+import org.eclipse.team.internal.ui.PromptingDialog;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -72,6 +72,6 @@ public class ReplaceWithRemoteAction extends CVSAction {
* Note: This method is designed to be overridden by test cases.
*/
protected IPromptCondition getPromptCondition() {
- return PromptingDialog.getOverwriteLocalChangesPrompt();
+ return getOverwriteLocalChangesPrompt();
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
index c3f1b186b..0a2c38117 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
@@ -29,8 +29,8 @@ import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
+import org.eclipse.team.internal.ui.PromptingDialog;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -52,7 +52,7 @@ public class ReplaceWithTagAction extends CVSAction {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(),
- PromptingDialog.getOverwriteLocalChangesPrompt(),
+ getOverwriteLocalChangesPrompt(),
Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$
final IResource[] resources = prompt.promptForMultiple();
if(resources.length == 0) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
index 72d4fd9ad..dffbbf14d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
@@ -6,7 +6,6 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -18,27 +17,24 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
-import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.team.internal.ccvs.ui.TagAsVersionDialog;
+import org.eclipse.team.internal.ui.IPromptCondition;
+import org.eclipse.team.internal.ui.PromptingDialog;
/**
* TagAction tags the selected resources with a version tag specified by the user.
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index feaa66936..d531bbb39 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -128,6 +128,40 @@
class="org.eclipse.team.internal.ui.target.TargetProjectAction">
</action>
</objectContribution>
+
+ <objectContribution
+ objectClass="org.eclipse.team.internal.ui.target.RemoteResourceElement"
+ id="org.eclipse.team.internal.ui.target.RemoteResourceElement">
+ <action
+ label="Get As..."
+ tooltip="Get As..."
+ class="org.eclipse.team.internal.ui.target.GetAsAction"
+ id="org.eclipse.team.internal.ui.target.GetAsAction">
+ </action>
+ <action
+ label="Get As Project"
+ tooltip="Get As Project"
+ 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="Get As..."
+ tooltip="Get As..."
+ class="org.eclipse.team.internal.ui.target.GetAsAction"
+ id="org.eclipse.team.internal.ui.target.GetAsAction">
+ </action>
+ <action
+ label="Get As Project"
+ tooltip="Get As Project"
+ class="org.eclipse.team.internal.ui.target.GetAsProjectAction"
+ id="org.eclipse.team.internal.ui.target.GetAsProjectAction">
+ </action>
+ </objectContribution>
</extension>
<!-- ************** Views ********************** -->
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPromptCondition.java
index 4ebe0cd6c..19a4a12e8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/IPromptCondition.java
@@ -8,12 +8,14 @@
* Contributors:
* IBM - Initial implementation
******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui;
+package org.eclipse.team.internal.ui;
import org.eclipse.core.resources.IResource;
/**
* Input to a confirm prompt
+ *
+ * @see PromptingDialog
*/
public interface IPromptCondition {
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java
index 6ecbf78f2..5488965de 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial implementation
******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui;
+package org.eclipse.team.internal.ui;
import java.util.ArrayList;
import java.util.List;
@@ -72,20 +72,6 @@ public class PromptingDialog {
}
/**
- * A helper prompt condition for prompting for CVS dirty state.
- */
- public static IPromptCondition getOverwriteLocalChangesPrompt() {
- return new IPromptCondition() {
- public boolean needsPrompt(IResource resource) {
- return CVSDecorator.isDirty(resource);
- }
- public String promptMessage(IResource resource) {
- return Policy.bind("ReplaceWithAction.localChanges", resource.getName());//$NON-NLS-1$
- }
- };
- }
-
- /**
* Opens the confirmation dialog based on the prompt condition settings.
*/
private boolean confirmOverwrite(String msg) throws InterruptedException {
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 dd417628b..c731da99c 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
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -26,7 +27,6 @@ import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -159,6 +159,23 @@ public class TeamUIPlugin extends AbstractUIPlugin {
if (createdShell) parent.dispose();
}
}
+
+ /**
+ * Creates a progress monitor and runs the specified runnable.
+ *
+ * @param parent the parent Shell for the dialog
+ * @param cancelable if true, the dialog will support cancelation
+ * @param runnable the runnable
+ *
+ * @exception InvocationTargetException when an exception is thrown from the runnable
+ * @exception InterruptedException when the progress monitor is cancelled
+ */
+ public static void runWithProgressDialog(Shell parent, boolean cancelable,
+ final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+
+ new ProgressMonitorDialog(parent).run(cancelable, cancelable, runnable);
+ }
+
/**
* @see Plugin#startup()
*/
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index 48c22af8d..315d59a3d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -135,11 +135,29 @@ TargetSiteCreationWizard.description=Select the type of site you want to connect
TargetSiteCreationWizard.mappingPageTitle=Specify the location on the site
TargetSiteCreationWizard.siteSelectionPage=Select or create a site
-SiteSelectionPage.description=Select and existing site or create new site where you can to deploy your resources.
+SiteSelectionPage.description=Select and existing site or create new site where you can deploy your resources.
SiteSelectionPage.label=Select an existing site or create a new one:
SiteSelectionPage.useExisting=Use Existing Site
SiteSelectionPage.createNew=Create a new Site
+GetAsProject.thisResourceExists=The resource ''{0}'' already exists in the workspace. Overwrite?
+GetAsProject.thisExternalFileExists=The folder ''{0}'' exists in the local file system. Overwrite?
+GetAsProject.confirmOverwrite=Confirm Overwrite
+GetAsProject.taskName1=Receiving ''{0}''
+GetAsProject.taskNameN=Receiving {0} folders
+GetAsProject.errorCreatingProject=Error creating project: {0}
+GetAsProject.errorGettingResources=Error getting resources
+
+GetAs.checkoutFailed=Problems encountered receiving the remote folder
+GetAs.enterProjectTitle=Get ''{0}'' As...
+GetAs.taskname=Receiving ''{0}'' as ''{1}''
+
+Error=Error
+
+CreateNewFolderAction.errorCreatingFolder=Error creating the remote folder.
+CreateNewFolderAction.title=New Remote Folder
+CreateNewFolderAction.message=Enter the name for the new remote folder:
+CreateNewFolderAction.newFolderName=New Folder
GetAction.title=Get
GetAction.working=Retrieving...
@@ -147,11 +165,21 @@ GetAction.working=Retrieving...
PutAction.title=Put
PutAction.working=Storing...
-SiteExplorerViewaddSiteAction=Add a Site
-SiteExplorerViewaddSiteActionTooltip=Add a Site
+SiteExplorerView.addSiteAction=Add a Site
+SiteExplorerView.addSiteActionTooltip=Add a Site
+SiteExplorerView.newFolderAction=Fo&lder...
+SiteExplorerView.newMenu=&New
+SiteExplorerView.Name_1=Name
+SiteExplorerView.Size_2=Size
+SiteExplorerView.Modified_3=Modified
+SiteExplorerView.URL_4=URL
+
+SiteExplorerViewLabelProvider.fileSize={0} KB
MappingSelectionPage.description=Specify the location on the site where you want to deploy your resources.
MappingSelectionPage.label=Select the site or a folder:
+MappingSelectionPage.newFolderLabel=&New Folder...
+
ConfigureTargetWizardQuestion_2=Question
ConfigureTargetWizardError_6=Error
ConfigureTargetWizardError_mapping_the_project_with_this_site_7=Error mapping the project with this site
@@ -165,11 +193,9 @@ GetAction.Exception_getting_provider_2=Exception getting provider
GetSyncAction.Getting..._1=Getting...
PutAction.Exception_getting_provider_2=Exception getting provider
PutSyncAction.Putting..._1=Putting...
-SiteExplorerView.Name_1=Name
-SiteExplorerView.Size_2=Size
-SiteExplorerView.Modified_3=Modified
-SiteExplorerView.URL_4=URL
+
TargetCatchupReleaseViewer.Get_1=Get
TargetCatchupReleaseViewer.Put_2=Put
-SiteExplorerViewLabelProvider.bytes={0} Bytes
-SiteSelectionPage.currentLocation={0} (current location)
+
+SiteSelectionPage.siteLabelCurrentWithMapping={0} (current as {1})
+SiteSelectionPage.siteLabelCurrent={0} (current)
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
index 9bc87ab39..bdc59a098 100644
--- 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
@@ -49,6 +49,8 @@ public class ConfigureTargetWizard extends Wizard implements IConfigurationWizar
protected IConfigurationWizard wizard;
protected ConfigureProjectWizardMainPage mainPage;
+ protected static MappingSelectionPage mappingPage;
+
private String pluginId = UIConstants.PLUGIN_ID;
protected final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
@@ -109,20 +111,21 @@ public class ConfigureTargetWizard extends Wizard implements IConfigurationWizar
setWindowTitle(getWizardWindowTitle());
if(sites.length > 0 && project != null) {
- Site site = null;
TargetProvider provider = null;
try {
provider = TargetManager.getProvider(project);
} catch (TeamException e) {
TeamUIPlugin.log(e.getStatus());
- }
- if(provider != null) {
- site = provider.getSite();
}
- siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE), site); //$NON-NLS-1$ //$NON-NLS-2$
+ siteSelectionPage = new SiteSelectionPage("site-selection-page", Policy.bind("TargetSiteCreationWizard.siteSelectionPage"), TeamImages.getImageDescriptor(UIConstants.IMG_WIZBAN_SHARE), provider); //$NON-NLS-1$ //$NON-NLS-2$
addPage(siteSelectionPage);
}
+ if(project != null) {
+ mappingPage = new MappingSelectionPage(ConfigureTargetWizard.MAPPING_PAGE_NAME, Policy.bind("webdavMainPage.mappingTitle"), null); //$NON-NLS-1$
+ mappingPage.setWizard(this);
+ }
+
try {
if(wizards.size() == 1) {
ConfigurationWizardElement element = (ConfigurationWizardElement)wizards.getChildren()[0];
@@ -174,7 +177,6 @@ public class ConfigureTargetWizard extends Wizard implements IConfigurationWizar
// }
if(page == siteSelectionPage) {
if(siteSelectionPage.getSite() != null) {
- MappingSelectionPage mappingPage = getMappingPage();
mappingPage.setSite(siteSelectionPage.getSite());
mappingPage.setPreviousPage(page);
return mappingPage;
@@ -190,8 +192,8 @@ public class ConfigureTargetWizard extends Wizard implements IConfigurationWizar
return super.getNextPage(page);
}
- private MappingSelectionPage getMappingPage() {
- return (MappingSelectionPage)getPage(MAPPING_PAGE_NAME);
+ public static MappingSelectionPage getMappingPage() {
+ return mappingPage;
}
public boolean canFinish() {
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
new file mode 100644
index 000000000..d778131b9
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/CreateNewFolderAction.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ui.target;
+
+import java.lang.reflect.InvocationTargetException;
+
+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.core.target.IRemoteTargetResource;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+
+/**
+ * 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 {
+ createDir(getShell(), getSelectedRemoteFolders()[0]);
+ } catch (TeamException e) {
+ handle(e, Policy.bind("Error"), Policy.bind("CreateNewFolderAction.errorCreatingFolder")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public static IRemoteTargetResource createDir(Shell shell, final IRemoteTargetResource parent) throws TeamException {
+ final String[] suggestedFolderName = new String[] {Policy.bind("CreateNewFolderAction.newFolderName")}; //$NON-NLS-1$
+ try {
+ TeamUIPlugin.runWithProgress(shell, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ IRemoteResource[] members;
+ try {
+ members = parent.members(null);
+ } catch (TeamException e) {
+ return;
+ }
+ int numNewFolders = 0;
+ for (int i = 0; i < members.length; i++) {
+ if(members[i].getName().equals(Policy.bind("CreateNewFolderAction.newFolderName"))) { //$NON-NLS-1$
+ numNewFolders++;
+ }
+ }
+ if(numNewFolders != 0) {
+ suggestedFolderName[0] += " " + numNewFolders; //$NON-NLS-1$
+ }
+ }
+ });
+ // ignore, just use the default name
+ } catch (InvocationTargetException e) {
+ } catch (InterruptedException e) {
+ }
+
+ InputDialog dialog = new InputDialog(shell,
+ Policy.bind("CreateNewFolderAction.title"), //$NON-NLS-1$
+ Policy.bind("CreateNewFolderAction.message"), //$NON-NLS-1$
+ suggestedFolderName[0],
+ null);
+ if(dialog.open() == dialog.OK) {
+ String folderName = dialog.getValue();
+ IRemoteTargetResource newFolder = parent.getFolder(folderName);
+ newFolder.mkdirs();
+ return newFolder;
+ }
+ return null;
+ }
+}
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
index 8b053766c..e306d26d0 100644
--- 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
@@ -28,7 +28,8 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
* Action for getting the contents of the selected resources
*/
-public class GetAction extends TeamAction { public void run(IAction action) {
+public class GetAction extends TeamAction {
+ public void run(IAction action) {
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
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
new file mode 100644
index 000000000..9588b8cdb
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsAction.java
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial 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.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.target.IRemoteTargetResource;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.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 WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
+ try {
+ hasProjectMetaFile[0] = hasProjectMetaFile(remoteFolder, monitor);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ }, Policy.bind("GetAs.checkoutFailed"), this.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.subMonitorFor(monitor, 95));
+
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ }, Policy.bind("GetAs.checkoutFailed"), this.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
new file mode 100644
index 000000000..a5f5dd33c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/GetAsProjectAction.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ui.target;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+import java.lang.reflect.InvocationTargetException;
+
+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.core.target.IRemoteTargetResource;
+import org.eclipse.team.core.target.Site;
+import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.core.target.UrlUtil;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.PromptingDialog;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+
+/**
+ * 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 {
+ TeamUIPlugin.runWithProgressDialog(getShell(), true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ monitor.beginTask(getTaskName(remoteFolders), IProgressMonitor.UNKNOWN);
+ monitor.setTaskName(getTaskName(remoteFolders));
+ for (int i = 0; i < remoteFolders.length; i++) {
+ IProject project = (IProject)projects[i];
+ IRemoteTargetResource remote = remoteFolders[i];
+ IProgressMonitor subMonitor = Policy.subMonitorFor(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/MappingSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
index 31dfe5540..9880e1432 100644
--- 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
@@ -17,24 +17,26 @@ import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.ErrorDialog;
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.wizard.IWizardPage;
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.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.Site;
import org.eclipse.team.internal.core.target.UrlUtil;
import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.ui.model.WorkbenchLabelProvider;
public class MappingSelectionPage extends TargetWizardPage {
@@ -73,11 +75,54 @@ public class MappingSelectionPage extends TargetWizardPage {
updateTextPath();
}
});
+ 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();
+ IRemoteTargetResource selectedFolder = getSelectedRemoteFolder(selection);
+ IRemoteTargetResource newFolder = CreateNewFolderAction.createDir(shell, selectedFolder);
+ viewer.refresh(currentSelection);
+ viewer.setExpandedState(currentSelection, true);
+ viewer.setSelection(new StructuredSelection(currentSelection));
+ } catch (TeamException e) {
+ ErrorDialog.openError(shell,
+ Policy.bind("Error"), //$NON-NLS-1$
+ Policy.bind("CreateNewFolderAction.errorCreatingFolder"), //$NON-NLS-1$
+ e.getStatus());
+ return;
+ }
+ }
+ });
setViewerInput();
setControl(composite);
setPageComplete(true);
}
+ 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.
*/
@@ -91,12 +136,7 @@ public class MappingSelectionPage extends TargetWizardPage {
if(o instanceof RemoteResourceElement) {
RemoteResourceElement element = (RemoteResourceElement) o;
URL remoteResourceURL;
- try {
- remoteResourceURL = element.getRemoteResource().getURL();
- } catch(TeamException e) {
- TeamUIPlugin.handle(e);
- return;
- }
+ remoteResourceURL = element.getRemoteResource().getURL();
this.path = UrlUtil.getTrailingPath(
remoteResourceURL,
this.site.getURL());
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
index 1db2b2024..18633f0d0 100644
--- 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
@@ -26,6 +26,9 @@ import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.IWorkbenchAdapter;
+/**
+ * Used to show IRemoteTargetResource instances in the UI.
+ */
public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
final public static int SHOW_FILES = 1;
final public static int SHOW_FOLDERS = 2;
@@ -101,4 +104,10 @@ public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
public Object getParent(Object o) {
return null;
}
+ public boolean equals(Object obj) {
+ if(obj == null) return false;
+ if(!(obj instanceof RemoteResourceElement)) return false;
+ RemoteResourceElement otherElement = ((RemoteResourceElement)obj);
+ return otherElement.getRemoteResource().getURL().equals(getRemoteResource().getURL());
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
index 210a191de..a8d6d8434 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
@@ -20,19 +20,30 @@ import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.TargetManager;
import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+/**
+ * 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 LocalTargetSyncElement localSyncElement;
+ private IResource local;
private TargetProvider provider;
public RemoteTargetSyncElement(IResource local, IRemoteTargetResource remote) {
- this.localSyncElement = new LocalTargetSyncElement(local);
+ this.local = local;
this.remote = remote;
try {
this.provider = TargetManager.getProvider(local.getProject());
- } catch (TeamException e) {
+ } catch (TeamException e) {
+ TeamUIPlugin.log(e.getStatus());
+ this.remote = null;
}
}
@@ -61,7 +72,7 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
* @see LocalSyncElement#create(IResource, IRemoteResource, Object)
*/
public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
- return localSyncElement.create(local, base, data);
+ return new RemoteTargetSyncElement(local, remote);
}
/**
@@ -96,7 +107,7 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
* @see ILocalSyncElement#getLocal()
*/
public IResource getLocal() {
- return localSyncElement.getLocal();
+ return local;
}
/**
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
index 3ff0f8ca6..6ea70cf74 100644
--- 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
@@ -10,51 +10,65 @@
******************************************************************************/
package org.eclipse.team.internal.ui.target;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import javax.swing.text.html.parser.TagElement;
-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.operation.IRunnableWithProgress;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnPixelData;
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.wizard.WizardDialog;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.custom.SashForm;
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.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.ISiteListener;
import org.eclipse.team.core.target.Site;
import org.eclipse.team.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.team.ui.TeamImages;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+/**
+ * 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.
+ *
+ * @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$
@@ -68,6 +82,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
// The view's actions
private Action addSiteAction;
+ private Action newFolderAction;
/**
* @see IWorkbenchPart#createPartControl(Composite)
@@ -78,7 +93,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
root = new SiteRootsElement(TargetManager.getSites(), RemoteResourceElement.SHOW_FOLDERS);
- treeViewer = new TreeViewer(sash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ treeViewer = new TreeViewer(sash, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
treeViewer.setContentProvider(new SiteLazyContentProvider());
treeViewer.setLabelProvider(new WorkbenchLabelProvider());
@@ -93,45 +108,73 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- updateFileTable();
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ final IRemoteTargetResource remoteFolder = getSelectedRemoteFolder(selection);
+ updateFileTable(remoteFolder);
+ }
+ });
+
+ treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent e) {
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ if(selection.size() == 1) {
+ expandInTreeCurrentSelection(selection, true /*toggle expanded*/);
+ }
}
});
treeViewer.setInput(root);
Table table = new Table(sash, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- TableLayout tlayout = new TableLayout();
+ TableLayout layout = new TableLayout();
TableColumn tableColumn = new TableColumn(table, SWT.NULL);
tableColumn.setText(Policy.bind("SiteExplorerView.Name_1")); //$NON-NLS-1$
+ 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);
+ layout.addColumnData(new ColumnWeightData(20, true));
tableColumn = new TableColumn(table, SWT.NULL);
tableColumn.setText(Policy.bind("SiteExplorerView.Modified_3")); //$NON-NLS-1$
tableColumn = new TableColumn(table, SWT.NULL);
+ layout.addColumnData(new ColumnWeightData(20, true));
tableColumn.setText(Policy.bind("SiteExplorerView.URL_4")); //$NON-NLS-1$
ColumnLayoutData cLayout = new ColumnPixelData(21);
- tlayout.addColumnData(cLayout);
- cLayout = new ColumnPixelData(20);
- tlayout.addColumnData(cLayout);
- cLayout = new ColumnWeightData(100, true);
- tlayout.addColumnData(cLayout);
- cLayout = new ColumnPixelData(100);
- tlayout.addColumnData(cLayout);
- table.setLayout(tlayout);
+ table.setLayout(layout);
table.setHeaderVisible(true);
tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new SiteLazyContentProvider());
tableViewer.setLabelProvider(new SiteExplorerViewLabelProvider());
+ tableViewer.getControl().addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ if (event.keyCode == SWT.F5) {
+ refresh();
+ }
+ }
+ });
+
+ tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent e) {
+ IStructuredSelection selection = (IStructuredSelection)tableViewer.getSelection();
+ if(selection.size() == 1) {
+ final IRemoteTargetResource remote = getSelectedRemoteFolder(selection);
+ if(remote.isContainer()) {
+ IStructuredSelection treeSelection = (IStructuredSelection)treeViewer.getSelection();
+ expandInTreeCurrentSelection(treeSelection, false /*don't toggle*/);
+ treeViewer.setSelection(new StructuredSelection(new RemoteResourceElement(remote)));
+ }
+ }
+ }
+ });
+
TargetManager.addSiteListener(this);
initalizeToolbarActions();
}
- private IRemoteTargetResource getSelectedRemoteFolder() {
- IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ private IRemoteTargetResource getSelectedRemoteFolder(IStructuredSelection selection) {
if (!selection.isEmpty()) {
final List filesSelection = new ArrayList();
Iterator it = selection.iterator();
@@ -150,15 +193,29 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
}
return null;
}
+
+ private void expandInTreeCurrentSelection(IStructuredSelection selection, boolean toggle) {
+ if (!selection.isEmpty()) {
+ Iterator it = selection.iterator();
+ while(it.hasNext()) {
+ Object element = it.next();
+ if(toggle) {
+ treeViewer.setExpandedState(element, !treeViewer.getExpandedState(element));
+ } else {
+ treeViewer.setExpandedState(element, true);
+ }
+ }
+ }
+ }
/**
* Method updateFileTable.
*/
- private void updateFileTable() {
- final IRemoteTargetResource remoteFolder = getSelectedRemoteFolder();
+ private void updateFileTable(IRemoteTargetResource remoteFolder) {
final Set tags = new HashSet();
if(remoteFolder != null) {
- tableViewer.setInput(new RemoteResourceElement(remoteFolder, RemoteResourceElement.SHOW_FILES));
+ RemoteResourceElement folderElement = new RemoteResourceElement(remoteFolder);
+ tableViewer.setInput(folderElement);
}
}
@@ -167,7 +224,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
// Create actions
// Refresh (toolbar)
- addSiteAction = new Action(Policy.bind("SiteExplorerViewaddSiteAction"), TeamImages.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT)) { //$NON-NLS-1$
+ addSiteAction = new Action(Policy.bind("SiteExplorerView.addSiteAction"), TeamImages.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT)) { //$NON-NLS-1$
public void run() {
ConfigureTargetWizard wizard = new ConfigureTargetWizard();
wizard.init(null, null);
@@ -175,12 +232,60 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
dialog.open();
}
};
- addSiteAction.setToolTipText(Policy.bind("SiteExplorerViewaddSiteActionTooltip")); //$NON-NLS-1$
+ addSiteAction.setToolTipText(Policy.bind("SiteExplorerView.addSiteActionTooltip")); //$NON-NLS-1$
+
+ newFolderAction = new Action(Policy.bind("SiteExplorerView.newFolderAction"), WorkbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
+ public void run() {
+ Shell shell = treeViewer.getTree().getShell();
+ try {
+ // assume that only one folder is selected in the folder tree
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ Object currentSelection = selection.getFirstElement();
+ IRemoteTargetResource selectedFolder = getSelectedRemoteFolder(selection);
+ IRemoteTargetResource newFolder = CreateNewFolderAction.createDir(shell, selectedFolder);
+ treeViewer.refresh(currentSelection);
+ expandInTreeCurrentSelection(new StructuredSelection(currentSelection), false);
+ treeViewer.setSelection(new StructuredSelection(currentSelection));
+ } catch (TeamException e) {
+ ErrorDialog.openError(shell,
+ Policy.bind("Error"), //$NON-NLS-1$
+ Policy.bind("CreateNewFolderAction.errorCreatingFolder"), //$NON-NLS-1$
+ e.getStatus());
+ return;
+ }
+ }
+ };
IActionBars bars = getViewSite().getActionBars();
IToolBarManager tbm = bars.getToolBarManager();
tbm.add(addSiteAction);
tbm.update(false);
+
+
+ MenuManager treeMgr = new MenuManager();
+ MenuManager tableMgr = new MenuManager();
+ Tree tree = treeViewer.getTree();
+ Table table = tableViewer.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(newFolderAction) ;
+ }
+ };
+ treeMgr.addMenuListener(menuListener);
+ treeMgr.setRemoveAllWhenShown(true);
+ tableMgr.addMenuListener(menuListener);
+ tableMgr.setRemoveAllWhenShown(true);
+ tree.setMenu(treeMenu);
+ table.setMenu(tableMenu);
+ getSite().registerContextMenu(tableMgr, tableViewer);
+ getSite().registerContextMenu(treeMgr, treeViewer);
}
/**
@@ -207,6 +312,5 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
root = new SiteRootsElement(TargetManager.getSites(), RemoteResourceElement.SHOW_FOLDERS);
treeViewer.setInput(root);
treeViewer.refresh();
- tableViewer.refresh();
}
} \ No newline at end of file
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
index c44455d13..62b18733b 100644
--- 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
@@ -11,7 +11,6 @@
package org.eclipse.team.internal.ui.target;
import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ui.Policy;
@@ -32,7 +31,12 @@ public class SiteExplorerViewLabelProvider extends WorkbenchLabelProvider implem
return super.getText(element);
case 1 :
if(element instanceof RemoteResourceElement) {
- return Policy.bind("SiteExplorerViewLabelProvider.bytes", new Integer(((RemoteResourceElement)element).getRemoteResource().getSize()).toString()); //$NON-NLS-1$
+ int size = ((RemoteResourceElement)element).getRemoteResource().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) {
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
index 35f7c149d..3f0f932ab 100644
--- 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
@@ -1,24 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
package org.eclipse.team.internal.ui.target;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
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.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -29,21 +30,27 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.team.core.target.Site;
import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.core.target.UrlUtil;
import org.eclipse.team.internal.ui.Policy;
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 Site site;
- private Site initialSiteSelection;
+ private TargetProvider currentProvider;
- public SiteSelectionPage(String pageName, String title, ImageDescriptor titleImage, Site site) {
+ public SiteSelectionPage(String pageName, String title, ImageDescriptor titleImage, TargetProvider currentProvider) {
super(pageName, title, titleImage);
setDescription(Policy.bind("SiteSelectionPage.description")); //$NON-NLS-1$
- initialSiteSelection = site;
+ this.currentProvider = currentProvider;
}
protected TableViewer createTable(Composite parent) {
@@ -73,8 +80,13 @@ public class SiteSelectionPage extends TargetWizardPage {
table.setContentProvider(new WorkbenchContentProvider());
table.setLabelProvider(new WorkbenchLabelProvider() {
protected String decorateText(String input, Object element) {
- if(element.equals(new SiteElement(initialSiteSelection))) {
- return Policy.bind("SiteSelectionPage.currentLocation", super.decorateText(input, element)); //$NON-NLS-1$
+ 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);
}
@@ -121,8 +133,8 @@ public class SiteSelectionPage extends TargetWizardPage {
useNewRepo.setSelection(true);
} else {
useExistingRepo.setSelection(true);
- if(initialSiteSelection != null) {
- table.setSelection(new StructuredSelection(new SiteElement(initialSiteSelection)));
+ if(currentProvider != null) {
+ table.setSelection(new StructuredSelection(new SiteElement(currentProvider.getSite())));
} else {
table.setSelection(new StructuredSelection(new SiteElement(sites[0])));
}
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
new file mode 100644
index 000000000..61612466a
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetAction.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ui.target;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.target.IRemoteTargetResource;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+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) {
+ TeamUIPlugin.log(e.getStatus());
+ }
+ }
+ 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];
+ }
+}

Back to the top