From af957ba00cd91956098a23ab4183fb7e4e09da2c Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Sun, 11 Jun 2017 13:29:22 +0800 Subject: [PATCH] bug fix --- .../search/manager/ActionSearchManager.java | 7 +- .../search/manager/DocumentSearchManager.java | 4 +- .../search/manager/FileSearchManager.java | 104 +++++++++--------- .../search/manager/PluginSearchManager.java | 6 +- .../manager/RecommendSearchManager.java | 4 +- 5 files changed, 61 insertions(+), 64 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java index 6b208c4904..928f68a3dc 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java @@ -23,9 +23,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; - private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION); - private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION); public synchronized static ActionSearchManager getActionSearchManager() { if (actionSearchManager == null) { @@ -41,7 +39,6 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { moreModelList = new SearchResult(); if (StringUtils.isBlank(searchText)) { lessModelList.add(TITLE_MODEL); - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); return lessModelList; } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) { @@ -68,7 +65,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { lessModelList.addAll(result); } } else { - lessModelList.add(0, MORE_MODEL); + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } @@ -90,7 +87,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { public static ActionModel getModelFromCloud(String actionName ) { List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); for (UpdateActionModel updateActionModel : updateActions) { - if (ComparatorUtils.equals(actionName, updateActionModel.getClassName())) { + if (ComparatorUtils.equals(actionName, updateActionModel.getClassName()) && updateActionModel.getAction().isEnabled()) { return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()); } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java index e6f8df0fa0..695101986c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java @@ -23,7 +23,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private SearchResult lessModelList; private SearchResult moreModelList; private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); - private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT); public synchronized static DocumentSearchManager getDocumentSearchManager() { if (documentSearchManager == null) { @@ -39,7 +38,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { moreModelList = new SearchResult(); if (StringUtils.isBlank(searchText)) { lessModelList.add(TITLE_MODEL); - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); return lessModelList; } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { @@ -73,7 +71,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { lessModelList.addAll(searchResult); } } else { - lessModelList.add(0, MORE_MODEL); + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index c27e180dfb..80c9d4b642 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -24,6 +24,9 @@ import java.util.List; * Created by XiaXiang on 2017/3/27. */ public class FileSearchManager implements AlphaFineSearchProcessor { + private static final int MARK_LENGTH = 6; + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE); + private static FileSearchManager fileSearchManager = null; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; @@ -31,11 +34,6 @@ public class FileSearchManager implements AlphaFineSearchProcessor { //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 private boolean isContainCpt = true; private boolean isContainFrm = true; - private static FileSearchManager fileSearchManager = null; - private static final int MARK_LENGTH = 6; - - private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE); - private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE); public synchronized static FileSearchManager getFileSearchManager() { init(); @@ -48,6 +46,17 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } } + /** + * 根据文件路径获取文件模型 + * + * @param filePath + * @return + */ + public static FileModel getModelFromCloud(String filePath) { + String name = AlphaFineHelper.findFileName(filePath); + return new FileModel(name, filePath); + } + public synchronized SearchResult getLessSearchResult(String searchText) { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); @@ -61,48 +70,48 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } if (StringUtils.isBlank(searchText)) { lessModelList.add(TITLE_MODEL); - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); return lessModelList; } - if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { - Env env = FRContext.getCurrentEnv(); - fileNodes = new ArrayList<>(); - fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); - isContainCpt = true; - isContainFrm = true; - for (FileNode node : fileNodes) { - boolean isAlreadyContain = false; - String fileEnvPath = node.getEnvPath(); - String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath); - isAlreadyContain = searchFile(searchText, node, isAlreadyContain); - searchFileContent(searchText, node, isAlreadyContain, filePath); - } - SearchResult result = new SearchResult(); - for (Object object : filterModelList) { - if (!AlphaFineHelper.getFilterResult().contains(object)) { - result.add(object); - } + Env env = FRContext.getCurrentEnv(); + fileNodes = new ArrayList<>(); + fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); + isContainCpt = true; + isContainFrm = true; + for (FileNode node : fileNodes) { + boolean isAlreadyContain = false; + String fileEnvPath = node.getEnvPath(); + String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath); + isAlreadyContain = searchFile(searchText, node, isAlreadyContain); + searchFileContent(searchText, node, isAlreadyContain, filePath); + } + SearchResult result = new SearchResult(); + for (Object object : filterModelList) { + if (!AlphaFineHelper.getFilterResult().contains(object)) { + result.add(object); } - if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, TITLE_MODEL); - if (result.size() == 0) { - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); - } else { - lessModelList.addAll(result); - } + + } + if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, TITLE_MODEL); + if (result.size() == 0) { + lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); } else { - lessModelList.add(0, MORE_MODEL); - lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); - moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); + lessModelList.addAll(result); } + } else { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE)); + lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } + return this.lessModelList; } /** * 搜索文件内容 + * * @param searchText * @param node * @param isAlreadyContain @@ -137,6 +146,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { /** * 搜索模板 + * * @param searchText * @param node * @param isAlreadyContain @@ -144,7 +154,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { */ private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { - if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { + if (node.getName().toLowerCase().contains(searchText)) { FileModel model = new FileModel(node.getName(), node.getEnvPath()); this.filterModelList.add(model); isAlreadyContain = true; @@ -160,6 +170,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { /** * 获取工作目录下所有符合要求的模板 + * * @param env * @param rootFilePath * @param recurse @@ -177,6 +188,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { /** * 获取当前工作目录下所有模板 + * * @param env * @param rootFilePath * @param nodeList @@ -187,32 +199,23 @@ public class FileSearchManager implements AlphaFineSearchProcessor { FileNode[] fns = env.listFile(rootFilePath); for (int i = 0; i < fns.length; i++) { FileNode fileNode = fns[i]; - if (isContainCpt && fileNode.isFileType("cpt")) { - nodeList.add(fileNode); - } else if (isContainFrm && fileNode.isFileType("frm")) { - nodeList.add(fileNode); - } else if (fileNode.isDirectory()) { + if (fileNode.isDirectory()) { if (recurse) { listAll(env, rootFilePath + File.separator + fns[i].getName(), nodeList, true); } else { nodeList.add(fns[i]); } + } else if (isContainCpt && fileNode.isFileType("cpt")) { + nodeList.add(fileNode); + } else if (isContainFrm && fileNode.isFileType("frm")) { + nodeList.add(fileNode); } } } - /** - * 根据文件路径获取文件模型 - * @param filePath - * @return - */ - public static FileModel getModelFromCloud(String filePath) { - String name = AlphaFineHelper.findFileName(filePath); - return new FileModel(name, filePath); - } - /** * 是否包含cpt + * * @return */ public boolean isContainCpt() { @@ -225,6 +228,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { /** * 是否包含frm + * * @return */ public boolean isContainFrm() { diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java index f3f8d0b205..dcdda514ea 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java @@ -24,10 +24,7 @@ import java.net.URLEncoder; */ public class PluginSearchManager implements AlphaFineSearchProcessor { private static PluginSearchManager pluginSearchManager = null; - private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); - private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN); - private SearchResult lessModelList; private SearchResult moreModelList; @@ -46,7 +43,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { this.moreModelList = new SearchResult(); if (StringUtils.isBlank(searchText)) { lessModelList.add(TITLE_MODEL); - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); return lessModelList; } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainPlugin()) { @@ -80,7 +76,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { lessModelList.addAll(searchResult); } } else { - lessModelList.add(0, MORE_MODEL); + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java index 051c8e66ee..9b38f71443 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java @@ -13,6 +13,7 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.CodeUtils; +import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; @@ -36,6 +37,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { @Override public synchronized SearchResult getLessSearchResult(String searchText) { this.modelList = new SearchResult(); + this.recommendModelList = new ArrayList<>(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { String result; HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText)); @@ -64,7 +66,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { } catch (JSONException e) { FRLogger.getLogger().error("recommend search error! :" + e.getMessage()); } - if (modelList.size() > 0) { + if (recommendModelList.size() > 0) { modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); modelList.addAll(recommendModelList); }