mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: cleanup - make class inner
This commit is contained in:
@@ -69,90 +69,90 @@ class GitRewordAction : GitCommitEditingAction() {
|
||||
}
|
||||
|
||||
override fun getFailureTitle(): String = "Couldn't Reword Commit"
|
||||
}
|
||||
|
||||
private fun getCommitDataFromCache(data: VcsLogData, commit: VcsShortCommitDetails): VcsCommitMetadata? {
|
||||
val commitIndex = data.getCommitIndex(commit.id, commit.root)
|
||||
val commitData = data.commitDetailsGetter.getCommitDataIfAvailable(commitIndex)
|
||||
if (commitData != null) return commitData
|
||||
private fun getCommitDataFromCache(data: VcsLogData, commit: VcsShortCommitDetails): VcsCommitMetadata? {
|
||||
val commitIndex = data.getCommitIndex(commit.id, commit.root)
|
||||
val commitData = data.commitDetailsGetter.getCommitDataIfAvailable(commitIndex)
|
||||
if (commitData != null) return commitData
|
||||
|
||||
val message = data.index.dataGetter?.getFullMessage(commitIndex)
|
||||
if (message != null) return VcsCommitMetadataImpl(commit.id, commit.parents, commit.commitTime, commit.root, commit.subject,
|
||||
commit.author, message, commit.committer, commit.authorTime)
|
||||
return null
|
||||
}
|
||||
|
||||
private fun loadCommitData(project: Project, data: VcsLogData, commit: VcsShortCommitDetails): VcsCommitMetadata? {
|
||||
var commitData: VcsCommitMetadata? = null
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||
{
|
||||
try {
|
||||
commitData = VcsLogUtil.getDetails(data, commit.root, commit.id)
|
||||
}
|
||||
catch (e: VcsException) {
|
||||
val error = "Couldn't load changes of " + commit.id.asString()
|
||||
LOG.warn(error, e)
|
||||
val notification = VcsNotifier.STANDARD_NOTIFICATION.createNotification(
|
||||
"", error, NotificationType.ERROR, null)
|
||||
VcsNotifier.getInstance(project).notify(notification)
|
||||
}
|
||||
}, "Loading Commit Message", true, project)
|
||||
return commitData
|
||||
}
|
||||
|
||||
private fun rewordInBackground(project: Project, commit: VcsCommitMetadata, repository: GitRepository, newMessage: String) {
|
||||
object : Task.Backgroundable(project, "Rewording") {
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
GitRewordOperation(repository, commit, newMessage).execute()
|
||||
}
|
||||
}.queue()
|
||||
}
|
||||
|
||||
private class RewordDialog(val project: Project, val commit: VcsCommitMetadata, val repository: GitRepository)
|
||||
: DialogWrapper(project, true) {
|
||||
|
||||
val originalHEAD = repository.info.currentRevision
|
||||
val commitEditor = createCommitEditor()
|
||||
|
||||
init {
|
||||
init()
|
||||
isModal = false
|
||||
title = "Reword Commit"
|
||||
}
|
||||
|
||||
override fun createCenterPanel() =
|
||||
JBUI.Panels.simplePanel(DEFAULT_HGAP, DEFAULT_VGAP)
|
||||
.addToTop(JBLabel("Edit message for commit ${commit.id.toShortString()} by ${getShortPresentation(commit.author)}"))
|
||||
.addToCenter(commitEditor)
|
||||
|
||||
override fun getPreferredFocusedComponent() = commitEditor.editorField
|
||||
|
||||
override fun getDimensionServiceKey() = "GitRewordDialog"
|
||||
|
||||
private fun createCommitEditor(): CommitMessage {
|
||||
val editor = CommitMessage(project, false, false, true)
|
||||
editor.setText(commit.fullMessage)
|
||||
editor.editorField.setCaretPosition(0)
|
||||
editor.editorField.addSettingsProvider { editor ->
|
||||
// display at least several rows for one-line messages
|
||||
val MIN_ROWS = 3
|
||||
if ((editor as EditorImpl).visibleLineCount < MIN_ROWS) {
|
||||
verticalStretch = 1.5F
|
||||
}
|
||||
}
|
||||
return editor
|
||||
}
|
||||
|
||||
override fun doValidate(): ValidationInfo? {
|
||||
if (repository.info.currentRevision != originalHEAD) {
|
||||
return ValidationInfo("Can't reword commit: repository state was changed")
|
||||
}
|
||||
val message = data.index.dataGetter?.getFullMessage(commitIndex)
|
||||
if (message != null) return VcsCommitMetadataImpl(commit.id, commit.parents, commit.commitTime, commit.root, commit.subject,
|
||||
commit.author, message, commit.committer, commit.authorTime)
|
||||
return null
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
super.doOKAction()
|
||||
private fun loadCommitData(project: Project, data: VcsLogData, commit: VcsShortCommitDetails): VcsCommitMetadata? {
|
||||
var commitData: VcsCommitMetadata? = null
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||
{
|
||||
try {
|
||||
commitData = VcsLogUtil.getDetails(data, commit.root, commit.id)
|
||||
}
|
||||
catch (e: VcsException) {
|
||||
val error = "Couldn't load changes of " + commit.id.asString()
|
||||
LOG.warn(error, e)
|
||||
val notification = VcsNotifier.STANDARD_NOTIFICATION.createNotification(
|
||||
"", error, NotificationType.ERROR, null)
|
||||
VcsNotifier.getInstance(project).notify(notification)
|
||||
}
|
||||
}, "Loading Commit Message", true, project)
|
||||
return commitData
|
||||
}
|
||||
|
||||
rewordInBackground(project, commit, repository, commitEditor.comment)
|
||||
private fun rewordInBackground(project: Project, commit: VcsCommitMetadata, repository: GitRepository, newMessage: String) {
|
||||
object : Task.Backgroundable(project, "Rewording") {
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
GitRewordOperation(repository, commit, newMessage).execute()
|
||||
}
|
||||
}.queue()
|
||||
}
|
||||
|
||||
private inner class RewordDialog(val project: Project, val commit: VcsCommitMetadata, val repository: GitRepository)
|
||||
: DialogWrapper(project, true) {
|
||||
|
||||
val originalHEAD = repository.info.currentRevision
|
||||
val commitEditor = createCommitEditor()
|
||||
|
||||
init {
|
||||
init()
|
||||
isModal = false
|
||||
title = "Reword Commit"
|
||||
}
|
||||
|
||||
override fun createCenterPanel() =
|
||||
JBUI.Panels.simplePanel(DEFAULT_HGAP, DEFAULT_VGAP)
|
||||
.addToTop(JBLabel("Edit message for commit ${commit.id.toShortString()} by ${getShortPresentation(commit.author)}"))
|
||||
.addToCenter(commitEditor)
|
||||
|
||||
override fun getPreferredFocusedComponent() = commitEditor.editorField
|
||||
|
||||
override fun getDimensionServiceKey() = "GitRewordDialog"
|
||||
|
||||
private fun createCommitEditor(): CommitMessage {
|
||||
val editor = CommitMessage(project, false, false, true)
|
||||
editor.setText(commit.fullMessage)
|
||||
editor.editorField.setCaretPosition(0)
|
||||
editor.editorField.addSettingsProvider { editor ->
|
||||
// display at least several rows for one-line messages
|
||||
val MIN_ROWS = 3
|
||||
if ((editor as EditorImpl).visibleLineCount < MIN_ROWS) {
|
||||
verticalStretch = 1.5F
|
||||
}
|
||||
}
|
||||
return editor
|
||||
}
|
||||
|
||||
override fun doValidate(): ValidationInfo? {
|
||||
if (repository.info.currentRevision != originalHEAD) {
|
||||
return ValidationInfo("Can't reword commit: repository state was changed")
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
super.doOKAction()
|
||||
|
||||
rewordInBackground(project, commit, repository, commitEditor.comment)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user