From 90c5f43113e425c9552db0d13ebd6a9cd5de903a Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Fri, 8 Nov 2024 00:12:05 +0800
Subject: [PATCH 01/15] [Feat] right click the mouse and the toolbar will
display the corresponding icon
---
.../codesnapidea/actions/PopupDialogAction.kt | 54 +++++++++++++++++++
src/main/kotlin/icons/SdkIcons.kt | 17 ++++++
src/main/resources/META-INF/plugin.xml | 30 +++++++++--
src/main/resources/icons/sdk_16.svg | 7 +++
4 files changed, 103 insertions(+), 5 deletions(-)
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
create mode 100644 src/main/kotlin/icons/SdkIcons.kt
create mode 100644 src/main/resources/icons/sdk_16.svg
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
new file mode 100644
index 0000000..d1bcf86
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
@@ -0,0 +1,54 @@
+package com.github.raoe.codesnapidea.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.Messages
+import javax.swing.Icon
+
+/**
+ * ClassName:PopupDialogAction
+Package:com.github.raoe.codesnapidea.actions
+@DATE:06/11/2024 10:34 pm
+@Author:XuYuanFeng
+TODO:
+ */
+
+class PopupDialogAction: AnAction {
+ constructor() : super() {
+ // This default constructor is used by the IntelliJ Platform framework to instantiate this class based on plugin.xml
+ // declarations. Only needed in `PopupDialogAction` class because a second constructor is overridden.
+ }
+
+ constructor(text: String?, description: String?, icon: Icon?) : super(text, description, icon) {
+ // This constructor is used to support dynamically added menu actions.
+ // It sets the text, description to be displayed for the menu item.
+ // Otherwise, the default AnAction constructor is used by the IntelliJ Platform.
+ }
+
+ override fun actionPerformed(event: AnActionEvent) {
+ // Using the event, create and show a dialog
+ val currentProject: Project? = event.project
+ val message = StringBuilder(event.presentation.text + " Selected123!")
+ // If an element is selected in the editor, add info about it.
+ val selectedElement = event.getData(CommonDataKeys.NAVIGATABLE)
+ if (selectedElement != null) {
+ message.append("\nSelected Element: ").append(selectedElement)
+ }
+ val title = event.presentation.description
+ Messages.showMessageDialog(
+ currentProject,
+ message.toString(),
+ title,
+ Messages.getInformationIcon()
+ )
+ }
+
+ override fun update(event: AnActionEvent) {
+ // Set the availability based on whether a project is open
+ val project: Project? = event.project
+ event.presentation.isEnabledAndVisible = project != null
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/icons/SdkIcons.kt b/src/main/kotlin/icons/SdkIcons.kt
new file mode 100644
index 0000000..d2bfe96
--- /dev/null
+++ b/src/main/kotlin/icons/SdkIcons.kt
@@ -0,0 +1,17 @@
+package icons
+
+import com.intellij.openapi.util.IconLoader
+import javax.swing.Icon
+
+/**
+* ClassName:SdkIcons
+ Package:com.github.raoe.codesnapidea.icons
+ @DATE:06/11/2024 10:33 pm
+ @Author:XuYuanFeng
+ TODO:
+ */
+
+object SdkIcons {
+ @JvmField
+ val Sdk_default_icon: Icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons::class.java)
+}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index a8a4acb..871f8cf 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -2,17 +2,37 @@
com.github.raoe.codesnapidea
CodeSnap.idea
- raoe
-
+
+ xuyuanfeng
+
com.intellij.modules.platform
-
messages.MyBundle
-
-
+
+
+
+
+
diff --git a/src/main/resources/icons/sdk_16.svg b/src/main/resources/icons/sdk_16.svg
new file mode 100644
index 0000000..011462b
--- /dev/null
+++ b/src/main/resources/icons/sdk_16.svg
@@ -0,0 +1,7 @@
+
From 3c304bdff41d51ef8d37fa839c05835924b1a77c Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Fri, 8 Nov 2024 00:21:13 +0800
Subject: [PATCH 02/15] [Feat] right click and get code Text
---
.../codesnapidea/actions/PopupDialogAction.kt | 23 +++++++++++--------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
index d1bcf86..a4ec0a8 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
@@ -3,6 +3,7 @@ package com.github.raoe.codesnapidea.actions
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import javax.swing.Icon
@@ -28,20 +29,22 @@ class PopupDialogAction: AnAction {
}
override fun actionPerformed(event: AnActionEvent) {
- // Using the event, create and show a dialog
- val currentProject: Project? = event.project
- val message = StringBuilder(event.presentation.text + " Selected123!")
- // If an element is selected in the editor, add info about it.
- val selectedElement = event.getData(CommonDataKeys.NAVIGATABLE)
- if (selectedElement != null) {
- message.append("\nSelected Element: ").append(selectedElement)
+ val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
+ val project: Project? = event.getData(CommonDataKeys.PROJECT)
+ val selectedText: String? = editor?.selectionModel?.selectedText
+ val message = StringBuilder()
+ if (!selectedText.isNullOrEmpty()) {
+ message.append(selectedText).append(" Selected123!")
+ } else {
+ message.append("No text selected123!")
}
- val title = event.presentation.description
+ val title = "Selection Info"
+ val icon: Icon = Messages.getInformationIcon()
Messages.showMessageDialog(
- currentProject,
+ project,
message.toString(),
title,
- Messages.getInformationIcon()
+ icon
)
}
From c3b579caab09b5cb51eea602fb573887c9a43290 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Sun, 10 Nov 2024 15:47:20 +0800
Subject: [PATCH 03/15] [Feat] Code Snap Drop-down tab option feature
development
---
.../com/github/raoe/codesnapidea/MyBundle.kt | 1 -
.../actions/DefaultCodeSnapAction.kt | 41 +++++++++++++++++++
.../codesnapidea/actions/JpgCodeSnapAction.kt | 40 ++++++++++++++++++
.../codesnapidea/actions/PopupDialogAction.kt | 5 ++-
.../codesnapidea/actions/SvgCodeSnapAction.kt | 40 ++++++++++++++++++
src/main/resources/META-INF/plugin.xml | 14 ++++---
6 files changed, 132 insertions(+), 9 deletions(-)
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/actions/DefaultCodeSnapAction.kt
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/actions/JpgCodeSnapAction.kt
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/actions/SvgCodeSnapAction.kt
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/MyBundle.kt b/src/main/kotlin/com/github/raoe/codesnapidea/MyBundle.kt
index 5603d17..0d7ec2f 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/MyBundle.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/MyBundle.kt
@@ -6,7 +6,6 @@ import org.jetbrains.annotations.PropertyKey
@NonNls
private const val BUNDLE = "messages.MyBundle"
-//just a test
object MyBundle : DynamicBundle(BUNDLE) {
@JvmStatic
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/DefaultCodeSnapAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/DefaultCodeSnapAction.kt
new file mode 100644
index 0000000..4bad577
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/DefaultCodeSnapAction.kt
@@ -0,0 +1,41 @@
+package com.github.raoe.codesnapidea.actions
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.Messages
+import javax.swing.Icon
+
+/**
+ * ClassName:DefaultCodeSnapAction
+Package:com.github.raoe.codesnapidea.actions
+@DATE:10/11/2024 3:13 pm
+@Author:XuYuanFeng
+TODO:
+ */
+class DefaultCodeSnapAction: AnAction() {
+ /**
+ * default codeSnap
+ */
+ override fun actionPerformed(event: AnActionEvent) {
+ val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
+ val project: Project? = event.getData(CommonDataKeys.PROJECT)
+ val selectedText: String? = editor?.selectionModel?.selectedText
+ val message = StringBuilder()
+ if (!selectedText.isNullOrEmpty()) {
+ message.append(selectedText).append(" Selected!Default")
+ // call the native function
+ } else {
+ message.append("No text selected!")
+ }
+ val title = "Selection Info"
+ val icon: Icon = Messages.getInformationIcon()
+ Messages.showMessageDialog(
+ project,
+ message.toString(),
+ title,
+ icon
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/JpgCodeSnapAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/JpgCodeSnapAction.kt
new file mode 100644
index 0000000..ca30fd2
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/JpgCodeSnapAction.kt
@@ -0,0 +1,40 @@
+package com.github.raoe.codesnapidea.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.Messages
+import javax.swing.Icon
+
+/**
+ * ClassName:JpgCodeSnapAction
+Package:com.github.raoe.codesnapidea.actions
+@DATE:10/11/2024 3:15 pm
+@Author:XuYuanFeng
+TODO:
+ */
+
+class JpgCodeSnapAction: AnAction() {
+ override fun actionPerformed(event: AnActionEvent) {
+ val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
+ val project: Project? = event.getData(CommonDataKeys.PROJECT)
+ val selectedText: String? = editor?.selectionModel?.selectedText
+ val message = StringBuilder()
+ if (!selectedText.isNullOrEmpty()) {
+ message.append(selectedText).append(" Selected!JPG")
+ // call the native function
+ } else {
+ message.append("No text selected!")
+ }
+ val title = "Selection Info"
+ val icon: Icon = Messages.getInformationIcon()
+ Messages.showMessageDialog(
+ project,
+ message.toString(),
+ title,
+ icon
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
index a4ec0a8..01cd6b6 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
@@ -34,9 +34,10 @@ class PopupDialogAction: AnAction {
val selectedText: String? = editor?.selectionModel?.selectedText
val message = StringBuilder()
if (!selectedText.isNullOrEmpty()) {
- message.append(selectedText).append(" Selected123!")
+ message.append(selectedText).append(" Selected!")
+ // call the native function
} else {
- message.append("No text selected123!")
+ message.append("No text selected!")
}
val title = "Selection Info"
val icon: Icon = Messages.getInformationIcon()
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/SvgCodeSnapAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/SvgCodeSnapAction.kt
new file mode 100644
index 0000000..efa6e79
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/SvgCodeSnapAction.kt
@@ -0,0 +1,40 @@
+package com.github.raoe.codesnapidea.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.Messages
+import javax.swing.Icon
+
+/**
+ * ClassName:SvgCodeSnapAction
+Package:com.github.raoe.codesnapidea.actions
+@DATE:10/11/2024 3:14 pm
+@Author:XuYuanFeng
+TODO:
+ */
+
+class SvgCodeSnapAction: AnAction() {
+ override fun actionPerformed(event: AnActionEvent) {
+ val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
+ val project: Project? = event.getData(CommonDataKeys.PROJECT)
+ val selectedText: String? = editor?.selectionModel?.selectedText
+ val message = StringBuilder()
+ if (!selectedText.isNullOrEmpty()) {
+ message.append(selectedText).append(" Selected!SVG")
+ // call the native function
+ } else {
+ message.append("No text selected!")
+ }
+ val title = "Selection Info"
+ val icon: Icon = Messages.getInformationIcon()
+ Messages.showMessageDialog(
+ project,
+ message.toString(),
+ title,
+ icon
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 871f8cf..0a4baab 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -2,10 +2,8 @@
com.github.raoe.codesnapidea
CodeSnap.idea
-
- xuyuanfeng
+
+ xuyuanfeng
com.intellij.modules.platform
messages.MyBundle
@@ -30,9 +28,13 @@
-
-
+
+
+
+
+
+
From 5a491a484afe69de34640ba1ce0706af004315fa Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Sun, 10 Nov 2024 16:14:13 +0800
Subject: [PATCH 04/15] [Feat] Code Snap Drop-down tab option feature
development
---
.../actions/AsciiCodeSnapAction.kt | 39 +++++++++++++++++++
src/main/resources/META-INF/plugin.xml | 7 ++--
2 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/actions/AsciiCodeSnapAction.kt
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/AsciiCodeSnapAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/AsciiCodeSnapAction.kt
new file mode 100644
index 0000000..7df525f
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/AsciiCodeSnapAction.kt
@@ -0,0 +1,39 @@
+package com.github.raoe.codesnapidea.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.Messages
+import javax.swing.Icon
+
+/**
+ * ClassName:AsciiCodeSnapAction
+Package:com.github.raoe.codesnapidea.actions
+@DATE:10/11/2024 4:02 pm
+@Author:XuYuanFeng
+TODO: ASCII CodeSnap
+ */
+class AsciiCodeSnapAction: AnAction() {
+ override fun actionPerformed(event: AnActionEvent) {
+ val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
+ val project: Project? = event.getData(CommonDataKeys.PROJECT)
+ val selectedText: String? = editor?.selectionModel?.selectedText
+ val message = StringBuilder()
+ if (!selectedText.isNullOrEmpty()) {
+ message.append(selectedText).append(" Selected!JPG")
+ // call the native function
+ } else {
+ message.append("No text selected!")
+ }
+ val title = "Selection Info"
+ val icon: Icon = Messages.getInformationIcon()
+ Messages.showMessageDialog(
+ project,
+ message.toString(),
+ title,
+ icon
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 0a4baab..8d2bce5 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -32,9 +32,10 @@
-
-
-
+
+
+
+
From 294ba6193a3e4d050b1e4eca2b5751e206b3c08e Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Sun, 10 Nov 2024 16:38:40 +0800
Subject: [PATCH 05/15] [Feat] Code Snap Drop-down tab option feature
development
---
src/main/resources/META-INF/plugin.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 8d2bce5..f1383f7 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -32,10 +32,10 @@
-
-
-
-
+
+
+
+
From b107cf34ff64d67e3b239df573f6600fed3a9b08 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Sun, 10 Nov 2024 16:51:36 +0800
Subject: [PATCH 06/15] [Feat] Code Snap Drop-down tab option feature
development
---
.../codesnapidea/actions/PopupDialogAction.kt | 20 ++-----------------
src/main/resources/META-INF/plugin.xml | 4 ++++
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
index 01cd6b6..7c0c6b4 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt
@@ -4,6 +4,7 @@ import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import javax.swing.Icon
@@ -29,24 +30,7 @@ class PopupDialogAction: AnAction {
}
override fun actionPerformed(event: AnActionEvent) {
- val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
- val project: Project? = event.getData(CommonDataKeys.PROJECT)
- val selectedText: String? = editor?.selectionModel?.selectedText
- val message = StringBuilder()
- if (!selectedText.isNullOrEmpty()) {
- message.append(selectedText).append(" Selected!")
- // call the native function
- } else {
- message.append("No text selected!")
- }
- val title = "Selection Info"
- val icon: Icon = Messages.getInformationIcon()
- Messages.showMessageDialog(
- project,
- message.toString(),
- title,
- icon
- )
+ ShowSettingsUtil.getInstance().showSettingsDialog(event.getProject(), "OtherSettings");
}
override fun update(event: AnActionEvent) {
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index f1383f7..93eec2d 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -38,4 +38,8 @@
+
+
+
+
From cf3c9ba39e28844b56aca754ff7765cbfb77aaa7 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Wed, 13 Nov 2024 20:59:57 +0800
Subject: [PATCH 07/15] [UPDATE] DOC update
---
README.md | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/README.md b/README.md
index 3295bc9..be9536e 100644
--- a/README.md
+++ b/README.md
@@ -4,26 +4,6 @@
[![Version](https://img.shields.io/jetbrains/plugin/v/MARKETPLACE_ID.svg)](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID)
[![Downloads](https://img.shields.io/jetbrains/plugin/d/MARKETPLACE_ID.svg)](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID)
-## Template ToDo list
-- [x] Create a new [IntelliJ Platform Plugin Template][template] project.
-- [ ] Get familiar with the [template documentation][template].
-- [ ] Adjust the [pluginGroup](./gradle.properties) and [pluginName](./gradle.properties), as well as the [id](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin).
-- [ ] Adjust the plugin description in `README` (see [Tips][docs:plugin-description])
-- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate).
-- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time.
-- [ ] Set the `MARKETPLACE_ID` in the above README badges. You can obtain it once the plugin is published to JetBrains Marketplace.
-- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables).
-- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate).
-- [ ] Click the Watch button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes.
-
-
-This Fancy IntelliJ Platform Plugin is going to be your implementation of the brilliant ideas that you have.
-
-This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be extracted by the [Gradle](/build.gradle.kts) during the build process.
-
-To keep everything working, do not remove `` sections.
-
-
## Installation
- Using the IDE built-in plugin system:
From 990db10b98f7341e504b368d172a0d76f9e6aa88 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Wed, 13 Nov 2024 21:20:37 +0800
Subject: [PATCH 08/15] Revert "[UPDATE] DOC update"
This reverts commit cf3c9ba39e28844b56aca754ff7765cbfb77aaa7.
---
README.md | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/README.md b/README.md
index be9536e..3295bc9 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,26 @@
[![Version](https://img.shields.io/jetbrains/plugin/v/MARKETPLACE_ID.svg)](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID)
[![Downloads](https://img.shields.io/jetbrains/plugin/d/MARKETPLACE_ID.svg)](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID)
+## Template ToDo list
+- [x] Create a new [IntelliJ Platform Plugin Template][template] project.
+- [ ] Get familiar with the [template documentation][template].
+- [ ] Adjust the [pluginGroup](./gradle.properties) and [pluginName](./gradle.properties), as well as the [id](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin).
+- [ ] Adjust the plugin description in `README` (see [Tips][docs:plugin-description])
+- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate).
+- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time.
+- [ ] Set the `MARKETPLACE_ID` in the above README badges. You can obtain it once the plugin is published to JetBrains Marketplace.
+- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables).
+- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate).
+- [ ] Click the Watch button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes.
+
+
+This Fancy IntelliJ Platform Plugin is going to be your implementation of the brilliant ideas that you have.
+
+This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be extracted by the [Gradle](/build.gradle.kts) during the build process.
+
+To keep everything working, do not remove `` sections.
+
+
## Installation
- Using the IDE built-in plugin system:
From 19c04706db217ad015ad7dbd2faf9a49264f5810 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Wed, 13 Nov 2024 22:14:44 +0800
Subject: [PATCH 09/15] [feature_dev_0.1] CodeSnap Configuration Setting
function develop
---
.run/Run Plugin.run.xml | 6 +-
.../configuration/CodeSnapConfiguration.kt | 54 +++++++++++
.../raoe/codesnapidea/ui/CodeSnapSettings.kt | 39 ++++++++
.../codesnapidea/ui/CodeSnapSettingsUI.kt | 92 +++++++++++++++++++
src/main/resources/META-INF/plugin.xml | 2 +-
5 files changed, 189 insertions(+), 4 deletions(-)
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnapConfiguration.kt
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt
create mode 100644 src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml
index 00a760e..fe579fb 100644
--- a/.run/Run Plugin.run.xml
+++ b/.run/Run Plugin.run.xml
@@ -5,7 +5,7 @@
-
+
@@ -19,7 +19,7 @@
true
true
false
- false
+ false
-
+
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnapConfiguration.kt b/src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnapConfiguration.kt
new file mode 100644
index 0000000..b6151e0
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnapConfiguration.kt
@@ -0,0 +1,54 @@
+package com.github.raoe.codesnapidea.configuration;
+
+import com.github.raoe.codesnapidea.ui.CodeSnapSettingsUI
+import com.intellij.openapi.components.BaseState
+import com.intellij.openapi.options.Configurable
+import com.intellij.openapi.options.ConfigurationException
+import org.jetbrains.annotations.Nls
+import org.jetbrains.annotations.Nullable
+import javax.swing.JComponent
+
+
+/**
+ * ClassName:CodeSnapConfiguration
+ * Package:com.github.raoe.codesnapidea.configuration
+ *
+ * @DATE:13/11/2024 9:34 pm
+ * @Author:XuYuanFeng TODO:
+ */
+class CodeSnapConfiguration: Configurable {
+ private var mySettingsUI: CodeSnapSettingsUI? = null
+ @Nls
+ override fun getDisplayName(): String {
+ return "CodeSnap Configuration" // 配置页面的显示名称
+ }
+
+ @Nullable
+ override fun getHelpTopic(): String? {
+ return "help-topic-id" // 配置页面的帮助主题ID
+ }
+
+ @Nullable
+ override fun createComponent(): JComponent? {
+ mySettingsUI = CodeSnapSettingsUI()
+ return mySettingsUI?.getPanel() // 返回配置界面的组件
+ }
+
+ override fun isModified(): Boolean {
+ return mySettingsUI?.isModified() ?: false // 检查设置是否被修改
+ }
+
+ @Throws(ConfigurationException::class)
+ override fun apply() {
+ mySettingsUI?.apply() // 应用设置
+ }
+
+ override fun reset() {
+ mySettingsUI?.reset() // 重置设置
+ }
+
+ override fun disposeUIResources() {
+ mySettingsUI = null // 释放UI资源
+ }
+
+}
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt
new file mode 100644
index 0000000..45e62f3
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt
@@ -0,0 +1,39 @@
+package com.github.raoe.codesnapidea.ui
+
+import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.State
+import com.intellij.openapi.components.Storage
+
+/**
+ * ClassName:CodeSnapSettings
+Package:com.github.raoe.codesnapidea.ui
+@DATE:13/11/2024 10:11 pm
+@Author:XuYuanFeng
+TODO:
+ */
+@State(name = "CodeSnapSettings", storages = [Storage("codeSnapSettings.xml")])
+class CodeSnapSettings : PersistentStateComponent {
+ class State(var shortcutEnabled: Boolean = false, var shortcut: String = "defaultShortcut", var defaultSavePath: String = "/default/path")
+
+ private var state = State()
+
+ override fun getState(): State {
+ return state
+ }
+
+ override fun loadState(state: State) {
+ this.state = state
+ }
+
+ var shortcutEnabled: Boolean
+ get() = state.shortcutEnabled
+ set(value) { state.shortcutEnabled = value }
+
+ var shortcut: String
+ get() = state.shortcut
+ set(value) { state.shortcut = value }
+
+ var defaultSavePath: String
+ get() = state.defaultSavePath
+ set(value) { state.defaultSavePath = value }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
new file mode 100644
index 0000000..884d5fa
--- /dev/null
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
@@ -0,0 +1,92 @@
+package com.github.raoe.codesnapidea.ui;
+
+import com.intellij.ide.util.PropertiesComponent
+import com.intellij.openapi.components.ServiceManager
+import com.intellij.openapi.diagnostic.thisLogger
+import java.awt.FlowLayout
+import java.io.File
+import java.util.*
+import javax.swing.*
+
+/**
+ * ClassName:CodeSnapSettingsUI
+ * Package:com.github.raoe.codesnapidea.ui
+ *
+ * @DATE:13/11/2024 9:38 pm
+ * @Author:XuYuanFeng TODO:
+ */
+class CodeSnapSettingsUI {
+ private val properties: PropertiesComponent = ServiceManager.getService(PropertiesComponent::class.java)
+ var shortcutEnabled: Boolean
+ get() = properties.getBoolean("codeSnap.shortcutEnabled", false)
+ set(value) = properties.setValue("codeSnap.shortcutEnabled", value)
+
+ var shortcut: String
+ get() = properties.getValue("codeSnap.shortcut", "defaultShortcut")
+ set(value) = properties.setValue("codeSnap.shortcut", value)
+
+ var defaultSavePath: String
+ get() = properties.getValue("codeSnap.defaultSavePath", "/default/path")
+ set(value) = properties.setValue("codeSnap.defaultSavePath", value)
+
+
+ private val myPanel: JPanel = JPanel(FlowLayout())
+ private val myShortcutField: JCheckBox = JCheckBox("Enable Shortcut")
+ private val myShortcutTextField: JTextField = JTextField(20)
+ private val mySavePathField: JTextField = JTextField(20)
+ private val mySavePathButton: JButton = JButton("Browse...")
+ init {
+// myPanel.add(myShortcutField)
+// myPanel.add(myShortcutTextField)
+ myPanel.add(mySavePathField)
+ myPanel.add(mySavePathButton)
+ mySavePathButton.addActionListener {
+ val fileChooser = JFileChooser()
+ fileChooser.selectedFile = File(mySavePathField.text)
+ if (fileChooser.showOpenDialog(myPanel) == JFileChooser.APPROVE_OPTION) {
+ mySavePathField.text = fileChooser.selectedFile.absolutePath
+ }
+ }
+ }
+
+ fun getPanel(): JPanel {
+ return myPanel
+ }
+
+ fun isModified(): Boolean {
+ // 检查是否修改了设置
+ return myShortcutField.isSelected != shortcutEnabled ||
+ myShortcutTextField.text != shortcut ||
+ mySavePathField.text != defaultSavePath
+ }
+
+ fun apply() {
+ // 应用设置的逻辑
+ // 这里需要具体实现
+ shortcutEnabled = myShortcutField.isSelected
+ shortcut = myShortcutTextField.text
+ defaultSavePath = mySavePathField.text
+ thisLogger().info("app apply>>>>>>>>>>>>>>>>>>>>>>>")
+ }
+
+ fun reset() {
+ // 重置设置的逻辑
+ // 这里需要具体实现
+ myShortcutField.isSelected = shortcutEnabled
+ myShortcutTextField.text = shortcut
+ mySavePathField.text = defaultSavePath
+ thisLogger().info("app reset>>>>>>>>>>>>>>>>>>>>>>>")
+ }
+
+ fun saveSettings() {
+ val properties = ServiceManager.getService(PropertiesComponent::class.java)
+ properties.setValue("codeSnapShortcut", myShortcutTextField.text)
+ properties.setValue("codeSnapSavePath", mySavePathField.text)
+ }
+
+ fun loadSettings() {
+ val properties = ServiceManager.getService(PropertiesComponent::class.java)
+ myShortcutTextField.text = properties.getValue("codeSnapShortcut", "defaultShortcut")
+ mySavePathField.text = properties.getValue("codeSnapSavePath", "defaultSavePath")
+ }
+}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 93eec2d..ac98899 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -40,6 +40,6 @@
-
+
From bb20a8ef48c7b6b1d037de1abc59b78c15c7b5c7 Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Wed, 13 Nov 2024 22:34:59 +0800
Subject: [PATCH 10/15] [feature_dev_0.1] CodeSnap Configuration Setting
function develop
---
.../github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
index 884d5fa..9ddeb79 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
@@ -31,13 +31,11 @@ class CodeSnapSettingsUI {
private val myPanel: JPanel = JPanel(FlowLayout())
- private val myShortcutField: JCheckBox = JCheckBox("Enable Shortcut")
- private val myShortcutTextField: JTextField = JTextField(20)
+ private val myShortcutField: JCheckBox = JCheckBox("Default Save Path:")
private val mySavePathField: JTextField = JTextField(20)
private val mySavePathButton: JButton = JButton("Browse...")
init {
-// myPanel.add(myShortcutField)
-// myPanel.add(myShortcutTextField)
+ myPanel.add(myShortcutField)
myPanel.add(mySavePathField)
myPanel.add(mySavePathButton)
mySavePathButton.addActionListener {
@@ -56,7 +54,6 @@ class CodeSnapSettingsUI {
fun isModified(): Boolean {
// 检查是否修改了设置
return myShortcutField.isSelected != shortcutEnabled ||
- myShortcutTextField.text != shortcut ||
mySavePathField.text != defaultSavePath
}
@@ -64,7 +61,6 @@ class CodeSnapSettingsUI {
// 应用设置的逻辑
// 这里需要具体实现
shortcutEnabled = myShortcutField.isSelected
- shortcut = myShortcutTextField.text
defaultSavePath = mySavePathField.text
thisLogger().info("app apply>>>>>>>>>>>>>>>>>>>>>>>")
}
@@ -73,20 +69,17 @@ class CodeSnapSettingsUI {
// 重置设置的逻辑
// 这里需要具体实现
myShortcutField.isSelected = shortcutEnabled
- myShortcutTextField.text = shortcut
mySavePathField.text = defaultSavePath
thisLogger().info("app reset>>>>>>>>>>>>>>>>>>>>>>>")
}
fun saveSettings() {
val properties = ServiceManager.getService(PropertiesComponent::class.java)
- properties.setValue("codeSnapShortcut", myShortcutTextField.text)
properties.setValue("codeSnapSavePath", mySavePathField.text)
}
fun loadSettings() {
val properties = ServiceManager.getService(PropertiesComponent::class.java)
- myShortcutTextField.text = properties.getValue("codeSnapShortcut", "defaultShortcut")
mySavePathField.text = properties.getValue("codeSnapSavePath", "defaultSavePath")
}
}
From 3c6c9f12ea47ce3e9c533ee4765dea2a7ff89b7a Mon Sep 17 00:00:00 2001
From: xuyuanfeng <986771570@qq.com>
Date: Sun, 17 Nov 2024 15:35:31 +0800
Subject: [PATCH 11/15] [feature_dev_0.1] develop the Default Save Path Text
---
.../codesnapidea/ui/CodeSnapSettingsUI.kt | 28 +++++++------------
src/main/resources/META-INF/plugin.xml | 2 +-
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
index 9ddeb79..805d31a 100644
--- a/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
+++ b/src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettingsUI.kt
@@ -3,6 +3,7 @@ package com.github.raoe.codesnapidea.ui;
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.diagnostic.thisLogger
+import org.jdesktop.swingx.JXTextField
import java.awt.FlowLayout
import java.io.File
import java.util.*
@@ -17,25 +18,17 @@ import javax.swing.*
*/
class CodeSnapSettingsUI {
private val properties: PropertiesComponent = ServiceManager.getService(PropertiesComponent::class.java)
- var shortcutEnabled: Boolean
- get() = properties.getBoolean("codeSnap.shortcutEnabled", false)
- set(value) = properties.setValue("codeSnap.shortcutEnabled", value)
-
- var shortcut: String
- get() = properties.getValue("codeSnap.shortcut", "defaultShortcut")
- set(value) = properties.setValue("codeSnap.shortcut", value)
-
- var defaultSavePath: String
+ private var defaultSavePath: String
get() = properties.getValue("codeSnap.defaultSavePath", "/default/path")
set(value) = properties.setValue("codeSnap.defaultSavePath", value)
-
-
- private val myPanel: JPanel = JPanel(FlowLayout())
- private val myShortcutField: JCheckBox = JCheckBox("Default Save Path:")
+ private val myPanel: JPanel = JPanel(FlowLayout(FlowLayout.LEFT))
private val mySavePathField: JTextField = JTextField(20)
private val mySavePathButton: JButton = JButton("Browse...")
+ private val mySavePathLabel: JLabel = JLabel("默认保存路径:")
init {
- myPanel.add(myShortcutField)
+ // 使用 defaultSavePath 属性来设置 JTextField 的值
+ defaultSavePath = "/default/path"
+ myPanel.add(mySavePathLabel)
myPanel.add(mySavePathField)
myPanel.add(mySavePathButton)
mySavePathButton.addActionListener {
@@ -43,6 +36,8 @@ class CodeSnapSettingsUI {
fileChooser.selectedFile = File(mySavePathField.text)
if (fileChooser.showOpenDialog(myPanel) == JFileChooser.APPROVE_OPTION) {
mySavePathField.text = fileChooser.selectedFile.absolutePath
+ // 更新 defaultSavePath 属性
+ defaultSavePath = fileChooser.selectedFile.absolutePath
}
}
}
@@ -53,14 +48,12 @@ class CodeSnapSettingsUI {
fun isModified(): Boolean {
// 检查是否修改了设置
- return myShortcutField.isSelected != shortcutEnabled ||
- mySavePathField.text != defaultSavePath
+ return mySavePathField.text != defaultSavePath
}
fun apply() {
// 应用设置的逻辑
// 这里需要具体实现
- shortcutEnabled = myShortcutField.isSelected
defaultSavePath = mySavePathField.text
thisLogger().info("app apply>>>>>>>>>>>>>>>>>>>>>>>")
}
@@ -68,7 +61,6 @@ class CodeSnapSettingsUI {
fun reset() {
// 重置设置的逻辑
// 这里需要具体实现
- myShortcutField.isSelected = shortcutEnabled
mySavePathField.text = defaultSavePath
thisLogger().info("app reset>>>>>>>>>>>>>>>>>>>>>>>")
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index ac98899..d6a4569 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -17,7 +17,7 @@
-