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);
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:

2
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)) {

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")) {
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;
}
}

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");
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);
}

Loading…
Cancel
Save