Browse Source

Merge pull request #935 in BA/design from ~XIAOXIA/design:9.0 to 9.0

* commit 'da5f6844bd4962ce1da5603d38ad718e78c6fa41':
  格式化一下代码 没改东西
master
superman 8 years ago
parent
commit
5bf7f09e2d
  1. 8
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 6
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  3. 1
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  4. 3
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  5. 12
      designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  6. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java
  7. 1
      designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java
  8. 6
      designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  9. 1
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  10. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  11. 110
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  12. 13
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  13. 4
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  14. 1
      designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java
  15. 1
      designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java
  16. 33
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  17. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java
  18. 28
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  19. 85
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  20. 5
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  21. 6
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

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

@ -66,14 +66,6 @@ public class AlphaFineConstants {
public static final Font GREATER_FONT = new Font("Song_TypeFace", 0, 20);
public static final String PLUGIN_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
public static final String PLUGIN_URL = "http://shop.finereport.com/plugin/";

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

@ -12,7 +12,6 @@ import com.fr.general.Inter;
import com.fr.general.ProcessCanceledException;
import com.fr.stable.StringUtils;
import java.util.List;
/**
@ -35,6 +34,7 @@ public class AlphaFineHelper {
/**
* 获取文件名上级目录
*
* @param text
* @return
*/
@ -44,6 +44,7 @@ public class AlphaFineHelper {
/**
* 分割字符串获取文件名文件名上级目录等
*
* @param text
* @param index
* @return
@ -60,6 +61,7 @@ public class AlphaFineHelper {
/**
* 获取文件名
*
* @param text
* @return
*/
@ -84,6 +86,4 @@ public class AlphaFineHelper {
}
}

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

@ -21,6 +21,7 @@ public enum CellType {
return FILE;
}
public int getTypeValue() {
return typeValue;
}

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

@ -1,7 +1,7 @@
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.cell.model.AlphaCellModel;
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;
@ -13,6 +13,7 @@ import com.fr.json.JSONObject;
*/
public class CellModelHelper {
private static final String RESULT = "result";
public static AlphaCellModel getModelFromJson(JSONObject object) {
int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null;

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

@ -19,6 +19,12 @@ public class ActionModel extends AlphaCellModel {
super(name, content, type);
}
public ActionModel(String name, String description, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
this.setDescription(description);
}
@Override
public boolean equals(Object o) {
if (this == o) {
@ -37,12 +43,6 @@ public class ActionModel extends AlphaCellModel {
return action != null ? action.hashCode() : 0;
}
public ActionModel(String name, String description, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
this.setDescription(description);
}
public Action getAction() {
return action;
}

2
designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java

@ -62,6 +62,7 @@ public abstract class AlphaCellModel {
/**
* model转json
*
* @return
* @throws JSONException
*/
@ -69,6 +70,7 @@ public abstract class AlphaCellModel {
/**
* 获取需要保存到云中心的信息
*
* @return
*/
abstract public String getStoreInformation();

1
designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java

@ -29,6 +29,7 @@ public class MoreModel {
this.name = name;
this.isLoading = true;
}
public MoreModel(String name, boolean isLoading) {
this.name = name;
this.isLoading = isLoading;

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

@ -10,6 +10,8 @@ import com.fr.json.JSONObject;
* Created by XiaXiang on 2017/4/20.
*/
public class PluginModel extends AlphaCellModel {
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/";
private String pluginUrl;
private String imageUrl;
private String version;
@ -18,12 +20,11 @@ public class PluginModel extends AlphaCellModel {
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;
@ -130,7 +131,6 @@ public class PluginModel extends AlphaCellModel {
}
public int getPluginId() {
return pluginId;
}

1
designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -16,6 +16,7 @@ import java.awt.*;
public class ContentCellRender implements ListCellRenderer<Object> {
private UILabel name;
private UILabel content;
public ContentCellRender() {
this.name = new UILabel();
this.content = new UILabel();

2
designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java

@ -3,6 +3,7 @@ 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.model.MoreModel;
import javax.swing.*;
import java.awt.*;
@ -17,6 +18,7 @@ public class TitleCellRender implements ListCellRenderer<Object> {
this.name = new UILabel();
this.more = new UILabel();
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
MoreModel moreModel = (MoreModel) value;

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

@ -59,18 +59,6 @@ import java.util.concurrent.ExecutionException;
* Created by XiaXiang on 2017/3/21.
*/
public class AlphaFineDialog extends UIDialog {
private AlphaFineTextField searchTextField;
private UIButton closeButton;
private JPanel searchResultPane;
private Point pressedPoint;
private UIScrollPane leftSearchResultPane;
private JPanel rightSearchResultPane;
private JList searchResultList;
private SearchListModel searchListModel;
private SwingWorker searchWorker;
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
private boolean forceOpen;
private static final String ACTION_MARK_SHORT = "k:1 ";
private static final String ACTION_MARK = "k:setting ";
private static final String DOCUMENT_MARK_SHORT = "k:2 ";
@ -83,6 +71,17 @@ public class AlphaFineDialog extends UIDialog {
private static final String DS_NAME = "dsname=\"";
private static final String PLUGIN_MARK_SHORT = "k:4 ";
private static final String PLUGIN_MARK = "k:shop ";
private AlphaFineTextField searchTextField;
private UIButton closeButton;
private JPanel searchResultPane;
private Point pressedPoint;
private UIScrollPane leftSearchResultPane;
private JPanel rightSearchResultPane;
private JList searchResultList;
private SearchListModel searchListModel;
private SwingWorker searchWorker;
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
private boolean forceOpen;
public AlphaFineDialog(Frame parent, boolean forceOpen) {
@ -93,6 +92,32 @@ public class AlphaFineDialog extends UIDialog {
initComponents();
}
/**
* 全局快捷键
*
* @return
*/
public static AWTEventListener listener() {
return new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent) {
KeyEvent e = (KeyEvent) event;
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore();
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) {
doClickAction();
}
}
}
};
}
private static void doClickAction() {
AlphaFineHelper.showAlphaFineDialog(false);
}
/**
* 初始化全部组件
@ -155,6 +180,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 设置面板位置
*
* @param win
*/
private void centerWindow(Window win) {
@ -172,8 +198,21 @@ public class AlphaFineDialog extends UIDialog {
win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE);
}
// TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape();
// public void paint(Graphics g){
//
// Graphics2D g2 = (Graphics2D) g.create();
// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// g2.setRenderingHints(qualityHints);
// g2.setPaint(Color.WHITE);
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
// g2.dispose();
// }
/**
* 执行搜索
*
* @param text
*/
private void doSearch(String text) {
@ -200,19 +239,6 @@ public class AlphaFineDialog extends UIDialog {
repaint();
}
// TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape();
// public void paint(Graphics g){
//
// Graphics2D g2 = (Graphics2D) g.create();
// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// g2.setRenderingHints(qualityHints);
// g2.setPaint(Color.WHITE);
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
// g2.dispose();
// }
/**
* 展示搜索结果
*/
@ -279,6 +305,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 重新构建搜索结果列表
* 先根据输入判断是不是隐藏的搜索功能
*
* @param searchText
*/
private void rebuildList(String searchText) {
@ -311,6 +338,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 普通搜索
*
* @param searchText
*/
private void doNormalSearch(String searchText) {
@ -322,7 +350,6 @@ public class AlphaFineDialog extends UIDialog {
getPluginList(searchText);
}
private synchronized void getDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (Object object : documentModelList) {
@ -373,7 +400,6 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* 初始化监听器
*/
@ -645,33 +671,6 @@ public class AlphaFineDialog extends UIDialog {
}, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
}
/**
* 全局快捷键
* @return
*/
public static AWTEventListener listener() {
return new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent) {
KeyEvent e = (KeyEvent) event;
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore();
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) {
doClickAction();
}
}
}
};
}
private static void doClickAction() {
AlphaFineHelper.showAlphaFineDialog(false);
}
@Override
public void checkValid() throws Exception {
@ -709,6 +708,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 保存本地本地常用
*
* @param cellModel
*/
private void saveHistory(AlphaCellModel cellModel) {
@ -722,6 +722,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 上传数据到服务器
*
* @param searchKey
* @param cellModel
*/
@ -754,6 +755,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 点击显示更多时添加对应的model到list点击收起是移除model
*
* @param index
* @param selectedValue
*/

13
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java

@ -20,12 +20,6 @@ import java.awt.event.ActionListener;
public class AlphaFinePane extends BasicPane {
private static AlphaFinePane alphaFinePane;
public static AlphaFinePane getAlphaFinePane() {
if (alphaFinePane == null) {
alphaFinePane = new AlphaFinePane();
}
return alphaFinePane;
}
public AlphaFinePane() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14));
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
@ -56,6 +50,13 @@ public class AlphaFinePane extends BasicPane {
});
}
public static AlphaFinePane getAlphaFinePane() {
if (alphaFinePane == null) {
alphaFinePane = new AlphaFinePane();
}
return alphaFinePane;
}
@Override
protected String title4PopupWindow() {
return "AlphaFine";

4
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java

@ -6,7 +6,8 @@ import com.fr.report.web.button.Image;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import static java.awt.event.KeyEvent.VK_ESCAPE;
@ -64,6 +65,7 @@ public class AlphaFineTextField extends UITextField {
/**
* 添加键盘监听器
*
* @param component
*/
public void initKeyListener(final Component component) {

1
designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java

@ -9,7 +9,6 @@ public class SearchResult extends ArrayList<Object> {
private boolean needMore;
public boolean isNeedMore() {
return needMore;
}

1
designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java

@ -15,6 +15,7 @@ import java.awt.*;
*/
public class ActionPreviewPane extends JPanel {
private static final Font NAME = new Font("Song_TypeFace", 0, 14);
public ActionPreviewPane() {
setLayout(new BorderLayout());
setBackground(null);

33
designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java

@ -19,11 +19,11 @@ import java.util.List;
* Created by XiaXiang on 2017/3/27.
*/
public class ActionSearchManager implements AlphaFineSearchProcessor {
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION);
private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION);
public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) {
@ -32,6 +32,22 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
return actionSearchManager;
}
/**
* 根据类名获取对象
*
* @param actionName
* @return
*/
public static ActionModel getModelFromCloud(String actionName) {
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) {
if (ComparatorUtils.equals(actionName, updateActionModel.getClassName()) && updateActionModel.getAction().isEnabled()) {
return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction());
}
}
return null;
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
filterModelList = new SearchResult();
@ -78,19 +94,4 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
public SearchResult getMoreSearchResult() {
return moreModelList;
}
/**
* 根据类名获取对象
* @param actionName
* @return
*/
public static ActionModel getModelFromCloud(String actionName ) {
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) {
if (ComparatorUtils.equals(actionName, updateActionModel.getClassName()) && updateActionModel.getAction().isEnabled()) {
return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction());
}
}
return null;
}
}

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

@ -8,6 +8,7 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
public interface AlphaFineSearchProcessor {
/**
* 获取默认显示条数
*
* @param searchText
* @return
*/
@ -15,6 +16,7 @@ public interface AlphaFineSearchProcessor {
/**
* 获取剩余条数
*
* @return
*/
SearchResult getMoreSearchResult();

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

@ -19,10 +19,10 @@ import com.fr.stable.StringUtils;
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT);
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT);
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
@ -32,6 +32,19 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return documentSearchManager;
}
/**
* 根据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 synchronized SearchResult getLessSearchResult(String searchText) {
lessModelList = new SearchResult();
@ -86,6 +99,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
/**
* 无连接
*
* @return
*/
private SearchResult getNoConnectList() {
@ -95,18 +109,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return result;
}
/**
* 根据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;

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

@ -4,8 +4,8 @@ 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.model.PluginModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
@ -23,8 +23,8 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN);
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
@ -37,6 +37,47 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
}
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 = isFromCloud ? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic");
} 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);
}
/**
* 根据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);
}
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
@ -97,48 +138,8 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return result;
}
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 = isFromCloud? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic");
} 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);
}
}
}

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

@ -135,9 +135,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
/**
* 获取xml
*
* @return
*/
private File getRecentFile() {
@ -157,6 +157,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/**
* 创建XML
*
* @param envFile
*/
private void createRecentFile(File envFile) {
@ -212,6 +213,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/**
* 根据搜索字段获取对应的model列表
*
* @param searchText
* @return
*/
@ -233,6 +235,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/**
* 将搜索结果加入到当前MAP中
*
* @param searchKey
* @param cellModel
*/

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

@ -13,7 +13,6 @@ import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.List;
@ -22,11 +21,11 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31.
*/
public class RecommendSearchManager implements AlphaFineSearchProcessor {
//todo:for test
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey=";
private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList;
private List<AlphaCellModel> recommendModelList = new ArrayList<>();
//todo:for test
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey=";
public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (recommendSearchManager == null) {
@ -34,6 +33,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
}
return recommendSearchManager;
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult();

Loading…
Cancel
Save