Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] right click the mouse and the toolbar will display the corresp… #8

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .run/Run Plugin.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="scriptParameters" value="--stacktrace" />
<option name="taskDescriptions">
<list />
</option>
Expand All @@ -19,7 +19,7 @@
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<ForceTestExec>false</ForceTestExec>
<method v="2" />
</configuration>
</component>
</component>
Binary file added images/CodeSnap.idea原型图V0.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/main/kotlin/com/github/raoe/codesnapidea/MyBundle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.jetbrains.annotations.PropertyKey

@NonNls
private const val BUNDLE = "messages.MyBundle"
//just a test
object MyBundle : DynamicBundle(BUNDLE) {

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.github.raoe.codesnapidea.actions

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys

Check warning on line 5 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.editor.Editor

Check warning on line 6 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages

Check warning on line 9 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
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() {

Check warning on line 21 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Constructor is never used
// 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) {

Check warning on line 26 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Constructor is never used
// 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) {
ShowSettingsUtil.getInstance().showSettingsDialog(event.getProject(), "OtherSettings");

Check warning on line 33 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant semicolon

Redundant semicolon

Check notice on line 33 in src/main/kotlin/com/github/raoe/codesnapidea/actions/PopupDialogAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Accessor call that can be replaced with property access syntax

Use of getter method instead of property access syntax
}

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
}

}
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.github.raoe.codesnapidea.configuration;

Check warning on line 1 in src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnap.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant semicolon

Redundant semicolon

import CodeSnapSettingsUI

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 CodeSnap: Configurable {
private var mySettingsUI: CodeSnapSettingsUI? = null
@Nls
override fun getDisplayName(): String {
return "CodeSnap Configuration" // 配置页面的显示名称
}

@Nullable
override fun getHelpTopic(): String? {

Check warning on line 27 in src/main/kotlin/com/github/raoe/codesnapidea/configuration/CodeSnap.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant nullable return type

'getHelpTopic' always returns non-null type
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资源
}

}
Original file line number Diff line number Diff line change
@@ -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<CodeSnapSettings.State> {

Check warning on line 15 in src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "CodeSnapSettings" is never used
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

Check warning on line 28 in src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "shortcutEnabled" is never used
get() = state.shortcutEnabled
set(value) { state.shortcutEnabled = value }

var shortcut: String

Check warning on line 32 in src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "shortcut" is never used
get() = state.shortcut
set(value) { state.shortcut = value }

var defaultSavePath: String

Check warning on line 36 in src/main/kotlin/com/github/raoe/codesnapidea/ui/CodeSnapSettings.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "defaultSavePath" is never used
get() = state.defaultSavePath
set(value) { state.defaultSavePath = value }
}
Loading
Loading