From e977efb6bba4b1e1b3fbfd8aca3e43ded57969c1 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Wed, 20 Jan 2016 19:23:59 +0300 Subject: [PATCH] [patch]: rollback dialog should inform user about binaries if needed --- .../diff/impl/patch/formove/PatchApplier.java | 9 +++++++- .../patch/formove/UndoApplyPatchDialog.java | 21 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java index c0c4d73f9672..f0749e1c3a75 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java @@ -29,6 +29,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.*; @@ -306,6 +307,12 @@ public class PatchApplier { return applier.getFailedPatches(); } }); + boolean shouldInformAboutBinaries = ContainerUtil.exists(group, new Condition() { + @Override + public boolean value(PatchApplier applier) { + return !applier.getBinaryPatches().isEmpty(); + } + }); UndoApplyPatchDialog.rollbackApplyPatch(project, ContainerUtil.map(allFailed, new Function() { @Override public FilePath fun(FilePatch filePatch) { @@ -315,7 +322,7 @@ public class PatchApplier { : filePatch.getAfterName(); return VcsUtil.getFilePath(path); } - }), beforeLabel); + }), beforeLabel, shouldInformAboutBinaries); } protected void addSkippedItems(final TriggerAdditionOrDeletion trigger) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/UndoApplyPatchDialog.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/UndoApplyPatchDialog.java index 908ce16ffe14..17f7b6dcb802 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/UndoApplyPatchDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/UndoApplyPatchDialog.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.changes.ui.FilePathChangesTreeList; import com.intellij.ui.components.JBLabel; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,14 +37,19 @@ class UndoApplyPatchDialog extends DialogWrapper { private final List myFailedFilePaths; private final Label myBeforeLabel; private final Project myProject; + private final boolean myShouldInformAboutBinaries; - private UndoApplyPatchDialog(@NotNull Project project, @NotNull List filePaths, @NotNull Label beforeLabel) { + private UndoApplyPatchDialog(@NotNull Project project, + @NotNull List filePaths, + @NotNull Label beforeLabel, + boolean shouldInformAboutBinaries) { super(project, true); myProject = project; setTitle("Patch Applying Partly Failed"); setOKButtonText("Rollback"); myFailedFilePaths = filePaths; myBeforeLabel = beforeLabel; + myShouldInformAboutBinaries = shouldInformAboutBinaries; init(); } @@ -52,9 +58,16 @@ class UndoApplyPatchDialog extends DialogWrapper { protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new BorderLayout()); int numFiles = myFailedFilePaths.size(); + JPanel labelsPanel = new JPanel(new BorderLayout()); String detailedText = numFiles == 0 ? "" : String.format("Failed to apply %s below. ", StringUtil.pluralize("file", numFiles)); final JLabel infoLabel = new JBLabel(detailedText + "Would you like to rollback all applied?"); - panel.add(infoLabel, BorderLayout.NORTH); + labelsPanel.add(infoLabel, BorderLayout.NORTH); + if (myShouldInformAboutBinaries) { + JLabel warningLabel = new JLabel("Rollback doesn't affect binaries"); + warningLabel.setIcon(UIUtil.getBalloonWarningIcon()); + labelsPanel.add(warningLabel, BorderLayout.CENTER); + } + panel.add(labelsPanel, BorderLayout.NORTH); if (numFiles > 0) { FilePathChangesTreeList browser = new FilePathChangesTreeList(myProject, myFailedFilePaths, false, false, null, null) { @Override @@ -80,7 +93,7 @@ class UndoApplyPatchDialog extends DialogWrapper { } static void rollbackApplyPatch(@NotNull Project project, @NotNull List filePaths, - @NotNull Label historyLabel) { - new UndoApplyPatchDialog(project, filePaths, historyLabel).show(); + @NotNull Label historyLabel, boolean shouldInformAboutBinaries) { + new UndoApplyPatchDialog(project, filePaths, historyLabel, shouldInformAboutBinaries).show(); } }