From b00644e34e67809ff63ba7aa57f3f1a837653c2f Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 7 May 2022 16:37:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-70681=20=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=AB=98=E4=BA=AE=E5=92=8C=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=87=86=E7=A1=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/component/AlphaFineFrame.java | 24 +++++++------------ .../ProductNewsSearchWorkerManager.java | 7 +++--- .../alphafine/search/SearchWorkerManager.java | 7 +++--- .../manager/fun/AlphaFineSearchProvider.java | 12 ++++++++++ .../manager/impl/ActionSearchManager.java | 7 ++++++ .../manager/impl/DocumentSearchManager.java | 12 +++++++--- .../manager/impl/FileSearchManager.java | 11 +++++++++ .../manager/impl/PluginSearchManager.java | 11 ++++++++- 8 files changed, 65 insertions(+), 26 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 28300c9b2a..d97710ef16 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -171,38 +171,26 @@ public class AlphaFineFrame extends JFrame { this.settingSearchWorkerManager = new SearchWorkerManager( CellType.ACTION, - searchTextBean -> { - ActionSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation()); - return ActionSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText()); - }, + searchTextBean -> ActionSearchManager.getInstance().getSearchResult(searchTextBean), this, new SimpleRightSearchResultPane(new NoResultPane(NO_RESULT, AlphaFineConstants.NO_RESULT_ICON)) ); fileSearchWorkerManager = new SearchWorkerManager( CellType.FILE, - searchTextBean -> { - FileSearchManager.getInstance().getLessSearchResult(searchTextBean.getSearchText(), searchTextBean.getSegmentation()); - return FileSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText()); - }, + searchTextBean -> FileSearchManager.getInstance().getSearchResult(searchTextBean), this, new LoadingRightSearchResultPane() ); documentWorkerManager = new SearchWorkerManager( CellType.DOCUMENT, - searchTextBean -> { - DocumentSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation()); - return DocumentSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText()); - }, + searchTextBean -> DocumentSearchManager.getInstance().getSearchResult(searchTextBean), this, new SimpleRightSearchResultPane(new JPanel()) ); pluginSearchWorkerManager = new SearchWorkerManager( CellType.PLUGIN, - searchTextBean -> { - PluginSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation()); - return PluginSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText()); - }, + searchTextBean -> PluginSearchManager.getInstance().getSearchResult(searchTextBean), this, new LoadingRightSearchResultPane() ); @@ -663,6 +651,10 @@ public class AlphaFineFrame extends JFrame { resultPane.add(panel, flag); } + public void removeSearchResultPane(JPanel panel) { + resultPane.remove(panel); + } + private void doSearch(String text) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java index 0c230844b8..40161e9baa 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java @@ -48,10 +48,11 @@ public class ProductNewsSearchWorkerManager implements SearchManager { checkSearchWork(); searchOver = false; networkError = false; - if (searchResultPane == null) { - searchResultPane = new ProductNewsSearchResultPane(searchTextBean.getSegmentation()); - alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result()); + if (searchResultPane != null) { + alphaFineFrame.removeSearchResultPane(searchResultPane); } + searchResultPane = new ProductNewsSearchResultPane(searchTextBean.getSegmentation()); + alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result()); this.searchWorker = new SwingWorker, Void>() { @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java index 7aa86b84ae..0b25c3ca1e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java @@ -48,10 +48,11 @@ public class SearchWorkerManager implements SearchManager { } private void initSearchResult(SearchTextBean searchTextBean) { - if (searchResultPane == null) { - searchResultPane = new SearchResultPane(searchTextBean.getSegmentation(), resultShowPane); - alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result()); + if (searchResultPane != null) { + alphaFineFrame.removeSearchResultPane(searchResultPane); } + searchResultPane = new SearchResultPane(searchTextBean.getSegmentation(), resultShowPane); + alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java index b75aa894c4..631fce88ea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.fun; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.SearchTextBean; /** * Created by XiaXiang on 2017/3/27. @@ -20,4 +21,15 @@ public interface AlphaFineSearchProvider { * @return */ SearchResult getMoreSearchResult(String searchText); + + + /** + * 获取所有搜索结果 取决于具体实现 + * + * @param searchTextBean + * @return + */ + default SearchResult getSearchResult(SearchTextBean searchTextBean) { + return new SearchResult(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index 1c4fec0903..a2a1a7037f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -8,6 +8,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.SearchTextBean; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.mainframe.toolbar.UpdateActionModel; @@ -101,4 +102,10 @@ public class ActionSearchManager implements AlphaFineSearchProvider { public SearchResult getMoreSearchResult(String searchText) { return moreModelList; } + + @Override + public SearchResult getSearchResult(SearchTextBean searchTextBean) { + getLessSearchResult(searchTextBean.getSegmentation()); + return filterModelList; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 0b49530831..7a74ee6c1d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -7,15 +7,14 @@ import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.DocumentModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.SearchTextBean; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; -import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; -import java.io.IOException; /** * Created by XiaXiang on 2017/3/27. @@ -24,6 +23,7 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { private static volatile DocumentSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList; + private SearchResult searchResult; public static DocumentSearchManager getInstance() { if (instance == null) { @@ -54,6 +54,7 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { public SearchResult getLessSearchResult(String[] searchText) { lessModelList = new SearchResult(); moreModelList = new SearchResult(); + searchResult = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { if (ArrayUtils.isEmpty(searchText)) { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); @@ -63,7 +64,7 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { if(noConnectList != null){ return noConnectList; } - SearchResult searchResult = new SearchResult(); + searchResult = new SearchResult(); for (int j = 0; j < searchText.length; j++) { String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j]; try { @@ -106,4 +107,9 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { return moreModelList; } + @Override + public SearchResult getSearchResult(SearchTextBean searchTextBean) { + getLessSearchResult(searchTextBean.getSegmentation()); + return searchResult; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 327d0555c2..cbba249380 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -9,16 +9,19 @@ import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.FileModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.SearchTextBean; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNodes; import com.fr.general.ComparatorUtils; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.rpc.ExceptionHandler; import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import java.util.Arrays; /** @@ -71,6 +74,8 @@ public class FileSearchManager implements AlphaFineSearchProvider { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); + FineLoggerFactory.getLogger().error("===={}====", searchStr); + FineLoggerFactory.getLogger().error("分词 ==={}===", Arrays.toString(searchText)); for (int j = 0; j < searchText.length; j++) { this.searchText = dealWithSearchText(searchText[j]); if (StringUtils.isBlank(this.searchText) || ComparatorUtils.equals(this.searchText, DS_NAME)) { @@ -114,6 +119,12 @@ public class FileSearchManager implements AlphaFineSearchProvider { return moreModelList; } + @Override + public SearchResult getSearchResult(SearchTextBean searchTextBean) { + getLessSearchResult(searchTextBean.getSearchText(), searchTextBean.getSegmentation()); + return filterModelList; + } + private void doSearch(String searchText) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { for (FileNode node : fileNodes) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 31a1b18ed9..56f7078b41 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -7,6 +7,7 @@ import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.SearchTextBean; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; @@ -28,6 +29,7 @@ import java.net.URLEncoder; public class PluginSearchManager implements AlphaFineSearchProvider { private SearchResult lessModelList; private SearchResult moreModelList; + private SearchResult searchResult; private PluginSearchManager() { @@ -97,7 +99,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { public SearchResult getLessSearchResult(String[] searchText) { this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - SearchResult searchResult = new SearchResult(); + this.searchResult = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainPlugin()) { if (ArrayUtils.isEmpty(searchText)) { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); @@ -146,4 +148,11 @@ public class PluginSearchManager implements AlphaFineSearchProvider { public SearchResult getMoreSearchResult(String searchText) { return this.moreModelList; } + + + @Override + public SearchResult getSearchResult(SearchTextBean searchTextBean) { + getLessSearchResult(searchTextBean.getSegmentation()); + return searchResult; + } }