From 2fb040b215e91ec31762cdbae19bace7c4bd9814 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 23 May 2017 11:55:07 +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 --- .../design/mainframe/alphafine/CellType.java | 23 ++++++++++++------- .../alphafine/cell/CellModelHelper.java | 2 +- .../searchManager/RecentSearchManager.java | 5 +++- .../searchManager/RecommendSearchManager.java | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/CellType.java b/designer/src/com/fr/design/mainframe/alphafine/CellType.java index f1a6197ca6..652ac99de8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer/src/com/fr/design/mainframe/alphafine/CellType.java @@ -7,30 +7,37 @@ 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 cellType) { + public static CellType parse(int typeValue) { CellType type; - switch (cellType) { - case 0: + switch (typeValue) { + case RECOMMEND_VALUE: type = RECOMMEND; break; - case 1: + case ACTION_VALUE: type = ACTION; break; - case 2: + case DOCUMENT_VALUE: type = DOCUMENT; break; - case 3: + case FILE_VALUE: type = FILE; break; - case 4: + case PLUGIN_VALUE: type = PLUGIN; break; - case 5: + case REUSE_VALUE: type = REUSE; break; default: diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java b/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java index fdae196573..e5d6664d8f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java @@ -13,7 +13,7 @@ import com.fr.json.JSONObject; */ public class CellModelHelper { private static final String RESULT = "result"; - public static AlphaCellModel jsonToModel(JSONObject object) { + public static AlphaCellModel getModelFromJson(JSONObject object) { int typeValue = object.optInt("cellType"); AlphaCellModel cellModel = null; switch (CellType.parse(typeValue)) { 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 408ee2c84b..8afe874416 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java @@ -90,7 +90,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear if (nodeName.equals("model")) { String name = reader.getAttrAsString("cellModel", StringUtils.EMPTY); try { - list.add(CellModelHelper.jsonToModel(new JSONObject(name))); + list.add(CellModelHelper.getModelFromJson(new JSONObject(name))); } catch (JSONException e) { FRLogger.getLogger().error(e.getMessage()); } @@ -231,6 +231,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear for (String key : recentKVModelMap.keySet()) { if (ComparatorUtils.equals(key, searchText)) { recentModelList = recentKVModelMap.get(searchText); + if (recentModelList.size() > 3) { + return recentModelList.subList(0, 2); + } return recentModelList; } } 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 3febada364..dfd7a85091 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java @@ -44,7 +44,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { JSONArray jsonArray = jsonObject.optJSONArray("result"); if (jsonArray != null && jsonArray.length() > 0) { for (int i = 0; i < jsonArray.length(); i++) { - AlphaCellModel alphaCellModel = CellModelHelper.jsonToModel((JSONObject) jsonArray.get(i)); + AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); if (!RecentSearchManager.getInstance().getRecentModelList().contains(alphaCellModel)) { this.modelList.add(alphaCellModel); }