From a9f5c15cc85d9f402c9f4d4dd32495758b0533ec Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 24 Mar 2022 17:04:05 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-68355=20=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E6=95=B0=E6=8D=AE=E9=9B=86=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=91=E6=90=9C=E7=B4=A2=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=E5=8C=B9=E9=85=8D=E6=95=B0=E6=8D=AE=E5=88=97=EF=BC=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=97=E6=89=80=E5=9C=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=B2=A1=E6=9C=89=E5=B1=95=E5=BC=80=20=E3=80=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E6=8A=8A=E5=88=87=E6=8D=A2=E5=9B=9E=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E7=94=A8=E6=94=BE=E5=9C=A8TableDataTreePane?= =?UTF-8?q?=E7=9A=84refreshDockingView=E9=87=8C=E5=8F=88=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?TableDataTreePane=E7=9A=84=E6=AF=8F=E4=B8=80=E6=AC=A1getInstanc?= =?UTF-8?q?e=E9=83=BD=E4=BC=9A=E5=8E=BB=E8=B0=83=E7=94=A8=E4=B8=80?= =?UTF-8?q?=E6=AC=A1refreshDockingView=EF=BC=8C=E6=90=9C=E7=B4=A2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=BF=87=E7=A8=8B=E4=B8=AD=E4=BC=9A=E7=BB=8F=E5=B8=B8?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=88=B0TableDataTreePane.getInstance?= =?UTF-8?q?=EF=BC=8C=E6=89=80=E4=BB=A5=E9=80=A0=E6=88=90=E4=BA=86=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=8A=B6=E6=80=81=E4=B8=8A=E7=9A=84=E7=B4=8A=E4=B9=B1?= =?UTF-8?q?=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=911.=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95TreeSearchStatus=EF=BC=8C=E6=96=B0=E5=A2=9ENo?= =?UTF-8?q?t=5FIn=5FSearch=5FMode=EF=BC=8C=E8=A7=86=E4=B8=BA=E9=9D=9E?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=BC=8F=EF=BC=8C=E5=85=B6=E5=AE=83?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81=EF=BC=88=E6=90=9C=E7=B4=A2=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E6=90=9C=E7=B4=A2=E4=B8=AD=E6=AD=A2=EF=BC=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=AE=8C=E6=88=90=E7=AD=89=EF=BC=89=E7=BB=9F=E7=BB=9F?= =?UTF-8?q?=E8=A7=86=E4=B8=BA=E6=90=9C=E7=B4=A2=E6=A8=A1=E5=BC=8F=202.=20?= =?UTF-8?q?=E5=9C=A8=E9=9C=80=E8=A6=81=E9=80=80=E5=87=BA=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=9A=84=E5=9C=B0=E6=96=B9=EF=BC=88=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=95=B0=E6=8D=AE=E9=9B=86Tab=E5=92=8C=E6=96=B0?= =?UTF-8?q?=E6=89=93=E5=BC=80=E4=B8=80=E4=B8=AA=E6=A8=A1=E6=9D=BF=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=8A=A0=E4=B8=8A=E9=80=80=E5=87=BA=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=9B=E4=B8=8D=E6=8A=8A=E9=80=BB=E8=BE=91=E6=94=BE?= =?UTF-8?q?=E5=88=B0refreshDockingView=E9=87=8C=203.=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91=E4=B8=8A=E9=9D=A2?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E7=9A=84=E7=AC=AC=E4=BA=8C=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=9C=A8=E9=9C=80=E8=A6=81=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E5=9C=BA=E6=99=AF=E9=87=8C=EF=BC=8C=E4=BC=9A=E6=98=BE?= =?UTF-8?q?=E5=BE=97=E6=AF=94=E8=BE=83=E6=9D=BE=E6=95=A3=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E6=88=91=E6=B2=A1=E6=89=BE=E5=88=B0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=A5=BD=E7=9A=84=E5=9C=B0=E6=96=B9=E5=8F=AF=E4=BB=A5=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=90=9E=E3=80=82=E6=9C=89=E6=80=9D=E8=B7=AF=E7=9A=84?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=B8=AE=E5=BF=99=E6=8F=90=E4=BE=9B=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=84=9F=E8=B0=A2~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataTreePane.java | 6 ++-- .../search/TableDataTreeSearchManager.java | 26 +++++++++++++---- .../control/pre/TableDataPreSearchTask.java | 5 ++++ .../pane/TableDataSearchRemindPane.java | 12 ++++---- .../search/pane/TreeSearchToolbarPane.java | 28 +++++++++++++------ .../search/searcher/TreeSearchStatus.java | 2 ++ .../DesignerFrameFileDealerPane.java | 4 +++ 7 files changed, 61 insertions(+), 22 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 45897f7ac0..b1d23d03cd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -588,9 +588,6 @@ public class TableDataTreePane extends BasicTableDataTreePane { private void populate(TableDataSourceOP op) { this.op = op; - if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING) { - TableDataTreeSearchManager.getInstance().switchBackToolBar(); - } tableDataTree.populate(op); checkButtonEnabled(); } @@ -744,6 +741,9 @@ public class TableDataTreePane extends BasicTableDataTreePane { if (op != null) { op.setDataMode(modeArray[buttonGroup.getSelectedIndex()]); addMenuDef.setEnabled(modeArray[buttonGroup.getSelectedIndex()] == TEMPLATE_TABLE_DATA); + if (TableDataTreeSearchManager.getInstance().isInSearchMode()) { + TableDataTreeSearchManager.getInstance().outOfSearchMode(); + } refreshDockingView(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java index afc28e59f9..f47f457aa3 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java @@ -64,7 +64,7 @@ public class TableDataTreeSearchManager { } private void init() { - this.treeSearchStatus = TreeSearchStatus.SEARCH_NOT_BEGIN; + this.treeSearchStatus = TreeSearchStatus.NOT_IN_SEARCH_MODE; } private static class Holder { @@ -194,11 +194,19 @@ public class TableDataTreeSearchManager { /** * 切换回工具栏 */ - public void switchBackToolBar() { - setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN); + public void restoreToolBarAndTreePane() { + setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE); + if (treeSearcher != null) { + treeSearcher.afterSearch(); + } + restoreTreePane(); + } + + public void restoreTreePane() { lastSearchText = null; - treeSearcher.afterSearch(); - rendererHelper.restore(getCurrentTableDataTree()); + if (rendererHelper != null) { + rendererHelper.restore(getCurrentTableDataTree()); + } } /** @@ -264,4 +272,12 @@ public class TableDataTreeSearchManager { } return false; } + + public boolean isInSearchMode() { + return getTreeSearchStatus() != TreeSearchStatus.NOT_IN_SEARCH_MODE; + } + + public void outOfSearchMode() { + restoreToolBarAndTreePane(); + } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java index 009f027653..1e42349122 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java @@ -1,9 +1,11 @@ package com.fr.design.data.datapane.management.search.control.pre; +import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.datapane.management.search.control.TreeSearchTask; import com.fr.design.data.datapane.management.search.control.common.TableDataSearchResult; import com.fr.design.data.datapane.management.search.control.TreeSearchCallback; import com.fr.design.data.datapane.management.search.control.TreeSearchResult; +import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.log.FineLoggerFactory; @@ -27,6 +29,9 @@ public class TableDataPreSearchTask implements TreeSearchTask { public void run() { TreeSearchResult result; try { + if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCH_NOT_BEGIN) { + return; + } tableDataWrapper.calculateColumnNameList(); result = new TableDataSearchResult.Builder() .buildSuccess(true) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java index 7d62f876ba..3b78ba311f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java @@ -50,7 +50,7 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu @Override public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) { TreeSearchStatus status = event.getTreeSearchStatus(); - if (status == TreeSearchStatus.SEARCH_NOT_BEGIN) { + if (status == TreeSearchStatus.SEARCH_NOT_BEGIN || status == TreeSearchStatus.NOT_IN_SEARCH_MODE) { remindPane.onNotBegin(); treePane.onNotBegin(); } else if (status == TreeSearchStatus.SEARCHING) { @@ -147,12 +147,12 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu } } - private class RemindPane extends JPanel implements TreeSearchStatusChange { + private static class RemindPane extends JPanel implements TreeSearchStatusChange { - private static final String IN_SEARCHING = "Fine-Design_Tree_Search_In_Searching"; - private static final String STOP_SEARCHING = "Fine-Design_Tree_Search_Stop_Search"; - private static final String SEARCHING_STOPPED = "Fine-Design_Tree_Search_Search_Stopped"; - private static final String DONE_SEARCHING = "Fine-Design_Tree_Search_Search_Completed"; + private static final String IN_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_In_Searching"); + private static final String STOP_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_Stop_Search"); + private static final String SEARCHING_STOPPED = Toolkit.i18nText("Fine-Design_Tree_Search_Search_Stopped"); + private static final String DONE_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_Search_Completed"); private UILabel textLabel; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java index 454009bf27..aa88ed48e0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java @@ -5,6 +5,8 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.constants.UIConstants; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; +import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChangeEvent; +import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChangeListener; import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -32,7 +34,7 @@ import java.awt.event.MouseEvent; /** * @author Yvan */ -public class TreeSearchToolbarPane extends Panel { +public class TreeSearchToolbarPane extends Panel implements TreeSearchStatusChangeListener { public static final String TOOLBAR_PANE = "toolbarPane"; @@ -85,6 +87,7 @@ public class TreeSearchToolbarPane extends Panel { initContentPane(); add(contentPane, BorderLayout.CENTER); setPreferredSize(new Dimension(240, 30)); + TableDataTreeSearchManager.getInstance().registerTreeSearchStatusChangeListener(this); } private void initContentPane() { @@ -147,7 +150,7 @@ public class TreeSearchToolbarPane extends Panel { @Override public void mouseClicked(MouseEvent e) { searchTextField.setText(StringUtils.EMPTY); - TableDataTreeSearchManager.getInstance().switchBackToolBar(); + TableDataTreeSearchManager.getInstance().outOfSearchMode(); switchPane(TOOLBAR_PANE); } }); @@ -158,12 +161,10 @@ public class TreeSearchToolbarPane extends Panel { } private void dealWithTextChange() { - // 判断搜索是否正在进行 - if (StringUtils.isEmpty(searchTextField.getText()) && TableDataTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCH_NOT_BEGIN) { - TableDataTreeSearchManager.getInstance().setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN); - DesignModelAdapter currentModelAdapter = DesignModelAdapter.getCurrentModelAdapter(); - TableDataTreePane tableDataTreePane = (TableDataTreePane) TableDataTreePane.getInstance(currentModelAdapter); - tableDataTreePane.refreshDockingView(); + if (StringUtils.isEmpty(searchTextField.getText()) && TableDataTreeSearchManager.getInstance().isInSearchMode()) { + // 如果是搜索模式下,看作是用户删除输入框文字,仅复原TableDataTreePane + TableDataTreeSearchManager.getInstance().restoreTreePane(); + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); } } @@ -189,4 +190,15 @@ public class TreeSearchToolbarPane extends Panel { public void setPlaceHolder(String placeHolder) { this.searchTextField.setPlaceholder(placeHolder); } + + /** + * 根据搜索状态变化,来调整自身面板的显示 + * + * @param event + */ + @Override + public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) { + TreeSearchStatus treeSearchStatus = event.getTreeSearchStatus(); + switchPane(treeSearchStatus == TreeSearchStatus.NOT_IN_SEARCH_MODE ? TOOLBAR_PANE : SEARCH_PANE); + } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java index fd59f60ea2..835e9ded6d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java @@ -5,6 +5,8 @@ package com.fr.design.data.datapane.management.search.searcher; */ public enum TreeSearchStatus { + NOT_IN_SEARCH_MODE, + /** * 搜索未开始 */ 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 2b7a321a82..ab30582dd4 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 @@ -11,6 +11,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.FileOperations; @@ -244,6 +245,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt DesignModelAdapter.setCurrentModelAdapter(jt.getModel()); fireDSChanged(); + if (TableDataTreeSearchManager.getInstance().isInSearchMode()) { + TableDataTreeSearchManager.getInstance().outOfSearchMode(); + } TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); //处理自动新建的模板