diff --git a/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java b/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
index ca172a1..24385ea 100644
--- a/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
+++ b/src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
@@ -9,6 +9,7 @@
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;
@@ -39,7 +40,6 @@ public void actionPerformed(@NotNull AnActionEvent event) {
// 文件夹(包)
PsiDirectory directory = ideView.getOrChooseDirectory();
if (Objects.isNull(directory)) {
- LOG.error(JsonAssistantBundle.messageOnSystem("json.to.javabean.null.directory.text"));
return;
}
@@ -62,8 +62,20 @@ private boolean isAvailable(DataContext dataContext) {
return false;
}
+ boolean enabled = false;
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
- return project != null && view != null && view.getDirectories().length != 0;
+ if (project != null && view != null && view.getDirectories().length != 0) {
+ PsiDirectory chooseDirectory = view.getOrChooseDirectory();
+ if (Objects.nonNull(chooseDirectory)) {
+ VirtualFile virtualFile = chooseDirectory.getVirtualFile();
+
+ // todo 未找到解决方案
+ String path = virtualFile.getPath();
+ enabled = path.contains("/test/java") || path.contains("/main/java") || path.contains("/test/kotlin") || path.contains("/main/kotlin");
+ }
+ }
+
+ return enabled;
}
}
diff --git a/src/main/java/cn/memoryzy/json/constant/PluginConstant.java b/src/main/java/cn/memoryzy/json/constant/PluginConstant.java
index 6d7cdc2..7e25c61 100644
--- a/src/main/java/cn/memoryzy/json/constant/PluginConstant.java
+++ b/src/main/java/cn/memoryzy/json/constant/PluginConstant.java
@@ -8,4 +8,6 @@ public class PluginConstant {
public static final String PLUGIN_ID = "cn.memoryzy.json.Json-Assistant";
+ public static final String JSON_EXAMPLE = "{\"name\": \"王铁柱\", \"age\": 18}";
+
}
diff --git a/src/main/java/cn/memoryzy/json/ui/JsonStructureWindow.java b/src/main/java/cn/memoryzy/json/ui/JsonStructureWindow.java
index 5719a16..2273e5f 100644
--- a/src/main/java/cn/memoryzy/json/ui/JsonStructureWindow.java
+++ b/src/main/java/cn/memoryzy/json/ui/JsonStructureWindow.java
@@ -223,7 +223,7 @@ public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean sel
nodeTypeStr = "object";
squareBracketsEnd = "]";
sizeStrPre = " (";
- sizeStr = size + " " + JsonAssistantBundle.message("json.structure.window.size.obj.text");
+ sizeStr = size + " " + JsonAssistantBundle.messageOnSystem("json.structure.window.size.obj.text");
sizeStrPost = ")";
icon = JsonAssistantIcons.Structure.JSON_OBJECT;
@@ -235,7 +235,7 @@ public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean sel
nodeTypeStr = "array";
squareBracketsEnd = "]";
sizeStrPre = " (";
- sizeStr = size + " " + JsonAssistantBundle.message("json.structure.window.size.array.text");
+ sizeStr = size + " " + JsonAssistantBundle.messageOnSystem("json.structure.window.size.array.text");
sizeStrPost = ")";
icon = JsonAssistantIcons.Structure.JSON_ARRAY;
@@ -247,7 +247,7 @@ public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean sel
nodeTypeStr = "array_object";
squareBracketsEnd = "]";
sizeStrPre = " (";
- sizeStr = size + " " + JsonAssistantBundle.message("json.structure.window.size.obj.text");
+ sizeStr = size + " " + JsonAssistantBundle.messageOnSystem("json.structure.window.size.obj.text");
sizeStrPost = ")";
icon = JsonAssistantIcons.Structure.JSON_OBJECT_ITEM;
diff --git a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.form b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.form
index f903d93..f1dc3f1 100644
--- a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.form
+++ b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.form
@@ -17,41 +17,49 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
index 04239f5..9825da4 100644
--- a/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
+++ b/src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
@@ -8,6 +8,7 @@
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.memoryzy.json.bundles.JsonAssistantBundle;
+import cn.memoryzy.json.constant.PluginConstant;
import cn.memoryzy.json.enums.LombokAnnotationEnum;
import cn.memoryzy.json.ui.basic.MultiRowLanguageTextField;
import cn.memoryzy.json.ui.basic.TextFieldErrorPopupDecorator;
@@ -91,7 +92,7 @@ private void createUIComponents() {
// 声明 Json 类型编辑器
jsonTextField = new MultiRowLanguageTextField(Json5Language.INSTANCE, project, "", true);
jsonTextField.setFont(new Font("Consolas", Font.PLAIN, 15));
- jsonTextField.setPlaceholder(JsonAssistantBundle.messageOnSystem("json.window.placeholder.text"));
+ jsonTextField.setPlaceholder(JsonAssistantBundle.messageOnSystem("json.window.placeholder.text") + PluginConstant.JSON_EXAMPLE);
}
@Override
diff --git a/src/main/resources/messages/JsonAssistantBundle.properties b/src/main/resources/messages/JsonAssistantBundle.properties
index d297347..c9fcef8 100644
--- a/src/main/resources/messages/JsonAssistantBundle.properties
+++ b/src/main/resources/messages/JsonAssistantBundle.properties
@@ -13,38 +13,37 @@ 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
-action.json.processing.description=Perform various Json processing.
-action.json.format.text=Json Formatting
-action.json.format.description=Beautify json.
-action.json.compress.text=Json Compressing
-action.json.compress.description=Compress the Json into a single line.
-action.json.structure.text=Json Structuring
-action.json.structure.description=Convert Json to tree.
+json.window.label.text=Class Name:
+json.window.placeholder.text=Examples:
+action.json.processing.text=Json Pr_ocessing
+action.json.processing.description=Perform various Json processing
+action.json.format.text=Json Beautify
+action.json.format.description=Beautify JSON.
+action.json.compress.text=Json Minify
+action.json.compress.description=Compress the Json into a single line
+action.json.structure.text=Json Tree Structure
+action.json.structure.description=Convert Json to a tree structure
action.collapse.all.text=Collapse All
-action.collapse.all.description=Collapse all nodes.
+action.collapse.all.description=Collapse all nodes
action.expand.all.text=Expand All
action.expand.all.description=Expand all nodes
action.json.structure.window.copy.key.text=Copy Key
-action.json.structure.window.copy.key.description=Copy keys to clipboard.
+action.json.structure.window.copy.key.description=Copy keys to clipboard
action.json.structure.window.copy.value.text=Copy Value
action.json.structure.window.copy.value.description=Copy values to the clipboard.
action.json.structure.window.copy.key.value.text=Copy Key-Value
-action.json.structure.window.copy.key.value.description=Copy key-value to the clipboard.
+action.json.structure.window.copy.key.value.description=Copy key-value to the clipboard
action.json.structure.window.expand.multi.text=Expand
-action.json.structure.window.expand.multi.description=Expand the node and its children.
+action.json.structure.window.expand.multi.description=Expand the node and its children
action.json.structure.window.collapse.multi.text=Collapse
-action.json.structure.window.collapse.multi.description=Collapses the node and its children.
+action.json.structure.window.collapse.multi.description=Collapses the node and its children
action.json.structure.window.remove.text=Remove...
-action.json.structure.window.remove.description=Remove the node.
+action.json.structure.window.remove.description=Remove the node
action.javabean.to.json.text=_Convert to JSON
-action.javabean.to.json.description=Convert JavaBean To Json.
-action.to.json.javabean.text=_Java Class from Json
-action.to.json.javabean.description=Convert Json To JavaBean.
+action.javabean.to.json.description=Convert JavaBean To Json
+action.to.json.javabean.text=Java Class _from Json
+action.to.json.javabean.description=Convert Json To JavaBean
action.donate.text=Donate
action.donate.description=If you find the plugin helpful to you, please consider donating to support me, your support will be my motivation to continue to work hard!
action.kt.class.property.to.json.text=_Convert to JSON
-action.kt.class.property.to.json.description=Convert the data class to json.
\ No newline at end of file
+action.kt.class.property.to.json.description=Convert the kotlin property to Json
\ No newline at end of file
diff --git a/src/main/resources/messages/JsonAssistantBundle_zh.properties b/src/main/resources/messages/JsonAssistantBundle_zh.properties
index acb9f7c..3a8251d 100644
--- a/src/main/resources/messages/JsonAssistantBundle_zh.properties
+++ b/src/main/resources/messages/JsonAssistantBundle_zh.properties
@@ -1,10 +1,10 @@
json.window.title=\u004a\u0073\u006f\u006e\u0020\u7a97\u53e3
ok.button.text=\u786e\u5b9a
popup.json.processing.title=\u529f\u80fd
-json.structure.window.title=\u004a\u0073\u006f\u006e\u0020\u7ed3\u6784
+json.structure.window.title=\u004a\u0073\u006f\u006e\u0020\u6811
json.structure.window.size.obj.text=\u5c5e\u6027
json.structure.window.size.array.text=\u5143\u7d20
-notify.javabean.to.json.tip.recursion=\u8be5\u7c7b\u5c5e\u6027\u9012\u5f52\u65f6\u6df1\u5ea6\u8fc7\u5927\uff0c\u65e0\u6cd5\u7ee7\u7eed\uff01
+notify.javabean.to.json.tip.recursion=\u8be5\u7c7b\u5c5e\u6027\u9012\u5f52\u8fc7\u6df1\uff0c\u65e0\u6cd5\u7ee7\u7eed\uff01
notify.javabean.to.json.tip.copy=\u5df2\u62f7\u8d1d\u81f3\u526a\u8d34\u677f\uff01
json.to.javabean.title=\u004a\u0073\u006f\u006e\u0020\u8f6c\u4e3a\u0020\u004a\u0061\u0076\u0061\u0042\u0065\u0061\u006e
json.to.javabean.ok.button.text=\u751f\u6210
@@ -13,17 +13,16 @@ 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
+json.window.label.text=\u7c7b\u540d\u003a
+json.window.placeholder.text=\u793a\u4f8b\uff1a
action.json.processing.text=\u004a\u0073\u006f\u006e\u0020\u5904\u7406
action.json.processing.description=\u8fdb\u884c\u0020\u004a\u0073\u006f\u006e\u0020\u7684\u5404\u79cd\u5904\u7406
-action.json.format.text=\u004a\u0073\u006f\u006e\u0020\u683c\u5f0f\u5316
+action.json.format.text=\u7f8e\u5316\u0020\u004a\u0073\u006f\u006e
action.json.format.description=\u7f8e\u5316\u0020\u004a\u0073\u006f\u006e
-action.json.compress.text=\u004a\u0073\u006f\u006e\u0020\u538b\u7f29
+action.json.compress.text=\u538b\u7f29\u0020\u004a\u0073\u006f\u006e
action.json.compress.description=\u5c06\u0020\u004a\u0073\u006f\u006e\u0020\u538b\u7f29\u6210\u4e00\u884c
-action.json.structure.text=\u004a\u0073\u006f\u006e\u0020\u7ed3\u6784\u5316
-action.json.structure.description=\u5c06\u0020\u004a\u0073\u006f\u006e\u0020\u8f6c\u4e3a\u6811
+action.json.structure.text=\u6811\u5316\u0020\u004a\u0073\u006f\u006e
+action.json.structure.description=\u5c06\u0020\u004a\u0073\u006f\u006e\u0020\u8f6c\u4e3a\u6811\u7ed3\u6784
action.collapse.all.text=\u6298\u53e0\u6240\u6709
action.collapse.all.description=\u6298\u53e0\u5168\u90e8\u8282\u70b9
action.expand.all.text=\u5c55\u5f00\u6240\u6709