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. 16
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 10
      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. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  8. 1
      designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java
  9. 6
      designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  10. 5
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  11. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  12. 126
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  13. 13
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  14. 4
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  15. 6
      designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java
  16. 2
      designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java
  17. 1
      designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java
  18. 7
      designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java
  19. 2
      designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java
  20. 10
      designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java
  21. 33
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  22. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java
  23. 30
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  24. 87
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  25. 5
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  26. 6
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

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

@ -57,21 +57,13 @@ public class AlphaFineConstants {
public static final Color RED = new Color(0xf46c4c); public static final Color RED = new Color(0xf46c4c);
public static final Font SMALL_FONT = new Font("Song_TypeFace",0,10); public static final Font SMALL_FONT = new Font("Song_TypeFace", 0, 10);
public static final Font MEDIUM_FONT = new Font("Song_TypeFace",0,12);
public static final Font LARGE_FONT = new Font("Song_TypeFace",0,18);
public static final Font GREATER_FONT = new Font("Song_TypeFace",0,20);
public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12);
public static final Font LARGE_FONT = new Font("Song_TypeFace", 0, 18);
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_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");

10
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.general.ProcessCanceledException;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.List; import java.util.List;
/** /**
@ -35,15 +34,17 @@ public class AlphaFineHelper {
/** /**
* 获取文件名上级目录 * 获取文件名上级目录
*
* @param text * @param text
* @return * @return
*/ */
public static String findFolderName (String text) { public static String findFolderName(String text) {
return getSplitText(text, 2); return getSplitText(text, 2);
} }
/** /**
* 分割字符串获取文件名文件名上级目录等 * 分割字符串获取文件名文件名上级目录等
*
* @param text * @param text
* @param index * @param index
* @return * @return
@ -60,10 +61,11 @@ public class AlphaFineHelper {
/** /**
* 获取文件名 * 获取文件名
*
* @param text * @param text
* @return * @return
*/ */
public static String findFileName (String text) { public static String findFileName(String text) {
return getSplitText(text, 1); return getSplitText(text, 1);
} }
@ -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; return FILE;
} }
public int getTypeValue() { public int getTypeValue() {
return typeValue; return typeValue;
} }

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.cell; package com.fr.design.mainframe.alphafine.cell;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.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.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager; 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.FileSearchManager;
@ -13,6 +13,7 @@ import com.fr.json.JSONObject;
*/ */
public class CellModelHelper { public class CellModelHelper {
private static final String RESULT = "result"; private static final String RESULT = "result";
public static AlphaCellModel getModelFromJson(JSONObject object) { public static AlphaCellModel getModelFromJson(JSONObject object) {
int typeValue = object.optInt("cellType"); int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null; 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); super(name, content, type);
} }
public ActionModel(String name, String description, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
this.setDescription(description);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@ -37,12 +43,6 @@ public class ActionModel extends AlphaCellModel {
return action != null ? action.hashCode() : 0; 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() { public Action getAction() {
return action; return action;
} }

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

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

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

@ -9,7 +9,7 @@ import com.fr.json.JSONObject;
/** /**
* Created by XiaXiang on 2017/4/20. * Created by XiaXiang on 2017/4/20.
*/ */
public class FileModel extends AlphaCellModel{ public class FileModel extends AlphaCellModel {
private String filePath; private String filePath;
public FileModel(String name, String content, CellType type) { public FileModel(String name, String content, CellType type) {

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

@ -29,6 +29,7 @@ public class MoreModel {
this.name = name; this.name = name;
this.isLoading = true; this.isLoading = true;
} }
public MoreModel(String name, boolean isLoading) { public MoreModel(String name, boolean isLoading) {
this.name = name; this.name = name;
this.isLoading = isLoading; 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. * Created by XiaXiang on 2017/4/20.
*/ */
public class PluginModel extends AlphaCellModel { 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 pluginUrl;
private String imageUrl; private String imageUrl;
private String version; private String version;
@ -18,12 +20,11 @@ public class PluginModel extends AlphaCellModel {
private String informationUrl; private String informationUrl;
private int pluginId; private int pluginId;
private int price; private int price;
private static final String PLUGIN_INFORMATION_URL = "http://shop.finereport.com/ShopServer?pg=plugin&pid=";
private static final String REUSE_INFORMATION_URL = "http://shop.finereport.com/reuses/";
public PluginModel(String name, String content, CellType type) { public PluginModel(String name, String content, CellType type) {
super(name, content, type); super(name, content, type);
} }
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId) { public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId) {
super(name, content); super(name, content);
this.link = link; this.link = link;
@ -130,7 +131,6 @@ public class PluginModel extends AlphaCellModel {
} }
public int getPluginId() { public int getPluginId() {
return pluginId; return pluginId;
} }

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

@ -16,6 +16,7 @@ import java.awt.*;
public class ContentCellRender implements ListCellRenderer<Object> { public class ContentCellRender implements ListCellRenderer<Object> {
private UILabel name; private UILabel name;
private UILabel content; private UILabel content;
public ContentCellRender() { public ContentCellRender() {
this.name = new UILabel(); this.name = new UILabel();
this.content = new UILabel(); this.content = new UILabel();
@ -24,14 +25,14 @@ public class ContentCellRender implements ListCellRenderer<Object> {
@Override @Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof MoreModel) { if (value instanceof MoreModel) {
return new TitleCellRender().getListCellRendererComponent(list, value,index,isSelected,cellHasFocus); return new TitleCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
} }
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(Color.white); panel.setBackground(Color.white);
if (isSelected) { if (isSelected) {
panel.setBackground(AlphaFineConstants.BLUE); panel.setBackground(AlphaFineConstants.BLUE);
} }
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
AlphaCellModel model = (AlphaCellModel) value; AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName()); name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";

8
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.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -17,12 +18,13 @@ public class TitleCellRender implements ListCellRenderer<Object> {
this.name = new UILabel(); this.name = new UILabel();
this.more = new UILabel(); this.more = new UILabel();
} }
@Override @Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
MoreModel moreModel = (MoreModel)value; MoreModel moreModel = (MoreModel) value;
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(AlphaFineConstants.WHITE); panel.setBackground(AlphaFineConstants.WHITE);
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
name.setText(moreModel.getName()); name.setText(moreModel.getName());
name.setFont(AlphaFineConstants.SMALL_FONT); name.setFont(AlphaFineConstants.SMALL_FONT);
more.setFont(AlphaFineConstants.SMALL_FONT); more.setFont(AlphaFineConstants.SMALL_FONT);
@ -31,7 +33,7 @@ public class TitleCellRender implements ListCellRenderer<Object> {
more.setForeground(AlphaFineConstants.DARK_GRAY); more.setForeground(AlphaFineConstants.DARK_GRAY);
panel.add(name, BorderLayout.WEST); panel.add(name, BorderLayout.WEST);
if (moreModel.isNeedMore()) { if (moreModel.isNeedMore()) {
this.more.setBorder(BorderFactory.createEmptyBorder(0,0,0,10)); this.more.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
panel.add(this.more, BorderLayout.EAST); panel.add(this.more, BorderLayout.EAST);
} }
if (moreModel.isLoading()) { if (moreModel.isLoading()) {

126
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. * Created by XiaXiang on 2017/3/21.
*/ */
public class AlphaFineDialog extends UIDialog { 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_SHORT = "k:1 ";
private static final String ACTION_MARK = "k:setting "; private static final String ACTION_MARK = "k:setting ";
private static final String DOCUMENT_MARK_SHORT = "k:2 "; 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 DS_NAME = "dsname=\"";
private static final String PLUGIN_MARK_SHORT = "k:4 "; private static final String PLUGIN_MARK_SHORT = "k:4 ";
private static final String PLUGIN_MARK = "k:shop "; 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) { public AlphaFineDialog(Frame parent, boolean forceOpen) {
@ -93,6 +92,32 @@ public class AlphaFineDialog extends UIDialog {
initComponents(); 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);
}
/** /**
* 初始化全部组件 * 初始化全部组件
@ -113,7 +138,7 @@ public class AlphaFineDialog extends UIDialog {
closeButton = new UIButton() { closeButton = new UIButton() {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
g.setColor( Color.white ); g.setColor(Color.white);
g.fillRect(0, 0, getSize().width, getSize().height); g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g); super.paintComponent(g);
} }
@ -155,6 +180,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 设置面板位置 * 设置面板位置
*
* @param win * @param win
*/ */
private void centerWindow(Window win) { private void centerWindow(Window win) {
@ -169,11 +195,24 @@ public class AlphaFineDialog extends UIDialog {
winSize.width = screenSize.width; winSize.width = screenSize.width;
} }
//这里设置位置:水平居中,竖直偏上 //这里设置位置:水平居中,竖直偏上
win.setLocation((screenSize.width - winSize.width ) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); 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 * @param text
*/ */
private void doSearch(String text) { private void doSearch(String text) {
@ -181,7 +220,7 @@ public class AlphaFineDialog extends UIDialog {
if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { if (StringUtils.isBlank(text) || text.equals("AlphaFine")) {
removeSearchResult(); removeSearchResult();
} else if (text.contains("'")) { } else if (text.contains("'")) {
return; return;
} else { } else {
showSearchResult(); showSearchResult();
} }
@ -200,19 +239,6 @@ public class AlphaFineDialog extends UIDialog {
repaint(); 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();
// }
/** /**
* 展示搜索结果 * 展示搜索结果
*/ */
@ -239,7 +265,7 @@ public class AlphaFineDialog extends UIDialog {
leftSearchResultPane = new UIScrollPane(searchResultList); leftSearchResultPane = new UIScrollPane(searchResultList);
leftSearchResultPane.setBackground(Color.white); leftSearchResultPane.setBackground(Color.white);
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
rightSearchResultPane = new JPanel(); rightSearchResultPane = new JPanel();
rightSearchResultPane.setBackground(Color.white); rightSearchResultPane.setBackground(Color.white);
@ -279,6 +305,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 重新构建搜索结果列表 * 重新构建搜索结果列表
* 先根据输入判断是不是隐藏的搜索功能 * 先根据输入判断是不是隐藏的搜索功能
*
* @param searchText * @param searchText
*/ */
private void rebuildList(String searchText) { private void rebuildList(String searchText) {
@ -311,6 +338,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 普通搜索 * 普通搜索
*
* @param searchText * @param searchText
*/ */
private void doNormalSearch(String searchText) { private void doNormalSearch(String searchText) {
@ -322,7 +350,6 @@ public class AlphaFineDialog extends UIDialog {
getPluginList(searchText); getPluginList(searchText);
} }
private synchronized void getDocumentList(final String searchText) { private synchronized void getDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (Object object : documentModelList) { for (Object object : documentModelList) {
@ -373,7 +400,6 @@ public class AlphaFineDialog extends UIDialog {
} }
/** /**
* 初始化监听器 * 初始化监听器
*/ */
@ -567,7 +593,7 @@ public class AlphaFineDialog extends UIDialog {
private void showDefaultPreviewPane() { private void showDefaultPreviewPane() {
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif")));
label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0));
rightSearchResultPane.add(label, BorderLayout.CENTER); rightSearchResultPane.add(label, BorderLayout.CENTER);
validate(); validate();
repaint(); repaint();
@ -642,36 +668,9 @@ public class AlphaFineDialog extends UIDialog {
} }
} }
} }
}, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.KEY_EVENT_MASK); }, 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 @Override
public void checkValid() throws Exception { public void checkValid() throws Exception {
@ -683,7 +682,7 @@ public class AlphaFineDialog extends UIDialog {
if (value instanceof ActionModel) { if (value instanceof ActionModel) {
((ActionModel) value).getAction().actionPerformed(null); ((ActionModel) value).getAction().actionPerformed(null);
} else if (value instanceof FileModel) { } else if (value instanceof FileModel) {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel)value).getFilePath(), false))); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel) value).getFilePath(), false)));
} else if (value instanceof PluginModel) { } else if (value instanceof PluginModel) {
String url = ((PluginModel) value).getPluginUrl(); String url = ((PluginModel) value).getPluginUrl();
try { try {
@ -709,6 +708,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 保存本地本地常用 * 保存本地本地常用
*
* @param cellModel * @param cellModel
*/ */
private void saveHistory(AlphaCellModel cellModel) { private void saveHistory(AlphaCellModel cellModel) {
@ -722,6 +722,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 上传数据到服务器 * 上传数据到服务器
*
* @param searchKey * @param searchKey
* @param cellModel * @param cellModel
*/ */
@ -754,12 +755,13 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 点击显示更多时添加对应的model到list点击收起是移除model * 点击显示更多时添加对应的model到list点击收起是移除model
*
* @param index * @param index
* @param selectedValue * @param selectedValue
*/ */
private void rebuildShowMoreList(int index, MoreModel selectedValue) { private void rebuildShowMoreList(int index, MoreModel selectedValue) {
SearchResult moreResult = getMoreResult(selectedValue); SearchResult moreResult = getMoreResult(selectedValue);
if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { if ((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) {
for (int i = 0; i < moreResult.size(); i++) { for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.add(index + AlphaFineConstants.SHOW_SIZE + 1 + i, moreResult.get(i)); this.searchListModel.add(index + AlphaFineConstants.SHOW_SIZE + 1 + i, moreResult.get(i));
} }

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 { public class AlphaFinePane extends BasicPane {
private static AlphaFinePane alphaFinePane; private static AlphaFinePane alphaFinePane;
public static AlphaFinePane getAlphaFinePane() {
if (alphaFinePane == null) {
alphaFinePane = new AlphaFinePane();
}
return alphaFinePane;
}
public AlphaFinePane() { public AlphaFinePane() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14)); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14));
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { 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 @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "AlphaFine"; 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 com.fr.stable.StringUtils;
import java.awt.*; 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; import static java.awt.event.KeyEvent.VK_ESCAPE;
@ -64,6 +65,7 @@ public class AlphaFineTextField extends UITextField {
/** /**
* 添加键盘监听器 * 添加键盘监听器
*
* @param component * @param component
*/ */
public void initKeyListener(final Component component) { public void initKeyListener(final Component component) {

6
designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java

@ -25,17 +25,17 @@ public abstract class DocumentAdapter implements DocumentListener {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
textChanged(e); textChanged(e);
} }
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
textChanged(e); textChanged(e);
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
textChanged(e); textChanged(e);
} }
protected abstract void textChanged(DocumentEvent e); protected abstract void textChanged(DocumentEvent e);

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

@ -8,7 +8,7 @@ import javax.swing.*;
public class SearchListModel extends DefaultListModel { public class SearchListModel extends DefaultListModel {
SearchResult myDelegate; SearchResult myDelegate;
public SearchListModel( SearchResult searchResult) { public SearchListModel(SearchResult searchResult) {
this.myDelegate = searchResult; this.myDelegate = searchResult;
} }

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

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

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

@ -14,13 +14,14 @@ import java.awt.*;
* Created by XiaXiang on 2017/5/5. * Created by XiaXiang on 2017/5/5.
*/ */
public class ActionPreviewPane extends JPanel { public class ActionPreviewPane extends JPanel {
private static final Font NAME = new Font("Song_TypeFace",0,14); private static final Font NAME = new Font("Song_TypeFace", 0, 14);
public ActionPreviewPane() { public ActionPreviewPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(null); setBackground(null);
setBorder(BorderFactory.createEmptyBorder(135,0,0,0)); setBorder(BorderFactory.createEmptyBorder(135, 0, 0, 0));
UILabel image = new UILabel(); UILabel image = new UILabel();
image.setPreferredSize(new Dimension(150,111)); image.setPreferredSize(new Dimension(150, 111));
image.setHorizontalAlignment(SwingConstants.CENTER); image.setHorizontalAlignment(SwingConstants.CENTER);
image.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); image.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
image.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/noresult.png")); image.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/noresult.png"));

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

@ -20,7 +20,7 @@ public class DocumentPreviewPane extends JPanel {
UITextArea contentArea = new UITextArea(summary); UITextArea contentArea = new UITextArea(summary);
titleArea.setOpaque(false); titleArea.setOpaque(false);
contentArea.setOpaque(false); contentArea.setOpaque(false);
titleArea.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); titleArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
titleArea.setForeground(AlphaFineConstants.BLUE); titleArea.setForeground(AlphaFineConstants.BLUE);
contentArea.setForeground(AlphaFineConstants.BLACK); contentArea.setForeground(AlphaFineConstants.BLACK);
titleArea.setPreferredSize(new Dimension(360, 30)); titleArea.setPreferredSize(new Dimension(360, 30));

10
designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java

@ -15,7 +15,7 @@ import java.awt.*;
public class PluginPreviewPane extends JPanel { public class PluginPreviewPane extends JPanel {
public PluginPreviewPane(String title, Image image, String version, String jartime, CellType type, int price) { public PluginPreviewPane(String title, Image image, String version, String jartime, CellType type, int price) {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(50,0,0,0)); setBorder(BorderFactory.createEmptyBorder(50, 0, 0, 0));
setBackground(Color.white); setBackground(Color.white);
UILabel imageLabel = new UILabel(); UILabel imageLabel = new UILabel();
image = image.getScaledInstance(200, 200, Image.SCALE_SMOOTH); image = image.getScaledInstance(200, 200, Image.SCALE_SMOOTH);
@ -26,17 +26,17 @@ public class PluginPreviewPane extends JPanel {
nameLabel.setBackground(Color.yellow); nameLabel.setBackground(Color.yellow);
nameLabel.setHorizontalAlignment(SwingConstants.CENTER); nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
JPanel line = new JPanel(); JPanel line = new JPanel();
line.setPreferredSize(new Dimension(200,1)); line.setPreferredSize(new Dimension(200, 1));
line.setBackground(AlphaFineConstants.GRAY); line.setBackground(AlphaFineConstants.GRAY);
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(Color.white); panel.setBackground(Color.white);
JPanel bottomPane = new JPanel(new BorderLayout()); JPanel bottomPane = new JPanel(new BorderLayout());
bottomPane.setBackground(Color.white); bottomPane.setBackground(Color.white);
bottomPane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); bottomPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
if (type == CellType.PLUGIN) { if (type == CellType.PLUGIN) {
UILabel versionLabel = new UILabel("V" + version); UILabel versionLabel = new UILabel("V" + version);
versionLabel.setHorizontalAlignment(SwingConstants.CENTER); versionLabel.setHorizontalAlignment(SwingConstants.CENTER);
versionLabel.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); versionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
versionLabel.setForeground(AlphaFineConstants.DARK_GRAY); versionLabel.setForeground(AlphaFineConstants.DARK_GRAY);
versionLabel.setFont(AlphaFineConstants.MEDIUM_FONT); versionLabel.setFont(AlphaFineConstants.MEDIUM_FONT);
panel.add(versionLabel, BorderLayout.CENTER); panel.add(versionLabel, BorderLayout.CENTER);
@ -47,7 +47,7 @@ public class PluginPreviewPane extends JPanel {
} }
nameLabel.setFont(AlphaFineConstants.LARGE_FONT); nameLabel.setFont(AlphaFineConstants.LARGE_FONT);
nameLabel.setBackground(AlphaFineConstants.BLUE); nameLabel.setBackground(AlphaFineConstants.BLUE);
nameLabel.setBorder(BorderFactory.createEmptyBorder(20,20,10,20)); nameLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20));
line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0));
String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : String.valueOf(price); String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : String.valueOf(price);
UILabel priceLabel = new UILabel(price0); UILabel priceLabel = new UILabel(price0);

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. * Created by XiaXiang on 2017/3/27.
*/ */
public class ActionSearchManager implements AlphaFineSearchProcessor { 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 static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList; private SearchResult filterModelList;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION);
public synchronized static ActionSearchManager getActionSearchManager() { public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) { if (actionSearchManager == null) {
@ -32,6 +32,22 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
return actionSearchManager; 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 @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
filterModelList = new SearchResult(); filterModelList = new SearchResult();
@ -78,19 +94,4 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
public SearchResult getMoreSearchResult() { public SearchResult getMoreSearchResult() {
return moreModelList; 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 { public interface AlphaFineSearchProcessor {
/** /**
* 获取默认显示条数 * 获取默认显示条数
*
* @param searchText * @param searchText
* @return * @return
*/ */
@ -15,6 +16,7 @@ public interface AlphaFineSearchProcessor {
/** /**
* 获取剩余条数 * 获取剩余条数
*
* @return * @return
*/ */
SearchResult getMoreSearchResult(); SearchResult getMoreSearchResult();

30
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. * Created by XiaXiang on 2017/3/27.
*/ */
public class DocumentSearchManager implements AlphaFineSearchProcessor { 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 static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT);
public synchronized static DocumentSearchManager getDocumentSearchManager() { public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) { if (documentSearchManager == null) {
@ -32,6 +32,19 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return documentSearchManager; 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 @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
lessModelList = new SearchResult(); lessModelList = new SearchResult();
@ -71,7 +84,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
lessModelList.addAll(searchResult); lessModelList.addAll(searchResult);
} }
} else { } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.DOCUMENT));
lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size()));
} }
@ -86,6 +99,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
/** /**
* 无连接 * 无连接
*
* @return * @return
*/ */
private SearchResult getNoConnectList() { private SearchResult getNoConnectList() {
@ -95,18 +109,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return result; 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 @Override
public SearchResult getMoreSearchResult() { public SearchResult getMoreSearchResult() {
return moreModelList; return moreModelList;

87
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.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; 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.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -23,8 +23,8 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class PluginSearchManager implements AlphaFineSearchProcessor { 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 final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN);
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; 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 @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
@ -76,7 +117,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
lessModelList.addAll(searchResult); lessModelList.addAll(searchResult);
} }
} else { } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.PLUGIN));
lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size()));
} }
@ -97,48 +138,8 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return result; 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 @Override
public SearchResult getMoreSearchResult() { public SearchResult getMoreSearchResult() {
return this.moreModelList; 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 * 获取xml
*
* @return * @return
*/ */
private File getRecentFile() { private File getRecentFile() {
@ -157,6 +157,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/** /**
* 创建XML * 创建XML
*
* @param envFile * @param envFile
*/ */
private void createRecentFile(File envFile) { private void createRecentFile(File envFile) {
@ -212,6 +213,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/** /**
* 根据搜索字段获取对应的model列表 * 根据搜索字段获取对应的model列表
*
* @param searchText * @param searchText
* @return * @return
*/ */
@ -233,6 +235,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
/** /**
* 将搜索结果加入到当前MAP中 * 将搜索结果加入到当前MAP中
*
* @param searchKey * @param searchKey
* @param cellModel * @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.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -22,11 +21,11 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31. * Created by XiaXiang on 2017/3/31.
*/ */
public class RecommendSearchManager implements AlphaFineSearchProcessor { 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 static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList; private SearchResult modelList;
private List<AlphaCellModel> recommendModelList = new ArrayList<>(); 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() { public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (recommendSearchManager == null) { if (recommendSearchManager == null) {
@ -34,6 +33,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
} }
return recommendSearchManager; return recommendSearchManager;
} }
@Override @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult(); this.modelList = new SearchResult();

Loading…
Cancel
Save