From cc21384b1d4f88bbf18be31ff045785dbc767f4c Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 16 Aug 2022 20:45:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75090=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/RenameAction.java | 5 +--- .../DefaultTemplateTreeDefineProcessor.java | 2 +- .../com/fr/design/file/TemplateTreePane.java | 26 +++++++++++++------ .../DesignerFrameFileDealerPane.java | 4 +++ .../search/TemplateTreeSearchManager.java | 5 ++++ .../pane/TemplateDirTreeSearchPane.java | 2 +- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java index 2df047264d..c38a015107 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java @@ -18,7 +18,6 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.utils.TemplateUtils; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; @@ -57,8 +56,6 @@ import static javax.swing.JOptionPane.YES_NO_OPTION; public class RenameAction extends UpdateAction { private FileOperations selectedOperation; - public static final com.fr.event.Event> TEMPLATE_RENAME = new Event>() { - }; public RenameAction() { @@ -273,7 +270,7 @@ public class RenameAction extends UpdateAction { boolean success = selectedOperation.rename(fnf, path, newPath); if (success) { - EventDispatcher.fire(TEMPLATE_RENAME, new TwoTuple<>(path, newPath)); + EventDispatcher.fire(DesignerFrameFileDealerPane.TEMPLATE_RENAME, new TwoTuple<>(path, newPath)); HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath); selectedOperation.refreshParent(); diff --git a/designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java b/designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java index e998d358d9..383d5993bd 100644 --- a/designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java +++ b/designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java @@ -202,7 +202,7 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { TemplateTreeSearchManager.getInstance().outOfSearchMode(); } - DesignerFrameFileDealerPane.getInstance().getSelectedOperation().refresh(); + DesignerFrameFileDealerPane.getInstance().getSelectedOperation().refreshParent(); String targetFile = StableUtils.pathJoin(targetDir, ((FileNode) (pasteNodes.get(0).getUserObject())).getName()); LocateAction.gotoEditingTemplateLeaf(targetFile); } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 1b298b9b12..9bace59455 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -16,6 +16,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.lock.LockInfoDialog; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; @@ -57,6 +58,9 @@ import java.util.Enumeration; import java.util.Objects; import java.util.Observable; import java.util.Observer; +import java.util.Set; +import java.util.stream.Collectors; + import org.jetbrains.annotations.Nullable; @@ -385,16 +389,22 @@ public class TemplateTreePane extends JPanel implements FileOperations { } } } - refreshAfterDelete(); + Set deletedFileNode = deletableNodes.stream().map(treeNode -> (FileNode) treeNode.getUserObject()).collect(Collectors.toSet()); + refreshAfterDelete(deletedFileNode); } - private void refreshAfterDelete() { - TreePath[] paths = reportletsTree.getSelectionPaths(); - if (paths == null) { - reportletsTree.refresh(); - } else { - for (TreePath path : Objects.requireNonNull(reportletsTree.getSelectionPaths())) { - reportletsTree.refreshParent(path); + private void refreshAfterDelete(Set deletedPaths) { + if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { + TemplateTreeSearchManager.getInstance().deleteMatchedNode(deletedPaths); + TemplateTreeSearchManager.getInstance().updateTemplateTree(); + } else { + TreePath[] paths = reportletsTree.getSelectionPaths(); + if (paths == null) { + reportletsTree.refresh(); + } else { + for (TreePath path : Objects.requireNonNull(reportletsTree.getSelectionPaths())) { + reportletsTree.refreshParent(path); + } } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 0e2649fb86..d0d2eece5c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; +import com.fr.chartx.TwoTuple; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -42,6 +43,7 @@ import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.event.Event; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; @@ -88,6 +90,8 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { + public static final com.fr.event.Event> TEMPLATE_RENAME = new Event>() { + }; private static final String FILE = "file"; public static final String FILE_NAME_LIMIT = "^[^/\\\\:<>\\*\\|\"\\?]+$"; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java index 5a25d17be0..9375e5fb81 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java @@ -15,6 +15,7 @@ import javax.swing.SwingUtilities; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -200,6 +201,10 @@ public class TemplateTreeSearchManager { return treeSearcher.getMatchSets().toArray(new FileNode[0]); } + public void deleteMatchedNode(Set fileNodes) { + treeSearcher.getMatchSets().removeAll(fileNodes); + } + /** * 当前模板树中的所有模板节点 * @return diff --git a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java index b2c9e54f0c..07636ce631 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java @@ -102,7 +102,7 @@ public class TemplateDirTreeSearchPane extends JPanel implements TreeSearchStatu } }; searchTextField.setBorderPainted(false); - searchTextField.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Search_Press_Enter_For_Search")); + searchTextField.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Dir_Search_Press_Enter_For_Search")); searchTextField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) {