mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Refactor "MarkTreeConflictResolvedAction"
This commit is contained in:
@@ -633,7 +633,7 @@ Select 'svn:ignore' patterns to be deleted.
|
||||
detect.nested.working.copies=Detect nested working copies
|
||||
svn.changeview.item.in.conflict.text=File has {0} conflict(s) and can not be committed
|
||||
svn.changeview.locally.deleted.item.in.conflict.text=File has {0} conflict(s)
|
||||
action.mark.tree.conflict.resolved.text=Mark Tree Conflict Resolved...
|
||||
action.Subversion.MarkTreeResolved.text=Mark Tree Conflict Resolved...
|
||||
action.mark.tree.conflict.resolved.confirmation.text=Do you want to mark tree conflict as resolved?
|
||||
action.mark.tree.conflict.resolved.confirmation.title=Mark Tree Conflict Resolved
|
||||
svn.integrate.changelist.warning.unresolved.conflicts.text=Integration interrupted. There are unresolved conflicts or skipped items.
|
||||
|
||||
+1
-2
@@ -23,7 +23,7 @@ import org.jetbrains.idea.svn.api.Depth
|
||||
/**
|
||||
* @author irengrig
|
||||
*/
|
||||
class MarkLocallyDeletedTreeConflictResolvedAction : DumbAwareAction(SvnBundle.message("action.mark.tree.conflict.resolved.text")) {
|
||||
class MarkLocallyDeletedTreeConflictResolvedAction : DumbAwareAction(SvnBundle.message("action.Subversion.MarkTreeResolved.text")) {
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val locallyDeletedChecker = MyLocallyDeletedChecker(e)
|
||||
@@ -51,7 +51,6 @@ class MarkLocallyDeletedTreeConflictResolvedAction : DumbAwareAction(SvnBundle.m
|
||||
val locallyDeletedChecker = MyLocallyDeletedChecker(e)
|
||||
e.presentation.isVisible = locallyDeletedChecker.isEnabled
|
||||
e.presentation.isEnabled = locallyDeletedChecker.isEnabled
|
||||
//e.getPresentation().setText(SvnBundle.message("action.mark.tree.conflict.resolved.text"));
|
||||
}
|
||||
|
||||
private fun resolveLocallyDeletedTextConflict(checker: MyLocallyDeletedChecker, exception: Ref<VcsException>) {
|
||||
|
||||
+33
-69
@@ -1,110 +1,74 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.idea.svn.actions
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.VcsDataKeys
|
||||
import com.intellij.openapi.vcs.VcsException
|
||||
import com.intellij.openapi.vcs.changes.Change
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil.getAfterPath
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil.getBeforePath
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager
|
||||
import org.jetbrains.idea.svn.ConflictedSvnChange
|
||||
import org.jetbrains.idea.svn.SvnBundle
|
||||
import org.jetbrains.idea.svn.SvnVcs
|
||||
import org.jetbrains.idea.svn.api.Depth
|
||||
import java.util.*
|
||||
|
||||
class MarkTreeConflictResolvedAction : AnAction(myText), DumbAware {
|
||||
private fun getConflictedChange(e: AnActionEvent) = e.getData(VcsDataKeys.CHANGE_LEAD_SELECTION)?.singleOrNull() as? ConflictedSvnChange
|
||||
|
||||
private fun getDistinctFiles(change: Change): Collection<FilePath> {
|
||||
val beforePath = getBeforePath(change)
|
||||
val afterPath = getAfterPath(change)
|
||||
val isAddMoveRename = beforePath == null || change.isMoved || change.isRenamed
|
||||
|
||||
return listOfNotNull(beforePath, if (isAddMoveRename) afterPath else null)
|
||||
}
|
||||
|
||||
class MarkTreeConflictResolvedAction : DumbAwareAction() {
|
||||
override fun update(e: AnActionEvent) {
|
||||
val checker = MyChecker(e)
|
||||
e.presentation.isVisible = checker.isEnabled
|
||||
e.presentation.isEnabled = checker.isEnabled
|
||||
e.presentation.text = myText
|
||||
}
|
||||
val project = e.project
|
||||
val conflictedChange = getConflictedChange(e)
|
||||
val enabled = project != null && conflictedChange?.conflictState?.isTree == true
|
||||
|
||||
private class MyChecker internal constructor(e: AnActionEvent) {
|
||||
var isEnabled: Boolean
|
||||
val change: ConflictedSvnChange?
|
||||
val project: Project?
|
||||
|
||||
init {
|
||||
val dc = e.dataContext
|
||||
project = CommonDataKeys.PROJECT.getData(dc)
|
||||
val changes = VcsDataKeys.CHANGE_LEAD_SELECTION.getData(dc)
|
||||
|
||||
if (project == null || changes == null || changes.size != 1) {
|
||||
isEnabled = false
|
||||
change = null
|
||||
}
|
||||
else {
|
||||
val change = changes[0]
|
||||
isEnabled = change is ConflictedSvnChange && change.conflictState.isTree
|
||||
if (isEnabled) {
|
||||
this.change = change as ConflictedSvnChange
|
||||
}
|
||||
else {
|
||||
this.change = null
|
||||
}
|
||||
}
|
||||
}
|
||||
e.presentation.isEnabledAndVisible = enabled
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val checker = MyChecker(e)
|
||||
if (!checker.isEnabled) return
|
||||
val project = e.project!!
|
||||
val conflictedChange = getConflictedChange(e)!!
|
||||
|
||||
val markText = SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.title")
|
||||
val result = Messages.showYesNoDialog(checker.project,
|
||||
SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.text"), markText,
|
||||
val result = Messages.showYesNoDialog(project, SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.text"), markText,
|
||||
Messages.getQuestionIcon())
|
||||
if (result == Messages.YES) {
|
||||
val exception = Ref<VcsException>()
|
||||
ProgressManager.getInstance().run(object : Task.Backgroundable(checker.project, markText, true) {
|
||||
object : Task.Backgroundable(project, markText, true) {
|
||||
private var exception: VcsException? = null
|
||||
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
val change = checker.change
|
||||
val path = change!!.treeConflictMarkHolder
|
||||
val vcs = SvnVcs.getInstance(checker.project!!)
|
||||
val path = conflictedChange.treeConflictMarkHolder
|
||||
val vcs = SvnVcs.getInstance(project)
|
||||
|
||||
try {
|
||||
vcs.getFactory(path.ioFile).createConflictClient().resolve(path.ioFile, Depth.EMPTY, false, false, true)
|
||||
}
|
||||
catch (e: VcsException) {
|
||||
exception.set(e)
|
||||
exception = e
|
||||
}
|
||||
|
||||
VcsDirtyScopeManager.getInstance(checker.project).filePathsDirty(getDistinctFiles(change), null)
|
||||
VcsDirtyScopeManager.getInstance(project).filePathsDirty(getDistinctFiles(conflictedChange), null)
|
||||
}
|
||||
})
|
||||
if (!exception.isNull) {
|
||||
AbstractVcsHelper.getInstance(checker.project).showError(exception.get(), markText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDistinctFiles(change: Change): Collection<FilePath> {
|
||||
val result = ArrayList<FilePath>(2)
|
||||
if (change.beforeRevision != null) {
|
||||
result.add(change.beforeRevision!!.file)
|
||||
override fun onSuccess() {
|
||||
if (exception != null) {
|
||||
AbstractVcsHelper.getInstance(project).showError(exception, markText)
|
||||
}
|
||||
}
|
||||
}.queue()
|
||||
}
|
||||
if (change.afterRevision != null) {
|
||||
if (change.beforeRevision == null || change.beforeRevision != null && (change.isMoved || change.isRenamed)) {
|
||||
result.add(change.afterRevision!!.file)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val myText = SvnBundle.message("action.mark.tree.conflict.resolved.text")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user