override fun actionPerformed()

in idea-plugin/src/main/java/org/jetbrains/bunches/idea/vcs/DiffWithMainAction.kt [27:53]


    override fun actionPerformed(e: AnActionEvent) {
        val project = e.project ?: return
        if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return

        val change = e.getChange() ?: return
        val revision = change.getRevision() ?: return
        val file = revision.file
        val mainFile = getMainFile(e.project, file.ioFile.absolutePath)

        val text = revision.content ?: return
        val diffContentFactory = DiffContentFactoryImpl.getInstance()

        val request: DiffRequest =
            if (mainFile != null) {
                SimpleDiffRequest(
                    "Comparison with the local main file ${mainFile.path}", diffContentFactory.create(project, mainFile),
                    diffContentFactory.create(text),
                    "Local ${mainFile.name}", "${file.name} from ${revision.revisionNumber.asString()}"
                )
            } else {
                ErrorDiffRequest(
                    "Comparison with the local main file ${file.parentPath}${file.ioFile.nameWithoutExtension}",
                    "Failed to find local main file content"
                )
            }
        DiffManager.getInstance().showDiff(project, request)
    }