Skip to content

Commit 212234f

Browse files
committed
feat: remove button after success and use apply
1 parent ee930df commit 212234f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/processor/EditFileCommandProcessor.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class EditFileCommandProcessor(private val project: Project) {
3939
}
4040

4141
if (isAutoSketchMode) {
42-
executeEditFileCommand(currentText, button, onDiffSketchCreated)
42+
executeEditFileCommand(currentText, button, panel, onDiffSketchCreated)
4343
} else {
4444
button.addActionListener {
45-
executeEditFileCommand(currentText, button, onDiffSketchCreated)
45+
executeEditFileCommand(currentText, button, panel, onDiffSketchCreated)
4646
}
4747
}
4848

@@ -65,6 +65,7 @@ class EditFileCommandProcessor(private val project: Project) {
6565
private fun executeEditFileCommand(
6666
currentText: String,
6767
button: JButton,
68+
panel: JPanel,
6869
onDiffSketchCreated: (SingleFileDiffSketch) -> Unit
6970
) {
7071
val isAutoSketchMode = AutoSketchMode.getInstance(project).isEnable
@@ -74,22 +75,24 @@ class EditFileCommandProcessor(private val project: Project) {
7475

7576
executeEditFileCommandAsync(project, currentText) { result ->
7677
runInEdt {
77-
handleExecutionResult(result, button, onDiffSketchCreated)
78+
handleExecutionResult(result, button, panel, onDiffSketchCreated)
7879
}
7980
}
8081
}
8182

8283
private fun handleExecutionResult(
8384
result: EditResult?,
8485
button: JButton,
86+
panel: JPanel,
8587
onDiffSketchCreated: (SingleFileDiffSketch) -> Unit
8688
) {
8789
when (result) {
8890
is EditResult.Success -> {
8991
val diffSketch = createSingleFileDiffSketch(result.targetFile, result.patch)
9092
onDiffSketchCreated(diffSketch)
91-
button.text = "Executed"
92-
button.icon = AllIcons.Actions.Checked
93+
panel.remove(button)
94+
panel.revalidate()
95+
panel.repaint()
9396
}
9497

9598
is EditResult.Error -> {

0 commit comments

Comments
 (0)