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);
}
public static File getInfoFile() {
return new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), AlphaFineConstants.SAVE_FILE_NAME));
}
public static String findFolderName (String text) {
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() {
JSONObject object = JSONObject.create();
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) {
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() {
JSONObject object = JSONObject.create();
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) {
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
protected SearchListModel doInBackground() {
return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText)));
return setListModel(new SearchListModel(AlphaSearchManager.getSearchManager().getLessSearchResult(searchText)));
}
@Override
@ -634,19 +634,19 @@ public class AlphaFineDialog extends UIDialog {
SearchResult moreResult;
switch (selectedValue.getType()) {
case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().showMoreSearchResult();
moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult();
break;
case DOCUMENT:
moreResult = DocumentSearchManager.getDocumentSearchManager().showMoreSearchResult();
moreResult = DocumentSearchManager.getDocumentSearchManager().getMoreSearchResult();
break;
case FILE:
moreResult = FileSearchManager.getFileSearchManager().showMoreSearchResult();
moreResult = FileSearchManager.getFileSearchManager().getMoreSearchResult();
break;
case ACTION:
moreResult = ActionSearchManager.getActionSearchManager().showMoreSearchResult();
moreResult = ActionSearchManager.getActionSearchManager().getMoreSearchResult();
break;
default:
moreResult = AlphaSearchManager.getSearchManager().showMoreSearchResult();
moreResult = AlphaSearchManager.getSearchManager().getMoreSearchResult();
}
return moreResult;
}
@ -655,17 +655,16 @@ public class AlphaFineDialog extends UIDialog {
return (SearchListModel) searchResultList.getModel();
}
//测试
public static void main(String[] args) {
AlphaFineDialog alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
alphaFineDialog.setSize(new Dimension(680,55));
alphaFineDialog.setVisible(true);
}
// //测试
// public static void main(String[] args) {
// AlphaFineDialog alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
// alphaFineDialog.setSize(new Dimension(680,55));
// alphaFineDialog.setVisible(true);
// }
public SearchListModel setjListModel(SearchListModel jListModel) {
public SearchListModel setListModel(SearchListModel jListModel) {
this.searchListModel = jListModel;
System.out.print(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 {
private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList = new SearchResult();
private SearchResult lessModelList = new SearchResult();
private SearchResult moreModelList = new SearchResult();
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) {
@ -31,7 +31,10 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
@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()) {
List<UpdateAction> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateAction updateAction : updateActions) {
@ -61,7 +64,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
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.
*/
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 FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager;
private static ConcludeSearchManager concludeSearchManager;
private static RecommendSearchManager recommendSearchManager;
private static RecentSearchManager recentSearchManager;
public synchronized static AlphaSearchManager getSearchManager() {
@ -29,19 +29,19 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager();
recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getInstance();
}
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
SearchResult latestModelList = recentSearchManager.showLessSearchResult(searchText);
SearchResult concludeModelList = concludeSearchManager.showLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.showLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.showLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.showLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.showLessSearchResult(searchText);
public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult latestModelList = 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);
@ -62,7 +62,7 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
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 {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList = new SearchResult();
private SearchResult moreModelList = new SearchResult();
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
@ -30,7 +30,9 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
public synchronized SearchResult getLessSearchResult(String searchText) {
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) {
String result;
String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1";
@ -78,7 +80,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
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.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
@ -120,7 +120,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
return moreModelList;
}

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

@ -35,7 +35,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
@ -49,10 +49,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
httpClient.asGet();
result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null;
if (jsonObject.optJSONObject("result") != null) {
jsonArray = jsonObject.optJSONArray("result");
}
JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonArray != null && jsonArray.length() > 0) {
int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
@ -106,7 +103,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
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.model.SearchResult;
import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
@ -100,7 +101,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
for (String key : recentKVModelMap.keySet()) {
writer.startTAG("RecentModelList");
writer.attr("searchKey", key);
for (AlphaCellModel model : recentKVModelMap.get(key)) {
try {
String name = model.ModelToJson().toString();
@ -111,7 +111,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
FRLogger.getLogger().error(e.getMessage());
}
}
writer.end();
}
}
@ -225,7 +224,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
public List<AlphaCellModel> getRecentModelList(String searchText) {
for (String key : recentKVModelMap.keySet()) {
if (key.equals(searchText)) {
if (ComparatorUtils.equals(key, searchText)) {
List<AlphaCellModel> list = recentKVModelMap.get(searchText);
return list;
}
@ -234,8 +233,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
//final AlphaCellModel alphaCellModel = getCellModel(cellModel);
if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey);
if (cellModels.contains(cellModel)) {
@ -244,51 +241,24 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} else {
cellModels.add(cellModel);
}
trimToSize(cellModels);
} else {
List<AlphaCellModel> list = new ArrayList<>();
list.add(cellModel);
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() {
if (recentModelList.size() > AlphaFineConstants.MAX_FILE_SIZE) {
recentModelList.remove(0);
private synchronized void trimToSize(List<AlphaCellModel> cellModels) {
if (cellModels.size() > AlphaFineConstants.MAX_FILE_SIZE) {
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
public SearchResult showLessSearchResult(String searchText) {
public SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult();
recentModelList = getRecentModelList(searchText);
if (recentModelList != null && recentModelList.size() > 0) {
@ -299,15 +269,8 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
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.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.model.SearchResult;
import com.fr.general.FRLogger;
@ -16,19 +15,19 @@ import com.fr.stable.CodeUtils;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class ConcludeSearchManager implements AlphaFineSearchProcessor {
private static ConcludeSearchManager concludeSearchManager = null;
public class RecommendSearchManager implements AlphaFineSearchProcessor {
private static RecommendSearchManager recommendSearchManager = null;
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() {
if (concludeSearchManager == null) {
concludeSearchManager = new ConcludeSearchManager();
public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (recommendSearchManager == null) {
recommendSearchManager = new RecommendSearchManager();
}
return concludeSearchManager;
return recommendSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
public synchronized SearchResult getLessSearchResult(String searchText) {
String result;
this.modelList = new SearchResult();
HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText));
@ -58,7 +57,7 @@ public class ConcludeSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
return new SearchResult();
}
Loading…
Cancel
Save