merge: let MergeTool to decide on confirmation message
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Tue, 11 Aug 2015 12:30:33 +0000 (15:30 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Wed, 12 Aug 2015 16:55:47 +0000 (19:55 +0300)
platform/diff-api/src/com/intellij/diff/merge/MergeTool.java
platform/diff-impl/src/com/intellij/diff/merge/MergeRequestProcessor.java
platform/diff-impl/src/com/intellij/diff/merge/TextMergeTool.java

index fbff78dac1e09a37682d4f669e7e4a0efbe02012..86bc574a5ebd4255ea9b0877956a59dcdac78d01 100644 (file)
@@ -61,6 +61,6 @@ public interface MergeTool {
   class ToolbarComponents {
     @Nullable public List<AnAction> toolbarActions;
     @Nullable public JComponent statusPanel;
-    @Nullable public BooleanGetter closeHandler; // return false if there are unsaved changes
+    @Nullable public BooleanGetter closeHandler; // return false if merge window should be prevented from closing and canceling resolve.
   }
 }
index ee2930526e256e51c6207b488efadd1d1bcba02a..094162807cd60ea9a1e9c03cc17272e7fd69e325 100644 (file)
@@ -29,9 +29,7 @@ import com.intellij.ide.impl.DataManagerImpl;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.diff.DiffBundle;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.BooleanGetter;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Key;
@@ -270,14 +268,9 @@ public abstract class MergeRequestProcessor implements Disposable {
     return myContext;
   }
 
+  @CalledInAwt
   public boolean checkCloseAction() {
-    if (!myConflictResolved && myCloseHandler != null && !myCloseHandler.get()) {
-      return Messages.showYesNoDialog(myPanel.getRootPane(),
-                                      DiffBundle.message("merge.dialog.exit.without.applying.changes.confirmation.message"),
-                                      DiffBundle.message("cancel.visual.merge.dialog.title"),
-                                      Messages.getQuestionIcon()) == Messages.YES;
-    }
-    return true;
+    return myConflictResolved || myCloseHandler == null || myCloseHandler.get();
   }
 
   @Nullable
index 0cf52ee6c7dbebbb924fda4cab52f0f350915959..5464cdb4b833be845f1b1fe56076644d6e6e8b6c 100644 (file)
@@ -164,7 +164,9 @@ public class TextMergeTool implements MergeTool {
       components.closeHandler = new BooleanGetter() {
         @Override
         public boolean get() {
-          return myViewer.isContentModified();
+          return Messages.showYesNoDialog(getComponent().getRootPane(),
+                                          DiffBundle.message("merge.dialog.exit.without.applying.changes.confirmation.message"),
+                                          DiffBundle.message("cancel.visual.merge.dialog.title"), Messages.getQuestionIcon()) == Messages.YES;
         }
       };