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 @@ - + + diff --git a/src/main/resources/messages/JsonAssistantBundle.properties b/src/main/resources/messages/JsonAssistantBundle.properties index 33d630f..c26ab62 100644 --- a/src/main/resources/messages/JsonAssistantBundle.properties +++ b/src/main/resources/messages/JsonAssistantBundle.properties @@ -13,6 +13,7 @@ json.to.javabean.invalid.json.text=Invalid Json json.to.javabean.already.exists.text=The ''{0}'' class already exists json.to.javabean.illegal.class.name.text=Illegal class name json.to.javabean.not.applicable.class.name.text=''{0}'' cannot be used for class names +json.to.javabean.null.directory.text=Please select the package to open the window! json.window.label.text= Class Name: json.window.placeholder.text=Please enter json... action.json.processing.text=_Json Processing diff --git a/src/main/resources/messages/JsonAssistantBundle_zh.properties b/src/main/resources/messages/JsonAssistantBundle_zh.properties index 89a44f7..6d5507f 100644 --- a/src/main/resources/messages/JsonAssistantBundle_zh.properties +++ b/src/main/resources/messages/JsonAssistantBundle_zh.properties @@ -13,6 +13,7 @@ json.to.javabean.invalid.json.text=\u65e0\u6548\u0020\u004a\u0053\u004f\u004e json.to.javabean.already.exists.text=''{0}''\u0020\u7c7b\u5df2\u5b58\u5728 json.to.javabean.illegal.class.name.text=\u975e\u6cd5\u7c7b\u540d json.to.javabean.not.applicable.class.name.text=''{0}''\u0020\u4e0d\u80fd\u7528\u4e8e\u7c7b\u540d +json.to.javabean.null.directory.text=\u8bf7\u9009\u4e2d\u5305\u4ee5\u6253\u5f00\u7a97\u53e3\uff01 json.window.label.text=\u0020\u0020\u7c7b\u540d\uff1a json.window.placeholder.text=\u8bf7\u8f93\u5165\u0020\u004a\u0073\u006f\u006e\u002e\u002e\u002e action.json.processing.text=\u004a\u0073\u006f\u006e\u0020\u5904\u7406