diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 1b975f948f..b1a3c18589 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -246,7 +246,7 @@ public class AlphaFineDialog extends UIDialog { this.searchWorker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { - rebuildList(searchTextField.getText()); + rebuildList(searchTextField.getText().toLowerCase()); return null; } @@ -262,10 +262,38 @@ public class AlphaFineDialog extends UIDialog { /** * 重新构建搜索结果列表 + * 先根据输入判断是不是隐藏的搜索功能 * @param searchText */ private void rebuildList(String searchText) { searchListModel.removeAllElements(); + if (searchText.startsWith("k:1 ") || searchText.startsWith("k:setting ")) { + getActionList(searchText.substring(4, searchText.length())); + return; + } else if (searchText.startsWith("k:2 ") || searchText.startsWith("k:help ")) { + getDocumentList(searchText.substring(4, searchText.length())); + return; + + } else if (searchText.startsWith("k:3 ") || searchText.startsWith("k:reportlets ")) { + getFileList(searchText.substring(4, searchText.length())); + return; + + } else if (searchText.startsWith("k:cpt ") || searchText.startsWith("k:frm ")) { + getFileList(searchText); + return; + } else if (searchText.startsWith("k:4 ") || searchText.startsWith("k:shop ")) { + getPluginList(searchText.substring(4, searchText.length())); + return; + + } + doNormalSearch(searchText.trim()); + } + + /** + * 普通搜索 + * @param searchText + */ + private void doNormalSearch(String searchText) { getRecentList(searchText); getRecommendList(searchText); getActionList(searchText); @@ -275,18 +303,13 @@ public class AlphaFineDialog extends UIDialog { } - private synchronized void getDocumentList(final String searchText) { - SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); for (Object object : documentModelList) { AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - - - } private synchronized void getFileList(final String searchText) { 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 6fe9f5d231..68adf0c447 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 @@ -27,7 +27,11 @@ public class FileSearchManager implements AlphaFineSearchProcessor { private SearchResult lessModelList; private SearchResult moreModelList; private List fileNodes = null; + //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 + 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); @@ -47,6 +51,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); + if (searchText.startsWith("k:frm ")) { + isContainCpt = false; + searchText = searchText.substring(MARK_LENGTH, searchText.length()); + } else if (searchText.startsWith("k:cpt ")) { + isContainFrm = false; + searchText = searchText.substring(MARK_LENGTH, searchText.length()); + } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { Env env = FRContext.getCurrentEnv(); fileNodes = new ArrayList<>(); @@ -151,7 +162,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { try { listAll(env, rootFilePath, fileNodeList, recurse); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FRContext.getLogger().error("file search error: " + e.getMessage(), e); } return fileNodeList; } @@ -168,14 +179,16 @@ public class FileSearchManager implements AlphaFineSearchProcessor { FileNode[] fns = env.listFile(rootFilePath); for (int i = 0; i < fns.length; i++) { FileNode fileNode = fns[i]; - if (fileNode.isDirectory()) { + if (isContainCpt && fileNode.isFileType("cpt")) { + nodeList.add(fileNode); + } else if (isContainFrm && fileNode.isFileType("frm")) { + nodeList.add(fileNode); + } else if (fileNode.isDirectory()) { if (recurse) { listAll(env, rootFilePath + File.separator + fns[i].getName(), nodeList, true); } else { nodeList.add(fns[i]); } - } else if (fileNode.isFileType("cpt") || fileNode.isFileType("frm")) { - nodeList.add(fileNode); } } } @@ -190,4 +203,27 @@ public class FileSearchManager implements AlphaFineSearchProcessor { return new FileModel(name, filePath); } + /** + * 是否包含cpt + * @return + */ + public boolean isContainCpt() { + return isContainCpt; + } + + public void setContainCpt(boolean containCpt) { + isContainCpt = containCpt; + } + + /** + * 是否包含frm + * @return + */ + public boolean isContainFrm() { + return isContainFrm; + } + + public void setContainFrm(boolean containFrm) { + isContainFrm = containFrm; + } }