Browse Source

代码质量

master
XiaXiang 8 years ago
parent
commit
2fb040b215
  1. 23
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  2. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  3. 5
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java
  4. 2
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java

23
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); RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
private int typeValue; 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) { CellType(int type) {
this.typeValue = type; this.typeValue = type;
} }
public static CellType parse(int cellType) { public static CellType parse(int typeValue) {
CellType type; CellType type;
switch (cellType) { switch (typeValue) {
case 0: case RECOMMEND_VALUE:
type = RECOMMEND; type = RECOMMEND;
break; break;
case 1: case ACTION_VALUE:
type = ACTION; type = ACTION;
break; break;
case 2: case DOCUMENT_VALUE:
type = DOCUMENT; type = DOCUMENT;
break; break;
case 3: case FILE_VALUE:
type = FILE; type = FILE;
break; break;
case 4: case PLUGIN_VALUE:
type = PLUGIN; type = PLUGIN;
break; break;
case 5: case REUSE_VALUE:
type = REUSE; type = REUSE;
break; break;
default: default:

2
designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java

@ -13,7 +13,7 @@ import com.fr.json.JSONObject;
*/ */
public class CellModelHelper { public class CellModelHelper {
private static final String RESULT = "result"; private static final String RESULT = "result";
public static AlphaCellModel jsonToModel(JSONObject object) { public static AlphaCellModel getModelFromJson(JSONObject object) {
int typeValue = object.optInt("cellType"); int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null; AlphaCellModel cellModel = null;
switch (CellType.parse(typeValue)) { switch (CellType.parse(typeValue)) {

5
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")) { if (nodeName.equals("model")) {
String name = reader.getAttrAsString("cellModel", StringUtils.EMPTY); String name = reader.getAttrAsString("cellModel", StringUtils.EMPTY);
try { try {
list.add(CellModelHelper.jsonToModel(new JSONObject(name))); list.add(CellModelHelper.getModelFromJson(new JSONObject(name)));
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -231,6 +231,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
if (ComparatorUtils.equals(key, searchText)) { if (ComparatorUtils.equals(key, searchText)) {
recentModelList = recentKVModelMap.get(searchText); recentModelList = recentKVModelMap.get(searchText);
if (recentModelList.size() > 3) {
return recentModelList.subList(0, 2);
}
return recentModelList; return recentModelList;
} }
} }

2
designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java

@ -44,7 +44,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
JSONArray jsonArray = jsonObject.optJSONArray("result"); JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonArray != null && jsonArray.length() > 0) { if (jsonArray != null && jsonArray.length() > 0) {
for (int i = 0; i < jsonArray.length(); i++) { 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)) { if (!RecentSearchManager.getInstance().getRecentModelList().contains(alphaCellModel)) {
this.modelList.add(alphaCellModel); this.modelList.add(alphaCellModel);
} }

Loading…
Cancel
Save