Browse Source

Merge remote-tracking branch 'origin/9.0' into 9.0

master
juhaoyu 8 years ago
parent
commit
7a4abc0942
  1. 14
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 45
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  3. 22
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  4. 41
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  5. 30
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java
  6. 27
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java
  7. 29
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java
  8. 77
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java
  9. 77
      designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  10. 21
      designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java
  11. 87
      designer/src/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java
  12. 66
      designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  13. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java
  14. 149
      designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  15. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  16. 5
      designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  17. 145
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  18. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/default_product.png
  19. 2
      designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java
  20. 2
      designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java
  21. 2
      designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java
  22. 2
      designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java
  23. 57
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  24. 21
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java
  25. 69
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java
  26. 95
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  27. 53
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  28. 128
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  29. 308
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  30. 69
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java
  31. 12
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java
  32. 89
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java
  33. 33
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java
  34. 91
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  35. 55
      designer/src/com/fr/design/mainframe/alphafine/searchManager/LatestSearchManager.java
  36. 105
      designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java
  37. 2
      designer/src/com/fr/design/parameter/ParameterDefinitePane.java
  38. 2
      designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java
  39. 2
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  40. 3
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties

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

@ -12,6 +12,8 @@ public class AlphaFineConstants {
public static final int SHOW_SIZE = 5;
public static final int MAX_FILE_SIZE = 100;
public static final int LATEST_SHOW_SIZE = 3;
public static final int HEIGHT = 680;
@ -72,13 +74,21 @@ public class AlphaFineConstants {
public static final String PLUGIN_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
public static final String PLUGIN_IMAGE_URL = "http://shop.finereport.com/plugin/";
public static final String PLUGIN_URL = "http://shop.finereport.com/plugin/";
public static final String REUSE_IMAGE_URL = "http://shop.finereport.com/reuse/";
public static final String REUSE_URL = "http://shop.finereport.com/reuse/";
public static final String DOCUMENT_DOC_URL = "http://help.finereport.com/doc-view-";
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 SERVER_URL = "http://cloud.fanruan.com/api/monitor/record_of_afsearch/single";
//TODO:先用本地服务器测试一下,避免影响云中心正常信息收集
public static final String CLOUD_TEST_URL = "http://localhost:8080/monitor/monitor/record_of_afsearch/single";
}

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

@ -1,34 +1,57 @@
package com.fr.design.mainframe.alphafine;
import com.fr.base.FRContext;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.stable.StableUtils;
import java.io.File;
import com.fr.stable.StringUtils;
/**
* Created by XiaXiang on 2017/5/8.
*/
public class AlphaFineHelper {
/**
* 弹出alphafine搜索面板
*/
public static void showAlphaFineDialog() {
AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
dialog.setVisible(true);
}
public static File getInfoFile() {
return new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), AlphaFineConstants.SAVE_FILE_NAME));
}
/**
* 获取文件名上级目录
* @param text
* @return
*/
public static String findFolderName (String text) {
String[] textArray = text.split(File.separator);
if (textArray != null && textArray.length > 1) {
return textArray[textArray.length - 2];
return getSplitText(text, 2);
}
/**
* 分割字符串获取文件名文件名上级目录等
* @param text
* @param index
* @return
*/
private static String getSplitText(String text, int index) {
if (StringUtils.isNotBlank(text)) {
String[] textArray = text.replaceAll("\\\\", "/").split("/");
if (textArray != null && textArray.length > 1) {
return textArray[textArray.length - index];
}
}
return null;
}
/**
* 获取文件名
* @param text
* @return
*/
public static String findFileName (String text) {
return getSplitText(text, 1);
}
}

22
designer/src/com/fr/design/mainframe/alphafine/CellType.java

@ -4,21 +4,29 @@ package com.fr.design.mainframe.alphafine;
* Created by XiaXiang on 2017/4/27.
*/
public enum CellType {
PLUGIN(0), DOCUMENT(1), FILE(2), ACTION(3), REUSE(4);
RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
private int typeValue;
private int cellType;
CellType(int type) {
this.cellType = type;
this.typeValue = type;
}
public static CellType parse(int typeValue) {
for (CellType type : CellType.values()) {
if (type.getTypeValue() == typeValue) {
return type;
}
}
return FILE;
public int getCellType() {
return cellType;
}
public int getTypeValue() {
return typeValue;
}
public void setCellType(int cellType) {
this.cellType = cellType;
public void setTypeValue(int typeValue) {
this.typeValue = typeValue;
}
}

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

@ -0,0 +1,41 @@
package com.fr.design.mainframe.alphafine.cell;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.*;
import com.fr.design.mainframe.alphafine.search.manager.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.PluginSearchManager;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/5/17.
*/
public class CellModelHelper {
private static final String RESULT = "result";
public static AlphaCellModel getModelFromJson(JSONObject object) {
int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null;
switch (CellType.parse(typeValue)) {
case ACTION:
cellModel = ActionSearchManager.getModelFromCloud(object.optString(RESULT));
break;
case DOCUMENT:
cellModel = DocumentSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
case FILE:
cellModel = FileSearchManager.getModelFromCloud(object.optString(RESULT));
break;
case PLUGIN:
case REUSE:
cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
}
return cellModel;
}
public static String getResultValueFromModel(AlphaCellModel cellModel) {
return cellModel.getStoreInformation();
}
}

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

@ -1,30 +0,0 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import javax.swing.*;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class ActionModel extends AlphaCellModel implements Serializable {
private Action action;
public ActionModel(String name, String content, CellType type) {
super(name, content, type);
}
public ActionModel(String name, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
}
public Action getAction() {
return action;
}
public void setAction(Action action) {
this.action = action;
}
}

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

@ -1,27 +0,0 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class DocumentModel extends AlphaCellModel {
private String documentUrl;
public DocumentModel(String name, String content, CellType type) {
super(name, content, type);
}
public DocumentModel(String name, String content, String documentUrl) {
super(name, content, CellType.DOCUMENT);
this.documentUrl = documentUrl;
}
public String getDocumentUrl() {
return documentUrl;
}
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
}

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

@ -1,29 +0,0 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class FileModel extends AlphaCellModel{
private String filePath;
public FileModel(String name, String content, CellType type) {
super(name, content, type);
}
public FileModel(String name, String content, String filePath) {
super(name, content, CellType.FILE);
this.filePath = filePath;
setDescription(AlphaFineHelper.findFolderName(content));
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}

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

@ -1,77 +0,0 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.ComparatorUtils;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class PluginModel extends AlphaCellModel {
private String pluginUrl;
private String imageUrl;
private String version;
private String jartime;
private String link;
private int price;
public PluginModel(String name, String content, CellType type) {
super(name, content, type);
}
public PluginModel(String name, String content, String pluginUrl, String imageUrl, String version, String jartime, CellType type, int price) {
super(name, content);
setType(type);
this.pluginUrl = pluginUrl;
this.imageUrl = imageUrl;
this.jartime = jartime;
this.version = version;
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getPluginUrl() {
return pluginUrl;
}
public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
public String getVersion() {
return version;
}
public void setVersion(String verSion) {
this.version = verSion;
}
public String getJartime() {
return jartime;
}
public void setJarTime(String jarTime) {
this.jartime = jarTime;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}

77
designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -0,0 +1,77 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import javax.swing.*;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class ActionModel extends AlphaCellModel implements Serializable {
private Action action;
private String actionName;
public ActionModel(String name, String content, CellType type) {
super(name, content, type);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ActionModel)) {
return false;
}
ActionModel that = (ActionModel) o;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
return action != null ? action.hashCode() : 0;
}
public ActionModel(String name, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
}
public Action getAction() {
return action;
}
public void setAction(Action action) {
this.action = action;
}
@Override
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
object.put("result", getAction().getClass().getName()).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
return object;
}
@Override
public String getStoreInformation() {
return getActionName();
}
public String getActionName() {
return getAction().getClass().getName();
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
}

21
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java → designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java

@ -1,13 +1,14 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/3/23.
*/
public class AlphaCellModel implements Serializable{
public abstract class AlphaCellModel {
private String name;
private String content;
private String description;
@ -58,4 +59,18 @@ public class AlphaCellModel implements Serializable{
public void setDescription(String description) {
this.description = description;
}
/**
* model转json
* @return
* @throws JSONException
*/
abstract public JSONObject ModelToJson() throws JSONException;
/**
* 获取需要保存到云中心的信息
* @return
*/
abstract public String getStoreInformation();
}

87
designer/src/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java

@ -0,0 +1,87 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class DocumentModel extends AlphaCellModel {
private String documentUrl;
private String informationUrl;
private int documentId;
public DocumentModel(String name, String content, CellType type) {
super(name, content, type);
}
public DocumentModel(String name, String content, int documentId) {
super(name, content, CellType.DOCUMENT);
this.documentId = documentId;
this.informationUrl = AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentId;
this.documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + documentId + ".html";
}
public String getDocumentUrl() {
return documentUrl;
}
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
@Override
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error("DocumentModel: " + e.getMessage());
}
return object;
}
@Override
public String getStoreInformation() {
return getInformationUrl();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DocumentModel)) {
return false;
}
DocumentModel that = (DocumentModel) o;
return documentUrl != null ? documentUrl.equals(that.documentUrl) : that.documentUrl == null;
}
@Override
public int hashCode() {
return documentUrl != null ? documentUrl.hashCode() : 0;
}
public int getDocumentId() {
return documentId;
}
public void setDocumentId(int documentId) {
this.documentId = documentId;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
}

66
designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java

@ -0,0 +1,66 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class FileModel extends AlphaCellModel{
private String filePath;
public FileModel(String name, String content, CellType type) {
super(name, content, type);
}
public FileModel(String name, String filePath) {
super(name, null, CellType.FILE);
this.filePath = filePath;
setDescription(AlphaFineHelper.findFolderName(filePath));
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@Override
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
object.put("result", getFilePath()).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
return object;
}
@Override
public String getStoreInformation() {
return getFilePath();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof FileModel)) {
return false;
}
FileModel fileModel = (FileModel) o;
return filePath != null ? filePath.equals(fileModel.filePath) : fileModel.filePath == null;
}
@Override
public int hashCode() {
return filePath != null ? filePath.hashCode() : 0;
}
}

2
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/MoreModel.java → designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.CellType;

149
designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -0,0 +1,149 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class PluginModel extends AlphaCellModel {
private String pluginUrl;
private String imageUrl;
private String version;
private String jartime;
private String link;
private String informationUrl;
private int pluginId;
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) {
super(name, content, type);
}
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId) {
super(name, content);
this.link = link;
setType(type);
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.jartime = jartime;
this.version = version;
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getPluginUrl() {
return pluginUrl;
}
public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
public String getVersion() {
return version;
}
public void setVersion(String verSion) {
this.version = verSion;
}
public String getJartime() {
return jartime;
}
public void setJarTime(String jarTime) {
this.jartime = jarTime;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
@Override
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getTypeValue()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
return object;
}
@Override
public String getStoreInformation() {
return getInformationUrl();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PluginModel)) {
return false;
}
PluginModel that = (PluginModel) o;
return pluginUrl != null ? pluginUrl.equals(that.pluginUrl) : that.pluginUrl == null;
}
@Override
public int hashCode() {
return pluginUrl != null ? pluginUrl.hashCode() : 0;
}
public int getPluginId() {
return pluginId;
}
public void setPluginId(int pluginId) {
this.pluginId = pluginId;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
}

8
designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java → designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -1,9 +1,9 @@
package com.fr.design.mainframe.alphafine.cell.cellRender;
package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
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.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import javax.swing.*;
import java.awt.*;
@ -32,7 +32,7 @@ public class ContentCellRender implements ListCellRenderer<Object> {
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0));
AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getCellType() + ".png";
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";
name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
name.setFont(AlphaFineConstants.MEDIUM_FONT);
name.setForeground(AlphaFineConstants.BLACK);

5
designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java → designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.alphafine.cell.cellRender;
package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import javax.swing.*;
import java.awt.*;
@ -36,6 +36,7 @@ public class TitleCellRender implements ListCellRenderer<Object> {
}
if (moreModel.isLoading()) {
ImageIcon imageIcon = new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif"));
//设置cell的加载动画
imageIcon.setImageObserver(list);
UILabel loadingLabel = new UILabel(imageIcon);

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

@ -9,16 +9,17 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.cellRender.ContentCellRender;
import com.fr.design.mainframe.alphafine.cell.cellModel.*;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender;
import com.fr.design.mainframe.alphafine.cell.model.*;
import com.fr.design.mainframe.alphafine.listener.ComponentHandler;
import com.fr.design.mainframe.alphafine.listener.DocumentAdapter;
import com.fr.design.mainframe.alphafine.model.SearchListModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.previewPane.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.FilePreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.searchManager.*;
import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.preview.FilePreviewPane;
import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.search.manager.*;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.form.main.Form;
@ -26,9 +27,13 @@ import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
@ -44,6 +49,9 @@ import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
/**
@ -172,7 +180,7 @@ public class AlphaFineDialog extends UIDialog {
private void showSearchResult(String searchText) {
if (searchResultPane == null) {
initSearchResultComponents();
initListListener();
initListListener(searchText);
}
initSearchWorker(searchText);
}
@ -207,8 +215,8 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker = new SwingWorker<SearchListModel, String>() {
@Override
protected SearchListModel doInBackground() throws Exception {
return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText)));
protected SearchListModel doInBackground() {
return setListModel(new SearchListModel(AlphaSearchManager.getSearchManager().getLessSearchResult(searchText)));
}
@Override
@ -224,7 +232,6 @@ public class AlphaFineDialog extends UIDialog {
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
searchResultList.setModel(null);
FRLogger.getLogger().error(e.getMessage());
}
@ -234,7 +241,7 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker.execute();
}
private void initListListener() {
private void initListListener(final String searchText) {
searchResultList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -245,11 +252,7 @@ public class AlphaFineDialog extends UIDialog {
searchResultList.setSelectedIndex(i);
doNavigate(selectedIndex);
if (selectedValue instanceof AlphaCellModel) {
SearchResult originalResultList = LatestSearchManager.getLatestSearchManager().getLatestModelList();
originalResultList.add(searchResultList.getSelectedValue());
LatestSearchManager.getLatestSearchManager().setLatestModelList(originalResultList);
//保存最近搜索
saveHistory(originalResultList);
saveHistory(searchText, (AlphaCellModel) selectedValue);
}
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
@ -284,7 +287,7 @@ public class AlphaFineDialog extends UIDialog {
if (selectedValue instanceof FileModel) {
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane();
if (fileName.endsWith("frm")) {
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
@ -314,7 +317,7 @@ public class AlphaFineDialog extends UIDialog {
}
};
this.searchWorker.execute();
} else if (fileName.endsWith("cpt")) {
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
@ -362,18 +365,29 @@ public class AlphaFineDialog extends UIDialog {
}
this.searchWorker = new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() throws Exception {
BufferedImage bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
protected Image doInBackground() {
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;
}
@Override
protected void done() {
try {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane(((PluginModel) selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
if (!isCancelled()) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane(((PluginModel) selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
}
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
@ -393,11 +407,11 @@ public class AlphaFineDialog extends UIDialog {
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) {
if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) {
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"));
rebuildList(index, selectedValue);
rebuildShowMoreList(index, selectedValue);
} else {
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"));
rebuildList(index, selectedValue);
rebuildShowMoreList(index, selectedValue);
}
}
@ -541,30 +555,51 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* todo:保存到本地的逻辑待修改
* @param searchResult
* 保存本地本地常用
* @param searchText
* @param cellModel
*/
private void saveHistory(SearchResult searchResult) {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(AlphaFineHelper.getInfoFile()));
os.writeObject(searchResult);
os.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
sendToServer();
private void saveHistory(String searchText, AlphaCellModel cellModel) {
RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger();
recentSearchManager.addRecentModel(searchText, cellModel);
recentSearchManager.saveXMLFile();
sendToServer(searchText, cellModel);
}
/**
*todo:还没做上传服务器
* 上传数据到服务器
* @param searchKey
* @param cellModel
*/
private void sendToServer() {
private void sendToServer(String searchKey, AlphaCellModel cellModel) {
String username = DesignerEnvManager.getEnvManager().getBBSName();
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String key = searchKey;
int resultkind = cellModel.getType().getTypeValue();
String resultValue = CellModelHelper.getResultValueFromModel(cellModel);
JSONObject object = JSONObject.create();
try {
object.put("uuid", uuid).put("activitykey", activitykey).put("username", username).put("createtime", createTime).put("key", key).put("resultkind", resultkind).put("resultValue", resultValue);
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
HashMap<String, String> para = new HashMap<>();
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
para.put("token", CodeUtils.md5Encode(date, "", "MD5"));
para.put("content", object.toString());
HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_TEST_URL, para, true);
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
FRLogger.getLogger().error("Failed to sent data to server!");
}
}
private void rebuildList(int index, MoreModel selectedValue) {
private void rebuildShowMoreList(int index, MoreModel selectedValue) {
SearchResult moreResult = getMoreResult(selectedValue);
if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) {
for (int i = 0; i < moreResult.size(); i++) {
@ -583,23 +618,30 @@ public class AlphaFineDialog extends UIDialog {
}
private void rebuildList() {
this.searchResultList.validate();
this.searchResultList.repaint();
validate();
repaint();
}
private SearchResult getMoreResult(MoreModel selectedValue) {
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;
}
@ -608,15 +650,7 @@ 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 SearchListModel setjListModel(SearchListModel jListModel) {
public SearchListModel setListModel(SearchListModel jListModel) {
this.searchListModel = jListModel;
return this.searchListModel;
}
@ -629,4 +663,5 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker = searchWorker;
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

2
designer/src/com/fr/design/mainframe/alphafine/previewPane/ActionPreviewPane.java → designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.previewPane;
package com.fr.design.mainframe.alphafine.preview;
/**
* Created by XiaXiang on 2017/5/5.

2
designer/src/com/fr/design/mainframe/alphafine/previewPane/DocumentPreviewPane.java → designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.previewPane;
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.itextarea.UITextArea;

2
designer/src/com/fr/design/mainframe/alphafine/previewPane/FilePreviewPane.java → designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.previewPane;
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;

2
designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java → designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine.previewPane;
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;

57
designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java

@ -1,13 +1,14 @@
package com.fr.design.mainframe.alphafine.searchManager;
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
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.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import java.util.List;
@ -29,10 +30,10 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
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) {
@ -40,26 +41,50 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
filterModelList.add(new ActionModel(updateAction.getName() ,updateAction));
}
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
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));
}
if (filterModelList.size() > 0) {
if (filterModelList != null && filterModelList.size() >0) {
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
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));
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.ACTION));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION));
}
}
}
return lessModelList;
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
return moreModelList;
}
/**
* 根据类名反射获取对象
* @param actionName
* @return
*/
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);
}
}

21
designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java

@ -0,0 +1,21 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/27.
*/
public interface AlphaFineSearchProcessor {
/**
* 获取默认显示条数
* @param searchText
* @return
*/
SearchResult getLessSearchResult(String searchText);
/**
* 获取剩余条数
* @return
*/
SearchResult getMoreSearchResult();
}

69
designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.Inter;
/**
* Created by XiaXiang on 2017/3/28.
*/
public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static AlphaSearchManager searchManager;
private static PluginSearchManager pluginSearchManager;
private static DocumentSearchManager documentSearchManager;
private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager;
private static RecommendSearchManager recommendSearchManager;
private static RecentSearchManager recentSearchManager;
public synchronized static AlphaSearchManager getSearchManager() {
init();
return searchManager;
}
private synchronized static void init() {
if (searchManager == null) {
searchManager = new AlphaSearchManager();
pluginSearchManager = PluginSearchManager.getPluginSearchManager();
documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getRecentSearchManger();
}
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult recentModelList = 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);
recentModelList.addAll(concludeModelList);
recentModelList.addAll(actionModelList);
recentModelList.addAll(fileModelList);
recentModelList.addAll(documentModelList);
recentModelList.addAll(pluginModelList);
return recentModelList;
}
public SearchResult showDefaultSearchResult() {
SearchResult searchResult = new SearchResult();
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Set")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Templates")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon")));
return searchResult;
}
@Override
public SearchResult getMoreSearchResult() {
return null;
}
}

95
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java

@ -0,0 +1,95 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.FRLogger;
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;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
documentSearchManager = new DocumentSearchManager();
}
return documentSearchManager;
}
@Override
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";
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return lessModelList;
}
result = httpClient.getResponseText();
try {
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = jsonObject.optJSONArray("docdata");
if (jsonArray != null && jsonArray.length() > 0) {
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.moreModelList.add(cellModel);
}
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));
}
}
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return lessModelList;
}
/**
* 根据json信息获取文档model
* @param object
* @return
*/
public static DocumentModel getModelFromCloud(JSONObject object) {
String name = object.optString("title");
String content = object.optString("summary");
int documentId = object.optInt("did");
return new DocumentModel(name, content, documentId);
}
@Override
public SearchResult getMoreSearchResult() {
return moreModelList;
}
}

53
designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java → designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java

@ -1,12 +1,13 @@
package com.fr.design.mainframe.alphafine.searchManager;
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
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.cell.cellModel.FileModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.FileModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode;
import com.fr.general.FRLogger;
@ -39,7 +40,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();
@ -86,15 +87,15 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line;
int columnNumber;
boolean test = false;
boolean isFoundInContent = false;
while ((line = reader.readLine()) != null) {
columnNumber = line.toLowerCase().indexOf(searchText);
if (columnNumber != -1) {
test = true;
isFoundInContent = true;
}
}
if (test && !isAlreadyContain) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(node.getName().length(), node.getEnvPath().length()),node.getEnvPath());
if (isFoundInContent && !isAlreadyContain) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model);
}
reader.close();
@ -106,10 +107,17 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
}
/**
* 搜索模板
* @param searchText
* @param node
* @param isAlreadyContain
* @return
*/
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(node.getName().length(), node.getEnvPath().length()),node.getEnvPath());
FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model);
isAlreadyContain = true;
}
@ -118,10 +126,17 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
@Override
public SearchResult showMoreSearchResult() {
public SearchResult getMoreSearchResult() {
return moreModelList;
}
/**
* 获取工作目录下所有符合要求的模板
* @param env
* @param rootFilePath
* @param recurse
* @return
*/
private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>();
try {
@ -132,6 +147,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
return fileNodeList;
}
/**
* 获取当前工作目录下所有模板
* @param env
* @param rootFilePath
* @param nodeList
* @param recurse
* @throws Exception
*/
private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.listFile(rootFilePath);
for (int i = 0; i < fns.length; i++) {
@ -148,4 +171,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
}
/**
* 根据文件路径获取文件模型
* @param filePath
* @return
*/
public static FileModel getModelFromCloud(String filePath) {
String name = AlphaFineHelper.findFileName(filePath);
return new FileModel(name, filePath);
}
}

128
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java

@ -0,0 +1,128 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() {
if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager();
}
return pluginSearchManager;
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) {
String result;
try {
String encodedKey = URLEncoder.encode(searchText, "UTF-8");
String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey;
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return lessModelList;
}
result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(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++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
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() > 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));
}
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return this.lessModelList;
}
private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) {
String name = object.optString("name");
String content = object.optString("description");
int pluginId = object.optInt("id");
String imageUrl = null;
try {
imageUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8");
} catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error(e.getMessage());
}
String version = null;
String jartime = null;
CellType type;
String link = object.optString("link");
if (ComparatorUtils.equals(link, "plugin")) {
version = isFromCloud? object.optString("pluginversion") : object.optString("version");
jartime = object.optString("jartime");
type = CellType.PLUGIN;
} else {
type = CellType.REUSE;
}
int price = object.optInt("price");
return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId);
}
@Override
public SearchResult getMoreSearchResult() {
return this.moreModelList;
}
/**
* 根据json获取对应的插件model
* @param object
* @return
*/
public static PluginModel getModelFromCloud(JSONObject object) {
JSONObject jsonObject = object.optJSONObject("result");
if (jsonObject != null) {
return getPluginModel(jsonObject, true);
} else {
return getPluginModel(object, false);
}
}
}

308
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java

@ -0,0 +1,308 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.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;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by XiaXiang on 2017/5/15.
*/
public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor {
private static final String XML_TAG = "AlphafineRecent";
private static final int MAX_SIZE = 3;
private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null;
private List<String> fileList;
private List<String> actionList;
private List<String> documentList;
private SearchResult modelList;
private List<String> pluginList;
private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
public synchronized static RecentSearchManager getRecentSearchManger() {
if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager();
try {
XMLTools.readFileXML(recentSearchManager, recentSearchManager.getRecentEnvFile());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return recentSearchManager;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String nodeName = reader.getTagName();
if (nodeName.equals("RecentModelList")) {
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY);
final ArrayList<AlphaCellModel> list = new ArrayList<AlphaCellModel>();
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
readCellModel(reader, list);
}
}
);
recentKVModelMap.put(key, list);
}
}
}
});
}
}
private void readCellModel(XMLableReader reader, List<AlphaCellModel> list) {
if (reader.isChildNode()) {
String nodeName = reader.getTagName();
if (nodeName.equals("model")) {
String name = reader.getAttrAsString("cellModel", StringUtils.EMPTY);
addModelToList(list, name);
}
}
}
private void addModelToList(List<AlphaCellModel> list, String name) {
try {
list.add(CellModelHelper.getModelFromJson(new JSONObject(name)));
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
if (!recentKVModelMap.isEmpty()) {
for (String key : recentKVModelMap.keySet()) {
writer.startTAG("RecentModelList");
writer.attr("searchKey", key);
for (AlphaCellModel model : recentKVModelMap.get(key)) {
try {
String name = model.ModelToJson().toString();
writer.startTAG("model");
writer.attr("cellModel", name);
writer.end();
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
writer.end();
}
}
writer.end();
}
@Override
public String fileName() {
return "alphafine_recent.xml";
}
public List<String> getFileList() {
return fileList;
}
public void setFileList(List<String> fileList) {
this.fileList = fileList;
}
public List<String> getActionList() {
return actionList;
}
public void setActionList(List<String> actionList) {
this.actionList = actionList;
}
public List<String> getDocumentList() {
return documentList;
}
public void setDocumentList(List<String> documentList) {
this.documentList = documentList;
}
public List<String> getPluginList() {
return pluginList;
}
public void setPluginList(List<String> pluginList) {
this.pluginList = pluginList;
}
/**
* 获取xml
* @return
*/
private File getRecentFile() {
if (recentFile == null) {
recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName());
}
return recentFile;
}
private File getRecentEnvFile() {
File envFile = getRecentFile();
if (!envFile.exists()) {
createRecentFile(envFile);
}
return envFile;
}
/**
* 创建XML
* @param envFile
*/
private void createRecentFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AlphafineRecent></AlphafineRecent>");
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
fileWriter.close();
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 保存XML到设计器安装目录
*/
public void saveXMLFile() {
File xmlFile = this.getRecentEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile());
}
String tempName = xmlFile.getName() + ProjectConstants.TEMP_SUFFIX;
File tempFile = new File(xmlFile.getParentFile(), tempName);
writeTempFile(tempFile);
IOUtils.renameTo(tempFile, xmlFile);
}
private void writeTempFile(File tempFile) {
try {
OutputStream fout = new FileOutputStream(tempFile);
XMLTools.writeOutputStreamXML(this, fout);
fout.flush();
fout.close();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
public List<AlphaCellModel> getRecentModelList() {
return recentModelList;
}
public void setRecentModelList(List<AlphaCellModel> recentModelList) {
this.recentModelList = recentModelList;
}
/**
* 根据搜索字段获取对应的model列表
* @param searchText
* @return
*/
public List<AlphaCellModel> getRecentModelList(String searchText) {
recentModelList = new ArrayList<>();
for (String key : recentKVModelMap.keySet()) {
if (ComparatorUtils.equals(key, searchText)) {
recentModelList = recentKVModelMap.get(searchText);
int size = recentModelList.size();
if (size > MAX_SIZE) {
return recentModelList.subList(size - MAX_SIZE, size);
}
return recentModelList;
}
}
return recentModelList;
}
/**
* 将搜索结果加入到当前MAP中
* @param searchKey
* @param cellModel
*/
public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey);
if (cellModels.contains(cellModel)) {
cellModels.remove(cellModel);
cellModels.add(cellModel);
} else {
cellModels.add(cellModel);
}
trimToSize(cellModels);
} else {
List<AlphaCellModel> list = new ArrayList<>();
list.add(cellModel);
recentKVModelMap.put(searchKey, list);
}
}
private synchronized void trimToSize(List<AlphaCellModel> cellModels) {
if (cellModels.size() > AlphaFineConstants.MAX_FILE_SIZE) {
cellModels.remove(0);
}
}
@Override
public SearchResult getLessSearchResult(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 getMoreSearchResult() {
return new SearchResult();
}
}

69
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.FRLogger;
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.
*/
public class RecommendSearchManager implements AlphaFineSearchProcessor {
private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList;
//todo:for test
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey=";
public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (recommendSearchManager == null) {
recommendSearchManager = new RecommendSearchManager();
}
return recommendSearchManager;
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
String result;
this.modelList = new SearchResult();
HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText));
httpClient.asGet();
httpClient.setTimeout(5000);
if (!httpClient.isServerAlive()) {
return modelList;
}
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.getModelFromJson((JSONObject) jsonArray.get(i));
if (!RecentSearchManager.getRecentSearchManger().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;
}
@Override
public SearchResult getMoreSearchResult() {
return new SearchResult();
}
}

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

@ -1,12 +0,0 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/27.
*/
public interface AlphaFineSearchProcessor {
SearchResult showLessSearchResult(String searchText);
SearchResult showMoreSearchResult();
}

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

@ -1,89 +0,0 @@
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.model.SearchResult;
import com.fr.general.Inter;
import java.io.*;
/**
* Created by XiaXiang on 2017/3/28.
*/
public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static AlphaSearchManager searchManager;
private static PluginSearchManager pluginSearchManager;
private static DocumentSearchManager documentSearchManager;
private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager;
private static ConcludeSearchManager concludeSearchManager;
private static LatestSearchManager latestSearchManager;
public synchronized static AlphaSearchManager getSearchManager() {
init();
return searchManager;
}
private synchronized static void init() {
if (searchManager == null) {
searchManager = new AlphaSearchManager();
pluginSearchManager = PluginSearchManager.getPluginSearchManager();
documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager();
latestSearchManager = LatestSearchManager.getLatestSearchManager();
}
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
SearchResult latestModelList = latestSearchManager.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);
latestModelList.addAll(concludeModelList);
latestModelList.addAll(actionModelList);
latestModelList.addAll(fileModelList);
latestModelList.addAll(documentModelList);
latestModelList.addAll(pluginModelList);
return latestModelList;
}
public SearchResult showDefaultSearchResult() {
SearchResult searchResult = new SearchResult();
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Set")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Templates")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon")));
return searchResult;
}
@Override
public SearchResult showMoreSearchResult() {
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;
}
}

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

@ -1,33 +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.general.Inter;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class ConcludeSearchManager implements AlphaFineSearchProcessor {
private static ConcludeSearchManager concludeSearchManager = null;
private SearchResult modelList;
public synchronized static ConcludeSearchManager getConcludeSearchManager() {
if (concludeSearchManager == null) {
concludeSearchManager = new ConcludeSearchManager();
}
return concludeSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
//todo: 猜您喜欢逻辑需要重新设计
this.modelList = new SearchResult();
modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false));
return modelList;
}
@Override
public SearchResult showMoreSearchResult() {
return null;
}
}

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

@ -1,91 +0,0 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
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;
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 java.security.AlgorithmConstraints;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
documentSearchManager = new DocumentSearchManager();
}
return documentSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) {
String result;
String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1";
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
result = httpClient.getResponseText();
try {
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null;
if (jsonObject.get("docdata") != null) {
jsonArray = (JSONArray) jsonObject.get("docdata");
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT));
} else {
lessModelList.add(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) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return lessModelList;
}
private DocumentModel getDocumentModel(JSONArray jsonArray, int i) throws JSONException {
JSONObject object = jsonArray.getJSONObject(i);
String name = (String) object.get("title");
String content = ((String) object.get("summary"));
String documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + object.get("did") + ".html";
return new DocumentModel(name, content, documentUrl);
}
@Override
public SearchResult showMoreSearchResult() {
return moreModelList;
}
}

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

@ -1,55 +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.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 (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;
}
}

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

@ -1,105 +0,0 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.PluginModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
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 java.net.URLEncoder;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() {
if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager();
}
return pluginSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) {
String result;
try {
String encodedKey = URLEncoder.encode(searchText, "UTF-8");
String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey;
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null;
if (jsonObject.get("result") != null) {
jsonArray = (JSONArray) jsonObject.get("result");
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN));
} else {
lessModelList.add(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) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return this.lessModelList;
}
private PluginModel getPluginModel(JSONArray jsonArray, int i) throws JSONException {
JSONObject object = jsonArray.getJSONObject(i);
String name = (String) object.get("name");
String content = ((String) object.get("description"));
String pluginUrl = AlphaFineConstants.REUSE_IMAGE_URL + object.get("id");
String imageUrl = ((String) object.get("pic"));
String version = null;
String jartime = null;
CellType type = CellType.REUSE;
String link = (String) object.get("link");
if (ComparatorUtils.equals(link, "plugin")) {
version = (String) object.get("version");
jartime = (String) object.get("jartime");
type = CellType.PLUGIN;
pluginUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + object.get("id");
}
int price = (int) object.get("price");
return new PluginModel(name, content, pluginUrl, imageUrl, version, jartime, type, price);
}
@Override
public SearchResult showMoreSearchResult() {
return this.moreModelList;
}
}

2
designer/src/com/fr/design/parameter/ParameterDefinitePane.java

@ -103,7 +103,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
}
};
this.add(paraDesignEditor.createWrapper(), BorderLayout.CENTER);
// WidgetToolBarPane.getInstance(formParaDesignEditor);
// WidgetToolBarPane.getRecentSearchManger(formParaDesignEditor);
setButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png"));
setButton.set4ToolbarButton();

2
designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java

@ -174,7 +174,7 @@ public class AlphafineConfigPane extends BasicPane {
AlphafineConfigManager alphafineConfigManager = designerEnvManager.getAlphafineConfigManager();
alphafineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected());
alphafineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected());
alphafineConfigManager.setContainDocument(this.isContainActionCheckbox.isSelected());
alphafineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected());
alphafineConfigManager.setContainConclude(this.isContainConcludeCheckbox.isSelected());
alphafineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected());
alphafineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected());

2
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -1997,7 +1997,7 @@ FR-Designer_AlphaFine_SearchRange=\u641C\u7D22\u8303\u56F4
FR-Designer-Plugin_Addon=\u5E94\u7528\u4E2D\u5FC3
FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5185\u5BB9
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
FR-Designer_AlphaFine_ShowAll=\u663E\u793A\u5168\u90E8
FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981
FR-Designer_AlphaFine_Latest=\u6700\u8FD1\u5E38\u7528
FR-Designer_AlphaFine_ShowLess=\u6536\u8D77

3
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -1998,4 +1998,5 @@ FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5167\u5BB9
FR-Designer_AlphaFine_Latest=\u6700\u8FD1\u5E38\u7528
FR-Designer_AlphaFine_ShowLess=\u6536\u8D77
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
Loading…
Cancel
Save