Add title to MultipleFileMergeDialog

MultipleFileMergeDialog.myDescriptionLabel above the table with unmerged files. Description may be null.

Overload AbstractVcsHelper.showMergeDialog with optional description.

Set the description in Git update processes to clarify, where these unmerged files came from - during update, before update, during unstash, etc.
This commit is contained in:
Kirill Likhodedov
2011-03-10 19:09:01 +03:00
parent 4ff32e1137
commit 06cb6a6d50
11 changed files with 70 additions and 20 deletions
@@ -93,15 +93,26 @@ public abstract class AbstractVcsHelper {
int maxCount,
final String title);
@NotNull
public abstract List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider);
/**
* Shows the multiple file merge dialog for resolving conflicts in the specified set of virtual files.
* Assumes all files are under the same VCS.
*
* @param files the files to show in the merge dialog.
* @return the files for which the merge was actually performed.
* @param provider MergeProvider to be used for merging.
* @param description Optional description text (may be HTML) to be shown at the top of the merge dialog.
* @return changed files for which the merge was actually performed.
*/
public abstract @NotNull List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider, @Nullable String description);
/**
* {@link #showMergeDialog(java.util.List, com.intellij.openapi.vcs.merge.MergeProvider)} without description.
*/
@NotNull
public abstract List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider);
/**
* {@link #showMergeDialog(java.util.List, com.intellij.openapi.vcs.merge.MergeProvider)} without description and with default merge provider
* for the current VCS.
*/
@NotNull
public abstract List<VirtualFile> showMergeDialog(List<VirtualFile> files);
@@ -631,10 +631,17 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
}
}
@Override
@NotNull
public List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider) {
return showMergeDialog(files, provider, null);
}
@Override
@NotNull
public List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider, @Nullable String description) {
if (files.isEmpty()) return Collections.emptyList();
final MultipleFileMergeDialog fileMergeDialog = new MultipleFileMergeDialog(myProject, files, provider);
final MultipleFileMergeDialog fileMergeDialog = new MultipleFileMergeDialog(myProject, files, provider, description);
fileMergeDialog.show();
return fileMergeDialog.getProcessedFiles();
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.vcs.merge.MultipleFileMergeDialog">
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -11,7 +11,7 @@
<grid id="5c044" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -47,9 +47,9 @@
</component>
</children>
</grid>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="9f9b5">
<scrollpane id="9f9b5" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -60,6 +60,22 @@
</component>
</children>
</scrollpane>
<grid id="b4733" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f8ecf" class="com.intellij.ui.components.JBLabel" binding="myDescriptionLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</form>
@@ -38,6 +38,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectOpenProcessor;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.table.TableView;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
@@ -63,6 +64,7 @@ public class MultipleFileMergeDialog extends DialogWrapper {
private JButton myAcceptTheirsButton;
private JButton myMergeButton;
private TableView<VirtualFile> myTable;
private JBLabel myDescriptionLabel;
private final MergeProvider myProvider;
private final MergeSession myMergeSession;
private final List<VirtualFile> myFiles;
@@ -105,7 +107,7 @@ public class MultipleFileMergeDialog extends DialogWrapper {
}
};
public MultipleFileMergeDialog(Project project, final List<VirtualFile> files, final MergeProvider provider) {
public MultipleFileMergeDialog(Project project, final List<VirtualFile> files, final MergeProvider provider, String description) {
super(project, false);
myProject = project;
myProjectManager = ProjectManagerEx.getInstanceEx();
@@ -113,6 +115,10 @@ public class MultipleFileMergeDialog extends DialogWrapper {
myFiles = new ArrayList<VirtualFile>(files);
myProvider = provider;
if (!StringUtil.isEmptyOrSpaces(description)) {
myDescriptionLabel.setText(description);
}
List<ColumnInfo> columns = new ArrayList<ColumnInfo>();
Collections.addAll(columns, NAME_COLUMN, TYPE_COLUMN);
if (myProvider instanceof MergeProvider2) {
@@ -29,6 +29,7 @@ import com.intellij.util.ui.UIUtil;
import git4idea.GitVcs;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.util.ArrayList;
@@ -43,17 +44,19 @@ public class GitMergeConflictResolver {
private final boolean myReverseMerge;
private final String myErrorNotificationTitle;
private final String myErrorNotificationAdditionalDescription;
@Nullable private final String myMergeDialogTitle;
private final AbstractVcsHelper myVcsHelper;
private final GitVcs myVcs;
/**
* @param reverseMerge specify if reverse merge provider has to be used for merging - it is the case of rebase or stash.
*/
public GitMergeConflictResolver(@NotNull Project project, boolean reverseMerge, @NonNls String errorNotificationTitle, @NotNull String errorNotificationAdditionalDescription) {
public GitMergeConflictResolver(@NotNull Project project, boolean reverseMerge, @Nullable String mergeDialogTitle, @NonNls String errorNotificationTitle, @NotNull String errorNotificationAdditionalDescription) {
myProject = project;
myReverseMerge = reverseMerge;
myErrorNotificationTitle = errorNotificationTitle;
myErrorNotificationAdditionalDescription = errorNotificationAdditionalDescription;
myMergeDialogTitle = mergeDialogTitle;
myVcsHelper = AbstractVcsHelper.getInstance(project);
myVcs = GitVcs.getInstance(project);
}
@@ -75,13 +78,11 @@ public class GitMergeConflictResolver {
if (unmergedFiles.isEmpty()) {
return proceedIfNothingToMerge();
} else {
// TODO add descriptive message to the dialog:
// You must resolve all conflicts before you continue rebase
final Collection<VirtualFile> finalUnmergedFiles = unmergedFiles;
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override public void run() {
final MergeProvider mergeProvider = myReverseMerge ? myVcs.getReverseMergeProvider() : myVcs.getMergeProvider();
myVcsHelper.showMergeDialog(new ArrayList<VirtualFile>(finalUnmergedFiles), mergeProvider);
myVcsHelper.showMergeDialog(new ArrayList<VirtualFile>(finalUnmergedFiles), mergeProvider, myMergeDialogTitle);
}
});
@@ -77,7 +77,8 @@ public class GitRebaser {
@Override protected void onFailure() {
if (rebaseConflictDetector.isMergeConflict()) {
result.set(new GitMergeConflictResolver(myProject, true, "Can't continue rebase", "Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.") {
result.set(new GitMergeConflictResolver(myProject, true, "Merge conflicts detected. Resolve them before continuing rebase.",
"Can't continue rebase", "Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.") {
@Override protected boolean proceedIfNothingToMerge() {
return continueRebase(root, "--continue");
}
@@ -83,7 +83,8 @@ public class GitMergeUpdater extends GitUpdater {
@Override protected void onFailure() {
final MergeError error = mergeError.get();
if (error == MergeError.CONFLICT) {
final boolean allMerged = new GitMergeConflictResolver(myProject, true, "Can't update", "") {
final boolean allMerged = new GitMergeConflictResolver(myProject, true, "Merge conflicts detected. Resolve them before continuing update.",
"Can't update", "") {
@Override protected boolean proceedIfNothingToMerge() throws VcsException {
merger.mergeCommit(myRoot);
return true;
@@ -65,7 +65,7 @@ public class GitRebaseUpdater extends GitUpdater {
@Override protected void onFailure() {
if (rebaseConflictDetector.isMergeConflict()) {
final boolean allMerged = new GitMergeConflictResolver(myProject, true, "Can't continue rebase", "Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.") {
final boolean allMerged = new GitMergeConflictResolver(myProject, true, "Merge conflicts detected. Resolve them before continuing rebase.", "Can't continue rebase", "Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.") {
@Override protected boolean proceedIfNothingToMerge() throws VcsException {
return myRebaser.continueRebase(myRoot);
}
@@ -135,7 +135,8 @@ public class GitStashChangesSaver extends GitChangesSaver {
@Override protected void onFailure() {
if (conflict.get()) {
new GitMergeConflictResolver(myProject, true, "Can't update", "").mergeFiles(Collections.singleton(root));
new GitMergeConflictResolver(myProject, true, "Uncommitted changes that were stashed before update have conflicts with updated files.",
"Can't update", "").mergeFiles(Collections.singleton(root));
} else {
GitUIUtil.notifyImportantError(myProject, "Couldn't unstash", "<br/>" + GitUIUtil.stringifyErrors(handler.errors()));
}
@@ -167,7 +167,7 @@ public class GitUpdateProcess {
return false;
}
return !new GitMergeConflictResolver(myProject, false, "Can't update", "") {
return !new GitMergeConflictResolver(myProject, false, "You have unfinished merge. These conflicts must be resolved before update.", "Can't update", "") {
@Override protected boolean proceedAfterAllMerged() throws VcsException {
myMerger.mergeCommit(mergingRoots);
return true;
@@ -207,7 +207,7 @@ public class GitUpdateProcess {
return false;
}
return !new GitMergeConflictResolver(myProject, true, "Can't update",
return !new GitMergeConflictResolver(myProject, true, "You have unfinished rebase process. These conflicts must be resolved before update.", "Can't update",
"Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.") {
@Override protected boolean proceedIfNothingToMerge() {
return rebaser.continueRebase(rebasingRoots);
@@ -109,6 +109,12 @@ public class HgMockVcsHelper extends AbstractVcsHelper {
String title) {
}
@NotNull
@Override
public List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider, @Nullable String description) {
return null;
}
@NotNull
@Override
public List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider) {