Browse Source

alphafine修改

master
XiaXiang 8 years ago
parent
commit
3d6a95e5a7
  1. 2
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 16
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  3. 18
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  4. 25
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java
  5. 3
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java
  6. 29
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java
  7. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java
  8. 13
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ModelHandel.java
  9. 56
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java
  10. 26
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  11. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/default_product.png
  12. 55
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java
  13. 26
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java
  14. 38
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java
  15. 56
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  16. 8
      designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java
  17. 59
      designer/src/com/fr/design/mainframe/alphafine/searchManager/LatestSearchManager.java
  18. 69
      designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java
  19. 43
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java

2
designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -82,6 +82,8 @@ public class AlphaFineConstants {
public static final String DOCUMENT_SEARCH_URL = "http://help.finereport.com/?api-search-title-"; public static final String DOCUMENT_SEARCH_URL = "http://help.finereport.com/?api-search-title-";
public static final String DOCUMENT_INFORMATION_URL = "http://help.finereport.com/?api-search-did-";
public static final String PLUGIN_IMAGE_URL = "http://shopres.finereport.com/"; public static final String PLUGIN_IMAGE_URL = "http://shopres.finereport.com/";
public static final String SERVER_URL = "http://cloud.fanruan.com/api/monitor/record_of_afsearch/single"; public static final String SERVER_URL = "http://cloud.fanruan.com/api/monitor/record_of_afsearch/single";

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

@ -5,6 +5,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.cell.cellModel.*; import com.fr.design.mainframe.alphafine.cell.cellModel.*;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog; import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.io.File; import java.io.File;
@ -23,14 +24,23 @@ public class AlphaFineHelper {
} }
public static String findFolderName (String text) { public static String findFolderName (String text) {
String[] textArray = text.split("/"); return getSplitText(text, 2);
if (textArray != null && textArray.length > 1) { }
return textArray[textArray.length - 2];
private static String getSplitText(String text, int index) {
if (StringUtils.isNotBlank(text)) {
String[] textArray = text.split("/");
if (textArray != null && textArray.length > 1) {
return textArray[textArray.length - index];
}
} }
return null; return null;
} }
public static String findFileName (String text) {
return getSplitText(text, 1);
}

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

@ -2,6 +2,10 @@ package com.fr.design.mainframe.alphafine.cell;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.*; import com.fr.design.mainframe.alphafine.cell.cellModel.*;
import com.fr.design.mainframe.alphafine.searchManager.ActionSearchManager;
import com.fr.design.mainframe.alphafine.searchManager.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.searchManager.FileSearchManager;
import com.fr.design.mainframe.alphafine.searchManager.PluginSearchManager;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
/** /**
@ -12,14 +16,14 @@ public class CellModelHelper {
int cellType = object.optInt("cellType"); int cellType = object.optInt("cellType");
switch (CellType.parse(cellType)) { switch (CellType.parse(cellType)) {
case ACTION: case ACTION:
return ActionModel.jsonToModel(object); return ActionSearchManager.getModelFromCloud(object.optString("result"));
case DOCUMENT: case DOCUMENT:
return DocumentModel.jsonToModel(object); return DocumentSearchManager.getModelFromCloud(object.optJSONObject("result"));
case FILE: case FILE:
return FileModel.jsonToModel(object); return FileSearchManager.getModelFromCloud(object.optString("result"));
case PLUGIN: case PLUGIN:
case REUSE: case REUSE:
return PluginModel.jsonToModel(object); return PluginSearchManager.getModelFromCloud(object.optJSONObject("result"));
} }
return null; return null;
@ -28,14 +32,14 @@ public class CellModelHelper {
public static String getResultValueFromModel(AlphaCellModel cellModel) { public static String getResultValueFromModel(AlphaCellModel cellModel) {
switch (cellModel.getType()) { switch (cellModel.getType()) {
case ACTION: case ACTION:
return cellModel.getName(); return ((ActionModel)cellModel).getActionName();
case DOCUMENT: case DOCUMENT:
return ((DocumentModel)cellModel).getDocumentUrl(); return ((DocumentModel)cellModel).getInformationUrl();
case FILE: case FILE:
return ((FileModel)cellModel).getFilePath(); return ((FileModel)cellModel).getFilePath();
case REUSE: case REUSE:
case PLUGIN: case PLUGIN:
return ((PluginModel)cellModel).getPluginUrl(); return ((PluginModel)cellModel).getInformationUrl();
} }
return null; return null;
} }

25
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java

@ -14,6 +14,8 @@ import java.io.Serializable;
public class ActionModel extends AlphaCellModel implements Serializable { public class ActionModel extends AlphaCellModel implements Serializable {
private Action action; private Action action;
private String actionName;
public ActionModel(String name, String content, CellType type) { public ActionModel(String name, String content, CellType type) {
super(name, content, type); super(name, content, type);
} }
@ -50,27 +52,18 @@ public class ActionModel extends AlphaCellModel implements Serializable {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("name", getName()).put("action", getAction().getClass().getName()).put("cellType", getType().getCellType()); object.put("result", getAction().getClass().getName()).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
return object; return object;
} }
public static ActionModel jsonToModel(JSONObject object ) { public String getActionName() {
String name = object.optString("name"); return getAction().getClass().getName();
String actionName = object.optString("action"); }
Action action = null;
try { public void setActionName(String actionName) {
Class<?> className = Class.forName(actionName); this.actionName = actionName;
action = (Action) className.newInstance();
} catch (ClassNotFoundException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (IllegalAccessException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (InstantiationException e) {
FRLogger.getLogger().error(e.getMessage());
}
return new ActionModel(name, action);
} }
} }

3
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java

@ -8,7 +8,7 @@ import com.fr.json.JSONObject;
/** /**
* Created by XiaXiang on 2017/3/23. * Created by XiaXiang on 2017/3/23.
*/ */
public abstract class AlphaCellModel implements ModelHandel { public abstract class AlphaCellModel {
private String name; private String name;
private String content; private String content;
private String description; private String description;
@ -60,7 +60,6 @@ public abstract class AlphaCellModel implements ModelHandel {
this.description = description; this.description = description;
} }
@Override
public JSONObject ModelToJson() throws JSONException { public JSONObject ModelToJson() throws JSONException {
return null; return null;
} }

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

@ -11,14 +11,18 @@ import com.fr.json.JSONObject;
*/ */
public class DocumentModel extends AlphaCellModel { public class DocumentModel extends AlphaCellModel {
private String documentUrl; private String documentUrl;
private String informationUrl;
private int documentId;
public DocumentModel(String name, String content, CellType type) { public DocumentModel(String name, String content, CellType type) {
super(name, content, type); super(name, content, type);
} }
public DocumentModel(String name, String content, String documentUrl) { public DocumentModel(String name, String content, int documentId) {
super(name, content, CellType.DOCUMENT); super(name, content, CellType.DOCUMENT);
this.documentUrl = documentUrl; this.documentId = documentId;
this.informationUrl = AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentId;
this.documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + documentId + ".html";
} }
public String getDocumentUrl() { public String getDocumentUrl() {
@ -33,7 +37,7 @@ public class DocumentModel extends AlphaCellModel {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("name", getName()).put("content", getContent()).put("documentUrl", getDocumentUrl()).put("cellType", getType().getCellType()); object.put("result", getInformationUrl()).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -55,10 +59,19 @@ public class DocumentModel extends AlphaCellModel {
return documentUrl != null ? documentUrl.hashCode() : 0; return documentUrl != null ? documentUrl.hashCode() : 0;
} }
public static DocumentModel jsonToModel(JSONObject object) { public int getDocumentId() {
String name = object.optString("title"); return documentId;
String content = object.optString("summary"); }
String documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + object.optString("did") + ".html";
return new DocumentModel(name, content, documentUrl); public void setDocumentId(int documentId) {
this.documentId = documentId;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
} }
} }

8
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java

@ -34,19 +34,13 @@ public class FileModel extends AlphaCellModel{
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("name", getName()).put("content", getContent()).put("filePath", getFilePath()).put("cellType", getType().getCellType()); object.put("result", getFilePath()).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
return object; return object;
} }
public static FileModel jsonToModel(JSONObject object) {
String name = object.optString("name");
String content = object.optString("content");
String filePath = object.optString("filePath");
return new FileModel(name, content, filePath);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {

13
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ModelHandel.java

@ -1,13 +0,0 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/5/16.
*/
public interface ModelHandel {
JSONObject ModelToJson() throws JSONException;
}

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

@ -19,15 +19,27 @@ public class PluginModel extends AlphaCellModel {
private String version; private String version;
private String jartime; private String jartime;
private String link; private String link;
private String informationUrl;
private int pluginId;
private int price; private int price;
private static final String PLUGIN_INFORMATION_URL = "http://shop.finereport.com/ShopServer?pg=plugin&pid=";
private static final String REUSE_INFORMATION_URL = "http://shop.finereport.com/reuses/";
public PluginModel(String name, String content, CellType type) { public PluginModel(String name, String content, CellType type) {
super(name, content, type); super(name, content, type);
} }
public PluginModel(String name, String content, String pluginUrl, String imageUrl, String version, String jartime, CellType type, int price) { public PluginModel(String name, String content, String imageUrl, String version, String jartime, CellType type, int price, int pluginId) {
super(name, content); super(name, content);
setType(type); setType(type);
this.pluginUrl = pluginUrl; this.pluginId = pluginId;
if (getType() == CellType.PLUGIN) {
this.pluginUrl = AlphaFineConstants.PLUGIN_URL + pluginId;
this.informationUrl = PLUGIN_INFORMATION_URL + this.pluginId;
} else {
this.pluginUrl = AlphaFineConstants.REUSE_URL + pluginId;
this.informationUrl = REUSE_INFORMATION_URL + this.pluginId;
}
this.imageUrl = imageUrl; this.imageUrl = imageUrl;
this.jartime = jartime; this.jartime = jartime;
this.version = version; this.version = version;
@ -86,7 +98,7 @@ public class PluginModel extends AlphaCellModel {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("name", getName()).put("content", getContent()).put("pluginUrl", getPluginUrl()).put("imageUrl", getImageUrl()).put("cellType", getType().getCellType()).put("jartime", getJartime()).put("version", getVersion()).put("price", getPrice()); object.put("result", getInformationUrl()).put("cellType", getType().getCellType());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -110,27 +122,21 @@ public class PluginModel extends AlphaCellModel {
return pluginUrl != null ? pluginUrl.hashCode() : 0; return pluginUrl != null ? pluginUrl.hashCode() : 0;
} }
public static PluginModel jsonToModel(JSONObject object) {
String name = object.optString("name");
String content = object.optString("description"); public int getPluginId() {
String pluginUrl = AlphaFineConstants.REUSE_URL + object.optString("id"); return pluginId;
String imageUrl = null; }
try {
imageUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8"); public void setPluginId(int pluginId) {
} catch (UnsupportedEncodingException e) { this.pluginId = pluginId;
FRLogger.getLogger().error(e.getMessage()); }
}
String version = null; public String getInformationUrl() {
String jartime = null; return informationUrl;
CellType type = CellType.REUSE; }
String link = object.optString("link");
if (ComparatorUtils.equals(link, "plugin")) { public void setInformationUrl(String informationUrl) {
version = object.optString("version"); this.informationUrl = informationUrl;
jartime = object.optString("jartime");
type = CellType.PLUGIN;
pluginUrl = AlphaFineConstants.PLUGIN_URL + object.optString("id");
}
int price = object.optInt("price");
return new PluginModel(name, content, pluginUrl, imageUrl, version, jartime, type, price);
} }
} }

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

@ -20,7 +20,7 @@ import com.fr.design.mainframe.alphafine.previewPane.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.FilePreviewPane; import com.fr.design.mainframe.alphafine.previewPane.FilePreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.PluginPreviewPane; import com.fr.design.mainframe.alphafine.previewPane.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.searchManager.*; import com.fr.design.mainframe.alphafine.searchManager.*;
import com.fr.design.mainframe.alphafine.recentSearch.RecentSearchManager; import com.fr.design.mainframe.alphafine.searchManager.RecentSearchManager;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.form.main.Form; import com.fr.form.main.Form;
@ -216,7 +216,7 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker = new SwingWorker<SearchListModel, String>() { this.searchWorker = new SwingWorker<SearchListModel, String>() {
@Override @Override
protected SearchListModel doInBackground() throws Exception { protected SearchListModel doInBackground() {
return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText))); return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText)));
} }
@ -366,8 +366,17 @@ public class AlphaFineDialog extends UIDialog {
} }
this.searchWorker = new SwingWorker<Image, Void>() { this.searchWorker = new SwingWorker<Image, Void>() {
@Override @Override
protected Image doInBackground() throws Exception { protected Image doInBackground() {
BufferedImage bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl())); BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) {
try {
bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png"));
} catch (IOException e1) {
FRLogger.getLogger().error(e.getMessage());
}
}
return bufferedImage; return bufferedImage;
} }
@ -560,7 +569,9 @@ public class AlphaFineDialog extends UIDialog {
} }
/** /**
*todo:还没做上传服务器 * 上传数据到服务器
* @param searchKey
* @param cellModel
*/ */
private void sendToServer(String searchKey, AlphaCellModel cellModel) { private void sendToServer(String searchKey, AlphaCellModel cellModel) {
String username = DesignerEnvManager.getEnvManager().getBBSName(); String username = DesignerEnvManager.getEnvManager().getBBSName();
@ -583,12 +594,10 @@ public class AlphaFineDialog extends UIDialog {
HttpClient httpClient = new HttpClient(AlphaFineConstants.testurl, para, true); HttpClient httpClient = new HttpClient(AlphaFineConstants.testurl, para, true);
httpClient.setTimeout(5000); httpClient.setTimeout(5000);
httpClient.asGet(); httpClient.asGet();
if (!httpClient.isServerAlive()) { if (!httpClient.isServerAlive()) {
//return false; FRLogger.getLogger().error("404");
} }
String res = httpClient.getResponseText();
} }
private void rebuildShowMoreList(int index, MoreModel selectedValue) { private void rebuildShowMoreList(int index, MoreModel selectedValue) {
@ -656,6 +665,7 @@ public class AlphaFineDialog extends UIDialog {
public SearchListModel setjListModel(SearchListModel jListModel) { public SearchListModel setjListModel(SearchListModel jListModel) {
this.searchListModel = jListModel; this.searchListModel = jListModel;
System.out.print(this.searchListModel);
return this.searchListModel; return this.searchListModel;
} }

BIN
designer/src/com/fr/design/mainframe/alphafine/images/default_product.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

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

@ -8,7 +8,9 @@ import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.ActionModel; import com.fr.design.mainframe.alphafine.cell.cellModel.ActionModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.json.JSONObject;
import java.util.List; import java.util.List;
@ -17,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; private SearchResult filterModelList = new SearchResult();
private SearchResult lessModelList; private SearchResult lessModelList = new SearchResult();
private SearchResult moreModelList; private SearchResult moreModelList = new SearchResult();
public synchronized static ActionSearchManager getActionSearchManager() { public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) { if (actionSearchManager == null) {
@ -30,9 +32,6 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult showLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.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) {
@ -40,20 +39,23 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
filterModelList.add(new ActionModel(updateAction.getName() ,updateAction)); filterModelList.add(new ActionModel(updateAction.getName() ,updateAction));
} }
} }
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); if (filterModelList != null && filterModelList.size() >0) {
for (int i = 0; i < length; i++) { final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
lessModelList.add(filterModelList.get(i)); for (int i = 0; i < length; i++) {
} lessModelList.add(filterModelList.get(i));
for (int i = length; i < filterModelList.size(); i++) { }
moreModelList.add(filterModelList.get(i)); for (int i = length; i < filterModelList.size(); i++) {
} moreModelList.add(filterModelList.get(i));
if (filterModelList.size() > 0) { }
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { if (filterModelList.size() > 0) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.ACTION)); if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
} else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.ACTION));
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION)); } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION));
}
} }
} }
} }
return lessModelList; return lessModelList;
} }
@ -62,4 +64,21 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
public SearchResult showMoreSearchResult() { public SearchResult showMoreSearchResult() {
return moreModelList; return moreModelList;
} }
public static ActionModel getModelFromCloud(String actionName ) {
UpdateAction action = null;
String name = null;
try {
Class<?> className = Class.forName(actionName);
action = (UpdateAction) className.newInstance();
name = action.getName();
} catch (ClassNotFoundException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (IllegalAccessException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (InstantiationException e) {
FRLogger.getLogger().error(e.getMessage());
}
return new ActionModel(name, action);
}
} }

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

@ -1,12 +1,9 @@
package com.fr.design.mainframe.alphafine.searchManager; package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
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.Inter; import com.fr.general.Inter;
import java.io.*;
/** /**
* Created by XiaXiang on 2017/3/28. * Created by XiaXiang on 2017/3/28.
*/ */
@ -17,7 +14,7 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static FileSearchManager fileSearchManager; private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager; private static ActionSearchManager actionSearchManager;
private static ConcludeSearchManager concludeSearchManager; private static ConcludeSearchManager concludeSearchManager;
private static LatestSearchManager latestSearchManager; private static RecentSearchManager recentSearchManager;
public synchronized static AlphaSearchManager getSearchManager() { public synchronized static AlphaSearchManager getSearchManager() {
init(); init();
@ -33,13 +30,13 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
fileSearchManager = FileSearchManager.getFileSearchManager(); fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager(); actionSearchManager = ActionSearchManager.getActionSearchManager();
concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager(); concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager();
latestSearchManager = LatestSearchManager.getLatestSearchManager(); recentSearchManager = RecentSearchManager.getInstance();
} }
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult showLessSearchResult(String searchText) {
SearchResult latestModelList = latestSearchManager.showLessSearchResult(searchText); SearchResult latestModelList = recentSearchManager.showLessSearchResult(searchText);
SearchResult concludeModelList = concludeSearchManager.showLessSearchResult(searchText); SearchResult concludeModelList = concludeSearchManager.showLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.showLessSearchResult(searchText); SearchResult actionModelList = actionSearchManager.showLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.showLessSearchResult(searchText); SearchResult fileModelList = fileSearchManager.showLessSearchResult(searchText);
@ -69,21 +66,4 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
return null; return null;
} }
public SearchResult getLatestSearchResult() {
ObjectInputStream is;
SearchResult searchResult;
try {
is = new ObjectInputStream(new FileInputStream(AlphaFineHelper.getInfoFile()));
searchResult = (SearchResult) is.readObject();
} catch (IOException e) {
searchResult = new SearchResult();
} catch (ClassNotFoundException e) {
searchResult = new SearchResult();
}
return searchResult;
}
} }

38
designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java

@ -1,8 +1,17 @@
package com.fr.design.mainframe.alphafine.searchManager; 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.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.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils;
/** /**
* Created by XiaXiang on 2017/3/31. * Created by XiaXiang on 2017/3/31.
@ -10,6 +19,7 @@ import com.fr.general.Inter;
public class ConcludeSearchManager implements AlphaFineSearchProcessor { public class ConcludeSearchManager implements AlphaFineSearchProcessor {
private static ConcludeSearchManager concludeSearchManager = null; private static ConcludeSearchManager concludeSearchManager = null;
private SearchResult modelList; private SearchResult modelList;
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/?searchKey=";
public synchronized static ConcludeSearchManager getConcludeSearchManager() { public synchronized static ConcludeSearchManager getConcludeSearchManager() {
if (concludeSearchManager == null) { if (concludeSearchManager == null) {
@ -19,15 +29,37 @@ public class ConcludeSearchManager implements AlphaFineSearchProcessor {
} }
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult showLessSearchResult(String searchText) {
//todo: 猜您喜欢逻辑需要重新设计 String result;
this.modelList = new SearchResult(); this.modelList = new SearchResult();
modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false)); HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText));
httpClient.asGet();
result = httpClient.getResponseText();
try {
JSONObject jsonObject = new JSONObject(result);
if (jsonObject.optString("status").equals("success")) {
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));
if (!RecentSearchManager.getInstance().getRecentModelList().contains(alphaCellModel)) {
this.modelList.add(alphaCellModel);
}
}
}
}
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
if (modelList.size() > 0) {
modelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false));
}
return modelList; return modelList;
} }
@Override @Override
public SearchResult showMoreSearchResult() { public SearchResult showMoreSearchResult() {
return null; return new SearchResult();
} }
} }

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

@ -13,15 +13,13 @@ import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import java.security.AlgorithmConstraints;
/** /**
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class DocumentSearchManager implements AlphaFineSearchProcessor { public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null; private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList; private SearchResult lessModelList = new SearchResult();
private SearchResult moreModelList; private SearchResult moreModelList = new SearchResult();
public synchronized static DocumentSearchManager getDocumentSearchManager() { public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) { if (documentSearchManager == null) {
@ -33,8 +31,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
@Override @Override
public synchronized SearchResult showLessSearchResult(String searchText) { public synchronized SearchResult showLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.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";
@ -44,26 +40,24 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
result = httpClient.getResponseText(); result = httpClient.getResponseText();
try { try {
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null; JSONArray jsonArray = jsonObject.optJSONArray("docdata");
if (jsonObject.get("docdata") != null) { if (jsonArray != null && jsonArray.length() > 0) {
jsonArray = (JSONArray) jsonObject.get("docdata"); final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
} for (int i = 0; i < length; i++) {
if (jsonArray.length() > 0) { DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { this.lessModelList.add(cellModel);
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); }
} else { for (int i = length; i < jsonArray.length(); i++) {
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT)); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.moreModelList.add(cellModel);
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT));
}
} }
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
DocumentModel cellModel = getDocumentModel(jsonArray, i);
this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
DocumentModel cellModel = getDocumentModel(jsonArray, i);
this.moreModelList.add(cellModel);
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -71,16 +65,16 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return lessModelList; return lessModelList;
} }
} }
return lessModelList; return lessModelList;
} }
private DocumentModel getDocumentModel(JSONArray jsonArray, int i) throws JSONException { public static DocumentModel getModelFromCloud(JSONObject object) {
JSONObject object = jsonArray.getJSONObject(i); String name = object.optString("title");
String name = (String) object.get("title"); String content = object.optString("summary");
String content = ((String) object.get("summary")); int documentId = object.optInt("did");
String documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + object.get("did") + ".html"; return new DocumentModel(name, content, documentId);
return new DocumentModel(name, content, documentUrl);
} }
@Override @Override

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

@ -4,6 +4,7 @@ import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.FileModel; import com.fr.design.mainframe.alphafine.cell.cellModel.FileModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel; import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
@ -11,6 +12,7 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -148,4 +150,10 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
} }
} }
public static FileModel getModelFromCloud(String filePath) {
String name = AlphaFineHelper.findFileName(filePath);
String content = AlphaFineHelper.findFolderName(filePath);
return new FileModel(name, content, filePath);
}
} }

59
designer/src/com/fr/design/mainframe/alphafine/searchManager/LatestSearchManager.java

@ -1,59 +0,0 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.recentSearch.RecentSearchManager;
import com.fr.general.Inter;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class LatestSearchManager implements AlphaFineSearchProcessor {
private static LatestSearchManager latestSearchManager = null;
private SearchResult modelList;
private SearchResult latestModelList;
public synchronized static LatestSearchManager getLatestSearchManager() {
if (latestSearchManager == null) {
latestSearchManager = new LatestSearchManager();
}
return latestSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.modelList = new SearchResult();
modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest"), false));
//todo: 本地常用逻辑需要重新设计
if (RecentSearchManager.getInstance().getRecentModelList(searchText) != null) {
modelList.addAll(RecentSearchManager.getInstance().getRecentModelList(searchText));
}
// if (getLatestModelList() != null && getLatestModelList().size() > 0) {
// modelList.addAll(getLatestModelList());
// }
return modelList;
}
@Override
public SearchResult showMoreSearchResult() {
return null;
}
public SearchResult getModelList() {
return modelList;
}
public void setModelList(SearchResult modelList) {
this.modelList = modelList;
}
public SearchResult getLatestModelList() {
if(this.latestModelList != null && this.latestModelList.size() > 0) {
return this.latestModelList;
}
return AlphaSearchManager.getSearchManager().getLatestSearchResult();
}
public void setLatestModelList(SearchResult latestModelList) {
this.latestModelList = latestModelList;
}
}

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

@ -13,6 +13,7 @@ import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.plugin.chart.designer.other.HyperlinkMapFactory;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -49,26 +50,28 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
result = httpClient.getResponseText(); result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null; JSONArray jsonArray = null;
if (jsonObject.get("result") != null) { if (jsonObject.optJSONObject("result") != null) {
jsonArray = (JSONArray) jsonObject.get("result"); jsonArray = jsonObject.optJSONArray("result");
} }
if (jsonArray.length() > 0) { if (jsonArray != null && jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); for (int i = 0; i < length; i++) {
} else { PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN)); this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
this.moreModelList.add(cellModel);
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN));
}
} }
} }
int length = Math.min(5, jsonArray.length());
for (int i = 0; i < length; i++) {
PluginModel cellModel = getPluginModel(jsonArray, i);
this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
PluginModel cellModel = getPluginModel(jsonArray, i);
this.moreModelList.add(cellModel);
}
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
return lessModelList; return lessModelList;
@ -77,29 +80,29 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return this.lessModelList; return this.lessModelList;
} }
private PluginModel getPluginModel(JSONArray jsonArray, int i) throws JSONException { private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) {
JSONObject object = jsonArray.getJSONObject(i); String name = object.optString("name");
String name = (String) object.get("name"); String content = object.optString("description");
String content = ((String) object.get("description")); int pluginId = object.optInt("id");
String pluginUrl = AlphaFineConstants.REUSE_URL + object.get("id");
String imageUrl = null; String imageUrl = null;
try { try {
imageUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.get("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8"); imageUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
String version = null; String version = null;
String jartime = null; String jartime = null;
CellType type = CellType.REUSE; CellType type;
String link = (String) object.get("link"); String link = object.optString("link");
if (ComparatorUtils.equals(link, "plugin")) { if (ComparatorUtils.equals(link, "plugin")) {
version = (String) object.get("version"); version = isFromCloud? object.optString("pluginversion") : object.optString("version");
jartime = (String) object.get("jartime"); jartime = object.optString("jartime");
type = CellType.PLUGIN; type = CellType.PLUGIN;
pluginUrl = AlphaFineConstants.PLUGIN_URL + object.get("id"); } else {
type = CellType.REUSE;
} }
int price = (int) object.get("price"); int price = object.optInt("price");
return new PluginModel(name, content, pluginUrl, imageUrl, version, jartime, type, price); return new PluginModel(name, content, imageUrl, version, jartime, type, price, pluginId);
} }
@Override @Override
@ -107,6 +110,14 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return this.moreModelList; return this.moreModelList;
} }
public static PluginModel getModelFromCloud(JSONObject object) {
JSONObject jsonObject = object.optJSONObject("result");
if (jsonObject != null) {
return getPluginModel(jsonObject, true);
}
return null;
}

43
designer/src/com/fr/design/mainframe/alphafine/recentSearch/RecentSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java

@ -1,14 +1,16 @@
package com.fr.design.mainframe.alphafine.recentSearch; package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
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.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.XMLFileManager; import com.fr.file.XMLFileManager;
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.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -29,7 +31,7 @@ import java.util.Map;
/** /**
* Created by XiaXiang on 2017/5/15. * Created by XiaXiang on 2017/5/15.
*/ */
public class RecentSearchManager extends XMLFileManager { public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor {
private static final String XML_TAG = "AlphafineRecent"; private static final String XML_TAG = "AlphafineRecent";
private static RecentSearchManager recentSearchManager = null; private static RecentSearchManager recentSearchManager = null;
@ -37,8 +39,7 @@ public class RecentSearchManager extends XMLFileManager {
private List<String> fileList; private List<String> fileList;
private List<String> actionList; private List<String> actionList;
private List<String> documentList; private List<String> documentList;
private SearchResult modelList;
//private List<recentKVModel> recentKVModelList = new ArrayList<>();
private List<String> pluginList; private List<String> pluginList;
private List<AlphaCellModel> recentModelList = new ArrayList<>(); private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>(); private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
@ -63,7 +64,7 @@ public class RecentSearchManager extends XMLFileManager {
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String nodeName = reader.getTagName(); String nodeName = reader.getTagName();
if (nodeName.equals("RecentModel")) { if (nodeName.equals("RecentModelList")) {
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY); String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY);
final ArrayList<AlphaCellModel> list = new ArrayList<AlphaCellModel>(); final ArrayList<AlphaCellModel> list = new ArrayList<AlphaCellModel>();
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
@ -71,7 +72,7 @@ public class RecentSearchManager extends XMLFileManager {
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String nodeName = reader.getTagName(); String nodeName = reader.getTagName();
if (nodeName.equals("modelList")) { 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.jsonToModel(new JSONObject(name)));
@ -97,18 +98,20 @@ public class RecentSearchManager extends XMLFileManager {
writer.startTAG(XML_TAG); writer.startTAG(XML_TAG);
if (!recentKVModelMap.isEmpty()) { if (!recentKVModelMap.isEmpty()) {
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
writer.startTAG("RecentModel"); writer.startTAG("RecentModelList");
writer.attr("searchKey", key); writer.attr("searchKey", key);
writer.startTAG("modelList");
for (AlphaCellModel model : recentKVModelMap.get(key)) { for (AlphaCellModel model : recentKVModelMap.get(key)) {
try { try {
String name = model.ModelToJson().toString(); String name = model.ModelToJson().toString();
writer.startTAG("model");
writer.attr("cellModel", name); writer.attr("cellModel", name);
writer.end();
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
writer.end();
writer.end(); writer.end();
} }
} }
@ -222,12 +225,12 @@ public class RecentSearchManager extends XMLFileManager {
public List<AlphaCellModel> getRecentModelList(String searchText) { public List<AlphaCellModel> getRecentModelList(String searchText) {
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
if (recentKVModelMap.keySet().contains(searchText)) { if (key.equals(searchText)) {
List<AlphaCellModel> list = recentKVModelMap.get(searchText); List<AlphaCellModel> list = recentKVModelMap.get(searchText);
return list; return list;
} }
} }
return null; return recentModelList;
} }
public void addRecentModel(String searchKey, AlphaCellModel cellModel) { public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
@ -284,6 +287,22 @@ public class RecentSearchManager extends XMLFileManager {
this.recentKVModelMap = recentKVModelMap; this.recentKVModelMap = recentKVModelMap;
} }
@Override
public SearchResult showLessSearchResult(String searchText) {
this.modelList = new SearchResult();
recentModelList = getRecentModelList(searchText);
if (recentModelList != null && recentModelList.size() > 0) {
modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest"), false));
}
modelList.addAll(recentModelList);
return modelList;
}
@Override
public SearchResult showMoreSearchResult() {
return new SearchResult();
}
// public List<recentKVModel> getRecentKVModelList() { // public List<recentKVModel> getRecentKVModelList() {
// return recentKVModelList; // return recentKVModelList;
// } // }
Loading…
Cancel
Save