Browse Source

Merge pull request #389 in DESIGN/design from ~ALEX.SUNG/design:feature/10.0 to feature/10.0

REPORT-6453 alphafine整合小帆

* commit '6e95b0939a7e07de101db5b25715f3a9a9b2fe1a':
  提升代码质量。。
  解决冲突,并提升代码质量
  解决冲突,并提升代码质量
  规范国际化文件及国际化定义。
  提升alphafine代码质量
  提升alphafine代码质量
  提升alphafine代码质量
  规范国际化文件及国际化定义。
  规范国际化文件及国际化定义。
research/10.0
Alex.Sung 6 years ago
parent
commit
ec5f1fc7f2
  1. 86
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  2. 119
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  3. 42
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  4. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java
  5. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  6. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  7. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java
  8. 58
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java
  9. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java
  10. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  11. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java
  12. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java
  13. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  14. 95
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  15. 39
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java
  16. 75
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  17. 399
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  18. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  19. 36
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ContainsCirclePane.java
  20. 41
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  21. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java
  22. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java
  23. 83
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  24. 76
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  25. 27
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  26. 151
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java
  27. 82
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  28. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  29. 142
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  30. 82
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  31. 100
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java
  32. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10.png
  33. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10@2x.png
  34. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8.png
  35. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8@2x.png
  36. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1.png
  37. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1@2x.png
  38. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2.png
  39. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2@2x.png
  40. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3.png
  41. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3@2x.png
  42. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4.png
  43. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4@2x.png
  44. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5.png
  45. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5@2x.png
  46. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6.png
  47. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6@2x.png
  48. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10.png
  49. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10@2x.png
  50. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8.png
  51. BIN
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8@2x.png

86
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -18,11 +18,11 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 是否开启alphafine
*/
private boolean isEnabled = true;
private boolean enabled = true;
/**
* 是否联网搜索
*/
private boolean isSearchOnLine = true;
private boolean searchOnLine = true;
/**
* 搜索范围
@ -34,27 +34,35 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 猜您需要
*/
private boolean isContainRecommend = true;
private boolean containRecommend = true;
/**
* 设置
*/
private boolean isContainAction = true;
private boolean containAction = true;
/**
* 帮助文档
*/
private boolean isContainDocument = true;
private boolean containDocument = true;
/**
* 模板
*/
private boolean isContainTemplate = true;
private boolean containTemplate = true;
/**
* 模板内容
*/
private boolean isContainFileContent;
private boolean containFileContent;
/**
* 应用中心
*/
private boolean isContainPlugin = true;
private boolean containPlugin = true;
/**
* 分词搜索
*/
private boolean needSegmentationCheckbox = true;
/**
* 智能客服
*/
private boolean needIntelligentCustomerService = true;
/**
* 快捷键
*/
@ -62,7 +70,7 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 是否提醒
*/
private boolean isNeedRemind = true;
private boolean needRemind = 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("needSegmentationCheckbox", true));
this.setNeedIntelligentCustomerService(reader.getAttrAsBoolean("needIntelligentCustomerService", true));
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
@ -115,16 +125,18 @@ 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("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService());
writer.end();
}
public boolean isSearchOnLine() {
return isSearchOnLine;
return searchOnLine;
}
public void setSearchOnLine(boolean searchOnLine) {
isSearchOnLine = searchOnLine;
this.searchOnLine = searchOnLine;
}
public String getShortcuts() {
@ -149,51 +161,51 @@ public class AlphaFineConfigManager implements XMLable {
}
public boolean isContainAction() {
return isContainAction;
return containAction;
}
public void setContainAction(boolean containAction) {
this.isContainAction = containAction;
this.containAction = containAction;
}
public boolean isContainDocument() {
return isContainDocument;
return containDocument;
}
public void setContainDocument(boolean containDocument) {
this.isContainDocument = containDocument;
this.containDocument = containDocument;
}
public boolean isContainTemplate() {
return isContainTemplate;
return containTemplate;
}
public void setContainTemplate(boolean containTemplate) {
this.isContainTemplate = containTemplate;
this.containTemplate = containTemplate;
}
public boolean isContainPlugin() {
return isContainPlugin;
return containPlugin;
}
public void setContainPlugin(boolean containPlugin) {
this.isContainPlugin = containPlugin;
this.containPlugin = containPlugin;
}
public boolean isContainRecommend() {
return isContainRecommend;
return containRecommend;
}
public void setContainRecommend(boolean containConclude) {
isContainRecommend = containConclude;
this.containRecommend = containConclude;
}
public boolean isEnabled() {
return isEnabled;
return enabled;
}
public void setEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public KeyStroke getShortCutKeyStore() {
@ -212,19 +224,35 @@ public class AlphaFineConfigManager implements XMLable {
}
public boolean isContainFileContent() {
return isContainFileContent;
return containFileContent;
}
public void setContainFileContent(boolean containFileContent) {
isContainFileContent = containFileContent;
this.containFileContent = containFileContent;
}
public boolean isNeedRemind() {
return isNeedRemind;
return needRemind;
}
public void setNeedRemind(boolean needRemind) {
isNeedRemind = needRemind;
this.needRemind = needRemind;
}
public boolean isNeedSegmentationCheckbox() {
return needSegmentationCheckbox;
}
public void setNeedSegmentationCheckbox(boolean needSegmentationCheckbox) {
this.needSegmentationCheckbox = needSegmentationCheckbox;
}
public boolean isNeedIntelligentCustomerService() {
return needIntelligentCustomerService;
}
public void setNeedIntelligentCustomerService(boolean needIntelligentCustomerService) {
this.needIntelligentCustomerService = needIntelligentCustomerService;
}
public int getOperateCount() {

119
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 enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox, needIntelligentCustomerService, containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox, containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox;
private UITextField shortcutsField;
public AlphaFineConfigPane() {
@ -76,24 +75,33 @@ public class AlphaFineConfigPane extends BasicPane {
private Component[][] initSearchRangeComponents() {
Component[][] components = new Component[][]{
new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox},
new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox}
new Component[]{containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox},
new Component[]{containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox},
new Component[]{needIntelligentCustomerService, null, null}
};
return components;
}
private Component[][] initOnlineComponents() {
Component[][] components = new Component[][]{
new Component[]{searchOnlineCheckbox, needSegmentationCheckbox, 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};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range"));
isContainRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend"));
isContainActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"));
isContainPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"));
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"));
containRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend"));
containActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"));
containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"));
containDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"));
containTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"));
containFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
needIntelligentCustomerService = 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,33 +146,40 @@ 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"));
isSearchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search"));
isSearchOnlineCheckbox.addActionListener(new ActionListener() {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Type"));
searchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search"));
needSegmentationCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Segmentation"));
searchOnlineCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isSearchOnlineCheckbox.isSelected()) {
isContainRecommendCheckbox.setEnabled(false);
isContainPluginCheckbox.setEnabled(false);
isContainDocumentCheckbox.setEnabled(false);
isContainRecommendCheckbox.setSelected(false);
isContainPluginCheckbox.setSelected(false);
isContainDocumentCheckbox.setSelected(false);
if (!searchOnlineCheckbox.isSelected()) {
containRecommendCheckbox.setEnabled(false);
containPluginCheckbox.setEnabled(false);
containDocumentCheckbox.setEnabled(false);
needIntelligentCustomerService.setEnabled(false);
containRecommendCheckbox.setSelected(false);
containPluginCheckbox.setSelected(false);
containDocumentCheckbox.setSelected(false);
needIntelligentCustomerService.setSelected(false);
} else {
isContainRecommendCheckbox.setEnabled(true);
isContainPluginCheckbox.setEnabled(true);
isContainDocumentCheckbox.setEnabled(true);
containRecommendCheckbox.setEnabled(true);
containPluginCheckbox.setEnabled(true);
containDocumentCheckbox.setEnabled(true);
needIntelligentCustomerService.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);
}
private void createOpenPane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable"));
isEnabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine"));
northPane.add(isEnabledCheckbox);
enabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine"));
northPane.add(enabledCheckbox);
contentPane.add(northPane);
}
@ -174,33 +189,39 @@ public class AlphaFineConfigPane extends BasicPane {
}
public void populate(AlphaFineConfigManager alphaFineConfigManager) {
this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.isSearchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.isContainFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.isContainDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.isContainDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine());
this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine());
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
}
public void update() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
AlphaFineConfigManager alphaFineConfigManager = designerEnvManager.getAlphaFineConfigManager();
alphaFineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected());
alphaFineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected());
alphaFineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected());
alphaFineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected());
alphaFineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected());
alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected());
alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected());
alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected());
alphaFineConfigManager.setContainPlugin(this.containPluginCheckbox.isSelected());
alphaFineConfigManager.setContainAction(this.containActionCheckbox.isSelected());
alphaFineConfigManager.setContainDocument(this.containDocumentCheckbox.isSelected());
alphaFineConfigManager.setContainRecommend(this.containRecommendCheckbox.isSelected());
alphaFineConfigManager.setEnabled(this.enabledCheckbox.isSelected());
alphaFineConfigManager.setSearchOnLine(this.searchOnlineCheckbox.isSelected());
alphaFineConfigManager.setContainTemplate(this.containTemplateCheckbox.isSelected());
alphaFineConfigManager.setContainFileContent(this.containFileContentCheckbox.isSelected());
alphaFineConfigManager.setNeedSegmentationCheckbox(this.needSegmentationCheckbox.isSelected());
alphaFineConfigManager.setNeedIntelligentCustomerService(this.needIntelligentCustomerService.isSelected());
alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText());
designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager);
try {
@ -234,10 +255,10 @@ public class AlphaFineConfigPane extends BasicPane {
}
public UICheckBox getIsContainFileContentCheckbox() {
return isContainFileContentCheckbox;
return containFileContentCheckbox;
}
public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) {
this.isContainFileContentCheckbox = isContainFileContentCheckbox;
this.containFileContentCheckbox = isContainFileContentCheckbox;
}
}

42
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -1,8 +1,11 @@
package com.fr.design.mainframe.alphafine;
import com.fr.base.extension.FileExtension;
import com.fr.general.CloudCenter;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.*;
/**
* 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);
@ -58,16 +69,22 @@ public class AlphaFineConstants {
public static final Color RED = new Color(0xf46c4c);
public static final String HIGH_LIGHT_COLOR = "rgb(51,148,240)";
public static final Font SMALL_FONT = new Font("Song_TypeFace", 0, 10);
public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12);
public static final Font 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);
public static final String IMAGE_URL = "/com/fr/design/mainframe/alphafine/images/";
public static final String ALPHA_HOT_IMAGE_NAME = "alphafine_hot";
public static final String PLUGIN_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
public static final String PLUGIN_URL = CloudCenter.getInstance().acquireUrlByKind("af.pluginInfo");
@ -87,7 +104,30 @@ public class AlphaFineConstants {
public static final String SEARCH_API = CloudCenter.getInstance().acquireUrlByKind("af.cloud_search");
public static final String SPECIAL_CHARACTER_REGEX = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]";
public static final String BOTTOM_REGEX_FIRST = "<div class=\"bang\">([\\s\\S]*?)class=\"jiaoyes\">YES</a><br/>";
public static final String BOTTOM_REGEX_SECOND = "<div class=\"yes_([\\s\\S]*?)帮助</a></div></div>";
public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs";
public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search");
public static final String COMPLEMENT_ADVICE_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.advice_search");
public static final String ALPHA_HOT_SEARCH = CloudCenter.getInstance().acquireUrlByKind("af.hot_search");
public static final String ALPHA_GO_TO_FORUM = CloudCenter.getInstance().acquireUrlByKind("af.go_fourm");
public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web");
public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]";
public static final String FIRST_PAGE = "-1";
public static final FileExtension[] FILE_EXTENSIONS= new FileExtension[]{FileExtension.CPT, FileExtension.FRM};
public static final int RECOMMEND_MAX_ITEM_NUM = 3;
}

2
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;

6
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,7 +32,10 @@ public class CellModelHelper {
case REUSE:
cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
case ROBOT:
case RECOMMEND_ROBOT:
cellModel = SimilarSearchManeger.getModelFromCloud(object.optJSONObject(RESULT));
break;
}
return cellModel;
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -51,7 +51,7 @@ public class ActionModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() {
public JSONObject modelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();

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

@ -75,7 +75,7 @@ public abstract class AlphaCellModel implements Comparable {
* @return
* @throws JSONException
*/
abstract public JSONObject ModelToJson() throws JSONException;
abstract public JSONObject modelToJson() throws JSONException;
/**
* 获取需要保存到云中心的信息

58
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java

@ -0,0 +1,58 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.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 JSONObject.EMPTY;
}
@Override
public String getStoreInformation() {
return "";
}
@Override
public boolean hasAction() {
return true;
}
@Override
public void doAction() {
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java

@ -40,7 +40,7 @@ public class DocumentModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() {
public JSONObject modelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();

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

@ -35,7 +35,7 @@ public class FileModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() {
public JSONObject modelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java

@ -37,7 +37,7 @@ public class MoreModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() throws JSONException {
public JSONObject modelToJson() throws JSONException {
return null;
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java

@ -13,7 +13,7 @@ public class NoResultModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() throws JSONException {
public JSONObject modelToJson() throws JSONException {
return null;
}

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -85,7 +85,7 @@ public class PluginModel extends AlphaCellModel {
}
@Override
public JSONObject ModelToJson() {
public JSONObject modelToJson() {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
@ -109,7 +109,7 @@ public class PluginModel extends AlphaCellModel {
if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) {
return;
}
WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]");
WebViewDlgHelper.showPluginInStore(getName(), "[" + modelToJson().optString("result") + "]");
}
@Override

95
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 hotItemModel = false;
public boolean isHotItemModel() {
return hotItemModel;
}
public void setHotItemModel(boolean hotItemModel) {
this.hotItemModel = 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 = AlphaFineConstants.ALPHA_GO_TO_WEB + 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());
}
}
}

39
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<Object> {
@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;
}
}

75
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<Object> {
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<Object> {
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(StringUtils.BLANK + 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(highLightModelName(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,37 @@ public class ContentCellRender implements ListCellRenderer<Object> {
panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_HEIGHT));
return panel;
}
/**
* 处理model的显示颜色将搜索词高亮
*
* @param modelName
* @param strings
* @return
*/
public String highLightModelName(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], "|<font color=" + AlphaFineConstants.HIGH_LIGHT_COLOR + ">" + strings[i] + "</font>|");
if (StringUtils.isNotEmpty(primaryStr)) {
modelName = modelName.replaceAll(strings[i], primaryStr);
}
}
modelName = "<HTML>" + modelName.replaceAll("\\|", "") + "</HTML>";
return modelName;
}
private String getReplacedString(String modelName, String string) {
int index = modelName.toLowerCase().indexOf(string.toLowerCase());
if (index == -1) {
return StringUtils.EMPTY;
}
return modelName.substring(index, index + string.length());
}
}

399
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -11,23 +11,29 @@ 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.RobotModel;
import com.fr.design.mainframe.alphafine.cell.model.BottomModel;
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.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.preview.RobotPreviewPane;
import com.fr.design.mainframe.alphafine.preview.ContainsCirclePane;
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.HotIssuesManager;
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.search.manager.impl.SegmentationManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.form.main.Form;
@ -48,12 +54,14 @@ import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent;
import javax.swing.Timer;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.AWTEvent;
@ -62,6 +70,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
@ -81,6 +90,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,8 +110,10 @@ 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;
private static final int TIMER_DELAY = 300;
private AlphaFineTextField searchTextField;
private UIButton closeButton;
@ -116,9 +129,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 alreadySearch = false;
private static boolean alreadyInitHot = false;
public AlphaFineDialog(Frame parent, boolean forceOpen) {
super(parent);
this.forceOpen = forceOpen;
@ -190,6 +211,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 +268,7 @@ public class AlphaFineDialog extends UIDialog {
*/
private void initProperties() {
setUndecorated(true);
//addComponentListener(new ComponentHandler());
//addComponentListener(new ComponentHandler());
setSize(AlphaFineConstants.FIELD_SIZE);
centerWindow(this);
@ -230,21 +290,10 @@ 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();
// }
/**
* 执行搜索
*
@ -254,16 +303,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 +343,7 @@ public class AlphaFineDialog extends UIDialog {
remove(searchResultPane);
searchResultPane = null;
}
setSize(AlphaFineConstants.FIELD_SIZE);
refreshContainer();
}
/**
@ -307,6 +360,8 @@ public class AlphaFineDialog extends UIDialog {
* 初始化搜索面板
*/
private void initSearchResultComponents() {
searchResultList = new AlphaFineList();
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT);
searchListModel = new SearchListModel(new SearchResult());
@ -314,7 +369,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 +479,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 +524,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 +690,44 @@ public class AlphaFineDialog extends UIDialog {
validate();
repaint();
}
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (Exception e) {
}
}
};
this.showWorker.execute();
break;
case ROBOT:
case RECOMMEND_ROBOT:
showDefaultPreviewPane();
checkWorker();
this.showWorker = new SwingWorker<String, Void>() {
@Override
protected String doInBackground() {
String content = RobotModel.getContent((selectedValue).getName());
if(StringUtils.isNotEmpty(content)){
//去掉小帆底部的信息
content = content.replaceAll(AlphaFineConstants.BOTTOM_REGEX_FIRST, "")
.replaceAll(AlphaFineConstants.BOTTOM_REGEX_SECOND, "");
return content;
}else{
return "";
}
}
@Override
protected void done() {
if (!isCancelled() && rightSearchResultPane != null) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new RobotPreviewPane((selectedValue).getName(), get()));
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("get hot item content error: " + e.getMessage());
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error("get hot item content execution error: " + e.getMessage());
}
validate();
repaint();
}
}
};
this.showWorker.execute();
@ -702,24 +799,74 @@ public class AlphaFineDialog extends UIDialog {
}
});
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() {
Timer timer = new Timer(TIMER_DELAY, new ActionListener() {
@Override
protected void textChanged(DocumentEvent e) {
if (isNoNeedSearch(searchTextField.getText())) {
public void actionPerformed(ActionEvent e) {
if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) {
alreadyInitHot = 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()) && StringUtils.isNotEmpty(beforeSearchStr)) {
if (alreadySearch) {
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()))){
segmentationResult = null;
}else{
segmentationResult = new String[]{getRealSearchText(searchTextField.getText())};
}
}
doSearch(searchTextField.getText().toLowerCase());
} catch (InterruptedException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
alreadySearch = true;
}
} else {
beforeSearchStr = searchTextField.getText();
alreadySearch = false;
}
if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) {
alreadyInitHot = false;
}
}
});
});
timer.start();
}
/**
* 去除特殊字符空格等
*/
private String getRealSearchText(String searchText){
searchText = searchText.toLowerCase();
Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX);
Matcher m = p.matcher(searchText);
searchText = m.replaceAll("").trim().replaceAll(" ", "");
if (searchText.length() == 0) {
return null;
}
return searchText;
}
/**
@ -760,7 +907,7 @@ public class AlphaFineDialog extends UIDialog {
@Override
public void checkValid() throws Exception {
//不处理
//不处理
}
/**
@ -780,6 +927,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 +1033,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 +1110,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* +-------------------------------------+
* | 自定义JList |
* | 自定义JList |
* +-------------------------------------+
*/
private class AlphaFineList extends JList<AlphaCellModel> {
@ -1030,7 +1187,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* +-------------------------------------+
* | 自定义ListModel |
* | 自定义ListModel |
* +-------------------------------------+
*/
private class SearchListModel extends DefaultListModel<AlphaCellModel> {
@ -1135,4 +1292,132 @@ 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 MouseAdapter() {
@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();
}
});
}
/**
* +-------------------------------------+
* | 自定义热门问题面板 |
* +-------------------------------------+
*/
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 MouseAdapter() {
@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();
}
});
bottomPanel.add(subTitle);
}
bottomPanel.setLayout(gridLayout);
bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 22, 0));
add(bottomPanel, BorderLayout.SOUTH);
}
}
}

17
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.
@ -23,18 +26,6 @@ public class AlphaFineTextField extends UITextField {
this.placeHolder = null;
}
@Override
public String getText() {
String text = super.getText();
if (text.trim().length() == 0 && placeHolder != null) {
text = placeHolder;
}
return text;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);

36
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 + AlphaFineConstants.ALPHA_HOT_IMAGE_NAME + 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);
}
}

41
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);
}
}

2
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);
/**
* 获取剩余条数

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java

@ -15,6 +15,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.stable.ArrayUtils;
import java.util.List;
@ -22,7 +23,7 @@ import java.util.List;
* Created by XiaXiang on 2017/3/27.
*/
public class ActionSearchManager implements AlphaFineSearchProvider {
private static ActionSearchManager instance;
private static volatile ActionSearchManager instance;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
@ -57,21 +58,23 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
filterModelList = new SearchResult();
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (StringUtils.isBlank(searchText)) {
if (ArrayUtils.isEmpty(searchText)) {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")));
return lessModelList;
}
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) {
List<UpdateActionModel> 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 +94,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;
}

83
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java

@ -0,0 +1,83 @@
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.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.io.IOException;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
/**
* @author alex.sung created on 2018/7/23.
*/
public class ComplementAdviceManager {
private static volatile 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 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 token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]);
String url = AlphaFineConstants.COMPLEMENT_ADVICE_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token;
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
if(jsonArray != null){
for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel();
JSONObject jsonObject = jsonArray.optJSONObject(i);
String temp = jsonObject.optString("keywords");
if (StringUtils.isNotEmpty(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());
}catch (IOException e1) {
FineLoggerFactory.getLogger().error("complement advice get result error: " + e1.getMessage());
}
}
if (searchResult.isEmpty()) {
return allModelList;
} else {
allModelList.addAll(searchResult);
}
}
return allModelList;
}
}

76
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java

@ -8,19 +8,20 @@ import com.fr.design.mainframe.alphafine.cell.model.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
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 com.fr.stable.ArrayUtils;
import java.io.IOException;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProvider {
private static DocumentSearchManager instance;
private static volatile DocumentSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList;
@ -50,48 +51,49 @@ public class DocumentSearchManager implements AlphaFineSearchProvider {
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
lessModelList = new SearchResult();
moreModelList = new SearchResult();
if (StringUtils.isBlank(searchText)) {
if (ArrayUtils.isEmpty(searchText)) {
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 url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j] + AlphaFineConstants.FIRST_PAGE;
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
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 (IOException e) {
FineLoggerFactory.getLogger().error("document search get result 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;

27
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -25,7 +25,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private static final String DS_NAME = "dsname=\"";
private static final String FRM_PREFIX = "k:frm ";
private static final String CPT_PREFIX = "k:cpt ";
private static FileSearchManager instance;
private static volatile FileSearchManager instance;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
@ -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 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("Fine-Design_Report_Templates")));
return lessModelList;
}
AlphaFineHelper.checkCancel();
fileNodes = FRContext.getFileNodes().list(ProjectConstants.REPORTLETS_NAME, AlphaFineConstants.FILE_EXTENSIONS, 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) {

151
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java

@ -0,0 +1,151 @@
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.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.io.IOException;
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 volatile HotIssuesManager instance;
private static final int HOT_ITEM_NUM = 6;
private static final int HOT_SUB_ITEM_NUM = 4;
private static final String HOT_ITEM = "item";
private static final String HOT_ITEM_DATA = "itemData";
private static final String HOT_ITEM_TEXT = "text";
private static final String HOT_TYPE = "type";
private static final String HOT_DATA = "data";
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<String, List> map = new HashMap<>();
/**
* 将子标题下的数据塞入modeList
* @param subTitle
* @return
*/
public SearchResult getTitleSearchResult(String subTitle) {
SearchResult modeList = new SearchResult();
modeList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText((subTitle))));
List<String> issueList = map.get(subTitle);
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() {
try {
String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH);
AlphaFineHelper.checkCancel();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
if(jsonArray != null){
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());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("hotissues search get result error: " + e.getMessage());
}
return data;
}
/**
* 根据子标题获取该标题下数据
* @param jsonObject
* @return
*/
private String[] getTitleStrings(JSONObject jsonObject) {
String[] temp = getSubTitleFromCloud(jsonObject.optJSONObject(HOT_DATA));
String[] temp1 = new String[1];
temp1[0] = jsonObject.optString(HOT_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(HOT_DATA));
return temp1;
}
/**
* 获取子标题和子标题下的问题列表
* @param data
* @return
*/
private void getIssueStrings(JSONObject data) {
try {
for (int j = 0; j < HOT_SUB_ITEM_NUM; j++) {
String temp = data.getString(HOT_ITEM + (j + 1));
JSONArray jsonArray = data.getJSONArray(HOT_ITEM_DATA + (j + 1));
List<String> tempList = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
tempList.add(jsonArray.optJSONObject(i).optString(HOT_ITEM_TEXT));
}
map.put(temp, tempList);
}
} catch (JSONException e) {
}
}
/**
* 获取问题列表
* @param data
* @return
*/
private String[] getSubTitleFromCloud(JSONObject data) {
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < HOT_SUB_ITEM_NUM; i++) {
String temp = data.optString(HOT_ITEM + (i + 1));
if (!StringUtils.isEmpty(temp)) {
list.add(temp);
}
}
String[] strings = new String[list.size()];
list.toArray(strings);
return strings;
}
}

82
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -9,16 +9,17 @@ import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
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 com.fr.stable.EncodeConstants;
import com.fr.stable.ArrayUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@ -26,7 +27,7 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProvider {
private static PluginSearchManager instance;
private static volatile PluginSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList;
@ -95,51 +96,52 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
public SearchResult getLessSearchResult(String[] searchText) {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (StringUtils.isBlank(searchText)) {
if (ArrayUtils.isEmpty(searchText)) {
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++) {
try {
String encodedKey = URLEncoder.encode(searchText[j], EncodeConstants.ENCODING_UTF_8);
String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey;
String result = HttpToolbox.get(url);
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);
}
}
}
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()));
}
} 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 (IOException e) {
FineLoggerFactory.getLogger().error("plugin search get result 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;

17
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java

@ -45,7 +45,7 @@ import java.util.List;
*/
public class RecentSearchManager implements AlphaFineSearchProvider {
private static final int MAX_SIZE = 100;
private static RecentSearchManager instance;
private static volatile RecentSearchManager instance;
IndexReader indexReader = null;
IndexSearcher indexSearcher = null;
//索引存储路径
@ -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) {
@ -132,11 +134,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
* @param cellModel
*/
public void addModel(String searchKey, AlphaCellModel cellModel) {
if(cellModel == null){
return;
}
try {
initWriter();
Document doc = new Document();
doc.add(new StringField("searchKey", searchKey, Field.Store.YES));
doc.add(new StringField("cellModel", cellModel.ModelToJson().toString(), Field.Store.YES));
doc.add(new StringField("cellModel", cellModel.modelToJson().toString(), Field.Store.YES));
doc.add(new LongField("time", System.currentTimeMillis(), Field.Store.YES));
writeDoc(doc);
} catch (JSONException e) {
@ -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")));

142
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -10,15 +10,16 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.ArrayUtils;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@ -26,10 +27,13 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31.
*/
public class RecommendSearchManager implements AlphaFineSearchProvider {
private static RecommendSearchManager instance;
private static volatile RecommendSearchManager instance;
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,38 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
searchText = searchText.replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
public SearchResult getLessSearchResult(String[] searchText) {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
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++) {
searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
try {
String result = HttpToolbox.get(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText[j]));
AlphaFineHelper.checkCancel();
JSONObject jsonObject = new JSONObject(result);
if ("success".equals(jsonObject.optString("status"))) {
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 (IOException e) {
FineLoggerFactory.getLogger().error("recommend search get result error! :" + e.getMessage());
}
} catch (JSONException e) {
FineLoggerFactory.getLogger().error("recommend search error! :" + e.getMessage());
}
Iterator<AlphaCellModel> modelIterator = recommendModelList.iterator();
while (modelIterator.hasNext()) {
AlphaCellModel model = modelIterator.next();
@ -80,14 +85,90 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
modelIterator.remove();
}
}
if (recommendModelList.size() > 0) {
modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false));
modelList.addAll(recommendModelList);
complementAdviceModelList = ComplementAdviceManager.getInstance().getAllSearchResult(searchText);
moreModelList.clear();
if (!recommendModelList.isEmpty()) {
if (complementAdviceModelList.isEmpty()) {
getRecommendSearchResult();
} else {
getRecommendAndAdviceSearchResult();
}
} else {
if (!complementAdviceModelList.isEmpty()) {
getComplementAdviceSearchResult();
} else {
return modelList;
}
}
}
return modelList;
}
/**
* 将推荐接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendSearchResult(){
if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {
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.RECOMMEND_MAX_ITEM_NUM));
moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM, recommendModelList.size()));
} else {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), false));
modelList.addAll(recommendModelList);
}
}
/**
* 将补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getComplementAdviceSearchResult(){
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);
}
}
/**
* 将推荐接口和补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendAndAdviceSearchResult(){
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.RECOMMEND_MAX_ITEM_NUM) {
modelList.addAll(recommendModelList.subList(0, AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM));
moreModelList.addAll(recommendModelList.subList(AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM, recommendModelList.size()));
if (complementAdviceModelList.size() >= AlphaFineConstants.SHOW_SIZE - AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {
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);
}
}
/**
* 是否已包含该model
*
@ -105,9 +186,10 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
return result;
}
@Override
public SearchResult getMoreSearchResult(String searchText) {
return new SearchResult();
return moreModelList;
}
public List<AlphaCellModel> getRecommendModelList() {

82
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

@ -0,0 +1,82 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
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 volatile SegmentationManager segmentationManager = null;
private static final int MAX_CHINESE_CHARACTERS_NUM = 4;
public static SegmentationManager getInstance() {
if (segmentationManager == null) {
synchronized (SegmentationManager.class) {
if (segmentationManager == null) {
segmentationManager = new SegmentationManager();
}
}
}
return segmentationManager;
}
/**
* 判断是否需要分词
*
* @param searchText
* @return
*/
public boolean isNeedSegmentation(String searchText) {
int count = 0;
Pattern p = Pattern.compile(AlphaFineConstants.CHINESE_CHARACTERS);
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) {
Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX);
Matcher m = p.matcher(searchText);
searchText = m.replaceAll(StringUtils.EMPTY).trim().replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
if (StringUtils.isEmpty(searchText)) {
return null;
}
if (!isNeedSegmentation(searchText)) {
return new String[]{searchText};
}
List<String> 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;
}
}

100
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

@ -0,0 +1,100 @@
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.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory;
import java.io.IOException;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
/**
* Created by alex.sung on 2018/8/3.
*/
public class SimilarSearchManeger implements AlphaFineSearchProvider {
private static volatile 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 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 token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]);
String url = AlphaFineConstants.SIMILAR_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token;
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
if(jsonArray != null){
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());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("similar search get result 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);
}
}

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine10@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine8@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot1@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot2@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot3@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot4@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot5@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/alphafine_hot6@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected10@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/selected8@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Loading…
Cancel
Save