Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-03-06 11:26:10 -0500
committerJean Michel-Lemieux2003-03-06 11:26:10 -0500
commit6c374130895e5a8af5a17101530a11e3478556b2 (patch)
treedc095dbaf9860c1d224621a34ba780c22bcc2ebc
parenta50a9bfd4538d4fba673338027f0388c3b49cafe (diff)
downloadeclipse.platform.team-isModifiedProgressBranch.tar.gz
eclipse.platform.team-isModifiedProgressBranch.tar.xz
eclipse.platform.team-isModifiedProgressBranch.zip
finished, ready to merge into HEADisModifiedProgressBranch
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java61
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java14
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java25
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties1
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java4
6 files changed, 66 insertions, 45 deletions
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 3f6b7a3e8..cd285ae0b 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
@@ -12,6 +12,7 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -422,10 +423,11 @@ abstract public class CVSAction extends TeamAction {
/**
* A helper prompt condition for prompting for CVS dirty state.
*/
- public static IPromptCondition getOverwriteLocalChangesPrompt(final List dirtyResources) {
+ public static IPromptCondition getOverwriteLocalChangesPrompt(final IResource[] dirtyResources) {
return new IPromptCondition() {
+ List resources = Arrays.asList(dirtyResources);
public boolean needsPrompt(IResource resource) {
- return dirtyResources.contains(resource);
+ return resources.contains(resource);
}
public String promptMessage(IResource resource) {
return Policy.bind("ReplaceWithAction.localChanges", resource.getName());//$NON-NLS-1$
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 825d8f060..230f658d0 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
@@ -11,7 +11,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;
@@ -25,10 +24,10 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
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.Policy;
-import org.eclipse.team.internal.ui.PromptingDialog;
+import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
+import org.eclipse.team.internal.ui.IPromptCondition;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
public class ReplaceWithRemoteAction extends WorkspaceAction {
@@ -37,21 +36,11 @@ public class ReplaceWithRemoteAction extends WorkspaceAction {
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
-
- IResource resources[] = checkOverwriteOfDirtyResources(getSelectedResources());
-
- // Do the replace
- Hashtable table = getProviderMapping(resources);
- Set keySet = table.keySet();
- monitor.beginTask(null, keySet.size() * 1000); //$NON-NLS-1$
- monitor.setTaskName(Policy.bind("ReplaceWithRemoteAction.replacing")); //$NON-NLS-1$
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
- CVSTeamProvider provider = (CVSTeamProvider)iterator.next();
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- provider.get(providerResources, IResource.DEPTH_INFINITE, subMonitor);
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
+ IResource resources[] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 20));
+ if(resources.length > 0) {
+ performReplace(resources, Policy.subMonitorFor(monitor, 80));
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
@@ -59,34 +48,32 @@ public class ReplaceWithRemoteAction extends WorkspaceAction {
monitor.done();
}
}
-
-
}, true /* cancelable */, PROGRESS_DIALOG);
}
- private IResource[] checkOverwriteOfDirtyResources(IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- List dirtyResources = new ArrayList();
- IResource[] selectedResources = getSelectedResources();
-
+ private void performReplace(IResource[] resources, IProgressMonitor monitor) throws TeamException {
try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, selectedResources.length * 1000);
- for (int i = 0; i < selectedResources.length; i++) {
- IResource resource = selectedResources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if(cvsResource.isModified(Policy.subMonitorFor(monitor, 1000))) {
- dirtyResources.add(resource);
- }
+ Hashtable table = getProviderMapping(resources);
+ Set keySet = table.keySet();
+ monitor.beginTask(null, keySet.size() * 10); //$NON-NLS-1$
+ monitor.setTaskName(Policy.bind("ReplaceWithRemoteAction.replacing")); //$NON-NLS-1$
+ Iterator iterator = keySet.iterator();
+ while (iterator.hasNext()) {
+ IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 10);
+ CVSTeamProvider provider = (CVSTeamProvider)iterator.next();
+ List list = (List)table.get(provider);
+ IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
+ provider.get(providerResources, IResource.DEPTH_INFINITE, subMonitor);
}
} finally {
- monitor.done();
+ monitor.done();
}
-
- PromptingDialog dialog = new PromptingDialog(getShell(), selectedResources,
- getOverwriteLocalChangesPrompt(dirtyResources), Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$
- return dialog.promptForMultiple();
}
+ protected IPromptCondition getPromptCondition(IResource[] dirtyResources) {
+ return getOverwriteLocalChangesPrompt(dirtyResources);
+ }
+
/**
* @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle()
*/
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 9aa1f6871..89107d2af 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
@@ -50,10 +50,16 @@ public class ReplaceWithTagAction extends WorkspaceAction {
// Show a busy cursor while display the tag selection dialog
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(),
- getOverwriteLocalChangesPrompt(),
- Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$
- final IResource[] resources = prompt.promptForMultiple();
+
+ IResource[] resources;
+ try {
+ resources =
+ checkOverwriteOfDirtyResources(
+ getSelectedResources(),
+ null /* no progress just a busy cursor for now */);
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ }
if(resources.length == 0) {
// nothing to do
return;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java
index 46767f1c3..809a193f8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java
@@ -46,6 +46,7 @@ import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ui.PromptingDialog;
/**
* This class represents an action performed on a local CVS workspace
@@ -522,4 +523,28 @@ public abstract class WorkspaceAction extends CVSAction {
return Policy.bind("ReplaceWithLatestAction.multipleTags"); //$NON-NLS-1$
}
}
+
+ protected IResource[] checkOverwriteOfDirtyResources(IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
+ List dirtyResources = new ArrayList();
+ IResource[] selectedResources = getSelectedResources();
+
+ try {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, selectedResources.length * 100);
+ monitor.setTaskName(Policy.bind("ReplaceWithAction.calculatingDirtyResources")); //$NON-NLS-1$
+ for (int i = 0; i < selectedResources.length; i++) {
+ IResource resource = selectedResources[i];
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if(cvsResource.isModified(Policy.subMonitorFor(monitor, 100))) {
+ dirtyResources.add(resource);
+ }
+ }
+ } finally {
+ monitor.done();
+ }
+
+ PromptingDialog dialog = new PromptingDialog(getShell(), selectedResources,
+ getOverwriteLocalChangesPrompt((IResource[]) dirtyResources.toArray(new IResource[dirtyResources.size()])), Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$
+ return dialog.promptForMultiple();
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 35acdf356..f39952719 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -438,6 +438,7 @@ ReplaceWithRemoteAction.problemMessage=Error Replacing With Latest From Reposito
ReplaceWithAction.confirmOverwrite=Confirm Overwrite
ReplaceWithAction.localChanges={0} has local changes which you are about to overwrite. Do you wish to overwrite?
+ReplaceWithAction.calculatingDirtyResources=Finding outgoing changes...
ReplaceWithLatestAction.multipleTags=&Latest from Repository
ReplaceWithLatestAction.multipleVersions=&Versions from Repository
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
index db00ef6f9..02c9098ce 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
@@ -164,7 +164,7 @@ public class CVSUITestCase extends LoggingTestCase {
*/
protected void actionReplaceWithRemote(IResource[] resources) {
ReplaceWithRemoteAction action = new ReplaceWithRemoteAction() {
- protected IPromptCondition getPromptCondition() {
+ protected IPromptCondition getPromptCondition(IResource[] resources) {
return new DummyPromptCondition();
}
};
@@ -215,7 +215,7 @@ public class CVSUITestCase extends LoggingTestCase {
protected String promptForTag(ICVSFolder folder) {
return name;
}
- protected IPromptCondition getPromptCondition() {
+ protected IPromptCondition getPromptCondition(IResource[] resources) {
return new DummyPromptCondition();
}
};

Back to the top