diff options
| author | Jens Baumgart | 2010-09-23 23:04:12 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2010-09-23 23:04:12 +0000 |
| commit | 1fc344e151da9716823bd5dd977a6a4d8782a69d (patch) | |
| tree | b78452a4d242488a21fc721b33b6fdf3e41f61aa | |
| parent | c47d2a967ab03bf5a75ce670a0c002045347b05a (diff) | |
| download | egit-1fc344e151da9716823bd5dd977a6a4d8782a69d.tar.gz egit-1fc344e151da9716823bd5dd977a6a4d8782a69d.tar.xz egit-1fc344e151da9716823bd5dd977a6a4d8782a69d.zip | |
Team->Commit: do not freeze UI while calculating diff
Calculating diffs on Team->commit was moved to non UI thread.
Progress reporting is supported.
A further commit could extend IndexDiff to support cancellation.
Bug: 324923
Change-Id: Ia53ff68a2cc15b04fe56ad673c798ec98d72a696
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 files changed, 38 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index 932f6e10e7..91f26ef222 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -2216,6 +2216,12 @@ public class UIText extends NLS { public static String CommitAction_MergeHeadErrorTitle; /** */ + public static String CommitActionHandler_caculatingChanges; + + /** */ + public static String CommitActionHandler_repository; + + /** */ public static String CommitFileDiffViewer_notContainedInCommit; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java index efe9bae732..a8cf8ddf72 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -34,6 +35,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.core.AdaptableFileTreeIterator; @@ -46,6 +48,7 @@ import org.eclipse.egit.ui.internal.dialogs.CommitDialog; import org.eclipse.egit.ui.internal.trace.GitTraceLocation; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.IndexDiff; import org.eclipse.jgit.lib.ObjectId; @@ -85,12 +88,25 @@ public class CommitActionHandler extends RepositoryActionHandler { } resetState(); + final IProject[] projects = getProjectsInRepositoryOfSelectedResources(event); try { - buildIndexHeadDiffList(event); - } catch (IOException e) { - Activator.handleError(UIText.CommitAction_errorComputingDiffs, e, + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { + + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + try { + buildIndexHeadDiffList(projects, monitor); + } catch (IOException e) { + throw new InvocationTargetException(e); + } + } + }); + } catch (InvocationTargetException e) { + Activator.handleError(UIText.CommitAction_errorComputingDiffs, e.getCause(), true); return null; + } catch (InterruptedException e) { + return null; } Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources(event)); @@ -262,11 +278,11 @@ public class CommitActionHandler extends RepositoryActionHandler { } } - private void buildIndexHeadDiffList(ExecutionEvent event) - throws IOException, ExecutionException { + private void buildIndexHeadDiffList(IProject[] selectedProjects, IProgressMonitor monitor) + throws IOException, OperationCanceledException { HashMap<Repository, HashSet<IProject>> repositories = new HashMap<Repository, HashSet<IProject>>(); - for (IProject project : getProjectsInRepositoryOfSelectedResources(event)) { + for (IProject project : selectedProjects) { RepositoryMapping repositoryMapping = RepositoryMapping .getMapping(project); assert repositoryMapping != null; @@ -283,9 +299,13 @@ public class CommitActionHandler extends RepositoryActionHandler { projects.add(project); } + monitor.beginTask(UIText.CommitActionHandler_caculatingChanges, + repositories.size()); for (Map.Entry<Repository, HashSet<IProject>> entry : repositories .entrySet()) { Repository repository = entry.getKey(); + monitor.subTask(NLS.bind(UIText.CommitActionHandler_repository, + repository.getDirectory().getPath())); HashSet<IProject> projects = entry.getValue(); AdaptableFileTreeIterator fileTreeIterator = @@ -303,7 +323,11 @@ public class CommitActionHandler extends RepositoryActionHandler { includeList(project, indexDiff.getModified(), notIndexed); includeList(project, indexDiff.getUntracked(), notTracked); } + if (monitor.isCanceled()) + throw new OperationCanceledException(); + monitor.worked(1); } + monitor.done(); } private void includeList(IProject project, HashSet<String> added, diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index 835e3c326e..1c51dde434 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -785,6 +785,8 @@ CommitAction_commit=Commit... CommitAction_ErrorReadingMergeMsg=Error reading from file .git/MERGE_MSG CommitAction_MergeHeadErrorMessage=The file .git/MERGE_MSG was not found although being in state Merged. CommitAction_MergeHeadErrorTitle=Inconsistent Merge state +CommitActionHandler_caculatingChanges=Calculating changes in selected repositories +CommitActionHandler_repository=Repository: {0} CommitFileDiffViewer_notContainedInCommit=File {0} is not contained in commit {1} CommitFileDiffViewer_SelectOneCommitMessage=Please select exactly one commit |
