From b46349667528edcf71d9ee61b0dadf21d4eccbe1 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 23 May 2017 14:46:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/alphafine/AlphaFineHelper.java | 19 ++++++++++ .../design/mainframe/alphafine/CellType.java | 35 +++---------------- .../cell/cellModel/AlphaCellModel.java | 9 +++++ .../alphafine/component/AlphaFineDialog.java | 2 +- .../searchManager/ActionSearchManager.java | 5 +++ .../AlphaFineSearchProcessor.java | 9 +++++ .../searchManager/AlphaSearchManager.java | 16 ++++----- .../searchManager/DocumentSearchManager.java | 17 +++++---- .../searchManager/FileSearchManager.java | 27 ++++++++++++++ .../searchManager/PluginSearchManager.java | 16 +++++---- .../searchManager/RecentSearchManager.java | 20 ++++++++++- .../searchManager/RecommendSearchManager.java | 2 +- .../parameter/ParameterDefinitePane.java | 8 ++--- 13 files changed, 128 insertions(+), 57 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 3e26ab16a..0e90194df 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -14,15 +14,29 @@ import java.io.File; */ public class AlphaFineHelper { + /** + * 弹出alphafine搜索面板 + */ public static void showAlphaFineDialog() { AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame()); dialog.setVisible(true); } + /** + * 获取文件名上级目录 + * @param text + * @return + */ public static String findFolderName (String text) { return getSplitText(text, 2); } + /** + * 分割字符串,获取文件名,文件名上级目录等 + * @param text + * @param index + * @return + */ private static String getSplitText(String text, int index) { if (StringUtils.isNotBlank(text)) { String[] textArray = text.split("/"); @@ -33,6 +47,11 @@ public class AlphaFineHelper { return null; } + /** + * 获取文件名 + * @param text + * @return + */ public static String findFileName (String text) { return getSplitText(text, 1); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/CellType.java b/designer/src/com/fr/design/mainframe/alphafine/CellType.java index 652ac99de..96b7db609 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer/src/com/fr/design/mainframe/alphafine/CellType.java @@ -7,43 +7,18 @@ public enum CellType { RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5); private int typeValue; - private static final int RECOMMEND_VALUE = 0; - private static final int ACTION_VALUE = 1; - private static final int DOCUMENT_VALUE = 2; - private static final int FILE_VALUE = 3; - private static final int PLUGIN_VALUE = 4; - private static final int REUSE_VALUE = 5; - CellType(int type) { this.typeValue = type; } public static CellType parse(int typeValue) { - CellType type; - switch (typeValue) { - case RECOMMEND_VALUE: - type = RECOMMEND; - break; - case ACTION_VALUE: - type = ACTION; - break; - case DOCUMENT_VALUE: - type = DOCUMENT; - break; - case FILE_VALUE: - type = FILE; - break; - case PLUGIN_VALUE: - type = PLUGIN; - break; - case REUSE_VALUE: - type = REUSE; - break; - default: - type = FILE; + for (CellType type : CellType.values()) { + if (type.getTypeValue() == typeValue) { + return type; + } } - return type; + return FILE; } public int getTypeValue() { diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java index 8055c8812..18cd2d843 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java @@ -60,8 +60,17 @@ public abstract class AlphaCellModel { this.description = description; } + /** + * model转json + * @return + * @throws JSONException + */ abstract public JSONObject ModelToJson() throws JSONException; + /** + * 获取需要保存到云中心的信息 + * @return + */ abstract public String getStoreInformation(); } 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 ba86aa027..0da64af97 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -561,7 +561,7 @@ public class AlphaFineDialog extends UIDialog { * @param cellModel */ private void saveHistory(String searchText, AlphaCellModel cellModel) { - RecentSearchManager recentSearchManager = RecentSearchManager.getInstance(); + RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger(); recentSearchManager.addRecentModel(searchText, cellModel); recentSearchManager.saveXMLFile(); sendToServer(searchText, cellModel); diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java index 0c3a55699..e13466b65 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java @@ -68,6 +68,11 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { return moreModelList; } + /** + * 根据类名反射获取对象 + * @param actionName + * @return + */ public static ActionModel getModelFromCloud(String actionName ) { UpdateAction action = null; String name = null; diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java index aaeb510df..3883fbac8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java @@ -6,7 +6,16 @@ import com.fr.design.mainframe.alphafine.model.SearchResult; * Created by XiaXiang on 2017/3/27. */ public interface AlphaFineSearchProcessor { + /** + * 获取默认显示条数 + * @param searchText + * @return + */ SearchResult getLessSearchResult(String searchText); + /** + * 获取剩余条数 + * @return + */ SearchResult getMoreSearchResult(); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java index 8462fbb2d..915db8ae2 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java @@ -30,24 +30,24 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor { fileSearchManager = FileSearchManager.getFileSearchManager(); actionSearchManager = ActionSearchManager.getActionSearchManager(); recommendSearchManager = RecommendSearchManager.getRecommendSearchManager(); - recentSearchManager = RecentSearchManager.getInstance(); + recentSearchManager = RecentSearchManager.getRecentSearchManger(); } } @Override public synchronized SearchResult getLessSearchResult(String searchText) { - SearchResult latestModelList = recentSearchManager.getLessSearchResult(searchText); + SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText); SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText); SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText); SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText); SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText); SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText); - latestModelList.addAll(concludeModelList); - latestModelList.addAll(actionModelList); - latestModelList.addAll(fileModelList); - latestModelList.addAll(documentModelList); - latestModelList.addAll(pluginModelList); - return latestModelList; + recentModelList.addAll(concludeModelList); + recentModelList.addAll(actionModelList); + recentModelList.addAll(fileModelList); + recentModelList.addAll(documentModelList); + recentModelList.addAll(pluginModelList); + return recentModelList; } public SearchResult showDefaultSearchResult() { diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java index 772597bc5..c16189345 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java @@ -56,13 +56,13 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); this.moreModelList.add(cellModel); } - if (jsonArray.length() > 0) { - if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); - } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT)); - } + if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); + } else { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT)); } + + } } catch (JSONException e) { @@ -75,6 +75,11 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { return lessModelList; } + /** + * 根据json信息获取文档model + * @param object + * @return + */ public static DocumentModel getModelFromCloud(JSONObject object) { String name = object.optString("title"); String content = object.optString("summary"); diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java index 4312b4e6b..55784d181 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java @@ -108,6 +108,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } } + /** + * 搜索模板 + * @param searchText + * @param node + * @param isAlreadyContain + * @return + */ private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { @@ -124,6 +131,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor { return moreModelList; } + /** + * 获取工作目录下所有符合要求的模板 + * @param env + * @param rootFilePath + * @param recurse + * @return + */ private List listTpl(Env env, String rootFilePath, boolean recurse) { List fileNodeList = new ArrayList(); try { @@ -134,6 +148,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor { return fileNodeList; } + /** + * 获取当前工作目录下所有模板 + * @param env + * @param rootFilePath + * @param nodeList + * @param recurse + * @throws Exception + */ private void listAll(Env env, String rootFilePath, List nodeList, boolean recurse) throws Exception { FileNode[] fns = env.listFile(rootFilePath); for (int i = 0; i < fns.length; i++) { @@ -150,6 +172,11 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } } + /** + * 根据文件路径获取文件模型 + * @param filePath + * @return + */ public static FileModel getModelFromCloud(String filePath) { String name = AlphaFineHelper.findFileName(filePath); String content = AlphaFineHelper.findFolderName(filePath); diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java index 9694caf89..dfbbf44b4 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java @@ -63,13 +63,12 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); this.moreModelList.add(cellModel); } - if (jsonArray.length() > 0) { - if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); - } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN)); - } + if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); + } else { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN)); } + } } catch (Exception e) { @@ -110,6 +109,11 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { return this.moreModelList; } + /** + * 根据json获取对应的插件model + * @param object + * @return + */ public static PluginModel getModelFromCloud(JSONObject object) { JSONObject jsonObject = object.optJSONObject("result"); if (jsonObject != null) { diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java index 6f87232ab..6066543d6 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java @@ -45,7 +45,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear private List recentModelList = new ArrayList<>(); private Map> recentKVModelMap = new HashMap<>(); - public synchronized static RecentSearchManager getInstance() { + public synchronized static RecentSearchManager getRecentSearchManger() { if (recentSearchManager == null) { recentSearchManager = new RecentSearchManager(); try { @@ -163,6 +163,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear this.pluginList = pluginList; } + /** + * 获取xml + * @return + */ private File getRecentFile() { if (recentFile == null) { recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName()); @@ -179,6 +183,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear return envFile; } + /** + * 创建XML + * @param envFile + */ private void createRecentFile(File envFile) { try { FileWriter fileWriter = new FileWriter(envFile); @@ -230,6 +238,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear this.recentModelList = recentModelList; } + /** + * 根据搜索字段获取对应的model列表 + * @param searchText + * @return + */ public List getRecentModelList(String searchText) { recentModelList = new ArrayList<>(); for (String key : recentKVModelMap.keySet()) { @@ -244,6 +257,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear return recentModelList; } + /** + * 将搜索结果加入到当前MAP中 + * @param searchKey + * @param cellModel + */ public void addRecentModel(String searchKey, AlphaCellModel cellModel) { if (recentKVModelMap.keySet().contains(searchKey)) { List cellModels = recentKVModelMap.get(searchKey); diff --git a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java index dfd7a8509..f8126ce96 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java @@ -45,7 +45,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { if (jsonArray != null && jsonArray.length() > 0) { for (int i = 0; i < jsonArray.length(); i++) { AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); - if (!RecentSearchManager.getInstance().getRecentModelList().contains(alphaCellModel)) { + if (!RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) { this.modelList.add(alphaCellModel); } } diff --git a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java index 81e334b9e..e45a144ac 100644 --- a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java @@ -103,7 +103,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } }; this.add(paraDesignEditor.createWrapper(), BorderLayout.CENTER); -// WidgetToolBarPane.getInstance(formParaDesignEditor); +// WidgetToolBarPane.getRecentSearchManger(formParaDesignEditor); setButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png")); setButton.set4ToolbarButton(); @@ -378,7 +378,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus currentIndex++; parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter); refreshParameter(); -// FormHierarchyTreePane.getInstance().refreshDockingView(); +// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); @@ -398,7 +398,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus currentIndex = currentIndex + NUM_IN_A_LINE - currentIndex % NUM_IN_A_LINE; parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter); refreshParameter(); -// FormHierarchyTreePane.getInstance().refreshDockingView(); +// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); @@ -420,7 +420,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus parameterArray = null; refreshParameter(); -// FormHierarchyTreePane.getInstance().refreshDockingView(); +// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); if (propertyChangeListener != null) { propertyChangeListener.propertyChange();