Skip to content

Commit

Permalink
准备发布1.2.0版本:
Browse files Browse the repository at this point in the history
- 更新插件版本至1.2.0
- 适配IDE2024.1
- 修复可能导致崩溃的问题- 优化线程策略以提高性能
  • Loading branch information
liuzhihang committed Sep 24, 2024
1 parent 994aadd commit a5dc517
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 40 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## [Unreleased]
## 1.1.9
## 1.2.0
### Added

### Changed
- 修复插件新版 IDEA 崩溃的问题
- 更新插件版本至1.2.0
- 适配IDE2024.1
- 修复可能导致崩溃的问题- 优化线程策略以提高性能

### Deprecated

Expand Down
21 changes: 9 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ org.gradle.configuration-cache=true
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching=true
# ????
pluginGroup = com.liuzhihang.toolkit
pluginName = Toolkit
pluginVersion = 1.1.9

pluginSinceBuild = 203.0
pluginUntilBuild =
pluginDescription = parts/description.html

platformType = IC
platformVersion = 2023.2

pluginGroup=com.liuzhihang.toolkit
pluginName=Toolkit
pluginVersion=1.2.0
pluginSinceBuild=241
pluginUntilBuild=
pluginDescription=parts/description.html
platformType=IC
platformVersion=2024.1
# ,-Dide.browser.jcef.log.level=verbose,-Duser.language=en-US
runIdeJvmArgs = -Dfile.encoding=utf-8
runIdeJvmArgs=-Dfile.encoding=utf-8
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public void update(@NotNull AnActionEvent e) {
}
}



/**
* 线程类型
*
* @return ActionUpdateThread
*/
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
}
18 changes: 9 additions & 9 deletions src/main/java/com/liuzhihang/toolkit/action/ToolkitAction.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package com.liuzhihang.toolkit.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.PsiFile;
import com.liuzhihang.toolkit.ui.ToolkitForm;
import com.liuzhihang.toolkit.utils.CustomPsiUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* 唤起操作面板
Expand All @@ -33,11 +27,17 @@ public void actionPerformed(AnActionEvent e) {
// VirtualFile actionFolder = event.getData(LangDataKeys.VIRTUAL_FILE);


if (project == null ) {
if (project == null) {
return;
}

ToolkitForm.getInstance(project, editor, psiFile).popup();

}


@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
}
30 changes: 26 additions & 4 deletions src/main/java/com/liuzhihang/toolkit/ui/Base64Form.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {

WriteCommandAction.runWriteCommandAction(project, () -> outputDocument.setText(writer));
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction("Decoder", "Decoder", AllIcons.Actions.ShowCode) {
Expand All @@ -109,10 +113,20 @@ public void actionPerformed(@NotNull AnActionEvent e) {

String text = inputDocument.getText().trim();

byte[] decode = Base64.getDecoder().decode(text);
String writer = new String(decode, StandardCharsets.UTF_8);
String writer;
try {
byte[] decode = Base64.getDecoder().decode(text);
writer = new String(decode, StandardCharsets.UTF_8);
} catch (Exception ex) {
writer = "数据错误,异常:" + ex.getMessage();
}

WriteCommandAction.runWriteCommandAction(project, () -> outputDocument.setText(writer));
String finalWriter = writer;
WriteCommandAction.runWriteCommandAction(project, () -> outputDocument.setText(finalWriter));
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

Expand All @@ -128,13 +142,21 @@ public void actionPerformed(@NotNull AnActionEvent e) {
popup.cancel();
NotificationUtils.infoNotify(ToolkitBundle.message("notify.copy.success"), project);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction("Close", "Generate entity", AllIcons.General.InspectionsOK) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
popup.cancel();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

// init toolbar
Expand All @@ -143,7 +165,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/liuzhihang/toolkit/ui/CronForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}

}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});


Expand All @@ -161,7 +165,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/liuzhihang/toolkit/ui/EntityJsonForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
popup.cancel();
NotificationUtils.infoNotify(ToolkitBundle.message("notify.copy.success"), project);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

// init toolbar
Expand All @@ -107,7 +111,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/com/liuzhihang/toolkit/ui/JsonFormatForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,32 @@ public void actionPerformed(@NotNull AnActionEvent e) {

WriteCommandAction.runWriteCommandAction(project, () -> jsonDocument.setText(resultText));
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction(message("json.format.compress.text"), "", AllIcons.Actions.Collapseall) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
compressAction();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction(message("json.format.format.text"), "", AllIcons.Json.Object) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
formatAction();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.addSeparator();
Expand All @@ -136,6 +148,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
popup.cancel();
NotificationUtils.infoNotify(message("notify.copy.success"), project);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction(message("json.format.next.text"), "", AllIcons.Actions.Rerun) {
Expand All @@ -144,6 +160,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
preview();
popup.cancel();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

// init toolbar
Expand All @@ -152,7 +172,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/liuzhihang/toolkit/ui/ParamPreviewForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
myIsPinned.set(true);
SettingsForm.getInstance(project).popup();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

group.addSeparator();
Expand All @@ -129,14 +133,17 @@ public boolean isSelected(@NotNull AnActionEvent e) {
public void setSelected(@NotNull AnActionEvent e, boolean state) {
myIsPinned.set(state);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

ActionToolbarImpl toolbar = (ActionToolbarImpl) ActionManager.getInstance()
.createActionToolbar("ToolkitHeadToolbar", group, true);
toolbar.setTargetComponent(headToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

headToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down Expand Up @@ -214,6 +221,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {

popup.cancel();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

// init toolbar
Expand All @@ -222,7 +233,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/liuzhihang/toolkit/ui/SettingsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
// 关闭
popup.cancel();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

rightGroup.add(new AnAction(message("common.confirm"), "", AllIcons.Actions.Commit) {
Expand All @@ -184,6 +188,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
apply();
popup.cancel();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

// init toolbar
Expand All @@ -192,7 +200,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolbar.setTargetComponent(tailToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

tailToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/liuzhihang/toolkit/ui/ToolkitForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
myIsPinned.set(true);
SettingsForm.getInstance(project).popup();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

group.addSeparator();
Expand All @@ -150,14 +154,19 @@ public boolean isSelected(@NotNull AnActionEvent e) {
public void setSelected(@NotNull AnActionEvent e, boolean state) {
myIsPinned.set(state);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});

ActionToolbarImpl toolbar = (ActionToolbarImpl) ActionManager.getInstance()
.createActionToolbar("ToolkitHeadToolbar", group, true);
toolbar.setTargetComponent(headToolbarPanel);

toolbar.setForceMinimumSize(true);
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
// toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
Utils.setSmallerFontForChildren(toolbar);

headToolbarPanel.add(toolbar.getComponent(), BorderLayout.EAST);
Expand Down
Loading

0 comments on commit a5dc517

Please sign in to comment.