diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.kt b/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.kt index 9f84348f8f4b..aeebf4972f36 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.kt +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.kt @@ -15,6 +15,10 @@ import org.jetbrains.annotations.ApiStatus */ @ApiStatus.OverrideOnly open class MergeDialogCustomizer { + companion object { + val DEFAULT_CUSTOMIZER_LIST = DiffEditorTitleCustomizerList(null, null, null) + } + /** * Returns the description that is shown above the list of conflicted files. * @@ -34,7 +38,7 @@ open class MergeDialogCustomizer { * Returns the title that is shown above the left panel in the 3-way merge dialog. * * @param file the file that is being merged. - * @see getLeftTitleCustomizer + * @see getTitleCustomizerList */ open fun getLeftPanelTitle(file: VirtualFile): String = DiffBundle.message("merge.version.title.our") @@ -42,7 +46,7 @@ open class MergeDialogCustomizer { * Returns the title that is shown above the center panel in the 3-way merge dialog. * * @param file the file that is being merged. - * @see getCenterTitleCustomizer + * @see getTitleCustomizerList */ open fun getCenterPanelTitle(file: VirtualFile): String = DiffBundle.message("merge.version.title.base") @@ -50,8 +54,8 @@ open class MergeDialogCustomizer { * Returns the title that is shown above the right panel in the 3-way merge dialog. * * @param file the file that is being merged. - * @param revisionNumber the revision number of the file at the right. Can be `null` if unknown. - * @see getRightTitleCustomizer + * @param revisionNumber the revision number of the file at the right. Can be null if unknown. + * @see getTitleCustomizerList */ open fun getRightPanelTitle(file: VirtualFile, revisionNumber: VcsRevisionNumber?): String = if (revisionNumber != null) @@ -75,26 +79,16 @@ open class MergeDialogCustomizer { open fun getColumnNames(): List? = null /** - * Allows to customize the left diff editor title in the 3-way merge dialog using [DiffEditorTitleCustomizer]. - * - * This method takes precedence over [getLeftPanelTitle], which is used as a fallback only if this method returns `null`. + * Allows to customize diff editor titles in the 3-way merge dialog using [DiffEditorTitleCustomizer] for each editor. + * This method takes precedence over methods like [getLeftPanelTitle]. + * If [DiffEditorTitleCustomizer] is null for the side, get(side)PanelTitle will be used as a fallback. */ @ApiStatus.Experimental - open fun getLeftTitleCustomizer(file: FilePath): DiffEditorTitleCustomizer? = null + open fun getTitleCustomizerList(file: FilePath): DiffEditorTitleCustomizerList = DEFAULT_CUSTOMIZER_LIST - /** - * Allows to customize the center diff editor title in the 3-way merge dialog using [DiffEditorTitleCustomizer]. - * - * This method takes precedence over [getCenterPanelTitle], which is used as a fallback only if this method returns `null`. - */ - @ApiStatus.Experimental - open fun getCenterTitleCustomizer(file: FilePath): DiffEditorTitleCustomizer? = null - - /** - * Allows to customize the right diff editor title in the 3-way merge dialog using [DiffEditorTitleCustomizer]. - * - * This method takes precedence over [getRightPanelTitle], which is used as a fallback only if this method returns `null`. - */ - @ApiStatus.Experimental - open fun getRightTitleCustomizer(file: FilePath): DiffEditorTitleCustomizer? = null + data class DiffEditorTitleCustomizerList( + val leftTitleCustomizer: DiffEditorTitleCustomizer?, + val centerTitleCustomizer: DiffEditorTitleCustomizer?, + val rightTitleCustomizer: DiffEditorTitleCustomizer? + ) } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.kt index d9e64fd8b424..6c86b9c1e047 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.kt @@ -3,7 +3,6 @@ package com.intellij.openapi.vcs.merge import com.intellij.CommonBundle import com.intellij.configurationStore.StoreReloadManager -import com.intellij.diff.DiffEditorTitleCustomizer import com.intellij.diff.DiffManager import com.intellij.diff.DiffRequestFactory import com.intellij.diff.InvalidDiffRequestException @@ -388,15 +387,7 @@ open class MultipleFileMergeDialog( } val filePath = VcsUtil.getFilePath(file) - val mergeTitleCustomizers = mergeDialogCustomizer.run { - listOf( - getLeftTitleCustomizer(filePath), - getCenterTitleCustomizer(filePath), - getRightTitleCustomizer(filePath) - ) - } - - ConflictData(mergeData, title, conflictTitles, mergeTitleCustomizers) + ConflictData(mergeData, title, conflictTitles, mergeDialogCustomizer.getTitleCustomizerList(filePath)) }, "Loading Revisions...", true, project) } catch (ex: VcsException) { @@ -442,7 +433,9 @@ open class MultipleFileMergeDialog( } break } - request.putUserData(EDITORS_TITLE_CUSTOMIZER, conflictData.contentTitleCustomizers) + conflictData.contentTitleCustomizers.run { + request.putUserData(EDITORS_TITLE_CUSTOMIZER, listOf(leftTitleCustomizer, centerTitleCustomizer, rightTitleCustomizer)) + } DiffManager.getInstance().showMerge(project, request) } updateModelFromFiles() @@ -470,6 +463,6 @@ open class MultipleFileMergeDialog( val mergeData: MergeData, val title: String, val contentTitles: List, - val contentTitleCustomizers: List + val contentTitleCustomizers: MergeDialogCustomizer.DiffEditorTitleCustomizerList ) } \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java index b3fabe49629d..1e16f6b516fd 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseProcess.java @@ -521,8 +521,17 @@ public class GitRebaseProcess { GitMergeProvider.calcColumnName(true, myBasePresentable)); } - @Nullable + @NotNull @Override + public DiffEditorTitleCustomizerList getTitleCustomizerList(@NotNull FilePath file) { + return new DiffEditorTitleCustomizerList( + getLeftTitleCustomizer(file), + null, + getRightTitleCustomizer(file) + ); + } + + @Nullable public DiffEditorTitleCustomizer getLeftTitleCustomizer(@NotNull FilePath file) { if (myIngoingCommit == null) { return null; @@ -550,7 +559,6 @@ public class GitRebaseProcess { } @Nullable - @Override public DiffEditorTitleCustomizer getRightTitleCustomizer(@NotNull FilePath file) { if (myHead == null || myMergeBase == null || myUpstreamHash == null) { return null;