diff --git a/build.gradle b/build.gradle
index f7a6718..cace5eb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ plugins {
}
group 'indi.bookmarkx'
-version '1.2.0' // todo
+version '1.2.1'
repositories {
mavenLocal()
@@ -26,12 +26,12 @@ intellij {
// version = '2023.1.3'
}
-patchPluginXml { // todo
+patchPluginXml {
sinceBuild = '210.0'
untilBuild = "233.*"
- changeNotes = "1. 版本支持到 IDEA 2023.3.*
" +
- "2. 支持行尾显示书签标题
" +
- "3. 书签描述改用鼠标悬停方式显示"
+ changeNotes = "1. 分组支持添加描述" +
+ "2. 分组支持重命名" +
+ "3. 优化树节点样式显示"
}
tasks.named('initializeIntelliJPlugin') {
diff --git a/src/main/java/indi/bookmarkx/BookmarksManager.java b/src/main/java/indi/bookmarkx/BookmarksManager.java
index 0392cd8..440ffd2 100644
--- a/src/main/java/indi/bookmarkx/BookmarksManager.java
+++ b/src/main/java/indi/bookmarkx/BookmarksManager.java
@@ -6,6 +6,7 @@
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
+import indi.bookmarkx.common.I18N;
import indi.bookmarkx.common.data.BookmarkArrayListTable;
import indi.bookmarkx.ui.dialog.BookmarkCreatorDialog;
import indi.bookmarkx.model.BookmarkConverter;
@@ -79,7 +80,7 @@ public void createBookRemark(Project project, Editor editor, VirtualFile file) {
}
final BookmarkNodeModel finalBookmarkNodeModel = bookmarkNodeModel;
final boolean addFlag = add;
- new BookmarkCreatorDialog(project)
+ new BookmarkCreatorDialog(project, I18N.get("bookmark.create.title"))
.defaultName(defaultName)
.defaultDesc(defaultDesc)
.showAndCallback((name, desc) -> {
@@ -88,7 +89,7 @@ public void createBookRemark(Project project, Editor editor, VirtualFile file) {
bookmarkArrayListTable.insert(finalBookmarkNodeModel);
if (addFlag) {
submitCreateBookRemark(finalBookmarkNodeModel, editor);
- }else {
+ } else {
if (!Objects.isNull(toolWindowRootPanel)) {
BookmarkTree tree = toolWindowRootPanel.tree();
BookmarkTreeNode nodeByModel = tree.getNodeByModel(finalBookmarkNodeModel);
diff --git a/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java b/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java
index dcc6655..99d77f8 100644
--- a/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java
+++ b/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java
@@ -2,7 +2,11 @@
import indi.bookmarkx.common.data.index.SimpleColumnIndex;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.function.Function;
/**
@@ -26,7 +30,7 @@ protected void addColumIndex(Function function) {
dataList.forEach(data -> {
try {
saveHunt(data, function, (SimpleColumnIndex>) index);
- }catch (Exception e) {
+ }catch (Exception ignored) {
}
});
diff --git a/src/main/java/indi/bookmarkx/ui/dialog/BookmarkCreatorDialog.java b/src/main/java/indi/bookmarkx/ui/dialog/BookmarkCreatorDialog.java
index 1b956c2..fb48f44 100644
--- a/src/main/java/indi/bookmarkx/ui/dialog/BookmarkCreatorDialog.java
+++ b/src/main/java/indi/bookmarkx/ui/dialog/BookmarkCreatorDialog.java
@@ -28,17 +28,15 @@ public class BookmarkCreatorDialog extends DialogWrapper {
private Project project;
-
- public BookmarkCreatorDialog(Project project) {
+ public BookmarkCreatorDialog(Project project, String title) {
super(true);
- setTitle("输入书签信息");
- this.project = project;
- init();
+ initSelf(project, title);
}
- @Override
- protected void init() {
- super.init();
+ private void initSelf(Project project, String title) {
+ setTitle(title);
+ this.project = project;
+ init();
}
public BookmarkCreatorDialog defaultName(String name) {
@@ -51,11 +49,19 @@ public BookmarkCreatorDialog defaultDesc(String desc) {
return this;
}
+ public BookmarkCreatorDialog namePrompt(String name) {
+ this.tfName.setPlaceholder(name);
+ return this;
+ }
+
+ public BookmarkCreatorDialog descPrompt(String name) {
+ this.tfDesc.setPlaceholder(name);
+ return this;
+ }
+
@Override
protected JComponent createCenterPanel() {
- tfName.setPlaceholder("输入展示在标签上的文本");
- tfDesc.setPlaceholder("输入对标签的详细描述");
tfDesc.setOneLineMode(false);
tfDesc.setBorder(JBUI.Borders.empty());
@@ -85,7 +91,7 @@ public void documentChanged(@NotNull DocumentEvent event) {
constraints.insets = JBUI.insets(5);
// 第一行第一列
- JLabel lbName = new JLabel("标签");
+ JLabel lbName = new JLabel("名称");
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 0;
diff --git a/src/main/java/indi/bookmarkx/ui/pannel/BookmarkTipPanel.java b/src/main/java/indi/bookmarkx/ui/pannel/BookmarkTipPanel.java
index d55d84a..70fdaac 100644
--- a/src/main/java/indi/bookmarkx/ui/pannel/BookmarkTipPanel.java
+++ b/src/main/java/indi/bookmarkx/ui/pannel/BookmarkTipPanel.java
@@ -5,15 +5,15 @@
import com.intellij.util.ui.HtmlPanel;
import com.intellij.util.ui.JBUI;
import indi.bookmarkx.model.AbstractTreeNodeModel;
-import indi.bookmarkx.model.BookmarkNodeModel;
import indi.bookmarkx.utils.HtmlUtil;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
+import javax.swing.JScrollPane;
import javax.swing.border.Border;
-import java.awt.*;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
/**
* 用于展示标签树节点的描述信息
@@ -42,15 +42,12 @@ protected static class TipHtmlPanel extends HtmlPanel {
private final String TITLE_TAG = "h3";
private final String DESC_TAG = "";
- public TipHtmlPanel(@NotNull AbstractTreeNodeModel abstractTreeNodeModel) {
+ public TipHtmlPanel(@NotNull AbstractTreeNodeModel nodeModel) {
StringBuilder sb = new StringBuilder();
- String name = HtmlUtil.wrapText(TITLE_TAG, abstractTreeNodeModel.getName());
+ String name = HtmlUtil.wrapText(TITLE_TAG, nodeModel.getName());
sb.append(name);
- if (abstractTreeNodeModel.isBookmark()) {
- BookmarkNodeModel model = (BookmarkNodeModel) abstractTreeNodeModel;
- String desc = StringUtils.isNotBlank(model.getDesc()) ? model.getDesc() : "no description";
- sb.append(desc);
- }
+ String desc = StringUtils.isNotBlank(nodeModel.getDesc()) ? nodeModel.getDesc() : "no description";
+ sb.append(desc);
setBody(sb.toString());
Border borderWithPadding = JBUI.Borders.empty(0, 10, 10, 10);
setBorder(borderWithPadding);
diff --git a/src/main/java/indi/bookmarkx/ui/tree/BmkTreeCellRenderer.java b/src/main/java/indi/bookmarkx/ui/tree/BmkTreeCellRenderer.java
index 03398ce..b66a07d 100644
--- a/src/main/java/indi/bookmarkx/ui/tree/BmkTreeCellRenderer.java
+++ b/src/main/java/indi/bookmarkx/ui/tree/BmkTreeCellRenderer.java
@@ -11,7 +11,6 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.Color;
import java.awt.Component;
-import java.awt.Graphics;
/**
* 标签树节点渲染
@@ -24,7 +23,7 @@
public class BmkTreeCellRenderer extends DefaultTreeCellRenderer {
public BmkTreeCellRenderer() {
-// ReflectionUtil.setField(DefaultTreeCellRenderer.class, this, Boolean.TYPE, "fillBackground", false);
+ // ReflectionUtil.setField(DefaultTreeCellRenderer.class, this, Boolean.TYPE, "fillBackground", false);
}
@Override
@@ -69,9 +68,4 @@ private void setColor(boolean selected, boolean hasFocus) {
public Color getBorderSelectionColor() {
return BaseColors.TRANSPARENT;
}
-
- @Override
- public void paint(Graphics g) {
- super.paint(g);
- }
}
diff --git a/src/main/java/indi/bookmarkx/ui/tree/BookmarkTree.java b/src/main/java/indi/bookmarkx/ui/tree/BookmarkTree.java
index 21518de..a5cd5b0 100644
--- a/src/main/java/indi/bookmarkx/ui/tree/BookmarkTree.java
+++ b/src/main/java/indi/bookmarkx/ui/tree/BookmarkTree.java
@@ -224,7 +224,7 @@ private void initContextMenu() {
BookmarkTreeNode selectedNode = (BookmarkTreeNode) path.getLastPathComponent();
AbstractTreeNodeModel nodeModel = (AbstractTreeNodeModel) selectedNode.getUserObject();
- new BookmarkCreatorDialog(project)
+ new BookmarkCreatorDialog(project, I18N.get("bookmark.create.title"))
.defaultName(nodeModel.getName())
.defaultDesc(nodeModel.getDesc())
.showAndCallback((name, desc) -> {
@@ -264,26 +264,6 @@ private void initContextMenu() {
return;
}
- @SuppressWarnings("all")
- InputValidatorEx validatorEx = inputString -> {
- if (StringUtil.isBlank(inputString))
- return I18N.get("groupNameNonNullMessage");
- return null;
- };
-
- @SuppressWarnings("all")
- String groupName = Messages.showInputDialog(
- I18N.get("groupNameInputMessage"),
- I18N.get("groupName"),
- null,
- null,
- validatorEx
- );
-
- if (StringUtil.isBlank(groupName)) {
- return;
- }
-
BookmarkTreeNode parent;
if (selectedNode.isGroup()) {
parent = selectedNode;
@@ -291,9 +271,19 @@ private void initContextMenu() {
parent = (BookmarkTreeNode) selectedNode.getParent();
}
- // 新的分组节点
- BookmarkTreeNode groupNode = new BookmarkTreeNode(new GroupNodeModel(groupName));
- model.insertNodeInto(groupNode, parent, 0);
+ final GroupNodeModel groupNodeModel = new GroupNodeModel();
+
+ new BookmarkCreatorDialog(project, I18N.get("group.create.title"))
+ .showAndCallback((name, desc) -> {
+ groupNodeModel.setName(name);
+ groupNodeModel.setDesc(desc);
+
+ // 新的分组节点
+ BookmarkTreeNode groupNode = new BookmarkTreeNode(groupNodeModel);
+ model.insertNodeInto(groupNode, parent, 0);
+
+ BookmarkTree.this.model.nodeChanged(selectedNode);
+ });
};
imAddGroup.addActionListener(addGroupListener);
diff --git a/src/main/resources/i18n/i18n_en.properties b/src/main/resources/i18n/i18n_en.properties
index 0ae1b55..dc72730 100644
--- a/src/main/resources/i18n/i18n_en.properties
+++ b/src/main/resources/i18n/i18n_en.properties
@@ -8,4 +8,6 @@ bookmark.notification.title=Bookmark-X Notification
bookmark.export.success=Bookmark export successful! File location: {0}
groupName=The group name
groupNameInputMessage=To add a name for the new grouping:
-groupNameNonNullMessage=The group name cannot be empty
\ No newline at end of file
+groupNameNonNullMessage=The group name cannot be empty
+group.create.title=Enter the bookmark group information
+bookmark.create.title=Enter the bookmark information
\ No newline at end of file
diff --git a/src/main/resources/i18n/i18n_zh.properties b/src/main/resources/i18n/i18n_zh.properties
index df0cf18..ebb550c 100644
--- a/src/main/resources/i18n/i18n_zh.properties
+++ b/src/main/resources/i18n/i18n_zh.properties
@@ -8,4 +8,6 @@ bookmark.notification.title=Bookmark-X 通知
bookmark.export.success=书签导出成功!文件位置:{0}
groupName=分组名称
groupNameInputMessage=为新增的分组添加名称:
-groupNameNonNullMessage=分组名称不能为空
\ No newline at end of file
+groupNameNonNullMessage=分组名称不能为空
+group.create.title=输入书签分组信息
+bookmark.create.title=输入书签信息
\ No newline at end of file