Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-04-04 13:57:06 -0500
committerMichael Valenta2002-04-04 13:57:06 -0500
commit862b6291506f82aa6ca43d60e733c8f7f4e92fbc (patch)
tree4abdb22adbcf55ef47c69f36fbea72e2339146ae
parentac41a3f30497367d21ee8e6330e8ba613ea9d813 (diff)
downloadeclipse.platform.team-862b6291506f82aa6ca43d60e733c8f7f4e92fbc.tar.gz
eclipse.platform.team-862b6291506f82aa6ca43d60e733c8f7f4e92fbc.tar.xz
eclipse.platform.team-862b6291506f82aa6ca43d60e733c8f7f4e92fbc.zip
7111: VCMFile.saveChanges() needs progress
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java53
2 files changed, 42 insertions, 13 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
index 5b35bb66f..693673ee4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
@@ -273,7 +273,7 @@ public abstract class SyncCompareInput extends CompareEditorInput {
}
return element;
} else {
- TeamFile file = new TeamFile(parent, mergeResource, type);
+ TeamFile file = new TeamFile(parent, mergeResource, type, shell);
file.addCompareInputChangeListener(listener);
return file;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
index a32788b88..262546220 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
@@ -6,6 +6,7 @@ package org.eclipse.team.ui.sync;
*/
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
@@ -17,14 +18,19 @@ import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.ui.TeamUIPlugin;
import org.eclipse.ui.internal.WorkbenchPlugin;
/**
@@ -43,10 +49,11 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
/**
* Creates a new file node.
*/
- public TeamFile(IDiffContainer parent, MergeResource res, int changeType) {
+ public TeamFile(IDiffContainer parent, MergeResource res, int changeType, Shell shell) {
super(parent, changeType);
Assert.isNotNull(res);
this.mergeResource = res;
+ this.shell = shell;
commonByteContents = new TypedBufferedContent(this, false) {
public InputStream createStream() throws CoreException {
@@ -233,17 +240,25 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
* Saves cached copy to disk and clears dirty flag.
*/
private void saveChanges() throws CoreException {
- InputStream stream = localByteContents.getContents();
- IFile file = (IFile) getResource();
- if (stream != null) {
- if (!file.exists()) {
- file.create(stream, false, null);
- } else {
- file.setContents(stream, false, true, null);
+ run(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ InputStream stream = localByteContents.getContents();
+ IFile file = (IFile) getResource();
+ if (stream != null) {
+ if (!file.exists()) {
+ file.create(stream, false, monitor);
+ } else {
+ file.setContents(stream, false, true, monitor);
+ }
+ } else {
+ file.delete(false, true, monitor);
+ }
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
}
- } else {
- file.delete(false, true, null);
- }
+ });
}
/**
* For debugging purposes only.
@@ -251,4 +266,18 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
public String toString() {
return "TeamFile(" + mergeResource.getName() + ")";
}
+
+ private void run(IRunnableWithProgress runnable) throws CoreException {
+ try {
+ new ProgressMonitorDialog(shell).run(false, false, runnable);
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof CoreException) {
+ throw (CoreException)e.getTargetException();
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, Policy.bind("simpleInternal"), e.getTargetException()));
+ }
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
}

Back to the top