Skip to content

Commit

Permalink
兼容2020.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MemoryZy committed Jul 8, 2024
1 parent 9919f40 commit aeae26e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/main/java/cn/memoryzy/json/actions/JsonToJavaBeanAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/memoryzy/json/ui/JsonToJavaBeanWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/optional/plugin-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<action id="MemoryZy.JsonAssistant.actions.JavaBeanToJson"
icon="JsonAssistantIcons.JSON"
class="cn.memoryzy.json.actions.JavaBeanToJsonAction">
<keyboard-shortcut keymap="$default" first-keystroke="alt N"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt shift N"/>
</action>

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<action id="MemoryZy.JsonAssistant.actions.JsonProcessing"
icon="JsonAssistantIcons.BOX"
class="cn.memoryzy.json.actions.JsonProcessingAction">
<keyboard-shortcut keymap="$default" first-keystroke="alt shift M"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt K"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt shift K"/>
</action>

<group id="MemoryZy.groups.JsonAssistant.JsonProcessPopupMenu" text="JsonAssistant Popup Menu Actions">
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages/JsonAssistantBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aeae26e

Please sign in to comment.