summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/diff
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/diff')
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareClipboardWithSelection.java3
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffPanelOptions.java15
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java36
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSplitter.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/MergePanel2.java61
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/DiffRequestFactoryImpl.java31
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeRequestImpl.java58
7 files changed, 146 insertions, 65 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareClipboardWithSelection.java b/platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareClipboardWithSelection.java
index a916d9e5bb34..372b14efcfe6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareClipboardWithSelection.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareClipboardWithSelection.java
@@ -73,8 +73,9 @@ public class CompareClipboardWithSelection extends BaseDiffAction {
SelectionModel selectionModel = myEditor.getSelectionModel();
if (selectionModel.hasSelection()) {
TextRange range = new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
+ boolean forceReadOnly = myEditor.isViewer();
myContents[1] = new FragmentContent(DiffContent.fromDocument(getProject(), getDocument()),
- range, getProject(), getDocumentFile(getDocument()));
+ range, getProject(), getDocumentFile(getDocument()), forceReadOnly);
}
else {
myContents [1] = DiffContent.fromDocument(getProject(), getDocument());
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffPanelOptions.java b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffPanelOptions.java
index 538058d2d190..ec7a316357e2 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffPanelOptions.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffPanelOptions.java
@@ -23,6 +23,8 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.DialogWrapperDialog;
import com.intellij.openapi.util.Disposer;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -56,25 +58,26 @@ public class DiffPanelOptions {
myShowSourcePolicy = showSourcePolicy;
}
- public void showSource(OpenFileDescriptor descriptor) {
+ public void showSource(@Nullable OpenFileDescriptor descriptor) {
+ if (descriptor == null || myDiffPanel.getProject() == null) return;
myShowSourcePolicy.showSource(descriptor, myDiffPanel);
}
public interface ShowSourcePolicy {
- void showSource(OpenFileDescriptor descriptor, DiffPanelImpl diffPanel);
+ void showSource(@NotNull OpenFileDescriptor descriptor, @NotNull DiffPanelImpl diffPanel);
ShowSourcePolicy DONT_SHOW = new ShowSourcePolicy() {
- public void showSource(OpenFileDescriptor descriptor, DiffPanelImpl diffPanel) {}
+ public void showSource(@NotNull OpenFileDescriptor descriptor, @NotNull DiffPanelImpl diffPanel) {}
};
ShowSourcePolicy OPEN_EDITOR = new ShowSourcePolicy() {
- public void showSource(OpenFileDescriptor descriptor, DiffPanelImpl diffPanel) {
+ public void showSource(@NotNull OpenFileDescriptor descriptor, @NotNull DiffPanelImpl diffPanel) {
FileEditorManager.getInstance(diffPanel.getProject()).openTextEditor(descriptor, true);
}
};
ShowSourcePolicy OPEN_EDITOR_AND_CLOSE_DIFF = new ShowSourcePolicy() {
- public void showSource(OpenFileDescriptor descriptor, DiffPanelImpl diffPanel) {
+ public void showSource(@NotNull OpenFileDescriptor descriptor, @NotNull DiffPanelImpl diffPanel) {
OPEN_EDITOR.showSource(descriptor, diffPanel);
if (diffPanel.getOwnerWindow() == null) return;
Disposer.dispose(diffPanel);
@@ -97,7 +100,7 @@ public class DiffPanelOptions {
};
ShowSourcePolicy DEFAULT = new ShowSourcePolicy() {
- public void showSource(OpenFileDescriptor descriptor, DiffPanelImpl diffPanel) {
+ public void showSource(@NotNull OpenFileDescriptor descriptor, @NotNull DiffPanelImpl diffPanel) {
Window window = diffPanel.getOwnerWindow();
if (window == null) return;
else if (window instanceof Frame) OPEN_EDITOR.showSource(descriptor, diffPanel);
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java
index 5f169146145c..8ea3242d9361 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java
@@ -73,7 +73,6 @@ import com.intellij.util.LineSeparator;
import com.intellij.util.containers.CacheOneStepIterator;
import com.intellij.util.diff.FilesTooBigForDiffException;
import com.intellij.util.ui.PlatformColors;
-import com.intellij.util.ui.UIUtil;
import gnu.trove.TIntFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -160,8 +159,8 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
myOwnerWindow = owner;
myIsSyncScroll = true;
final boolean v = !horizontal;
- myLeftSide = new DiffSideView(this, new CustomLineBorder(UIUtil.getBorderColor(), 1, 0, v ? 0 : 1, v ? 0 : 1));
- myRightSide = new DiffSideView(this, new CustomLineBorder(UIUtil.getBorderColor(), v ? 0 : 1, v ? 0 : 1, 1, 0));
+ myLeftSide = new DiffSideView(this, new CustomLineBorder(1, 0, v ? 0 : 1, v ? 0 : 1));
+ myRightSide = new DiffSideView(this, new CustomLineBorder(v ? 0 : 1, v ? 0 : 1, 1, 0));
myLeftSide.becomeMaster();
myDiffUpdater = new Rediffers(this);
@@ -298,13 +297,11 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
myData.setContents(content1, content2);
Project project = myData.getProject();
FileType[] types = DiffUtil.chooseContentTypes(new DiffContent[]{content1, content2});
- VirtualFile baseFile = content1.getFile();
- if (baseFile == null && myDiffRequest != null) {
- String path = myDiffRequest.getWindowTitle();
- if (path != null) baseFile = LocalFileSystem.getInstance().findFileByPath(path);
- }
- myLeftSide.setHighlighterFactory(createHighlighter(types[0], baseFile, project));
- myRightSide.setHighlighterFactory(createHighlighter(types[1], baseFile, project));
+ VirtualFile beforeFile = content1.getFile();
+ VirtualFile afterFile = content2.getFile();
+ String path = myDiffRequest == null ? null : myDiffRequest.getWindowTitle();
+ myLeftSide.setHighlighterFactory(createHighlighter(types[0], beforeFile, afterFile, path, project));
+ myRightSide.setHighlighterFactory(createHighlighter(types[1], afterFile, beforeFile, path, project));
setSplitterProportion(content1, content2);
rediff();
if (myIsRequestFocus) {
@@ -344,8 +341,16 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
}
// todo pay attention here
- private static DiffHighlighterFactory createHighlighter(FileType contentType, VirtualFile file, Project project) {
- return new DiffHighlighterFactoryImpl(contentType, file, project);
+ private static DiffHighlighterFactory createHighlighter(FileType contentType,
+ VirtualFile file,
+ VirtualFile otherFile,
+ String path,
+ Project project) {
+ VirtualFile baseFile = file;
+ if (baseFile == null) baseFile = otherFile;
+ if (baseFile == null && path != null) baseFile = LocalFileSystem.getInstance().findFileByPath(path);
+
+ return new DiffHighlighterFactoryImpl(contentType, baseFile, project);
}
void rediff() {
@@ -607,7 +612,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
return myData.getProject();
}
- public void showSource(OpenFileDescriptor descriptor) {
+ public void showSource(@Nullable OpenFileDescriptor descriptor) {
myOptions.showSource(descriptor);
}
@@ -1004,10 +1009,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
@Override
public void navigate(boolean requestFocus) {
- final OpenFileDescriptor descriptor = mySide.getCurrentOpenFileDescriptor();
- if (descriptor != null) {
- showSource(descriptor);
- }
+ showSource(mySide.getCurrentOpenFileDescriptor());
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSplitter.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSplitter.java
index 5f4507dcfad3..4b6a289d476e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSplitter.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSplitter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import com.intellij.openapi.diff.impl.highlighting.DiffPanelState;
import com.intellij.openapi.diff.impl.splitter.DiffDividerPaint;
import com.intellij.openapi.editor.event.VisibleAreaEvent;
import com.intellij.openapi.editor.event.VisibleAreaListener;
+import com.intellij.openapi.ui.Divider;
import com.intellij.openapi.ui.Splitter;
import javax.swing.*;
@@ -43,8 +44,8 @@ class DiffSplitter extends Splitter implements DiffSplitterI {
setHonorComponentsMinimumSize(false);
}
- protected Splitter.Divider createDivider() {
- return new Divider(){
+ protected Divider createDivider() {
+ return new DividerImpl(){
public void paint(Graphics g) {
super.paint(g);
myPaint.paint(g, this);
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/MergePanel2.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/MergePanel2.java
index 10362cc8b304..cbad541fe129 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/MergePanel2.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/MergePanel2.java
@@ -27,9 +27,7 @@ import com.intellij.openapi.diff.*;
import com.intellij.openapi.diff.actions.NextDiffAction;
import com.intellij.openapi.diff.actions.PreviousDiffAction;
import com.intellij.openapi.diff.actions.ToggleAutoScrollAction;
-import com.intellij.openapi.diff.impl.DiffUtil;
-import com.intellij.openapi.diff.impl.EditingSides;
-import com.intellij.openapi.diff.impl.GenericDataProvider;
+import com.intellij.openapi.diff.impl.*;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter;
import com.intellij.openapi.diff.impl.incrementalMerge.ChangeList;
@@ -49,16 +47,20 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
+import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
+import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.LabeledComponent;
+import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
-import com.intellij.util.diff.FilesTooBigForDiffException;
+import com.intellij.util.containers.Convertor;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -141,9 +143,6 @@ public class MergePanel2 implements DiffViewer {
private DiffRequest.ToolbarAddons createToolbar() {
return new DiffRequest.ToolbarAddons() {
public void customize(DiffToolbar toolbar) {
- ActionManager actionManager = ActionManager.getInstance();
- toolbar.addAction(actionManager.getAction(IdeActions.ACTION_COPY));
- toolbar.addAction(actionManager.getAction(IdeActions.ACTION_FIND));
toolbar.addAction(PreviousDiffAction.find());
toolbar.addAction(NextDiffAction.find());
toolbar.addSeparator();
@@ -235,6 +234,8 @@ public class MergePanel2 implements DiffViewer {
Editor base = getEditor(1);
Editor right = getEditor(2);
+ setupHighlighterSettings(left, base, right);
+
myMergeList.setMarkups(left, base, right);
EditingSides[] sides = {getFirstEditingSide(), getSecondEditingSide()};
myScrollSupport.install(sides);
@@ -271,6 +272,37 @@ public class MergePanel2 implements DiffViewer {
return myScrollSupport.isEnabled();
}
+ private void setupHighlighterSettings(Editor left, Editor base, Editor right) {
+ Editor[] editors = new Editor[]{left, base, right};
+ DiffContent[] contents = myData.getContents();
+ FileType[] types = DiffUtil.chooseContentTypes(contents);
+
+ VirtualFile fallbackFile = contents[1].getFile();
+ FileType fallbackType = contents[1].getContentType();
+
+ for (int i = 0; i < 3; i++) {
+ Editor editor = editors[i];
+ DiffContent content = contents[i];
+
+ EditorHighlighter highlighter =
+ createHighlighter(types[i], content.getFile(), fallbackFile, fallbackType, myData.getProject()).createHighlighter();
+ if (highlighter != null) {
+ ((EditorEx)editor).setHighlighter(highlighter);
+ }
+ }
+ }
+
+ private static DiffHighlighterFactory createHighlighter(FileType contentType,
+ VirtualFile file,
+ VirtualFile otherFile,
+ FileType otherType,
+ Project project) {
+ if (file == null) file = otherFile;
+ if (contentType == null) contentType = otherType;
+
+ return new DiffHighlighterFactoryImpl(contentType, file, project);
+ }
+
public void setHighlighterSettings(@Nullable EditorColorsScheme settings) {
for (EditorPlace place : getEditorPlaces()) {
setHighlighterSettings(settings, place);
@@ -337,7 +369,20 @@ public class MergePanel2 implements DiffViewer {
data.customizeToolbar(myPanel.resetToolbar());
myPanel.registerToolbarActions();
if ( data instanceof MergeRequestImpl && myBuilder != null){
- ((MergeRequestImpl)data).setActions(myBuilder, this);
+ Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() {
+ @Override
+ public Boolean convert(DialogWrapper dialog) {
+ ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList);
+ int changes = counter.getChangeCounter();
+ int conflicts = counter.getConflictCounter();
+ if (changes == 0 && conflicts == 0) return true;
+ return Messages.showYesNoDialog(dialog.getRootPane(),
+ DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts),
+ DiffBundle.message("apply.partially.resolved.merge.dialog.title"),
+ Messages.getQuestionIcon()) == Messages.YES;
+ }
+ };
+ ((MergeRequestImpl)data).setActions(myBuilder, this, preOkHook);
}
}
finally {
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/DiffRequestFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/DiffRequestFactoryImpl.java
index 3b13543e6972..962a0712465b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/DiffRequestFactoryImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/DiffRequestFactoryImpl.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.diff.DiffRequestFactory;
import com.intellij.openapi.diff.MergeRequest;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -27,11 +28,11 @@ import org.jetbrains.annotations.Nullable;
public class DiffRequestFactoryImpl extends DiffRequestFactory {
- public MergeRequest createMergeRequest(String leftText,
- String rightText,
- String originalContent,
+ public MergeRequest createMergeRequest(@NotNull String leftText,
+ @NotNull String rightText,
+ @NotNull String originalContent,
@NotNull VirtualFile file,
- Project project,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
final Document document = FileDocumentManager.getInstance().getDocument(file);
@@ -41,16 +42,26 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
cancelButtonPresentation);
}
else {
- return create3WayDiffRequest(leftText, rightText, originalContent, project, okButtonPresentation, cancelButtonPresentation);
+ return create3WayDiffRequest(leftText, rightText, originalContent, file.getFileType(), project, okButtonPresentation, cancelButtonPresentation);
}
}
- public MergeRequest create3WayDiffRequest(final String leftText,
- final String rightText,
- final String originalContent,
- final Project project,
+ public MergeRequest create3WayDiffRequest(@NotNull String leftText,
+ @NotNull String rightText,
+ @NotNull String originalContent,
+ @Nullable FileType type,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
- return new MergeRequestImpl(leftText, originalContent, rightText, project, okButtonPresentation, cancelButtonPresentation);
+ return new MergeRequestImpl(leftText, originalContent, rightText, type, project, okButtonPresentation, cancelButtonPresentation);
+ }
+
+ public MergeRequest create3WayDiffRequest(@NotNull String leftText,
+ @NotNull String rightText,
+ @NotNull String originalContent,
+ @Nullable Project project,
+ @Nullable final ActionButtonPresentation okButtonPresentation,
+ @Nullable final ActionButtonPresentation cancelButtonPresentation) {
+ return create3WayDiffRequest(leftText, rightText, originalContent, null, project, okButtonPresentation, cancelButtonPresentation);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeRequestImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeRequestImpl.java
index 3b1385eb7a59..938c1ee7a42d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeRequestImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeRequestImpl.java
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,39 +47,51 @@ public class MergeRequestImpl extends MergeRequest {
@Nullable private final ActionButtonPresentation myOkButtonPresentation;
@Nullable private final ActionButtonPresentation myCancelButtonPresentation;
- public MergeRequestImpl(String left,
- MergeVersion base,
- String right,
- Project project,
+ public MergeRequestImpl(@NotNull String left,
+ @NotNull MergeVersion base,
+ @NotNull String right,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
this(new SimpleContent(left), new MergeContent(base, project), new SimpleContent(right), project, okButtonPresentation,
cancelButtonPresentation);
}
- public MergeRequestImpl(DiffContent left,
- MergeVersion base,
- DiffContent right,
- Project project,
+ public MergeRequestImpl(@NotNull DiffContent left,
+ @NotNull MergeVersion base,
+ @NotNull DiffContent right,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
this(left, new MergeContent(base, project), right, project, okButtonPresentation, cancelButtonPresentation);
}
- public MergeRequestImpl(String left,
- String base,
- String right,
- Project project,
+ public MergeRequestImpl(@NotNull String left,
+ @NotNull String base,
+ @NotNull String right,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
- this(new SimpleContent(left), new SimpleContent(base), new SimpleContent(right), project, okButtonPresentation,
- cancelButtonPresentation);
+ this(left, base, right, null, project, okButtonPresentation, cancelButtonPresentation);
}
- private MergeRequestImpl(DiffContent left,
- DiffContent base,
- DiffContent right,
- Project project,
+ public MergeRequestImpl(@NotNull String left,
+ @NotNull String base,
+ @NotNull String right,
+ @Nullable FileType type,
+ @Nullable Project project,
+ @Nullable final ActionButtonPresentation okButtonPresentation,
+ @Nullable final ActionButtonPresentation cancelButtonPresentation) {
+ this(new SimpleContent(left, type),
+ new SimpleContent(base, type),
+ new SimpleContent(right, type),
+ project, okButtonPresentation, cancelButtonPresentation);
+ }
+
+ private MergeRequestImpl(@NotNull DiffContent left,
+ @NotNull DiffContent base,
+ @NotNull DiffContent right,
+ @Nullable Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
super(project);
@@ -176,6 +189,10 @@ public class MergeRequestImpl extends MergeRequest {
}
public void setActions(final DialogBuilder builder, MergePanel2 mergePanel) {
+ setActions(builder, mergePanel, null);
+ }
+
+ public void setActions(final DialogBuilder builder, MergePanel2 mergePanel, final Convertor<DialogWrapper, Boolean> preOkHook) {
builder.removeAllActions(); // otherwise dialog will get default actions (OK, Cancel)
if (myOkButtonPresentation != null) {
@@ -187,6 +204,7 @@ public class MergeRequestImpl extends MergeRequest {
builder.setOkOperation(new Runnable() {
@Override
public void run() {
+ if (preOkHook != null && !preOkHook.convert(builder.getDialogWrapper())) return;
myOkButtonPresentation.run(builder.getDialogWrapper());
}
});
@@ -221,11 +239,11 @@ public class MergeRequestImpl extends MergeRequest {
}
public static class MergeContent extends DiffContent {
- private final MergeVersion myTarget;
+ @NotNull private final MergeVersion myTarget;
private final Document myWorkingDocument;
private final Project myProject;
- public MergeContent(MergeVersion target, Project project) {
+ public MergeContent(@NotNull MergeVersion target, Project project) {
myTarget = target;
myProject = project;
myWorkingDocument = myTarget.createWorkingDocument(project);