From aeae26e18b49b8541a1c1b97a4183d5dbc571b5a Mon Sep 17 00:00:00 2001
From: Memory <1448208262@qq.com>
Date: Mon, 8 Jul 2024 13:02:13 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B92020.3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../json/actions/JsonToJavaBeanAction.java | 15 ++++++++-------
.../cn/memoryzy/json/ui/JsonToJavaBeanWindow.java | 4 ++--
.../resources/META-INF/optional/plugin-java.xml | 1 +
src/main/resources/META-INF/plugin.xml | 3 ++-
.../messages/JsonAssistantBundle.properties | 1 +
.../messages/JsonAssistantBundle_zh.properties | 1 +
6 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java b/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
index 1d46153..7012bdc 100644
--- a/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
+++ b/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
@@ -6,12 +6,11 @@
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.annotations.NotNull;
-import java.util.Arrays;
import java.util.Objects;
/**
@@ -33,16 +32,18 @@ public JsonToJavaBeanAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
Project project = event.getProject();
- // 当前 module
- Module module = event.getData(PlatformDataKeys.MODULE);
- if (Objects.isNull(project) || Objects.isNull(module)) {
- return;
- }
// 鼠标右键选择的路径
IdeView ideView = event.getRequiredData(LangDataKeys.IDE_VIEW);
// 文件夹(包)
PsiDirectory directory = ideView.getOrChooseDirectory();
+ if (Objects.isNull(directory)) {
+ LOG.error(JsonAssistantBundle.messageOnSystem("json.to.javabean.null.directory.text"));
+ return;
+ }
+
+ // 当前 module
+ Module module = ModuleUtil.findModuleForPsiElement(directory);
// 窗口
new JsonToJavaBeanWindow(project, directory, module).show();
}
diff --git a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
index 1e624c7..04239f5 100644
--- a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
+++ b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
@@ -81,8 +81,8 @@ public void windowOpened(WindowEvent e) {
label.setText(JsonAssistantBundle.messageOnSystem("json.window.label.text"));
setTitle(JsonAssistantBundle.message("json.to.javabean.title"));
- setOKButtonText(JsonAssistantBundle.message("json.to.javabean.ok.button.text"));
- setCancelButtonText(JsonAssistantBundle.message("json.to.javabean.cancel.button.text"));
+ setOKButtonText(JsonAssistantBundle.messageOnSystem("json.to.javabean.ok.button.text"));
+ setCancelButtonText(JsonAssistantBundle.messageOnSystem("json.to.javabean.cancel.button.text"));
init();
}
diff --git a/src/main/resources/META-INF/optional/plugin-java.xml b/src/main/resources/META-INF/optional/plugin-java.xml
index ae82631..866453a 100644
--- a/src/main/resources/META-INF/optional/plugin-java.xml
+++ b/src/main/resources/META-INF/optional/plugin-java.xml
@@ -3,6 +3,7 @@
+
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index ebcd39d..5e793df 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -25,7 +25,8 @@
-
+
+