generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(diff-ui): implement apply patch from clipboard dialog and enhanc…
…e SingleFileDiffLangSketch #153 Add a new dialog class `MyApplyPatchFromClipboardDialog` to handle the application of patches from the clipboard. This includes a custom checkbox for on-the-fly analysis option. Update `SingleFileDiffLangSketch` by: - Refactoring code for better readability. - Implementing progress indicator for rollback action. - Enhancing the rollback functionality to handle exceptions. - Changing the mouse event behavior for a better UI experience.
- Loading branch information
Showing
2 changed files
with
70 additions
and
45 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
core/src/main/kotlin/com/phodal/shirecore/ui/viewer/MyApplyPatchFromClipboardDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.phodal.shirecore.ui.viewer | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vcs.VcsApplicationSettings | ||
import com.intellij.openapi.vcs.VcsBundle | ||
import com.intellij.openapi.vcs.changes.patch.ApplyPatchDefaultExecutor | ||
import com.intellij.openapi.vcs.changes.patch.ApplyPatchDifferentiatedDialog | ||
import com.intellij.openapi.vcs.changes.patch.ApplyPatchMode | ||
import com.intellij.testFramework.LightVirtualFile | ||
import java.awt.event.ActionEvent | ||
import java.awt.event.KeyEvent | ||
import javax.swing.JCheckBox | ||
import javax.swing.JComponent | ||
|
||
class MyApplyPatchFromClipboardDialog(project: Project, clipboardText: String) : | ||
ApplyPatchDifferentiatedDialog( | ||
project, ApplyPatchDefaultExecutor(project), emptyList(), ApplyPatchMode.APPLY_PATCH_IN_MEMORY, | ||
LightVirtualFile("clipboardPatchFile", clipboardText), null, null, //NON-NLS | ||
null, null, null, false | ||
) { | ||
override fun createDoNotAskCheckbox(): JComponent? { | ||
return createAnalyzeOnTheFlyOptionPanel() | ||
} | ||
|
||
companion object { | ||
private fun createAnalyzeOnTheFlyOptionPanel(): JCheckBox { | ||
val removeOptionCheckBox = | ||
JCheckBox(VcsBundle.message("patch.apply.analyze.from.clipboard.on.the.fly.checkbox")) | ||
removeOptionCheckBox.mnemonic = KeyEvent.VK_L | ||
removeOptionCheckBox.isSelected = VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY | ||
removeOptionCheckBox.addActionListener { e: ActionEvent? -> | ||
VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY = removeOptionCheckBox.isSelected | ||
} | ||
return removeOptionCheckBox | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters