diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index b1c03c09bc..11bc0fb34c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -55,6 +55,14 @@ public class AlphaFineConfigManager implements XMLable { * 应用中心 */ private boolean isContainPlugin = true; + /** + * 分词搜索 + */ + private boolean isNeedSegmentationCheckbox = true; + /** + * 智能客服 + */ + private boolean isNeedIntelligentCustomerService = true; /** * 快捷键 */ @@ -94,6 +102,8 @@ public class AlphaFineConfigManager implements XMLable { this.setContainAction(reader.getAttrAsBoolean("isContainAction", true)); this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true)); this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false)); + this.setNeedSegmentationCheckbox(reader.getAttrAsBoolean("isNeedSegmentationCheckbox", true)); + this.setNeedIntelligentCustomerService(reader.getAttrAsBoolean("isNeedIntelligentCustomerService", true)); this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts())); this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true)); this.setOperateCount(reader.getAttrAsInt("operateCount", 0)); @@ -115,7 +125,9 @@ public class AlphaFineConfigManager implements XMLable { .attr("isContainPlugin", this.isContainPlugin()) .attr("isContainFileContent", this.isContainFileContent()) .attr("isNeedRemind", this.isNeedRemind()) - .attr("operateCount", this.getOperateCount()); + .attr("operateCount", this.getOperateCount()) + .attr("isNeedSegmentationCheckbox", this.isNeedSegmentationCheckbox()) + .attr("isNeedIntelligentCustomerService", this.isNeedIntelligentCustomerService()); writer.end(); } @@ -227,6 +239,21 @@ public class AlphaFineConfigManager implements XMLable { isNeedRemind = needRemind; } + public boolean isNeedSegmentationCheckbox() { + return isNeedSegmentationCheckbox; + } + + public void setNeedSegmentationCheckbox(boolean needSegmentationCheckbox) { + isNeedSegmentationCheckbox = needSegmentationCheckbox; + } + + public boolean isNeedIntelligentCustomerService() { + return isNeedIntelligentCustomerService; + } + + public void setNeedIntelligentCustomerService(boolean needIntelligentCustomerService) { + isNeedIntelligentCustomerService = needIntelligentCustomerService; + } public int getOperateCount() { return operateCount; } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index ddb8e425c8..1520a7e1dd 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -8,7 +8,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; - import com.fr.log.FineLoggerFactory; import javax.swing.*; @@ -56,7 +55,7 @@ public class AlphaFineConfigPane extends BasicPane { private static final double COLUMN_GAP = 180; private static final double ROW_GAP = 25; private KeyStroke shortCutKeyStore = null; - private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox; + private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isNeedSegmentationCheckbox, isNeedIntelligentCustomerService, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox; private UITextField shortcutsField; public AlphaFineConfigPane() { @@ -77,13 +76,21 @@ public class AlphaFineConfigPane extends BasicPane { private Component[][] initSearchRangeComponents() { Component[][] components = new Component[][]{ new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox}, - new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox} + new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox}, + new Component[]{isNeedIntelligentCustomerService, null, null} + }; + return components; + } + + private Component[][] initOnlineComponents() { + Component[][] components = new Component[][]{ + new Component[]{isSearchOnlineCheckbox, isNeedSegmentationCheckbox, null} }; return components; } private void createSearchConfigPane(JPanel contentPane) { - double[] rowSize = {ROW_GAP, ROW_GAP}; + double[] rowSize = {ROW_GAP, ROW_GAP, ROW_GAP}; double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; @@ -94,6 +101,7 @@ public class AlphaFineConfigPane extends BasicPane { isContainDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); isContainTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates")); isContainFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + isNeedIntelligentCustomerService = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Intelligent_Customer_Service")); JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize); northPane.add(searchConfigPane); contentPane.add(northPane); @@ -138,8 +146,9 @@ public class AlphaFineConfigPane extends BasicPane { } private void createOnlinePane(JPanel contentPane) { - JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet")); + JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Type")); isSearchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search")); + isNeedSegmentationCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Segmentation")); isSearchOnlineCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -147,17 +156,23 @@ public class AlphaFineConfigPane extends BasicPane { isContainRecommendCheckbox.setEnabled(false); isContainPluginCheckbox.setEnabled(false); isContainDocumentCheckbox.setEnabled(false); + isNeedIntelligentCustomerService.setEnabled(false); isContainRecommendCheckbox.setSelected(false); isContainPluginCheckbox.setSelected(false); isContainDocumentCheckbox.setSelected(false); + isNeedIntelligentCustomerService.setSelected(false); } else { isContainRecommendCheckbox.setEnabled(true); isContainPluginCheckbox.setEnabled(true); isContainDocumentCheckbox.setEnabled(true); + isNeedIntelligentCustomerService.setEnabled(true); } } }); - northPane.add(isSearchOnlineCheckbox); + double[] rowSize = {ROW_GAP}; + double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; + JPanel onlinePane = TableLayoutHelper.createTableLayoutPane(initOnlineComponents(), rowSize, columnSize); + northPane.add(onlinePane); contentPane.add(northPane); } @@ -187,6 +202,10 @@ public class AlphaFineConfigPane extends BasicPane { this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); + + this.isNeedSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); + this.isNeedIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); + this.isNeedIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine()); shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); } @@ -201,6 +220,8 @@ public class AlphaFineConfigPane extends BasicPane { alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected()); alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected()); alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected()); + alphaFineConfigManager.setNeedSegmentationCheckbox(this.isNeedSegmentationCheckbox.isSelected()); + alphaFineConfigManager.setNeedIntelligentCustomerService(this.isNeedIntelligentCustomerService.isSelected()); alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager); try { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 09de8e6ed8..cf7f04e0ae 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -2,7 +2,10 @@ package com.fr.design.mainframe.alphafine; import com.fr.general.CloudCenter; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; + /** * Created by XiaXiang on 2017/5/10. @@ -31,6 +34,10 @@ public class AlphaFineConstants { public static final int CELL_TITLE_HEIGHT = 24; + public static final int HOT_ICON_LABEL_HEIGHT = 36; + + public static final int HOT_ITEMS = 6; + public static final Dimension FULL_SIZE = new Dimension(680, 460); @@ -40,6 +47,10 @@ public class AlphaFineConstants { public static final Dimension ICON_LABEL_SIZE = new Dimension(64, 64); + public static final Dimension HOT_ICON_LABEL_SIZE = new Dimension(36, 36); + + public static final Dimension HOT_ISSUES_JAPNEL_SIZE = new Dimension(213,182); + public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40); public static final Color WHITE = new Color(0xf9f9f9); @@ -62,6 +73,8 @@ public class AlphaFineConstants { public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12); + public static final Font MEDIUM_FONT_ANOTHER = new Font("HiraginoSansGB-W3", 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); @@ -87,7 +100,13 @@ public class AlphaFineConstants { public static final String SEARCH_API = CloudCenter.getInstance().acquireUrlByKind("af.cloud_search"); + public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; + + public static final String SIMILAR_SEARCH_URL_PREFIX = "http://robot.finereport.com/openapi/like.php?action=search&"; + + public static final String COMPLEMENT_ADVICE_SEARCH_URL_PREFIX = "http://robot.finereport.com/openapi/getkw.php?"; + public static final String ALPHA_HOT_SEARCH = "http://robot.finereport.com/openapi/hot.php"; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java index 0f4f61a42b..3d533e47bb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java @@ -4,7 +4,7 @@ package com.fr.design.mainframe.alphafine; * Created by XiaXiang on 2017/4/27. */ public enum CellType { - RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6), MORE(7); + RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6), MORE(7), RECOMMEND_ROBOT(8), BOTTOM(9), ROBOT(10); private int typeValue; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java index d838f50a9d..b388f5e8ed 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java @@ -6,6 +6,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; import com.fr.json.JSONObject; /** @@ -31,6 +32,9 @@ public class CellModelHelper { case REUSE: cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject(RESULT)); break; + case ROBOT: + case RECOMMEND_ROBOT: + cellModel = SimilarSearchManeger.getModelFromCloud(object.optJSONObject(RESULT)); } return cellModel; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java new file mode 100644 index 0000000000..76528685eb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -0,0 +1,57 @@ +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 com.fr.log.FineLoggerFactory; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Created by alexsung on 2018/7/30. + */ +public class BottomModel extends AlphaCellModel { + /** + * 找不到答案?去论坛提问 + */ + public String getGoToWeb() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Internet_Forum"); + } + + public BottomModel(String name, String content) { + super(name, content, CellType.BOTTOM); + } + + public BottomModel() { + super(null, null, CellType.BOTTOM); + } + + @Override + public JSONObject ModelToJson() throws JSONException { + return null; + } + + @Override + public String getStoreInformation() { + return null; + } + + @Override + public boolean hasAction() { + return true; + } + + @Override + public void doAction() { + try { + Desktop.getDesktop().browse(new URI("http://bbs.fanruan.com/post_newthread_ajax.php?action=newthread&fid=39")); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (URISyntaxException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java new file mode 100644 index 0000000000..99ccab4bd0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java @@ -0,0 +1,95 @@ +package com.fr.design.mainframe.alphafine.cell.model; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import org.apache.commons.codec.digest.DigestUtils; + + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class RobotModel extends AlphaCellModel { + + private String title; + private String content; + + //热门问题列表的list不需要渲染图标,所以这里需要区分一下 + private boolean isHotItemModel = false; + + public boolean isHotItemModel() { + return isHotItemModel; + } + + public void setHotItemModel(boolean hotItemModel) { + isHotItemModel = hotItemModel; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public static String getContent(String titleStr) { + String result; + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr); + String url = "http://robot.finereport.com/openapi/reply.php?action=search&msg=" + titleStr + "&token=" + token; + HttpClient httpClient = new HttpClient(url); + httpClient.asGet(); + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + JSONObject jsonObject = new JSONObject(result); + return jsonObject.optString("msg"); + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage()); + } + return null; + } + + public RobotModel(String title, String content) { + super(title, content, CellType.ROBOT); + this.title = title; + } + + @Override + public JSONObject ModelToJson() throws JSONException { + JSONObject object = JSONObject.create(); + try { + JSONObject modelObject = JSONObject.create(); + modelObject.put("title", getTitle()).put("content", getContent()).put("searchCount", getSearchCount()); + object.put("result", modelObject).put("cellType", getType().getTypeValue()); + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("RobotModel: " + e.getMessage()); + } + return object; + } + + @Override + public String getStoreInformation() { + return null; + } + + @Override + public void doAction() { + try { + Desktop.getDesktop().browse(new URI("http://robot.finereport.com?send=" + super.getName())); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (URISyntaxException e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java new file mode 100644 index 0000000000..824fc3bfc0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java @@ -0,0 +1,39 @@ +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.BottomModel; + +import javax.swing.*; +import java.awt.Component; +import java.awt.BorderLayout; +import java.awt.Dimension; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class BottomCellRender implements ListCellRenderer { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + UILabel goToWebLabel = new UILabel(); + BottomModel bottomModel = (BottomModel) value; + JPanel panel = new JPanel(new BorderLayout()); + panel.setBackground(null); + panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + + JPanel line = new JPanel(); + line.setPreferredSize(new Dimension(200, 1)); + line.setBackground(AlphaFineConstants.GRAY); + panel.add(line, BorderLayout.NORTH); + + goToWebLabel.setFont(AlphaFineConstants.MEDIUM_FONT); + goToWebLabel.setText(bottomModel.getGoToWeb()); + goToWebLabel.setForeground(AlphaFineConstants.BLUE); + goToWebLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); + panel.add(goToWebLabel, BorderLayout.EAST); + + panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_TITLE_HEIGHT)); + return panel; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index d8cd66d97e..367de258c5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -4,11 +4,20 @@ import com.bulenkov.iconloader.IconLoader; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.cell.model.BottomModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; + +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Component; /** * Created by XiaXiang on 2017/4/20. @@ -19,6 +28,14 @@ public class ContentCellRender implements ListCellRenderer { private static final String CELL_PATH = AlphaFineConstants.IMAGE_URL + "alphafine"; private static final String SUFFIX = ".png"; + private String searchText; + private String[] segmentationResult; + + public ContentCellRender(String searchText, String[] segmentationResult) { + this.searchText = searchText; + this.segmentationResult = segmentationResult; + } + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { UILabel titleLabel = new UILabel(); @@ -26,21 +43,34 @@ public class ContentCellRender implements ListCellRenderer { if (value instanceof MoreModel) { return new TitleCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } + if (value instanceof BottomModel) { + return new BottomCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } AlphaCellModel model = (AlphaCellModel) value; JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(null); panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); - titleLabel.setText(" " + model.getName()); + if (model.hasAction()) { if (isSelected) { + titleLabel.setText(" " + model.getName()); String iconUrl = SELECTED_PATH + model.getType().getTypeValue() + SUFFIX; panel.setBackground(AlphaFineConstants.BLUE); titleLabel.setForeground(Color.WHITE); - titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + if(value instanceof RobotModel && ((RobotModel) value).isHotItemModel()){ + titleLabel.setIcon(null); + }else{ + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + } } else { + + titleLabel.setText(dealWithModelName(model.getName(), segmentationResult)); String iconUrl = CELL_PATH + model.getType().getTypeValue() + SUFFIX; - titleLabel.setIcon(IconLoader.getIcon(iconUrl)); - titleLabel.setForeground(AlphaFineConstants.BLACK); + if(value instanceof RobotModel && ((RobotModel) value).isHotItemModel()){ + titleLabel.setIcon(null); + }else{ + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); + } } } else { @@ -66,4 +96,35 @@ public class ContentCellRender implements ListCellRenderer { panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_HEIGHT)); return panel; } + + /** + * 处理model的显示颜色,将搜索词高亮 + * + * @param modelName + * @param strings + * @return + */ + public String dealWithModelName(String modelName, String strings[]) { + if (strings == null) { + return modelName; + } + for (int i = 0; i < strings.length; i++) { + String primaryStr = getReplacedString(modelName, strings[i]); + modelName = modelName.replaceAll("(?i)" + strings[i], "|" + strings[i] + "|"); + if(!StringUtils.isEmpty(primaryStr)){ + modelName = modelName.replaceAll(strings[i], primaryStr); + } + } + modelName = "" + modelName.replaceAll("\\|", "") + ""; + return modelName; + } + + private String getReplacedString(String modelName, String string) { + int index = modelName.toLowerCase().indexOf(string.toLowerCase()); + if(index == -1){ + return null; + } + return modelName.substring(index, index+string.length()); + + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index ef791195d5..af7cf2d265 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -11,23 +11,11 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; -import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; -import com.fr.design.mainframe.alphafine.cell.model.FileModel; -import com.fr.design.mainframe.alphafine.cell.model.MoreModel; -import com.fr.design.mainframe.alphafine.cell.model.PluginModel; +import com.fr.design.mainframe.alphafine.cell.model.*; import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; -import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.model.SearchResult; -import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; -import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; -import com.fr.design.mainframe.alphafine.preview.NoResultPane; -import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; -import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; +import com.fr.design.mainframe.alphafine.preview.*; +import com.fr.design.mainframe.alphafine.search.manager.impl.*; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.form.main.Form; @@ -45,35 +33,11 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import javax.imageio.ImageIO; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.event.DocumentEvent; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import java.awt.AWTEvent; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.Window; -import java.awt.event.AWTEventListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.*; +import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; @@ -81,6 +45,8 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.HashMap; import java.util.concurrent.ExecutionException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Created by XiaXiang on 2017/3/21. @@ -99,6 +65,7 @@ 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 static final String SIMILAR_MARK = "k:robot "; private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine"); private static final int MAX_SHOW_SIZE = 12; @@ -116,9 +83,17 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; private SwingWorker showWorker; private String storeText; + private String[] segmentationResult; //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; + private JPanel hotPane; + private JPanel backPane; + SearchResult modeList = null; + private static String beforeSearchStr = ""; + private static boolean isAlreadySearch = false; + private static boolean isAlreadyInitHot = false; + public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); this.forceOpen = forceOpen; @@ -190,6 +165,45 @@ public class AlphaFineDialog extends UIDialog { }); topPane.add(closeButton, BorderLayout.EAST); add(topPane, BorderLayout.CENTER); + + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + } + } + + /** + * 初始化热门界面 + */ + private void initHotPane() { + hotPane = new JPanel(); + hotPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + hotPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); + hotPane.setLayout(new BorderLayout()); + + UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot")); + uiLabel.setFont(AlphaFineConstants.SMALL_FONT); + uiLabel.setForeground(AlphaFineConstants.DARK_GRAY); + JPanel panel = new JPanel(); + + hotPane.add(uiLabel, BorderLayout.NORTH); + hotPane.add(panel, BorderLayout.CENTER); + + GridLayout gridLayout = new GridLayout(2, 3, 3, 3); + panel.setLayout(gridLayout); + + String[][] ss = HotIssuesManager.getInstance().getHotIssues(); + + if(ss != null){ + for (int i = 0; i < ss.length; i++) { + panel.add(new HotIssueJpanel(ss[i], i + 1)); + } + }else { + for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) { + panel.add(new HotIssueJpanel(new String[]{" "}, i + 1)); + } + } + add(hotPane, BorderLayout.SOUTH); + setSize(AlphaFineConstants.FULL_SIZE); } /** @@ -208,7 +222,7 @@ public class AlphaFineDialog extends UIDialog { */ private void initProperties() { setUndecorated(true); - //addComponentListener(new ComponentHandler()); +//addComponentListener(new ComponentHandler()); setSize(AlphaFineConstants.FIELD_SIZE); centerWindow(this); @@ -230,20 +244,20 @@ public class AlphaFineDialog extends UIDialog { if (winSize.width > screenSize.width) { winSize.width = screenSize.width; } - //这里设置位置:水平居中,竖直偏上 +//这里设置位置:水平居中,竖直偏上 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(), 15, 15); -// g2.dispose(); -// } +// 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(), 15, 15); +// g2.dispose(); +// } /** * 执行搜索 @@ -254,16 +268,21 @@ public class AlphaFineDialog extends UIDialog { showSearchResult(text); } - boolean isNoNeedSearch(String text) { - return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'") || StringUtils.isBlank(text); - } - @Override public void setVisible(boolean isVisible) { if (!isVisible) { dispose(); return; } + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + if (hotPane == null) { + initHotPane(); + } + }else{ + removeHotPane(); + setSize(AlphaFineConstants.FIELD_SIZE); + refreshContainer(); + } super.setVisible(isVisible); } @@ -289,8 +308,7 @@ public class AlphaFineDialog extends UIDialog { remove(searchResultPane); searchResultPane = null; } - setSize(AlphaFineConstants.FIELD_SIZE); - refreshContainer(); + } /** @@ -307,6 +325,8 @@ public class AlphaFineDialog extends UIDialog { * 初始化搜索面板 */ private void initSearchResultComponents() { + + searchResultList = new AlphaFineList(); searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT); searchListModel = new SearchListModel(new SearchResult()); @@ -314,7 +334,7 @@ public class AlphaFineDialog extends UIDialog { searchResultPane = new JPanel(); searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); searchResultPane.setLayout(new BorderLayout()); - searchResultList.setCellRenderer(new ContentCellRender()); + searchResultList.setCellRenderer(new ContentCellRender(storeText, segmentationResult)); leftSearchResultPane = new UIScrollPane(searchResultList); leftSearchResultPane.setBorder(null); @@ -424,17 +444,19 @@ public class AlphaFineDialog extends UIDialog { */ private void dealWithSearchText(String searchText) { if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { - buildActionList(getStoreText(searchText)); + buildActionList(new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { - buildDocumentList(getStoreText(searchText)); + buildDocumentList(new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { - buildFileList(getStoreText(searchText)); + buildFileList(new String[]{getStoreText(searchText)}); } else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { - buildFileList(searchText); + buildFileList(new String[]{searchText}); } else if (searchText.startsWith(DS_MARK)) { - buildFileList(DS_NAME + getStoreText(searchText)); + buildFileList(new String[]{DS_NAME + getStoreText(searchText)}); } else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { - buildPluginList(getStoreText(searchText)); + buildPluginList(new String[]{getStoreText(searchText)}); + } else if (searchText.startsWith(SIMILAR_MARK)) { + buildSimilarList(new String[]{getStoreText(searchText)}); } } @@ -467,39 +489,47 @@ public class AlphaFineDialog extends UIDialog { * @param searchText */ private void doNormalSearch(String searchText) { - buildRecentList(searchText); - buildRecommendList(searchText); - buildActionList(searchText); - buildFileList(searchText); - buildDocumentList(searchText); - buildPluginList(searchText); + if (segmentationResult != null) { + buildRecentList(segmentationResult); + buildRecommendList(segmentationResult); + buildActionList(segmentationResult); + buildFileList(segmentationResult); + buildDocumentList(segmentationResult); + buildPluginList(segmentationResult); + buildSimilarList(segmentationResult); + } + searchListModel.addElement(new BottomModel()); } - private void buildDocumentList(final String searchText) { + private void buildDocumentList(final String[] searchText) { addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildFileList(final String searchText) { + private void buildFileList(final String[] searchText) { addSearchResult(FileSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildActionList(final String searchText) { + private void buildActionList(final String[] searchText) { addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildPluginList(final String searchText) { + private void buildPluginList(final String[] searchText) { addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildRecommendList(final String searchText) { + private void buildRecommendList(final String[] searchText) { addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(searchText)); } - private void buildRecentList(final String searchText) { + private void buildRecentList(final String[] searchText) { addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(searchText)); } + private void buildSimilarList(final String[] searchText) { + addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(searchText)); + } + private synchronized void addSearchResult(SearchResult searchResult) { for (AlphaCellModel object : searchResult) { AlphaFineHelper.checkCancel(); @@ -625,12 +655,42 @@ public class AlphaFineDialog extends UIDialog { validate(); repaint(); } - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } catch (ExecutionException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + } catch (Exception e) { } + } + }; + this.showWorker.execute(); + break; + case ROBOT: + case RECOMMEND_ROBOT: + showDefaultPreviewPane(); + checkWorker(); + this.showWorker = new SwingWorker() { + @Override + protected String doInBackground() { + String content = RobotModel.getContent((selectedValue).getName()); + //去掉小帆底部的信息 + String regex1 = "
([\\s\\S]*?)class=\"jiaoyes\">YES
"; + String regex2 = "
"; + content = content.replaceAll(regex1, "") + .replaceAll(regex2, ""); + return content; + } + @Override + protected void done() { + if (!isCancelled() && rightSearchResultPane != null) { + rightSearchResultPane.removeAll(); + try { + rightSearchResultPane.add(new RobotPreviewPane((selectedValue).getName(), get())); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + validate(); + repaint(); + } } }; this.showWorker.execute(); @@ -702,24 +762,74 @@ public class AlphaFineDialog extends UIDialog { } }); - searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { + Timer timer = new Timer(300, new ActionListener() { @Override - protected void textChanged(DocumentEvent e) { - if (isNoNeedSearch(searchTextField.getText())) { + public void actionPerformed(ActionEvent e) { + if (!isAlreadyInitHot && searchTextField.getText().length() == 0) { + isAlreadyInitHot = true; removeSearchResult(); - } else { - try { - Thread.sleep(10); + refreshContainer(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + if (hotPane == null) { + initHotPane(); + setSize(AlphaFineConstants.FULL_SIZE); + } + }else{ + setSize(AlphaFineConstants.FIELD_SIZE); + } + refreshContainer(); + return; + } else if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) { + if (isAlreadySearch) { + return; + } else { + removeHotPane(); + removeSearchResult(); + refreshContainer(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) { + //是高级搜索 + if(searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)){ + segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase())); + } + //是普通搜索 + else{ + segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase()); + } + } else { + if(StringUtils.isEmpty(getRealSearchText(searchTextField.getText().toLowerCase()))){ + segmentationResult = null; + }else{ + segmentationResult = new String[]{getRealSearchText(searchTextField.getText().toLowerCase())}; + } + } doSearch(searchTextField.getText().toLowerCase()); - } catch (InterruptedException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage()); + isAlreadySearch = true; } - + } else { + beforeSearchStr = searchTextField.getText(); + isAlreadySearch = false; + } + if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) { + isAlreadyInitHot = false; } } - }); + }); + timer.start(); + } + /** + * 去除特殊字符,空格等 + */ + private String getRealSearchText(String searchText){ + String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(searchText); + searchText = m.replaceAll("").trim().replaceAll(" ", ""); + if (searchText.length() == 0) { + return null; + } + return searchText; } /** @@ -760,7 +870,7 @@ public class AlphaFineDialog extends UIDialog { @Override public void checkValid() throws Exception { - //不处理 +//不处理 } /** @@ -780,6 +890,9 @@ public class AlphaFineDialog extends UIDialog { * @param cellModel */ private void saveLocalHistory(final AlphaCellModel cellModel) { + if(cellModel instanceof BottomModel){ + return; + } Thread sendThread = new Thread(new Runnable() { @Override public void run() { @@ -883,6 +996,13 @@ public class AlphaFineDialog extends UIDialog { case ACTION: moreResult = ActionSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); break; + case ROBOT: + case RECOMMEND_ROBOT: + moreResult = SimilarSearchManeger.getInstance().getMoreSearchResult(searchTextField.getText()); + break; + case RECOMMEND: + moreResult = RecommendSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); + break; default: moreResult = new SearchResult(); } @@ -953,7 +1073,7 @@ public class AlphaFineDialog extends UIDialog { /** * +-------------------------------------+ - * | 自定义JList | + * | 自定义JList | * +-------------------------------------+ */ private class AlphaFineList extends JList { @@ -1030,7 +1150,7 @@ public class AlphaFineDialog extends UIDialog { /** * +-------------------------------------+ - * | 自定义ListModel | + * | 自定义ListModel | * +-------------------------------------+ */ private class SearchListModel extends DefaultListModel { @@ -1135,4 +1255,171 @@ public class AlphaFineDialog extends UIDialog { } } + public void showIssuesList() { + if (this.searchWorker != null && !this.searchWorker.isDone()) { + this.searchWorker.cancel(true); + this.searchWorker = null; + } + this.searchWorker = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + + resetContainer(); + for (AlphaCellModel object : modeList) { + searchListModel.addElement(object); + } + return null; + } + + @Override + protected void done() { + if (!isCancelled()) { + splitLabel.setIcon(null); + fireStopLoading(); + } + } + }; + this.searchWorker.execute(); + } + + /** + * 移除热门面板 + */ + private void removeHotPane() { + if (hotPane != null) { + remove(hotPane); + hotPane = null; + } + } + /** + * 增加返回面板 + */ + private void initBackPane() { + backPane = new JPanel(new BorderLayout()); + JLabel jLabel = new JLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Back")); + jLabel.setPreferredSize(new Dimension(680, 20)); + jLabel.setFont(AlphaFineConstants.SMALL_FONT); + jLabel.setForeground(AlphaFineConstants.DARK_GRAY); + backPane.add(jLabel, BorderLayout.CENTER); + jLabel.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + if (searchResultPane != null) { + remove(searchResultPane); + searchResultPane = null; + } + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + if (hotPane == null) { + initHotPane(); + } + setSize(AlphaFineConstants.FULL_SIZE); + }else{ + setSize(AlphaFineConstants.FIELD_SIZE); + } + refreshContainer(); + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + } + + /** + * +-------------------------------------+ + * | 自定义热门问题面板 | + * +-------------------------------------+ + */ + private class HotIssueJpanel extends JPanel { + + public HotIssueJpanel(String[] str, int pngIndex) { + this.setLayout(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + this.setSize(AlphaFineConstants.HOT_ISSUES_JAPNEL_SIZE); + + JPanel pane1 = new JPanel(new BorderLayout()); + ContainsCirclePane circle = new ContainsCirclePane(pngIndex); + circle.setBorder(BorderFactory.createEmptyBorder(20,0,10,0)); + pane1.add(circle, BorderLayout.NORTH); + add(pane1, BorderLayout.NORTH); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.setBackground(Color.white); + UILabel title = new UILabel(); + title.setText(str[0]); + title.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER); + title.setForeground(AlphaFineConstants.DARK_GRAY); + title.setHorizontalAlignment(JTextField.CENTER); + centerPanel.add(title); + add(centerPanel, BorderLayout.CENTER); + + JPanel bottomPanel = new JPanel(new BorderLayout()); + bottomPanel.setBackground(Color.white); + + GridLayout gridLayout = new GridLayout(2, 2); + + + for (int i = 1; i < str.length; i++) { + final UILabel subTitle = new UILabel(str[i]); + subTitle.setForeground(AlphaFineConstants.DARK_GRAY); + subTitle.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER); + subTitle.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + segmentationResult = null; + removeHotPane(); + if (searchResultPane == null) { + initSearchResultComponents(); + } + initBackPane(); + searchResultPane.add(backPane, BorderLayout.NORTH); + refreshContainer(); + modeList = HotIssuesManager.getInstance().getTitleSearchResult(subTitle.getText()); + showIssuesList(); + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + bottomPanel.add(subTitle); + } + bottomPanel.setLayout(gridLayout); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 22, 0)); + add(bottomPanel, BorderLayout.SOUTH); + } + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index a60a763967..006c0b7b8d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -3,7 +3,10 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.gui.itextfield.UITextField; import com.fr.report.web.button.Image; -import java.awt.*; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; + /** * Created by XiaXiang on 2017/3/21. @@ -26,13 +29,7 @@ public class AlphaFineTextField extends UITextField { @Override public String getText() { - String text = super.getText(); - - if (text.trim().length() == 0 && placeHolder != null) { - text = placeHolder; - } - - return text; + return super.getText(); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ContainsCirclePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ContainsCirclePane.java new file mode 100644 index 0000000000..e320c723a2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ContainsCirclePane.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.alphafine.preview; + +import com.bulenkov.iconloader.IconLoader; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; + +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Graphics; + +/** + * @Author alex.sung + * created by 2018.08.15 + */ +public class ContainsCirclePane extends JPanel { + + public ContainsCirclePane(int pngIndex) { + UILabel iconLabel = new UILabel(IconLoader.getIcon(AlphaFineConstants.IMAGE_URL + "alphafine_hot" + pngIndex + ".png")); + iconLabel.setPreferredSize(AlphaFineConstants.HOT_ICON_LABEL_SIZE); + iconLabel.setOpaque(true); + iconLabel.setBackground(Color.WHITE); + add(iconLabel); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + int height = AlphaFineConstants.HOT_ICON_LABEL_HEIGHT; + setBackground(Color.white); + int x0 = getSize().width / 2; + int y0 = height / 2 + 23; + int r = height / 2 + 9; + g.setColor(AlphaFineConstants.LIGHT_GRAY); + g.drawOval(x0 - r, y0 - r, r * 2, r * 2); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java new file mode 100644 index 0000000000..32c5cd8202 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java @@ -0,0 +1,41 @@ +package com.fr.design.mainframe.alphafine.preview; + + +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; + +import javax.swing.BorderFactory; +import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.text.html.HTMLEditorKit; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; + + +/** + * Created by alex.sung on 2018/8/3. + */ +public class RobotPreviewPane extends JPanel { + + public RobotPreviewPane(String title, String content) { + this.setLayout(new BorderLayout()); + this.setBackground(Color.WHITE); + this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); + UITextArea titleArea = new UITextArea(title); + titleArea.setBorder(null); + titleArea.setEditable(false); + titleArea.setForeground(AlphaFineConstants.BLUE); + titleArea.setFont(AlphaFineConstants.LARGE_FONT); + add(titleArea, BorderLayout.NORTH); + + JEditorPane editorPane = new JEditorPane(); + editorPane.setEditorKit(new HTMLEditorKit()); + editorPane.setText(content); + editorPane.setEditable(false); + JScrollPane jScrollPane = new JScrollPane(editorPane); + jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white)); + add(jScrollPane, BorderLayout.CENTER); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java index 9d29433a23..b75aa894c4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java @@ -12,7 +12,7 @@ public interface AlphaFineSearchProvider { * @param searchText * @return */ - SearchResult getLessSearchResult(String searchText); + SearchResult getLessSearchResult(String[] searchText); /** * 获取剩余条数 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index b17b14d068..6335be5615 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -57,21 +57,23 @@ public class ActionSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public synchronized SearchResult getLessSearchResult(String[] searchText) { filterModelList = new SearchResult(); lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { + if (searchText.length == 0) { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"))); return lessModelList; } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) { List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); for (UpdateActionModel updateActionModel : updateActions) { - AlphaFineHelper.checkCancel(); - if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { - if (updateActionModel.getSearchKey().contains(searchText) && updateActionModel.getAction().isEnabled()) { - filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); + for (int j = 0; j < searchText.length; j++) { + AlphaFineHelper.checkCancel(); + if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { + if (updateActionModel.getSearchKey().contains(searchText[j]) && updateActionModel.getAction().isEnabled()) { + filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); + } } } } @@ -91,7 +93,6 @@ public class ActionSearchManager implements AlphaFineSearchProvider { lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } - } return lessModelList; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java new file mode 100644 index 0000000000..c548a1b47c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java @@ -0,0 +1,84 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +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.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.json.JSONTokener; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import org.apache.commons.codec.digest.DigestUtils; + +/** + * @author alex.sung created on 2018/7/23. + */ +public class ComplementAdviceManager { + + public static int count = 0; + + private static ComplementAdviceManager instance; + private SearchResult allModelList; + + public static ComplementAdviceManager getInstance() { + if (instance == null) { + synchronized (ComplementAdviceManager.class) { + if (instance == null) { + instance = new ComplementAdviceManager(); + } + } + } + return instance; + } + + /** + * 从接口中获取补全建议结果 + * @param searchText + * @return + */ + public synchronized SearchResult getAllSearchResult(String[] searchText) { + allModelList = new SearchResult(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + SearchResult searchResult = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String result; + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); + String url = AlphaFineConstants.COMPLEMENT_ADVICE_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + HttpClient httpClient = new HttpClient(url); + httpClient.asGet(); + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + Object json = new JSONTokener(result).nextValue(); + if (json instanceof JSONArray) { + JSONArray jsonArray = new JSONArray(result); + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = jsonArray.optJSONObject(i); + + String temp = jsonObject.optString("keywords"); + if (!StringUtils.isEmpty(temp)) { + RobotModel robotModel = new RobotModel(temp, null); + if (!AlphaFineHelper.getFilterResult().contains(robotModel) && !allModelList.contains(robotModel)) { + allModelList.add(robotModel); + } + } + } + } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("complement advice search error: " + e.getMessage()); + } + } + if (searchResult.isEmpty()) { + return allModelList; + } else { + allModelList.addAll(searchResult); + } + } + return allModelList; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 59595229a3..cad89640e4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -14,7 +14,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; /** * Created by XiaXiang on 2017/3/27. @@ -50,48 +49,53 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public synchronized SearchResult getLessSearchResult(String[] searchText) { lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { + if (searchText.length == 0) { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); return lessModelList; } if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { - String result; - String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1"; - HttpClient httpClient = new HttpClient(url); - httpClient.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); - } - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - try { - JSONObject jsonObject = new JSONObject(result); - JSONArray jsonArray = jsonObject.optJSONArray("docdata"); - if (jsonArray != null) { - SearchResult searchResult = new SearchResult(); - for (int i = 0; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); - if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { - searchResult.add(cellModel); + SearchResult searchResult = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String result; + String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j] + "-1"; + HttpClient httpClient = new HttpClient(url); + httpClient.asGet(); + if (!httpClient.isServerAlive()) { + return getNoConnectList(); + } + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.optJSONArray("docdata"); + if (jsonArray != null) { + + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); + if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { + searchResult.add(cellModel); + } } } - if (searchResult.isEmpty()) { - return lessModelList; - } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); - lessModelList.addAll(searchResult); - } else { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); - lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); - moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); - } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("document search error: " + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("document search error: " + e.getMessage()); + } + lessModelList.clear(); + moreModelList.clear(); + if (searchResult.isEmpty()) { + return lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); + lessModelList.addAll(searchResult); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } } return lessModelList; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index d728598919..107cbb8648 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -33,7 +33,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { private FileNode[] fileNodes = null; //停止搜索 - //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 +//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 private boolean isContainCpt = true; private boolean isContainFrm = true; @@ -62,20 +62,23 @@ public class FileSearchManager implements AlphaFineSearchProvider { return new FileModel(name, filePath, searchCount); } - public synchronized SearchResult getLessSearchResult(String searchText) { + public synchronized SearchResult getLessSearchResult(String[] searchText) { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - this.searchText = dealWithSearchText(searchText); - if (StringUtils.isBlank(this.searchText) || ComparatorUtils.equals(this.searchText, DS_NAME)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"))); - return lessModelList; + for (int j = 0; j < searchText.length; j++) { + this.searchText = dealWithSearchText(searchText[j]); + if (StringUtils.isBlank(this.searchText) || ComparatorUtils.equals(this.searchText, DS_NAME)) { + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Templates"))); + return lessModelList; + } + AlphaFineHelper.checkCancel(); + fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true); + isContainCpt = true; + isContainFrm = true; + doSearch(this.searchText); } - AlphaFineHelper.checkCancel(); - fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, new FileExtension[]{FileExtension.CPT, FileExtension.FRM}, true); - isContainCpt = true; - isContainFrm = true; - doSearch(this.searchText); + if (filterModelList.isEmpty()) { return new SearchResult(); } else if (filterModelList.size() < AlphaFineConstants.SHOW_SIZE + 1) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java new file mode 100644 index 0000000000..1ec5625462 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -0,0 +1,153 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +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.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * Created by alex.sung on 2018/8/3. + */ +public class HotIssuesManager { + private static HotIssuesManager instance; + private static final int HOT_ITEM_NUM = 6; + private static final int HOT_SUB_ITEM_NUM = 4; + + public static HotIssuesManager getInstance() { + if (instance == null) { + synchronized (HotIssuesManager.class) { + if (instance == null) { + instance = new HotIssuesManager(); + } + } + } + return instance; + } + + String[][] data = new String[HOT_ITEM_NUM][]; + Map map = new HashMap<>(); + + /** + * 将子标题下的数据塞入modeList + * @param getStr + * @return + */ + public SearchResult getTitleSearchResult(String getStr) { + SearchResult modeList = new SearchResult(); + modeList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText((getStr)))); + + List issueList = map.get(getStr); + for (int i = 0; i < issueList.size(); i++) { + RobotModel robotModel = new RobotModel(issueList.get(i), null); + robotModel.setHotItemModel(true); + modeList.add(robotModel); + } + return modeList; + } + + /** + * 从热门问题接口获取热门问题 + * @return + */ + public String[][] getHotIssues() { + String result; + HttpClient httpClient = new HttpClient(AlphaFineConstants.ALPHA_HOT_SEARCH); + httpClient.asGet(); + if (!httpClient.isServerAlive()) { + return null; + } + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + JSONArray jsonArray = new JSONArray(result); + for (int i = 0; i < HOT_ITEM_NUM; i++) { + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = jsonArray.optJSONObject(i); + data[i] = getTitleStrings(jsonObject); + } + + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("hotissues search error: " + e.getMessage()); + } + return data; + } + + /** + * 根据子标题获取该标题下数据 + * @param jsonObject + * @return + */ + private String[] getTitleStrings(JSONObject jsonObject) { + String[] temp = getSubTitleFromCloud(jsonObject.optJSONObject("data")); + String[] temp1 = new String[1]; + temp1[0] = jsonObject.optString("type"); + int strLen1 = temp.length; + int strLen2 = temp1.length; + + temp1 = Arrays.copyOf(temp1, strLen2 + strLen1); + System.arraycopy(temp, 0, temp1, strLen2, strLen1); + + getIssueStrings(jsonObject.optJSONObject("data")); + + return temp1; + } + + /** + * 获取子标题和子标题下的问题列表 + * @param data + * @return + */ + private String[] getIssueStrings(JSONObject data) { + try { + for (int j = 0; j < HOT_SUB_ITEM_NUM; j++) { + String temp = data.getString("item" + (j + 1)); + JSONArray jsonArray = data.getJSONArray("itemData" + (j + 1)); + List tempList = new ArrayList<>(); + for (int i = 0; i < jsonArray.length(); i++) { + tempList.add(jsonArray.optJSONObject(i).optString("text")); + } + map.put(temp, tempList); + } + + } catch (JSONException e) { + } + return null; + } + + /** + * 获取问题列表 + * @param data + * @return + */ + private String[] getSubTitleFromCloud(JSONObject data) { + ArrayList list = new ArrayList<>(); + for (int i = 0; i < HOT_SUB_ITEM_NUM; i++) { + String temp = null; + try { + temp = data.getString("item" + (i + 1)); + } catch (JSONException e) { + } + if (!StringUtils.isEmpty(temp)) { + list.add(temp); + } + } + String[] strings = new String[list.size()]; + list.toArray(strings); + return strings; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 975e943119..c59b93c02f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -17,7 +17,6 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; import com.fr.plugin.basic.version.VersionIntervalFactory; -import com.fr.stable.StringUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -95,51 +94,53 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { + public synchronized SearchResult getLessSearchResult(String[] searchText) { this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - if (StringUtils.isBlank(searchText)) { + if (searchText.length == 0) { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); return lessModelList; } + SearchResult searchResult = 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.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); - } - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - JSONObject jsonObject = new JSONObject(result); - JSONArray jsonArray = jsonObject.optJSONArray("result"); - if (jsonArray != null) { - SearchResult searchResult = new SearchResult(); - for (int i = 0; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); - if (cellModel != null && !AlphaFineHelper.getFilterResult().contains(cellModel)) { - searchResult.add(cellModel); - } + for (int j = 0; j < searchText.length; j++) { + String result; + try { + String encodedKey = URLEncoder.encode(searchText[j], "UTF-8"); + String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey; + HttpClient httpClient = new HttpClient(url); + httpClient.asGet(); + if (!httpClient.isServerAlive()) { + return getNoConnectList(); } - if (searchResult.isEmpty()) { - return this.lessModelList; - } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); - lessModelList.addAll(searchResult); - } else { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); - lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); - moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.optJSONArray("result"); + if (jsonArray != null) { + for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); + PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); + if (cellModel != null && !AlphaFineHelper.getFilterResult().contains(cellModel)) { + searchResult.add(cellModel); + } + } } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("plugin search json error :" + e.getMessage()); + } catch (UnsupportedEncodingException e) { + FineLoggerFactory.getLogger().error("plugin search encode error :" + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("plugin search json error :" + e.getMessage()); - } catch (UnsupportedEncodingException e) { - FineLoggerFactory.getLogger().error("plugin search encode error :" + e.getMessage()); + } + if (searchResult.isEmpty()) { + return this.lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + lessModelList.addAll(searchResult); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } } return this.lessModelList; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 481442faca..b9c8e69623 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -72,9 +72,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { } @Override - public SearchResult getLessSearchResult(String searchText) { + public SearchResult getLessSearchResult(String[] searchText) { this.modelList = new SearchResult(); - recentModelList = getRecentModelList(searchText); + for (int j = 0; j < searchText.length; j++) { + recentModelList = getRecentModelList(searchText[j]); + } if (recentModelList != null && recentModelList.size() > 0) { modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest"))); if (recentModelList.size() > AlphaFineConstants.LATEST_SHOW_SIZE) { @@ -136,6 +138,9 @@ public class RecentSearchManager implements AlphaFineSearchProvider { initWriter(); Document doc = new Document(); doc.add(new StringField("searchKey", searchKey, Field.Store.YES)); + if(cellModel == null){ + System.out.println("null"); + } doc.add(new StringField("cellModel", cellModel.ModelToJson().toString(), Field.Store.YES)); doc.add(new LongField("time", System.currentTimeMillis(), Field.Store.YES)); writeDoc(doc); @@ -171,7 +176,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { initReader(); IndexSearcher searcher = new IndexSearcher(indexReader); - //构建排序字段 + //构建排序字段 SortField[] sortField = new SortField[1]; sortField[0] = new SortField("time", SortField.Type.LONG, true); Sort sortKey = new Sort(sortField); @@ -181,7 +186,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); ScoreDoc[] scores = docs.scoreDocs; this.recentModelList = new SearchResult(); - //遍历结果 + //遍历结果 for (ScoreDoc scoreDoc : scores) { Document document = searcher.doc(scoreDoc.doc); AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(document.get("cellModel"))); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index 8a2873e4b4..d75f1552d2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -15,6 +15,7 @@ import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; +import com.fr.json.JSONTokener; import com.fr.log.FineLoggerFactory; import com.fr.stable.CodeUtils; import com.fr.stable.StringUtils; @@ -30,6 +31,9 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { private SearchResult modelList; private SearchResult recommendModelList; + private SearchResult complementAdviceModelList; + private SearchResult moreModelList = new SearchResult(); + public static RecommendSearchManager getInstance() { if (instance == null) { synchronized (RecentSearchManager.class) { @@ -42,37 +46,45 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { } @Override - public synchronized SearchResult getLessSearchResult(String searchText) { - searchText = searchText.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + public synchronized SearchResult getLessSearchResult(String[] searchText) { + this.modelList = new SearchResult(); this.recommendModelList = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { - String result; - HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText)); - httpClient.asGet(); - if (!httpClient.isServerAlive()) { - return getNoConnectList(); - } - httpClient.setTimeout(3000); - result = httpClient.getResponseText(); - AlphaFineHelper.checkCancel(); - 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++) { - AlphaFineHelper.checkCancel(); - AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); - if (alphaCellModel != null && !alreadyContain(alphaCellModel)) { - this.recommendModelList.add(alphaCellModel); + for (int j = 0; j < searchText.length; j++) { + String result; + searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText[j])); + httpClient.asGet(); + if (!httpClient.isServerAlive()) { + return getNoConnectList(); + } + httpClient.setTimeout(3000); + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + Object json = new JSONTokener(result).nextValue(); + if (json instanceof JSONObject) { + 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++) { + AlphaFineHelper.checkCancel(); + AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); + if (alphaCellModel != null && !alreadyContain(alphaCellModel)) { + + this.recommendModelList.add(alphaCellModel); + } + } } } } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage()); } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage()); } + Iterator modelIterator = recommendModelList.iterator(); while (modelIterator.hasNext()) { AlphaCellModel model = modelIterator.next(); @@ -80,9 +92,63 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { modelIterator.remove(); } } + complementAdviceModelList = ComplementAdviceManager.getInstance().getAllSearchResult(searchText); + moreModelList.clear(); if (recommendModelList.size() > 0) { - modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); - modelList.addAll(recommendModelList); + if (complementAdviceModelList.size() == 0) { + if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE - 2) { + if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + } + modelList.addAll(recommendModelList.subList(0, AlphaFineConstants.SHOW_SIZE - 2)); + moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.SHOW_SIZE - 2, recommendModelList.size())); + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(recommendModelList); + } + } else { + if (recommendModelList.size() + complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE - 2) { + modelList.addAll(recommendModelList.subList(0, AlphaFineConstants.SHOW_SIZE - 2)); + moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.SHOW_SIZE - 2, recommendModelList.size())); + + if (complementAdviceModelList.size() >= 2) { + modelList.addAll(complementAdviceModelList.subList(0, 2)); + moreModelList.addAll(complementAdviceModelList.subList(2, complementAdviceModelList.size())); + } else { + modelList.addAll(complementAdviceModelList); + } + } else { + modelList.addAll(recommendModelList); + if (complementAdviceModelList.size() >= (AlphaFineConstants.SHOW_SIZE - recommendModelList.size())) { + modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE - recommendModelList.size())); + moreModelList.addAll(complementAdviceModelList.subList(2, complementAdviceModelList.size())); + } else { + modelList.addAll(complementAdviceModelList); + } + } + } else { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(recommendModelList); + modelList.addAll(complementAdviceModelList); + } + } + }else{ + if(complementAdviceModelList.size() > 0) { + if (complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) { + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND)); + modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(complementAdviceModelList.subList(AlphaFineConstants.SHOW_SIZE, complementAdviceModelList.size())); + }else{ + modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false)); + modelList.addAll(complementAdviceModelList); + } + }else{ + return modelList; + } } } return modelList; @@ -105,9 +171,10 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { return result; } + @Override public SearchResult getMoreSearchResult(String searchText) { - return new SearchResult(); + return moreModelList; } public List getRecommendModelList() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java new file mode 100644 index 0000000000..ff1d68b954 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java @@ -0,0 +1,81 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.stable.StringUtils; + +import com.fr.third.ibm.icu.text.BreakIterator; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class SegmentationManager { + private static SegmentationManager segmentationManager = null; + private static final int MAX_CHINESE_CHARACTERS_NUM = 4; + + public static SegmentationManager getInstance() { + if (segmentationManager == null) { + segmentationManager = new SegmentationManager(); + return segmentationManager; + } else { + return segmentationManager; + } + } + + /** + * 判断是否需要分词 + * + * @param searchText + * @return + */ + public boolean isNeedSegmentation(String searchText) { + int count = 0; + String reg = "[\\u4e00-\\u9fa5]"; + Pattern p = Pattern.compile(reg); + Matcher m = p.matcher(searchText); + while (m.find()) { + for (int i = 0; i <= m.groupCount(); i++) { + count = count + 1; + } + } + if (count >= MAX_CHINESE_CHARACTERS_NUM) { + return true; + } + return false; + } + + /** + * 对字符串进行分词 + * @param searchText + * @return + */ + public String[] startSegmentation(String searchText) { + String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(searchText); + searchText = m.replaceAll("").trim().replaceAll(" ", ""); + if (searchText.length() == 0) { + return null; + } + if(!isNeedSegmentation(searchText)){ + return new String[]{searchText}; + } + List result = new ArrayList<>(); + BreakIterator itor = BreakIterator.getWordInstance(); + itor.setText(searchText); + int start = itor.first(); + for (int end = itor.next(); + end != BreakIterator.DONE; + start = end, end = itor.next()) { + String temp = searchText.substring(start, end); + if (!StringUtils.isEmpty(temp)) { + result.add(temp); + } + } + String[] strings = new String[result.size()]; + result.toArray(strings); + return strings; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java new file mode 100644 index 0000000000..2a09182a0a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java @@ -0,0 +1,101 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +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.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.RobotModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; +import com.fr.json.JSONTokener; +import com.fr.log.FineLoggerFactory; +import org.apache.commons.codec.digest.DigestUtils; + +/** + * Created by alex.sung on 2018/8/3. + */ +public class SimilarSearchManeger implements AlphaFineSearchProvider { + private static SimilarSearchManeger instance; + private SearchResult lessModelList; + private SearchResult moreModelList = new SearchResult(); + + public static SimilarSearchManeger getInstance() { + if (instance == null) { + synchronized (SimilarSearchManeger.class) { + if (instance == null) { + instance = new SimilarSearchManeger(); + } + } + } + return instance; + } + + @Override + public synchronized SearchResult getLessSearchResult(String[] searchText) { + lessModelList = new SearchResult(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + SearchResult allModelList = new SearchResult(); + for (int j = 0; j < searchText.length; j++) { + String result; + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); + String url = AlphaFineConstants.SIMILAR_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + HttpClient httpClient = new HttpClient(url); + httpClient.asGet(); + result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); + try { + Object json = new JSONTokener(result).nextValue(); + if (json instanceof JSONArray) { + JSONArray jsonArray = new JSONArray(result); + if (jsonArray.length() != 0) { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.optJSONObject(i); + String title = jsonObject.optString("title"); + RobotModel robotModel = new RobotModel(title, null); + if (!AlphaFineHelper.getFilterResult().contains(robotModel) && !allModelList.contains(robotModel)) { + allModelList.add(robotModel); + } + } + } + } + } catch (JSONException e) { + FineLoggerFactory.getLogger().error("similar search error: " + e.getMessage()); + } + } + moreModelList.clear(); + if (allModelList.isEmpty()) { + return lessModelList; + } else if (allModelList.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"))); + lessModelList.addAll(allModelList); + } else { + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.ROBOT)); + lessModelList.addAll(allModelList.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(allModelList.subList(AlphaFineConstants.SHOW_SIZE, allModelList.size())); + } + } + return lessModelList; + } + + @Override + public SearchResult getMoreSearchResult(String searchText) { + return moreModelList; + } + + /** + * 根据json信息获取RobotModel + * + * @param object + * @return + */ + public static RobotModel getModelFromCloud(JSONObject object) { + String name = object.optString("title"); + String content = object.optString("content"); + return new RobotModel(name, content); + } +} diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10.png new file mode 100644 index 0000000000..2657e4d06d Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10@2x.png new file mode 100644 index 0000000000..a3d5423f97 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8.png new file mode 100644 index 0000000000..aae79cb065 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8@2x.png new file mode 100644 index 0000000000..667a7c0cdf Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1.png new file mode 100644 index 0000000000..a46dba3420 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1@2x.png new file mode 100644 index 0000000000..7263c72737 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2.png new file mode 100644 index 0000000000..fb5e7c60f1 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2@2x.png new file mode 100644 index 0000000000..7c8d133c34 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3.png new file mode 100644 index 0000000000..4313550571 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3@2x.png new file mode 100644 index 0000000000..761a362e91 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4.png new file mode 100644 index 0000000000..ddfd50c8dc Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4@2x.png new file mode 100644 index 0000000000..b504d2de22 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5.png new file mode 100644 index 0000000000..23522960fe Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5@2x.png new file mode 100644 index 0000000000..aca56d637f Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6.png new file mode 100644 index 0000000000..66d6c9530b Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6@2x.png new file mode 100644 index 0000000000..84ede5a553 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10.png new file mode 100644 index 0000000000..6242e61944 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10@2x.png new file mode 100644 index 0000000000..568b5428ee Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8.png new file mode 100644 index 0000000000..dd04302fc1 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8@2x.png b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8@2x.png new file mode 100644 index 0000000000..d02b7971d1 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8@2x.png differ