Browse Source

代码质量

master
XiaXiang 8 years ago
parent
commit
bcabaebbbf
  1. 4
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java
  3. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java
  4. 27
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  5. 13
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java
  6. 4
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java
  7. 20
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java
  8. 10
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  9. 4
      designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java
  10. 9
      designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java
  11. 53
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java
  12. 19
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java

4
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -19,10 +19,6 @@ public class AlphaFineHelper {
dialog.setVisible(true); dialog.setVisible(true);
} }
public static File getInfoFile() {
return new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), AlphaFineConstants.SAVE_FILE_NAME));
}
public static String findFolderName (String text) { public static String findFolderName (String text) {
return getSplitText(text, 2); return getSplitText(text, 2);
} }

4
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java

@ -37,7 +37,9 @@ public class DocumentModel extends AlphaCellModel {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("result", getInformationUrl()).put("cellType", getType().getCellType()); JSONObject modelObject = JSONObject.create();
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId());
object.put("result", modelObject).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }

4
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java

@ -98,7 +98,9 @@ public class PluginModel extends AlphaCellModel {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("result", getInformationUrl()).put("cellType", getType().getCellType()); JSONObject modelObject = JSONObject.create();
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getCellType()).put("price", getPrice()).put("id", getPluginId());
object.put("result", modelObject).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }

27
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -217,7 +217,7 @@ public class AlphaFineDialog extends UIDialog {
@Override @Override
protected SearchListModel doInBackground() { protected SearchListModel doInBackground() {
return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText))); return setListModel(new SearchListModel(AlphaSearchManager.getSearchManager().getLessSearchResult(searchText)));
} }
@Override @Override
@ -634,19 +634,19 @@ public class AlphaFineDialog extends UIDialog {
SearchResult moreResult; SearchResult moreResult;
switch (selectedValue.getType()) { switch (selectedValue.getType()) {
case PLUGIN: case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().showMoreSearchResult(); moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult();
break; break;
case DOCUMENT: case DOCUMENT:
moreResult = DocumentSearchManager.getDocumentSearchManager().showMoreSearchResult(); moreResult = DocumentSearchManager.getDocumentSearchManager().getMoreSearchResult();
break; break;
case FILE: case FILE:
moreResult = FileSearchManager.getFileSearchManager().showMoreSearchResult(); moreResult = FileSearchManager.getFileSearchManager().getMoreSearchResult();
break; break;
case ACTION: case ACTION:
moreResult = ActionSearchManager.getActionSearchManager().showMoreSearchResult(); moreResult = ActionSearchManager.getActionSearchManager().getMoreSearchResult();
break; break;
default: default:
moreResult = AlphaSearchManager.getSearchManager().showMoreSearchResult(); moreResult = AlphaSearchManager.getSearchManager().getMoreSearchResult();
} }
return moreResult; return moreResult;
} }
@ -655,17 +655,16 @@ public class AlphaFineDialog extends UIDialog {
return (SearchListModel) searchResultList.getModel(); return (SearchListModel) searchResultList.getModel();
} }
//测试 // //测试
public static void main(String[] args) { // public static void main(String[] args) {
AlphaFineDialog alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame()); // AlphaFineDialog alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
alphaFineDialog.setSize(new Dimension(680,55)); // alphaFineDialog.setSize(new Dimension(680,55));
alphaFineDialog.setVisible(true); // alphaFineDialog.setVisible(true);
} // }
public SearchListModel setjListModel(SearchListModel jListModel) { public SearchListModel setListModel(SearchListModel jListModel) {
this.searchListModel = jListModel; this.searchListModel = jListModel;
System.out.print(this.searchListModel);
return this.searchListModel; return this.searchListModel;
} }

13
designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java

@ -19,9 +19,9 @@ import java.util.List;
*/ */
public class ActionSearchManager implements AlphaFineSearchProcessor { public class ActionSearchManager implements AlphaFineSearchProcessor {
private static ActionSearchManager actionSearchManager = null; private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList = new SearchResult(); private SearchResult filterModelList;
private SearchResult lessModelList = new SearchResult(); private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult(); private SearchResult moreModelList;
public synchronized static ActionSearchManager getActionSearchManager() { public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) { if (actionSearchManager == null) {
@ -31,7 +31,10 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
filterModelList = new SearchResult();
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainAction()) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainAction()) {
List<UpdateAction> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); List<UpdateAction> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateAction updateAction : updateActions) { for (UpdateAction updateAction : updateActions) {
@ -61,7 +64,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return moreModelList; return moreModelList;
} }

4
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java

@ -6,7 +6,7 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public interface AlphaFineSearchProcessor { public interface AlphaFineSearchProcessor {
SearchResult showLessSearchResult(String searchText); SearchResult getLessSearchResult(String searchText);
SearchResult showMoreSearchResult(); SearchResult getMoreSearchResult();
} }

20
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java

@ -13,7 +13,7 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager; private static DocumentSearchManager documentSearchManager;
private static FileSearchManager fileSearchManager; private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager; private static ActionSearchManager actionSearchManager;
private static ConcludeSearchManager concludeSearchManager; private static RecommendSearchManager recommendSearchManager;
private static RecentSearchManager recentSearchManager; private static RecentSearchManager recentSearchManager;
public synchronized static AlphaSearchManager getSearchManager() { public synchronized static AlphaSearchManager getSearchManager() {
@ -29,19 +29,19 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
documentSearchManager = DocumentSearchManager.getDocumentSearchManager(); documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager(); fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager(); actionSearchManager = ActionSearchManager.getActionSearchManager();
concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager(); recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getInstance(); recentSearchManager = RecentSearchManager.getInstance();
} }
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult latestModelList = recentSearchManager.showLessSearchResult(searchText); SearchResult latestModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult concludeModelList = concludeSearchManager.showLessSearchResult(searchText); SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.showLessSearchResult(searchText); SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.showLessSearchResult(searchText); SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.showLessSearchResult(searchText); SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.showLessSearchResult(searchText); SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText);
latestModelList.addAll(concludeModelList); latestModelList.addAll(concludeModelList);
latestModelList.addAll(actionModelList); latestModelList.addAll(actionModelList);
latestModelList.addAll(fileModelList); latestModelList.addAll(fileModelList);
@ -62,7 +62,7 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return null; return null;
} }

10
designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java

@ -18,8 +18,8 @@ import com.fr.json.JSONObject;
*/ */
public class DocumentSearchManager implements AlphaFineSearchProcessor { public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null; private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList = new SearchResult(); private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult(); private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() { public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) { if (documentSearchManager == null) {
@ -30,7 +30,9 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) {
String result; String result;
String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1"; String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1";
@ -78,7 +80,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return moreModelList; return moreModelList;
} }

4
designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java

@ -41,7 +41,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
} }
} }
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.filterModelList = new SearchResult(); this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
@ -120,7 +120,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return moreModelList; return moreModelList;
} }

9
designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java

@ -35,7 +35,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
@ -49,10 +49,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
httpClient.asGet(); httpClient.asGet();
result = httpClient.getResponseText(); result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null; JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonObject.optJSONObject("result") != null) {
jsonArray = jsonObject.optJSONArray("result");
}
if (jsonArray != null && jsonArray.length() > 0) { if (jsonArray != null && jsonArray.length() > 0) {
int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
@ -106,7 +103,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return this.moreModelList; return this.moreModelList;
} }

53
designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java

@ -8,6 +8,7 @@ import com.fr.design.mainframe.alphafine.cell.cellModel.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel; import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.XMLFileManager; import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -100,7 +101,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
writer.startTAG("RecentModelList"); writer.startTAG("RecentModelList");
writer.attr("searchKey", key); writer.attr("searchKey", key);
for (AlphaCellModel model : recentKVModelMap.get(key)) { for (AlphaCellModel model : recentKVModelMap.get(key)) {
try { try {
String name = model.ModelToJson().toString(); String name = model.ModelToJson().toString();
@ -111,7 +111,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
writer.end(); writer.end();
} }
} }
@ -225,7 +224,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
public List<AlphaCellModel> getRecentModelList(String searchText) { public List<AlphaCellModel> getRecentModelList(String searchText) {
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
if (key.equals(searchText)) { if (ComparatorUtils.equals(key, searchText)) {
List<AlphaCellModel> list = recentKVModelMap.get(searchText); List<AlphaCellModel> list = recentKVModelMap.get(searchText);
return list; return list;
} }
@ -234,8 +233,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} }
public void addRecentModel(String searchKey, AlphaCellModel cellModel) { public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
//final AlphaCellModel alphaCellModel = getCellModel(cellModel);
if (recentKVModelMap.keySet().contains(searchKey)) { if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey); List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey);
if (cellModels.contains(cellModel)) { if (cellModels.contains(cellModel)) {
@ -244,51 +241,24 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} else { } else {
cellModels.add(cellModel); cellModels.add(cellModel);
} }
trimToSize(cellModels);
} else { } else {
List<AlphaCellModel> list = new ArrayList<>(); List<AlphaCellModel> list = new ArrayList<>();
list.add(cellModel); list.add(cellModel);
recentKVModelMap.put(searchKey, list); recentKVModelMap.put(searchKey, list);
} }
// if (alphaCellModel != null) {
// moveOnTop(alphaCellModel);
// } else {
// this.recentModelList.add(cellModel);
// }
// trimToSize();
} }
private void moveOnTop(AlphaCellModel alphaCellModel) {
recentModelList.remove(alphaCellModel);
recentModelList.add(alphaCellModel);
}
private synchronized void trimToSize() { private synchronized void trimToSize(List<AlphaCellModel> cellModels) {
if (recentModelList.size() > AlphaFineConstants.MAX_FILE_SIZE) { if (cellModels.size() > AlphaFineConstants.MAX_FILE_SIZE) {
recentModelList.remove(0); cellModels.remove(0);
} }
} }
private synchronized AlphaCellModel getCellModel(AlphaCellModel model) {
for (int i = recentModelList.size() - 1; i >= 0; i--) {
final AlphaCellModel entry = recentModelList.get(i);
String name = entry.getName();
if (name.equals(model.getName())) {
return entry;
}
}
return null;
}
public Map<String, List<AlphaCellModel>> getRecentKVModelMap() {
return recentKVModelMap;
}
public void setRecentKVModelMap(Map<String, List<AlphaCellModel>> recentKVModelMap) {
this.recentKVModelMap = recentKVModelMap;
}
@Override @Override
public SearchResult showLessSearchResult(String searchText) { public SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult(); this.modelList = new SearchResult();
recentModelList = getRecentModelList(searchText); recentModelList = getRecentModelList(searchText);
if (recentModelList != null && recentModelList.size() > 0) { if (recentModelList != null && recentModelList.size() > 0) {
@ -299,15 +269,8 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return new SearchResult(); return new SearchResult();
} }
// public List<recentKVModel> getRecentKVModelList() {
// return recentKVModelList;
// }
//
// public void setRecentKVModelList(List<recentKVModel> recentKVModelList) {
// this.recentKVModelList = recentKVModelList;
// }
} }

19
designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java

@ -2,7 +2,6 @@ package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.cellModel.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.cellModel.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel; import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -16,19 +15,19 @@ import com.fr.stable.CodeUtils;
/** /**
* Created by XiaXiang on 2017/3/31. * Created by XiaXiang on 2017/3/31.
*/ */
public class ConcludeSearchManager implements AlphaFineSearchProcessor { public class RecommendSearchManager implements AlphaFineSearchProcessor {
private static ConcludeSearchManager concludeSearchManager = null; private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList; private SearchResult modelList;
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/?searchKey="; private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchddKey=";
public synchronized static ConcludeSearchManager getConcludeSearchManager() { public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (concludeSearchManager == null) { if (recommendSearchManager == null) {
concludeSearchManager = new ConcludeSearchManager(); recommendSearchManager = new RecommendSearchManager();
} }
return concludeSearchManager; return recommendSearchManager;
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
String result; String result;
this.modelList = new SearchResult(); this.modelList = new SearchResult();
HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText)); HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText));
@ -58,7 +57,7 @@ public class ConcludeSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult getMoreSearchResult() {
return new SearchResult(); return new SearchResult();
} }
Loading…
Cancel
Save