From 5a5c2bceb3aa5791dd0f060ff291e971d05b275d Mon Sep 17 00:00:00 2001 From: Nonoas <1356955215@qq.com> Date: Tue, 25 Jun 2024 20:43:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#20=20=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E5=88=A4=E6=96=ADOpenFileDescriptor=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/indi/bookmarkx/RootWindowFactory.java | 3 ++- .../indi/bookmarkx/common/data/ArrayListTable.java | 2 +- .../common/data/BookmarkArrayListTable.java | 1 + .../indi/bookmarkx/model/BookmarkConverter.java | 14 +++++++++++--- .../bookmarkx/ui/pannel/BookmarksManagePanel.java | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/indi/bookmarkx/RootWindowFactory.java b/src/main/java/indi/bookmarkx/RootWindowFactory.java index f8cf128..85d5f91 100644 --- a/src/main/java/indi/bookmarkx/RootWindowFactory.java +++ b/src/main/java/indi/bookmarkx/RootWindowFactory.java @@ -1,5 +1,6 @@ package indi.bookmarkx; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowFactory; @@ -13,7 +14,7 @@ import java.util.Arrays; -public class RootWindowFactory implements ToolWindowFactory { +public class RootWindowFactory implements ToolWindowFactory, DumbAware { /** * plugin.xml 文件中的 key 名 diff --git a/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java b/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java index 99d77f8..e1f8f98 100644 --- a/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java +++ b/src/main/java/indi/bookmarkx/common/data/ArrayListTable.java @@ -29,7 +29,7 @@ protected void addColumIndex(Function function) { SimpleColumnIndex> index = new SimpleColumnIndex<>(); dataList.forEach(data -> { try { - saveHunt(data, function, (SimpleColumnIndex>) index); + saveHunt(data, function, index); }catch (Exception ignored) { } diff --git a/src/main/java/indi/bookmarkx/common/data/BookmarkArrayListTable.java b/src/main/java/indi/bookmarkx/common/data/BookmarkArrayListTable.java index 9f7e678..b433651 100644 --- a/src/main/java/indi/bookmarkx/common/data/BookmarkArrayListTable.java +++ b/src/main/java/indi/bookmarkx/common/data/BookmarkArrayListTable.java @@ -61,6 +61,7 @@ private List treeToList(BookmarkTree bookmarkTree,List list) { diff --git a/src/main/java/indi/bookmarkx/model/BookmarkConverter.java b/src/main/java/indi/bookmarkx/model/BookmarkConverter.java index 78befbe..29534aa 100644 --- a/src/main/java/indi/bookmarkx/model/BookmarkConverter.java +++ b/src/main/java/indi/bookmarkx/model/BookmarkConverter.java @@ -1,5 +1,6 @@ package indi.bookmarkx.model; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; @@ -13,9 +14,11 @@ */ public class BookmarkConverter { + private static final Logger log = Logger.getInstance(BookmarkConverter.class); + public static BookmarkPO convertToPO(AbstractTreeNodeModel model) { - if (model instanceof BookmarkNodeModel) { + if (model instanceof BookmarkNodeModel && model.isBookmark()) { BookmarkNodeModel nodeModel = (BookmarkNodeModel) model; BookmarkPO po = new BookmarkPO(); @@ -27,8 +30,13 @@ public static BookmarkPO convertToPO(AbstractTreeNodeModel model) { po.setDesc(nodeModel.getDesc()); po.setBookmark(true); - VirtualFile file = nodeModel.getOpenFileDescriptor().getFile(); - po.setVirtualFilePath(file.getPath()); + OpenFileDescriptor fileDescriptor = nodeModel.getOpenFileDescriptor(); + if (null != fileDescriptor) { + VirtualFile file = fileDescriptor.getFile(); + po.setVirtualFilePath(file.getPath()); + } else { + log.warn(String.format("%s指向的位置已不存在", nodeModel.getName())); + } return po; } else { GroupNodeModel nodeModel = (GroupNodeModel) model; diff --git a/src/main/java/indi/bookmarkx/ui/pannel/BookmarksManagePanel.java b/src/main/java/indi/bookmarkx/ui/pannel/BookmarksManagePanel.java index 199b193..f0f7256 100644 --- a/src/main/java/indi/bookmarkx/ui/pannel/BookmarksManagePanel.java +++ b/src/main/java/indi/bookmarkx/ui/pannel/BookmarksManagePanel.java @@ -113,7 +113,7 @@ class TreeLoadTask extends Task.Backgroundable { private DefaultTreeModel treeModel; public TreeLoadTask(Project project, BookmarkTree tree) { - super(project, "Loading Tree Data"); + super(project, "Loading tree data"); this.project = project; this.tree = tree; }