Browse Source

Pull request #8656: REPORT-67417 运营产品v1.0

Merge in DESIGN/design from ~HADES/design:feature/x to feature/x

* commit '936249f207dad39ea376f5feae0ddd1d72232c12':
  REPORT-67417 运营产品v1.0 add漏交类
  REPORT-67417 运营产品v1.0
feature/x
Hades 3 years ago
parent
commit
a0ecf11a4f
  1. 47
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  2. 19
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  3. 30
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/SizedStack.java
  4. 15
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  5. 39
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  6. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  7. 63
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java
  8. 43
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java
  9. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  10. 669
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  11. 72
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java
  12. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  13. 15
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  14. 68
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java
  15. 42
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java
  16. 63
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java
  17. 32
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/LineCellRender.java
  18. 79
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java
  19. 76
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java
  20. 48
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java
  21. 35
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java
  22. 126
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchListModel.java
  23. 83
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java
  24. 51
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java
  25. 58
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchTooltipPopup.java
  26. 91
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java
  27. 200
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/ProductNews.java
  28. 79
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java
  29. 94
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java
  30. 167
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java
  31. 22
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java
  32. 35
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java
  33. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ResultShowPane.java
  34. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java
  35. 32
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java
  36. 59
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java
  37. 86
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionWindow.java
  38. 100
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java
  39. 13
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java
  40. 37
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java
  41. 119
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java
  42. 75
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java
  43. 22
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  44. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/blue_bulb.svg
  45. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/bulb.svg
  46. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/close.svg
  47. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/group.svg
  48. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/group_new.svg
  49. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/groupbackgroud.svg
  50. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/history_search.svg
  51. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/hot_search.svg
  52. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/minimize.svg
  53. 25
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/new_tip.svg
  54. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search.svg

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

@ -1,5 +1,6 @@
package com.fr.design.actions.help.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem;
@ -8,6 +9,12 @@ import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -82,9 +89,29 @@ public class AlphaFineConfigManager implements XMLable {
*/
private boolean needRemind = true;
/**
* 产品动态
*/
private boolean productDynamics = true;
private Map<String, String> actionSearchTextCache = new HashMap<>(8);
private String cacheBuildNO;
// todo 暂不持久化 方便测试
/**
* key: 登录的bbs用户
* value: alphaFine历史搜索记录
*/
private Map<String, Stack<String>> historySearchMap = new LinkedHashMap<>();
/**
* key: 登录的bbs用户
* value: 已读的cid的集合
*/
private Map<String, Set<Long>> readSetMap = new LinkedHashMap<>();
/**
* 直接操作菜单次数
*/
@ -120,6 +147,7 @@ public class AlphaFineConfigManager implements XMLable {
this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false));
this.setNeedSegmentationCheckbox(reader.getAttrAsBoolean("needSegmentationCheckbox", true));
this.setNeedIntelligentCustomerService(reader.getAttrAsBoolean("needIntelligentCustomerService", true));
this.setProductDynamics(reader.getAttrAsBoolean("productDynamics", true));
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
@ -167,7 +195,8 @@ public class AlphaFineConfigManager implements XMLable {
.attr("isNeedRemind", this.isNeedRemind())
.attr("operateCount", this.getOperateCount())
.attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService());
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService())
.attr("productDynamics", this.isProductDynamics());
writeActionSearchTextCacheXML(writer);
writer.end();
}
@ -335,4 +364,20 @@ public class AlphaFineConfigManager implements XMLable {
public void setCacheBuildNO(@NotNull String cacheBuildNO) {
this.cacheBuildNO = cacheBuildNO;
}
public Stack<String> getHistorySearch() {
return historySearchMap.computeIfAbsent(DesignerEnvManager.getEnvManager().getDesignerLoginUsername(), k -> new SizedStack<>(3));
}
public Set<Long> getReadSet() {
return readSetMap.computeIfAbsent(DesignerEnvManager.getEnvManager().getDesignerLoginUsername(), k -> new HashSet<>());
}
public boolean isProductDynamics() {
return productDynamics;
}
public void setProductDynamics(boolean productDynamics) {
this.productDynamics = productDynamics;
}
}

19
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -55,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 enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox, needIntelligentCustomerService, containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox, containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox;
private UICheckBox enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox, needIntelligentCustomerService, productDynamicsCheckbox, containActionCheckbox, containDocumentCheckbox, containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox;
private UITextField shortcutsField;
public AlphaFineConfigPane() {
@ -75,9 +75,8 @@ public class AlphaFineConfigPane extends BasicPane {
private Component[][] initSearchRangeComponents() {
Component[][] components = new Component[][]{
new Component[]{containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox},
new Component[]{productDynamicsCheckbox, containActionCheckbox, containDocumentCheckbox},
new Component[]{containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox},
new Component[]{needIntelligentCustomerService, null, null}
};
return components;
}
@ -95,7 +94,7 @@ public class AlphaFineConfigPane extends BasicPane {
double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range"));
containRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend"));
productDynamicsCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_Dynamics"));
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"));
@ -153,16 +152,16 @@ public class AlphaFineConfigPane extends BasicPane {
@Override
public void actionPerformed(ActionEvent e) {
if (!searchOnlineCheckbox.isSelected()) {
containRecommendCheckbox.setEnabled(false);
productDynamicsCheckbox.setEnabled(false);
containPluginCheckbox.setEnabled(false);
containDocumentCheckbox.setEnabled(false);
needIntelligentCustomerService.setEnabled(false);
containRecommendCheckbox.setSelected(false);
productDynamicsCheckbox.setSelected(false);
containPluginCheckbox.setSelected(false);
containDocumentCheckbox.setSelected(false);
needIntelligentCustomerService.setSelected(false);
} else {
containRecommendCheckbox.setEnabled(true);
productDynamicsCheckbox.setEnabled(true);
containPluginCheckbox.setEnabled(true);
containDocumentCheckbox.setEnabled(true);
needIntelligentCustomerService.setEnabled(true);
@ -207,8 +206,8 @@ public class AlphaFineConfigPane extends BasicPane {
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && enabled4Locale);
this.containPluginCheckbox.setEnabled(enabled4Locale);
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && enabled4Locale);
this.containRecommendCheckbox.setEnabled(enabled4Locale);
this.productDynamicsCheckbox.setSelected(alphaFineConfigManager.isProductDynamics() && enabled4Locale);
this.productDynamicsCheckbox.setEnabled(enabled4Locale);
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
@ -226,7 +225,7 @@ public class AlphaFineConfigPane extends BasicPane {
alphaFineConfigManager.setContainPlugin(this.containPluginCheckbox.isSelected());
alphaFineConfigManager.setContainAction(this.containActionCheckbox.isSelected());
alphaFineConfigManager.setContainDocument(this.containDocumentCheckbox.isSelected());
alphaFineConfigManager.setContainRecommend(this.containRecommendCheckbox.isSelected());
alphaFineConfigManager.setProductDynamics(this.productDynamicsCheckbox.isSelected());
alphaFineConfigManager.setEnabled(this.enabledCheckbox.isSelected());
alphaFineConfigManager.setSearchOnLine(this.searchOnlineCheckbox.isSelected());
alphaFineConfigManager.setContainTemplate(this.containTemplateCheckbox.isSelected());

30
designer-base/src/main/java/com/fr/design/actions/help/alphafine/SizedStack.java

@ -0,0 +1,30 @@
package com.fr.design.actions.help.alphafine;
import java.util.Stack;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/23
*/
public class SizedStack<T> extends Stack<T> {
private final int maxSize;
public SizedStack(int size) {
super();
this.maxSize = size;
}
@Override
public T push(T object) {
while (this.size() >= maxSize) {
this.remove(0);
}
// 不重复
if (this.contains(object)) {
return object;
}
return super.push(object);
}
}

15
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -37,15 +37,19 @@ public class MessageWithLink extends JEditorPane {
}
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage) {
this(frontMessage, linkName, link, backMessage, LABEL.getBackground(), LABEL.getFont());
this(frontMessage, linkName, link, backMessage, LABEL.getBackground(), LABEL.getFont(), LABEL.getForeground());
}
public MessageWithLink(String message, String linkName, String link, Color color, Font font) {
this(message, linkName, link, StringUtils.EMPTY, color, font);
this(message, linkName, link, StringUtils.EMPTY, color, font, LABEL.getForeground());
}
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + frontMessage + "<a href=\"" + link + "\">" + linkName + "</a>" + backMessage + "</body></html>");
this(frontMessage, linkName, link, backMessage, color, font, LABEL.getForeground());
}
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color backgroundColor, Font font, Color fontColor) {
super("text/html", "<html><body style=\"" + generateStyle(backgroundColor, font, fontColor) + "\">" + frontMessage + "<a href=\"" + link + "\">" + linkName + "</a>" + backMessage + "</body></html>");
initListener(link);
setEditable(false);
setBorder(null);
@ -66,12 +70,13 @@ public class MessageWithLink extends JEditorPane {
});
}
private static StringBuilder generateStyle(Color color, Font font) {
private static StringBuilder generateStyle(Color backgroundColor, Font font, Color fontColor) {
// 构建相同风格样式
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("background-color: rgb(").append(color.getRed()).append(",").append(color.getGreen()).append(",").append(color.getBlue()).append(");");
style.append("color:rgb(").append(fontColor.getRed()).append(",").append(fontColor.getGreen()).append(",").append(fontColor.getBlue()).append(");");
style.append("background-color: rgb(").append(backgroundColor.getRed()).append(",").append(backgroundColor.getGreen()).append(",").append(backgroundColor.getBlue()).append(");");
return style;
}

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

@ -1,13 +1,20 @@
package com.fr.design.mainframe.alphafine;
import com.fr.base.extension.FileExtension;
import com.fr.base.svg.IconUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import com.fr.general.CloudCenter;
import com.fr.general.IOUtils;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.swing.Icon;
/**
@ -131,6 +138,8 @@ public class AlphaFineConstants {
public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview");
public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid");
public static final String JAVASCRIPT_PREFIX = "javascript:SendJava";
public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]";
@ -143,6 +152,36 @@ public class AlphaFineConstants {
public static final String BACK_ICON_NAME = "back@1x.png";
public static final Icon NO_RESULT_ICON = IOUtils.readIcon(AlphaFineConstants.IMAGE_URL + "noresult.png");
public static final Color FOREGROUND_COLOR = new Color(51, 51, 52);
/**
* 后面数字代表透明度 80%
*/
public static final Color FOREGROUND_COLOR_8 = new Color(51, 51, 52, 204);
public static final Color FOREGROUND_COLOR_6 = new Color(51, 51, 52, 153);
public static final Color FOREGROUND_COLOR_5 = new Color(51, 51, 52, 128);
public static final Color BACKGROUND_COLOR = new Color(245, 245, 247);
public static final Icon BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bulb.svg");
public static final Icon BLUE_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/blue_bulb.svg");
public static final String HOT_SEARCH = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search");
public static final Set<String> HOT_SEARCH_SET = new LinkedHashSet<>(
Arrays.asList(
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_ONE"),
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_TWO"),
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_THREE")
)
);
public static final ArrayList<String> CONJUNCTION = new ArrayList<String>() {{
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_HE"));
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_YU"));

14
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -2,12 +2,11 @@ package com.fr.design.mainframe.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.NoResultModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.HotIssuesManager;
@ -32,7 +31,7 @@ import java.util.List;
*/
public class AlphaFineHelper {
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed"));
private static AlphaFineDialog alphaFineDialog;
private static AlphaFineFrame alphaFineDialog;
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
private AlphaFineHelper() {
@ -62,7 +61,7 @@ public class AlphaFineHelper {
return;
}
if (alphaFineDialog == null) {
alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame(), forceOpen);
alphaFineDialog = new AlphaFineFrame();
alphaFineDialog.setVisible(true);
final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
manager.setNeedRemind(false);
@ -73,6 +72,13 @@ public class AlphaFineHelper {
}
public static void resetAlphaFineDialog() {
alphaFineDialog = null;
}
public static AlphaFineFrame getAlphaFineDialog() {
return alphaFineDialog;
}
/**
* 获取文件名上级目录

63
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java

@ -0,0 +1,63 @@
package com.fr.design.mainframe.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.stable.StringUtils;
import java.util.List;
import java.util.Set;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/20
*/
public class AlphaFineUtil {
public static String highLightModelName(String modelName, String[] strings) {
if (strings == null) {
return modelName;
}
for (String string : strings) {
String primaryStr = getReplacedString(modelName, string);
if (StringUtils.isNotEmpty(primaryStr)) {
modelName = modelName.replaceAll("(?i)" + primaryStr, "|<font color=" + AlphaFineConstants.HIGH_LIGHT_COLOR + ">" + primaryStr + "</font>|");
}
}
modelName = "<html><head><style> .style{" +
"overflow: hidden;" +
"text-overflow: ellipsis;" +
"white-space: nowrap;}" +
"</style></head><body class=\"style\">" + modelName.replaceAll("\\|", StringUtils.EMPTY) + "</body></HTML>";
return modelName;
}
private static String getReplacedString(String modelName, String string) {
//需要考虑modelName有空格的情况
//比如现在是work boo k 搜索词是workb,应该要替换的部分是work b
//先去掉已经匹配替换过的部分,因为考虑到分词的情况,可能会进行多次替换
final String regex = "\\|<font.*?</font>\\|";
modelName = modelName.replaceAll(regex, StringUtils.EMPTY);
//再去掉空格进行匹配
String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase();
int index = noBlackName.indexOf(string.toLowerCase());
if (index == -1) {
return StringUtils.EMPTY;
}
StringBuilder result = new StringBuilder();
int count = 0;
while (count < string.length()) {
char pos = modelName.charAt(index++);
result.append(pos);
count += pos == ' ' ? 0 : 1;
}
return result.toString();
}
public static boolean unread() {
Set<Long> readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet();
List<ProductNews> productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList();
return !productNewsList.isEmpty() && (readSet.size() != productNewsList.size());
}
}

43
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java

@ -1,15 +1,46 @@
package com.fr.design.mainframe.alphafine;
import com.fr.stable.StringUtils;
/**
* 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_ROBOT(8), BOTTOM(9), ROBOT(10);
RECOMMEND(0),
ACTION(1, "action", "actionResult"),
DOCUMENT(2, "document", "documentResult"),
FILE(3, "file", "fileResult"),
PLUGIN(4, "plugin", "pluginResult"),
REUSE(5),
NO_RESULT(6, "noResult", StringUtils.EMPTY),
MORE(7),
RECOMMEND_ROBOT(8),
BOTTOM(9),
ROBOT(10),
PRODUCT_NEWS(11, "productNews", "productNewsResult");
private int typeValue;
CellType(int type) {
/**
* 标志位 索引无搜索结果面板
*
* 空字符表示不涉及索引该项
*/
private String flagStr4None;
/**
* 标志位 索引有搜索结果面板
*/
private String flagStr4Result;
CellType(int type, String flagStr4None, String flagStr4Result) {
this.typeValue = type;
this.flagStr4None = flagStr4None;
this.flagStr4Result = flagStr4Result;
}
CellType(int type) {
this(type, StringUtils.EMPTY, StringUtils.EMPTY);
}
public static CellType parse(int typeValue) {
@ -29,5 +60,13 @@ public enum CellType {
public void setTypeValue(int typeValue) {
this.typeValue = typeValue;
}
public String getFlagStr4None() {
return flagStr4None;
}
public String getFlagStr4Result() {
return flagStr4Result;
}
}

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

@ -435,7 +435,7 @@ public class AlphaFineDialog extends UIDialog {
*/
private void removeLeftPane() {
if (searchListModel.isEmpty() && defaultPane == null) {
defaultPane = new NoResultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_NO_Result"), AlphaFineConstants.IMAGE_URL + "no_result.png");
defaultPane = new NoResultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_NO_Result"), AlphaFineConstants.NO_RESULT_ICON);
searchResultPane.remove(leftSearchResultPane);
searchResultPane.add(defaultPane, BorderLayout.WEST);
refreshContainer();
@ -661,7 +661,7 @@ public class AlphaFineDialog extends UIDialog {
break;
case ACTION:
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new NoResultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_No_Result"), AlphaFineConstants.IMAGE_URL + "noresult.png"));
rightSearchResultPane.add(new NoResultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_No_Result"), AlphaFineConstants.NO_RESULT_ICON));
validate();
repaint();
break;

669
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java

@ -0,0 +1,669 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.svg.IconUtils;
import com.fr.base.svg.SVGLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
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.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.preview.DefaultProductNewsPane;
import com.fr.design.mainframe.alphafine.preview.HelpDocumentNoResultPane;
import com.fr.design.mainframe.alphafine.preview.LoadingRightSearchResultPane;
import com.fr.design.mainframe.alphafine.preview.NoResultPane;
import com.fr.design.mainframe.alphafine.preview.NoResultWithLinkPane;
import com.fr.design.mainframe.alphafine.preview.SimpleRightSearchResultPane;
import com.fr.design.mainframe.alphafine.question.QuestionWindow;
import com.fr.design.mainframe.alphafine.search.ProductNewsSearchWorkerManager;
import com.fr.design.mainframe.alphafine.search.SearchTextBean;
import com.fr.design.mainframe.alphafine.search.SearchWorkerManager;
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.ProductNewsSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager;
import com.fr.design.utils.DesignUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.Timer;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/04/06
*/
public class AlphaFineFrame extends JFrame {
private static final String ADVANCED_SEARCH_MARK = "k:";
private static final int TIMER_DELAY = 300;
private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine");
private static final String SETTING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set");
private static final String NO_RESULT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_No_Result");
private static final String SKILLS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Skills");
private static final String SEARCH_TERM = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Search_Term");
private static final String SEARCH = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Search");
private static final String GO_FORUM = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Go_Forum");
private static final String TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates");
private static final String PRODUCT_NEWS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News");
private static final String HELP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help");
private static final String PLUGIN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon");
private static final String ONE_CLICK_READ = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_One_Click_Read");
private static final String NO_SEARCH_RESULT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_NO_Result");
private static final Image SEARCH_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/search.svg");
private final CardLayout cardLayout = new CardLayout();
private final JPanel resultPane = new JPanel(cardLayout);
private String storeText;
private String[] segmentationResult;
private UILabel useTipLabel;
private UILabel tipIconLabel;
private AlphaFineTextField searchTextField;
private AlphaFineList searchResultList;
private CellType selectedType;
private String beforeSearchStr = StringUtils.EMPTY;
private SearchWorkerManager settingSearchWorkerManager;
private SearchWorkerManager fileSearchWorkerManager;
private SearchWorkerManager documentWorkerManager;
private SearchWorkerManager pluginSearchWorkerManager;
private SearchWorkerManager currentSearchWorkerManager;
private ProductNewsSearchWorkerManager productNewsSearchWorkerManager;
public AlphaFineFrame() {
setUndecorated(true);
setSize(AlphaFineConstants.FIELD_SIZE);
initComponents();
centerWindow(this);
initSearchManager();
}
private void initSearchManager() {
this.productNewsSearchWorkerManager = new ProductNewsSearchWorkerManager(
CellType.PRODUCT_NEWS,
searchTextBean -> {
return ProductNewsSearchManager.getInstance().getSearchResult(searchTextBean.getSegmentation());
},
this
);
this.settingSearchWorkerManager = new SearchWorkerManager(
CellType.ACTION,
searchTextBean -> {
ActionSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation());
return ActionSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText());
},
this,
new SimpleRightSearchResultPane(new NoResultPane(NO_RESULT, AlphaFineConstants.NO_RESULT_ICON))
);
fileSearchWorkerManager = new SearchWorkerManager(
CellType.FILE,
searchTextBean -> {
FileSearchManager.getInstance().getLessSearchResult(searchTextBean.getSearchText(), searchTextBean.getSegmentation());
return FileSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText());
},
this,
new LoadingRightSearchResultPane()
);
documentWorkerManager = new SearchWorkerManager(
CellType.DOCUMENT,
searchTextBean -> {
DocumentSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation());
return DocumentSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText());
},
this,
new SimpleRightSearchResultPane(new JPanel())
);
pluginSearchWorkerManager = new SearchWorkerManager(
CellType.PLUGIN,
searchTextBean -> {
PluginSearchManager.getInstance().getLessSearchResult(searchTextBean.getSegmentation());
return PluginSearchManager.getInstance().getMoreSearchResult(searchTextBean.getSearchText());
},
this,
new LoadingRightSearchResultPane()
);
}
/**
* 初始化全部组件
*/
private void initComponents() {
add(createTopPane(), BorderLayout.NORTH);
initSearchTextField();
add(createSearchPane(), BorderLayout.CENTER);
add(createShowPane(), BorderLayout.SOUTH);
this.getContentPane().setBackground(Color.WHITE);
this.setIconImage(SEARCH_IMAGE);
this.setSize(AlphaFineConstants.FULL_SIZE);
}
private JPanel createTopPane() {
JPanel topPane = new JPanel(new BorderLayout());
topPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
topPane.setBackground(Color.WHITE);
JPanel topLeftPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
topLeftPane.setBackground(Color.WHITE);
UILabel alphaFineLabel = new UILabel("AlphaFine");
alphaFineLabel.setFont(new Font("Arial Black", Font.PLAIN, 20));
alphaFineLabel.setForeground(UIConstants.FLESH_BLUE);
topLeftPane.add(alphaFineLabel);
topPane.add(topLeftPane, BorderLayout.WEST);
JPanel topRightPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
topRightPane.setBackground(Color.WHITE);
JPanel tipPane = new JPanel(new BorderLayout());
tipPane.setBackground(Color.WHITE);
String toolTip = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Short_Cut", DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortcuts());
tipIconLabel = new UILabel(AlphaFineConstants.BULB_ICON);
tipIconLabel.addMouseListener(tipMouseListener);
tipIconLabel.setToolTipText(toolTip);
useTipLabel = new UILabel(SKILLS);
useTipLabel.addMouseListener(tipMouseListener);
useTipLabel.setToolTipText(toolTip);
useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
tipPane.add(tipIconLabel, BorderLayout.WEST);
tipPane.add(useTipLabel, BorderLayout.CENTER);
topRightPane.add(tipPane);
UIButton minimizeButton = createButton(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/minimize.svg"));
minimizeButton.addActionListener(e -> AlphaFineFrame.this.setExtendedState(JFrame.ICONIFIED));
topRightPane.add(minimizeButton);
UIButton closeButton = createButton(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/close.svg"));
closeButton.addActionListener(e -> AlphaFineFrame.this.dispose());
topRightPane.add(closeButton);
topPane.add(topRightPane, BorderLayout.EAST);
return topPane;
}
private MouseAdapter tipMouseListener = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
useTipLabel.setForeground(UIConstants.FLESH_BLUE);
tipIconLabel.setIcon(AlphaFineConstants.BLUE_BULB_ICON);
}
@Override
public void mouseExited(MouseEvent e) {
useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
tipIconLabel.setIcon(AlphaFineConstants.BULB_ICON);
}
};
private JPanel createSearchPane() {
JPanel searchPane = new JPanel(new BorderLayout());
searchPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
searchPane.add(searchTextField, BorderLayout.CENTER);
JButton searchButton = new JButton(SEARCH) {
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.FLESH_BLUE);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 4, 4);
super.paintComponent(g2d);
}
};
searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fireSearch();
}
});
searchButton.setPreferredSize(new Dimension(70, 60));
searchButton.setForeground(Color.WHITE);
searchButton.setBorderPainted(false);
searchButton.setContentAreaFilled(false);
searchPane.add(searchButton, BorderLayout.EAST);
searchPane.setBackground(Color.WHITE);
return searchPane;
}
private JPanel createShowPane() {
JPanel showPane = new JPanel(new BorderLayout());
resultPane.add(new DefaultProductNewsPane(), CellType.PRODUCT_NEWS.getFlagStr4None());
resultPane.add(new NoResultPane(NO_SEARCH_RESULT, AlphaFineConstants.NO_RESULT_ICON), CellType.NO_RESULT.getFlagStr4None());
resultPane.add(new NoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.ACTION.getFlagStr4None());
resultPane.add(new NoResultWithLinkPane(GO_FORUM, AlphaFineConstants.NO_RESULT_ICON), CellType.FILE.getFlagStr4None());
resultPane.add(new NoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.PLUGIN.getFlagStr4None());
resultPane.add(new HelpDocumentNoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON, generateMap()), CellType.DOCUMENT.getFlagStr4None());
JPanel labelPane = new JPanel(new BorderLayout());
labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
labelPane.setBackground(Color.WHITE);
JPanel labelContentPane = new JPanel(new BorderLayout());
UILabel tabLabel = new UILabel(PRODUCT_NEWS);
tabLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
tabLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
tabLabel.setPreferredSize(new Dimension(100, 30));
JPanel westPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
westPane.add(tabLabel);
labelContentPane.add(westPane, BorderLayout.WEST);
JPanel eastPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
UILabel readLabel = new UILabel(ONE_CLICK_READ);
readLabel.setHorizontalAlignment(SwingConstants.RIGHT);
readLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));;
readLabel.setPreferredSize(new Dimension(100, 30));
readLabel.setForeground(UIConstants.FLESH_BLUE);
readLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
List<ProductNews> productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList();
Set<Long> readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet();
for (ProductNews productNews : productNewsList) {
readSet.add(productNews.getId());
}
showPane.repaint();
}
});
eastPane.add(readLabel);
labelContentPane.add(eastPane, BorderLayout.EAST);
labelContentPane.setBackground(new Color(245, 245, 247));
labelPane.add(labelContentPane);
labelPane.setPreferredSize(new Dimension(AlphaFineConstants.FULL_SIZE.width, 30));
JPanel tabPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10));
tabPane.setBackground(Color.WHITE);
List<SelectedLabel> selectedLabelList = new ArrayList<>();
AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (alphaFineConfigManager.isProductDynamics()) {
selectedLabelList.add(new SelectedLabel(PRODUCT_NEWS, CellType.PRODUCT_NEWS, true));
}
if (alphaFineConfigManager.isContainAction()) {
selectedLabelList.add(new SelectedLabel(SETTING, CellType.ACTION));
}
if (alphaFineConfigManager.isContainFileContent() || alphaFineConfigManager.isContainTemplate()) {
selectedLabelList.add(new SelectedLabel(TEMPLATES, CellType.FILE));
}
if (alphaFineConfigManager.isContainDocument()) {
selectedLabelList.add(new SelectedLabel(HELP, CellType.DOCUMENT));
}
if (alphaFineConfigManager.isContainPlugin()) {
selectedLabelList.add(new SelectedLabel(PLUGIN, CellType.PLUGIN));
}
selectedType = selectedLabelList.get(0).getCellType();
for (SelectedLabel selectedLabel : selectedLabelList) {
selectedLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
for (SelectedLabel label : selectedLabelList) {
label.setSelected(false);
}
selectedLabel.setSelected(true);
tabLabel.setText(selectedLabel.getText());
readLabel.setVisible(false);
tabPane.repaint();
switch (selectedLabel.getCellType()) {
case PRODUCT_NEWS:
readLabel.setVisible(true);
switchType(CellType.PRODUCT_NEWS);
break;
case ACTION:
switchType(CellType.ACTION);
currentSearchWorkerManager = settingSearchWorkerManager;
break;
case FILE:
switchType(CellType.FILE);
currentSearchWorkerManager = fileSearchWorkerManager;
break;
case DOCUMENT:
switchType(CellType.DOCUMENT);
currentSearchWorkerManager = documentWorkerManager;
break;
case PLUGIN:
switchType(CellType.PLUGIN);
currentSearchWorkerManager = pluginSearchWorkerManager;
break;
}
if (currentSearchWorkerManager != null) {
AlphaFineList alphaFineList = currentSearchWorkerManager.getSearchResultList();
if (alphaFineList != null) {
alphaFineList.setSelectedIndex(0);
}
}
}
});
tabPane.add(selectedLabel);
}
showPane.add(tabPane, BorderLayout.NORTH);
showPane.add(labelPane, BorderLayout.CENTER);
showPane.add(resultPane, BorderLayout.SOUTH);
return showPane;
}
// todo 暂无 先做测试
private Map<String, String> generateMap() {
Map<String, String> linkMap = new LinkedHashMap<>();
linkMap.put("test", "https://www.baidu.com");
linkMap.put("test1", "https://www.baidu.com");
linkMap.put("test2", "https://www.baidu.com");
linkMap.put("test3", "https://www.baidu.com");
linkMap.put("test4", "https://www.baidu.com");
linkMap.put("test5", "https://www.baidu.com");
return linkMap;
}
private void switchType(CellType cellType) {
this.selectedType = cellType;
if (StringUtils.isEmpty(searchTextField.getText())) {
cardLayout.show(resultPane, cellType.getFlagStr4None());
} else {
cardLayout.show(resultPane, cellType.getFlagStr4Result());
checkSearchResult();
}
}
private void checkSearchResult() {
if (currentSearchWorkerManager == null) {
return;
}
searchResultList = currentSearchWorkerManager.getSearchResultList();
if (searchResultList != null) {
searchResultList.requestFocus();
}
boolean hasSearchResult = true;
if (selectedType == CellType.PRODUCT_NEWS) {
hasSearchResult = productNewsSearchWorkerManager.hasSearchResult();
} else {
hasSearchResult = currentSearchWorkerManager.hasSearchResult();
}
if (!hasSearchResult) {
cardLayout.show(resultPane, CellType.NO_RESULT.getFlagStr4None());
}
}
private void initSearchTextField() {
searchTextField = new AlphaFineTextField(PLACE_HOLDER);
initTextFieldListener();
searchTextField.setFont(DesignUtils.getDefaultGUIFont().applySize(14));
searchTextField.setBackground(Color.WHITE);
searchTextField.setPreferredSize(new Dimension(300, 60));
}
private void initTextFieldListener() {
searchTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// 搜索提示框
if (StringUtils.isNotEmpty(searchTextField.getText())) {
SearchTooltipPopup.getInstance().show(searchTextField);
}
AlphaFineToolTipList alphaFineToolTipList = SearchTooltipPopup.getInstance().getAlphaFineToolTipList();
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (!alphaFineToolTipList.isSelectionEmpty()) {
fireSearch(alphaFineToolTipList.getSelectedValue());
return;
}
fireSearch();
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (alphaFineToolTipList.getSelectedIndex() == alphaFineToolTipList.getModel().getSize() - 1) {
alphaFineToolTipList.setSelectedIndex(0);
}
alphaFineToolTipList.setSelectedIndex(alphaFineToolTipList.getSelectedIndex() + 1);
} else if (e.getKeyCode() == KeyEvent.VK_UP) {
alphaFineToolTipList.setSelectedIndex(alphaFineToolTipList.getSelectedIndex() - 1);
}
}
});
searchTextField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (StringUtils.isNotEmpty(searchTextField.getText())) {
SearchTooltipPopup.getInstance().show(searchTextField);
}
}
@Override
public void focusLost(FocusEvent e) {
if (e.getOppositeComponent() != SearchTooltipPopup.getInstance().getAlphaFineToolTipList()) {
SearchTooltipPopup.getInstance().hide();
}
}
});
startSearchTextFieldTimer();
}
private void startSearchTextFieldTimer() {
Timer timer = new Timer(TIMER_DELAY, e -> {
if (StringUtils.isEmpty(searchTextField.getText())) {
SearchTooltipPopup.getInstance().hide();
switchType(selectedType);
}
else if (searchTextField.hasFocus()) {
SearchTooltipPopup.getInstance().show(searchTextField);
}
});
timer.start();
}
public void fireSearch(String text) {
searchTextField.setText(text);
fireSearch();
}
private void fireSearch() {
// 焦点转移
AlphaFineFrame.this.requestFocus();
if (ComparatorUtils.equals(beforeSearchStr, searchTextField.getText())) {
return;
}
if (StringUtils.isEmpty(searchTextField.getText())) {
beforeSearchStr = StringUtils.EMPTY;
return;
}
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())};
}
}
DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getHistorySearch().push(searchTextField.getText());
doSearch(searchTextField.getText().toLowerCase());
beforeSearchStr = searchTextField.getText();
SearchTooltipPopup.getInstance().hide();
}
private void dealWithSearchResult() {
final AlphaCellModel model = searchResultList.getSelectedValue();
if (model != null) {
model.doAction();
}
}
public void showResult(String flag) {
cardLayout.show(resultPane, flag);
}
public void addResult(JPanel panel, String flag) {
resultPane.add(panel, flag);
}
private void doSearch(String text) {
SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult);
this.productNewsSearchWorkerManager.doSearch(searchTextBean);
this.settingSearchWorkerManager.doSearch(searchTextBean);
this.fileSearchWorkerManager.doSearch(searchTextBean);
this.documentWorkerManager.doSearch(searchTextBean);
this.pluginSearchWorkerManager.doSearch(searchTextBean);
}
public CellType getSelectedType() {
return selectedType;
}
public void setStoreText(String storeText) {
this.storeText = storeText;
}
/**
* 截取字符串中关键词
*
* @param searchText
* @return
*/
private String getStoreText(String searchText) {
//这里也需要先做一个去除不需要空格的处理
setStoreText((searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1)).replaceAll(StringUtils.BLANK, StringUtils.EMPTY));
return storeText;
}
/**
* 去除特殊字符空格等
*/
private String getRealSearchText(String searchText) {
searchText = searchText.toLowerCase();
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 (searchText.length() == 0) {
return null;
}
return searchText;
}
private UIButton createButton(Icon icon) {
UIButton button = new UIButton() {
@Override
public void paintComponent(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
}
};
button.setPreferredSize(new Dimension(20, 20));
button.setIcon(icon);
button.set4ToolbarButton();
button.setBorderPainted(false);
button.setRolloverEnabled(false);
return button;
}
/**
* 设置面板位置
*
* @param win
*/
private void centerWindow(Window win) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension winSize = win.getSize();
if (winSize.height > screenSize.height) {
winSize.height = screenSize.height;
}
if (winSize.width > screenSize.width) {
winSize.width = screenSize.width;
}
//这里设置位置:水平居中,竖直偏上
win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE);
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
QuestionWindow.getInstance().setVisible(!b);
}
@Override
public void dispose() {
super.dispose();
AlphaFineHelper.resetAlphaFineDialog();
QuestionWindow.getInstance().setVisible(true);
}
}

72
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java

@ -0,0 +1,72 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.preview.ResultShowPane;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JList;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/18
*/
public class AlphaFineList extends JList<AlphaCellModel> {
private ResultShowPane resultShowPane;
public AlphaFineList() {
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
AlphaCellModel selectedValue = getSelectedValue();
if (e.getClickCount() == 2 && selectedValue.hasAction()) {
dealWithSearchResult();
}
}
});
addListSelectionListener(e -> {
if (!e.getValueIsAdjusting() && getSelectedValue() != null) {
if (resultShowPane != null) {
resultShowPane.showResult(getSelectedValue());
}
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
dealWithSearchResult();
}
}
});
}
public void setResultShowPane(ResultShowPane resultShowPane) {
this.resultShowPane = resultShowPane;
}
@Override
public void setSelectedIndex(int index) {
super.setSelectedIndex(index);
AlphaCellModel alphaCellModel = getSelectedValue();
if (resultShowPane != null && alphaCellModel != null) {
resultShowPane.showResult(getSelectedValue());
}
ensureIndexIsVisible(getSelectedIndex());
}
private void dealWithSearchResult() {
final AlphaCellModel model = this.getSelectedValue();
if (model != null) {
model.doAction();
}
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java

@ -31,7 +31,7 @@ public class AlphaFinePane extends BasicPane {
setLayout(new BorderLayout());
UIButton refreshButton = new UIButton();
refreshButton.setIcon(IOUtils.readIcon(("/com/fr/design/mainframe/alphafine/images/smallsearch.png")));
refreshButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine"));
refreshButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Learn_More_About"));
refreshButton.set4ToolbarButton();
refreshButton.setRolloverEnabled(false);
this.add(refreshButton);

15
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java

@ -1,8 +1,9 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.report.web.button.Image;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
@ -13,6 +14,8 @@ import java.awt.RenderingHints;
*/
public class AlphaFineTextField extends UITextField {
private static final Color BORDER_COLOR = new Color(232, 232, 233);
private String placeHolder;
private Image image;
@ -36,8 +39,14 @@ public class AlphaFineTextField extends UITextField {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(super.getDisabledTextColor());
g2.drawString(placeHolder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top + 15);
g2.setColor(AlphaFineConstants.FOREGROUND_COLOR_5);
g2.drawString(placeHolder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top + 6);
}
@Override
protected void paintBorder(Graphics g) {
g.setColor(BORDER_COLOR);
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
}
public Image getImage() {

68
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java

@ -0,0 +1,68 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.svg.IconUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class AlphaFineToolTipContentCellRender implements ListCellRenderer<String> {
private static final Color SELECTED_COLOR = new Color(65, 155, 249, 26);
private static final Icon HOT_SEARCH_ICON = IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/hot_search.svg");
private static final Icon SEARCH_ICON = IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/search.svg");
private static final Icon HISTORY_SEARCH_ICON = IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/history_search.svg");
@Override
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index,
boolean isSelected, boolean cellHasFocus) {
if (StringUtils.isEmpty(value)) {
return new LineCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(null);
UILabel iconLabel = new UILabel();
iconLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 5, 0));
iconLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8);
iconLabel.setText(value);
if (ComparatorUtils.equals(value, AlphaFineConstants.HOT_SEARCH)) {
iconLabel.setIcon(HOT_SEARCH_ICON);
} else if (AlphaFineConstants.HOT_SEARCH_SET.contains(value)) {
iconLabel.setIcon(SEARCH_ICON);
} else {
iconLabel.setIcon(HISTORY_SEARCH_ICON);
}
if (isSelected && !ComparatorUtils.equals(value, AlphaFineConstants.HOT_SEARCH)) {
iconLabel.setText(AlphaFineUtil.highLightModelName(value, new String[]{value}));
panel.setBackground(SELECTED_COLOR);
}
panel.add(iconLabel, BorderLayout.WEST);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
panel.setPreferredSize(new Dimension(640, 32));
return panel;
}
}

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

@ -0,0 +1,42 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.general.ComparatorUtils;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JList;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class AlphaFineToolTipList extends JList<String> {
public AlphaFineToolTipList() {
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
AlphaFineHelper.getAlphaFineDialog().fireSearch(getSelectedValue());
}
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (ComparatorUtils.equals(getSelectedValue(), AlphaFineConstants.HOT_SEARCH)) {
return;
}
AlphaFineHelper.getAlphaFineDialog().fireSearch(getSelectedValue());
}
}
});
}
}

63
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java

@ -0,0 +1,63 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Dimension;
import java.util.Stack;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class AlphaSearchTooltipPane extends JPanel {
private AlphaFineToolTipList alphaFineToolTipList;
public AlphaSearchTooltipPane() {
alphaFineToolTipList = new AlphaFineToolTipList();
alphaFineToolTipList.setCellRenderer(new AlphaFineToolTipContentCellRender());
alphaFineToolTipList.setModel(getDefaultListModel());
UIScrollPane scrollPane = new UIScrollPane(alphaFineToolTipList);
scrollPane.setBorder(null);
scrollPane.setBackground(Color.WHITE);
this.add(scrollPane);
this.setPreferredSize(new Dimension(640, 250));
this.setBackground(Color.WHITE);
}
public AlphaFineToolTipList getAlphaFineToolTipList() {
return alphaFineToolTipList;
}
private DefaultListModel<String> getDefaultListModel() {
DefaultListModel<String> defaultListModel = new DefaultListModel<>();
defaultListModel.addElement(AlphaFineConstants.HOT_SEARCH);
for (String content : AlphaFineConstants.HOT_SEARCH_SET) {
defaultListModel.addElement(content);
}
return defaultListModel;
}
public void refreshHistory() {
Stack<String> stack = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getHistorySearch();
if (stack.isEmpty()) {
return;
}
DefaultListModel<String> defaultListModel = new DefaultListModel<>();
for (int i = stack.size() - 1; i >= 0; i--) {
defaultListModel.addElement(stack.get(i));
}
// defaultListModel.addElement(StringUtils.EMPTY);
defaultListModel.addElement(AlphaFineConstants.HOT_SEARCH);
for (String content : AlphaFineConstants.HOT_SEARCH_SET) {
defaultListModel.addElement(content);
}
alphaFineToolTipList.setModel(defaultListModel);
}
}

32
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/LineCellRender.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class LineCellRender implements ListCellRenderer<String> {
@Override
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index,
boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
UILabel splitLabel = new UILabel();
panel.setBackground(null);
splitLabel.setBackground(UIConstants.BARNOMAL);
splitLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 5,0));
panel.setPreferredSize(new Dimension(640, 1));
panel.add(splitLabel);
return panel;
}
}

79
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.utils.DesignUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/19
*/
public class ProductNewsContentCellRender implements ListCellRenderer<Object> {
private static final String FINE_REPORT = "FineReport";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
private String[] segmentationResult;
public ProductNewsContentCellRender(String[] segmentationResult) {
this.segmentationResult = segmentationResult;
}
public ProductNewsContentCellRender() {
this(null);
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
ProductNews productNews = (ProductNews) value;
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
panel.setBackground(Color.WHITE);
panel.add(new ProductNewsImagePanel(productNews), BorderLayout.WEST);
JPanel textPane = new JPanel(new BorderLayout());
textPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 0));
UILabel titleLabel = new UILabel(AlphaFineUtil.highLightModelName(productNews.getTitle(), segmentationResult));
titleLabel.setFont(DesignUtils.getDefaultGUIFont().applySize(20));
textPane.add(titleLabel, BorderLayout.NORTH);
JPanel infoPane = new JPanel(new BorderLayout());
UILabel productLabel = new UILabel(FINE_REPORT) {
@Override
protected void paintComponent(Graphics g) {
g.setColor(AlphaFineConstants.BACKGROUND_COLOR);
g.fillRect(0, getHeight() - 27, getWidth(), 23);
super.paintComponent(g);
}
};
productLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
infoPane.add(productLabel, BorderLayout.WEST);
UILabel dateLabel = new UILabel(DATE_FORMAT.format(productNews.getPushDate()));
dateLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
dateLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
infoPane.setBackground(Color.WHITE);
infoPane.add(dateLabel, BorderLayout.CENTER);
textPane.setBackground(Color.WHITE);
textPane.add(infoPane, BorderLayout.CENTER);
panel.add(textPane, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(500, 80));
return panel;
}
}

76
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java

@ -0,0 +1,76 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.GraphHelper;
import com.fr.base.svg.SVGLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import java.util.Set;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/15
*/
public class ProductNewsImagePanel extends JPanel {
private static final Image NEW_TIP_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/new_tip.svg");
private static final int BACKGROUND_HEIGHT = 20;
private static final Color BACKGROUND_COLOR = new Color(116, 181, 249);
private ProductNews productNews;
private int width = 200;
private int height = 150;
public ProductNewsImagePanel(ProductNews productNews) {
this.productNews = productNews;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// g2.setComposite(AlphaComposite.Src);
// g2.fill(new RoundRectangle2D.Float(0, 0, getWidth(), getHeight(), 5, 5));
// g2.setComposite(AlphaComposite.SrcAtop);
g2.drawImage(productNews.getImage(), 0, 0, getWidth(), getHeight(), this);
Set<Long> readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet();
if (!readSet.contains(productNews.getId())) {
g2.drawImage(NEW_TIP_IMAGE, 0, 0, this);
}
Color defaultColor = g2.getColor();
g2.setColor(BACKGROUND_COLOR);
g2.fillRect(0, getHeight() - BACKGROUND_HEIGHT, getWidth(), BACKGROUND_HEIGHT);
g2.setColor(Color.WHITE);
int x = (getWidth() - GraphHelper.getWidth(productNews.getTag().getDesc(), g2.getFont())) / 2;
g2.drawString(productNews.getTag().getDesc(), x, getHeight() - 5);
g2.setColor(defaultColor);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(width, height);
}
}

48
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java

@ -0,0 +1,48 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.log.FineLoggerFactory;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URI;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListModel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/21
*/
public class ProductNewsList extends JList<ProductNews> {
public ProductNewsList(ListModel<ProductNews> dataModel) {
super(dataModel);
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
dealWithClick();
}
}
});
}
public ProductNewsList() {
this(new DefaultListModel<>());
}
private void dealWithClick() {
ProductNews productNews = getSelectedValue();
try {
Desktop.getDesktop().browse(new URI(productNews.getUrl()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet().add(productNews.getId());
AlphaFineHelper.getAlphaFineDialog().repaint();
}
}

35
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.icontainer.UIScrollPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/21
*/
public class ProductNewsSearchResultPane extends JPanel {
private ProductNewsList productNewsList;
public ProductNewsSearchResultPane(String[] segmentationResult) {
productNewsList = new ProductNewsList();
UIScrollPane scrollPane = new UIScrollPane(productNewsList);
scrollPane.setBackground(Color.WHITE);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20));
productNewsList.setCellRenderer(new ProductNewsContentCellRender(segmentationResult));
this.setLayout(new BorderLayout());
this.setBackground(Color.WHITE);
this.add(scrollPane);
this.setPreferredSize(new Dimension(680, 305));
}
public ProductNewsList getProductNewsList() {
return productNewsList;
}
}

126
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchListModel.java

@ -0,0 +1,126 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/18
*/
public class SearchListModel extends DefaultListModel<AlphaCellModel> {
private static final int MAX_SHOW_SIZE = 12;
private static final long serialVersionUID = 7230585307439551228L;
private SearchResult myDelegate;
/**
* 第一有效的项是否被选中
*/
private boolean isValidSelected;
private UIScrollPane leftSearchResultPane;
private AlphaFineList searchResultList;
public SearchListModel(SearchResult searchResult, AlphaFineList searchResultList, UIScrollPane leftSearchResultPane) {
this.myDelegate = searchResult;
this.searchResultList = searchResultList;
this.leftSearchResultPane = leftSearchResultPane;
}
@Override
public void addElement(AlphaCellModel element) {
AlphaFineHelper.checkCancel();
int index = myDelegate.size();
myDelegate.add(element);
fireContentsChanged(this, index, index);
fireSelectedStateChanged(element, index);
}
@Override
protected void fireContentsChanged(Object source, int index0, int index1) {
if (myDelegate.size() > MAX_SHOW_SIZE) {
leftSearchResultPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 2));
} else {
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
super.fireContentsChanged(source, index0, index1);
}
/**
* 触发选中第一有效的项
*
* @param element
* @param index
*/
private void fireSelectedStateChanged(AlphaCellModel element, int index) {
if (element.hasAction() && !isValidSelected()) {
searchResultList.setSelectedIndex(index);
setValidSelected(true);
}
}
@Override
public AlphaCellModel getElementAt(int index) {
return myDelegate.get(index);
}
@Override
public void add(int index, AlphaCellModel element) {
myDelegate.add(index, element);
fireIntervalAdded(this, index, index);
}
@Override
public AlphaCellModel remove(int index) {
AlphaCellModel object = myDelegate.get(index);
myDelegate.remove(object);
fireContentsChanged(this, index, index);
return object;
}
@Override
public int getSize() {
return this.myDelegate.size();
}
@Override
public void removeAllElements() {
this.myDelegate.clear();
}
/**
* 重置选中状态
*/
public void resetSelectedState() {
setValidSelected(false);
}
private boolean isValidSelected() {
return isValidSelected;
}
private void setValidSelected(boolean selected) {
isValidSelected = selected;
}
@Override
public boolean isEmpty() {
return myDelegate.isEmpty();
}
public void resetState() {
for (int i = 0; i < getSize(); i++) {
getElementAt(i).resetState();
}
}
}

83
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java

@ -0,0 +1,83 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/19
*/
public class SearchResultContentCellRender implements ListCellRenderer<Object> {
private static final int OFFSET = 45;
private static final String SELECTED_PATH = AlphaFineConstants.IMAGE_URL + "selected";
private static final String CELL_PATH = AlphaFineConstants.IMAGE_URL + "alphafine";
private static final String SUFFIX = ".png";
private String[] segmentationResult;
public SearchResultContentCellRender(String[] segmentationResult) {
this.segmentationResult = segmentationResult;
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
AlphaCellModel model = (AlphaCellModel) value;
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(null);
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
// 图标icon 样式
UILabel iconLabel = new UILabel();
if (isSelected) {
iconLabel.setText(StringUtils.BLANK + model.getName());
String iconUrl = SELECTED_PATH + model.getType().getTypeValue() + SUFFIX;
panel.setBackground(AlphaFineConstants.BLUE);
iconLabel.setForeground(Color.WHITE);
iconLabel.setIcon(IOUtils.readIcon(iconUrl));
} else {
iconLabel.setText(AlphaFineUtil.highLightModelName(model.getName(), segmentationResult));
String iconUrl = CELL_PATH + model.getType().getTypeValue() + SUFFIX;
iconLabel.setIcon(IOUtils.readIcon(iconUrl));
}
iconLabel.setFont(AlphaFineConstants.MEDIUM_FONT);
// 内容详情label 样式
UILabel detailLabel = new UILabel();
String description = model.getDescription();
if (StringUtils.isNotBlank(description)) {
detailLabel.setText("-" + description);
detailLabel.setForeground(AlphaFineConstants.LIGHT_GRAY);
panel.add(detailLabel, BorderLayout.CENTER);
int width = (int) (iconLabel.getPreferredSize().getWidth() + detailLabel.getPreferredSize().getWidth());
if (width > AlphaFineConstants.LEFT_WIDTH - OFFSET) {
int nameWidth = (int) (AlphaFineConstants.LEFT_WIDTH - detailLabel.getPreferredSize().getWidth() - OFFSET);
iconLabel.setPreferredSize(new Dimension(nameWidth, AlphaFineConstants.CELL_HEIGHT));
}
} else {
iconLabel.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH - OFFSET, AlphaFineConstants.CELL_HEIGHT));
}
panel.add(iconLabel, BorderLayout.WEST);
panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_HEIGHT));
return panel;
}
}

51
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java

@ -0,0 +1,51 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.preview.ResultShowPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class SearchResultPane extends JPanel {
private AlphaFineList searchResultList;
private SearchListModel searchListModel;
private UIScrollPane leftSearchResultPane;
public SearchResultPane(String[] segmentationResult, ResultShowPane rightSearchResultPane) {
searchResultList = new AlphaFineList();
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT);
leftSearchResultPane = new UIScrollPane(searchResultList);
leftSearchResultPane.setBorder(null);
leftSearchResultPane.setBackground(Color.WHITE);
leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
searchListModel = new SearchListModel(new SearchResult(), searchResultList, leftSearchResultPane);
searchResultList.setModel(searchListModel);
searchResultList.setCellRenderer(new SearchResultContentCellRender(segmentationResult));
searchResultList.setResultShowPane(rightSearchResultPane);
this.setPreferredSize(AlphaFineConstants.CONTENT_SIZE);
this.setLayout(new BorderLayout());
this.add(leftSearchResultPane, BorderLayout.WEST);
this.add(rightSearchResultPane, BorderLayout.EAST);
this.setPreferredSize(new Dimension(680, 305));
}
public AlphaFineList getSearchResultList() {
return searchResultList;
}
public UIScrollPane getLeftSearchResultPane() {
return leftSearchResultPane;
}
}

58
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchTooltipPopup.java

@ -0,0 +1,58 @@
package com.fr.design.mainframe.alphafine.component;
import java.awt.Component;
import java.awt.Point;
import javax.swing.Popup;
import javax.swing.PopupFactory;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class SearchTooltipPopup {
private static final SearchTooltipPopup INSTANCE = new SearchTooltipPopup();
public static SearchTooltipPopup getInstance() {
return INSTANCE;
}
private AlphaSearchTooltipPane alphaSearchTooltipPane;
private SearchTooltipPopup() {
alphaSearchTooltipPane = new AlphaSearchTooltipPane();
}
private boolean showPopup;
private Popup popup;
public void show(Component owner) {
if (popup == null || !showPopup) {
PopupFactory pf = PopupFactory.getSharedInstance();
Point point = owner.getLocationOnScreen();
alphaSearchTooltipPane.refreshHistory();
popup = pf.getPopup(owner, alphaSearchTooltipPane, point.x, point.y + owner.getHeight());
}
if (!showPopup) {
alphaSearchTooltipPane.repaint();
popup.show();
getAlphaFineToolTipList().clearSelection();
showPopup = true;
}
}
public AlphaFineToolTipList getAlphaFineToolTipList() {
return alphaSearchTooltipPane.getAlphaFineToolTipList();
}
public void hide() {
if (popup != null) {
popup.hide();
}
showPopup = false;
}
}

91
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java

@ -0,0 +1,91 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.design.menu.SnapChatUtil;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.util.List;
import java.util.Set;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/07
*/
public class SelectedLabel extends UILabel {
private static final int WIDTH = 4;
private static final int HEIGHT = 4;
private static final int GAP = 2;
private boolean selected;
private boolean hasRead;
private CellType cellType;
public SelectedLabel(String text, CellType cellType, boolean selected) {
super(text);
this.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8);
this.selected = selected;
this.cellType = cellType;
}
public SelectedLabel(String text, CellType cellType) {
this(text, cellType, false);
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (selected) {
g2d.setColor(UIConstants.FLESH_BLUE);
setForeground(UIConstants.FLESH_BLUE);
g2d.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
} else {
setForeground(AlphaFineConstants.FOREGROUND_COLOR_8);
}
if (cellType == CellType.PRODUCT_NEWS && AlphaFineUtil.unread()) {
Color oldColor = g.getColor();
g2d.setColor(Color.RED);
g2d.fillOval(getWidth() - WIDTH, GAP, WIDTH, HEIGHT);
g2d.setColor(oldColor);
}
super.paintComponent(g);
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public boolean isHasRead() {
return hasRead;
}
public void setHasRead(boolean hasRead) {
this.hasRead = hasRead;
}
public CellType getCellType() {
return cellType;
}
}

200
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/ProductNews.java

@ -0,0 +1,200 @@
package com.fr.design.mainframe.alphafine.model;
import com.fr.design.i18n.Toolkit;
import java.awt.Image;
import java.util.Date;
/**
* 产品动态
*
* @author hades
* @version 11.0
* Created by hades on 2022/4/05
*/
public class ProductNews {
private long id;
private String title;
private Tag tag;
private Target target;
private Status status;
private String url;
private Image image;
private Date pushDate;
/**
* 创建cid的用户
*/
private int creator;
public long getId() {
return id;
}
public ProductNews setId(long id) {
this.id = id;
return this;
}
public String getTitle() {
return title;
}
public ProductNews setTitle(String title) {
this.title = title;
return this;
}
public Tag getTag() {
return tag;
}
public ProductNews setTag(Tag tag) {
this.tag = tag;
return this;
}
public Target getTarget() {
return target;
}
public ProductNews setTarget(Target target) {
this.target = target;
return this;
}
public Status getStatus() {
return status;
}
public ProductNews setStatus(Status status) {
this.status = status;
return this;
}
public String getUrl() {
return url;
}
public ProductNews setUrl(String url) {
this.url = url;
return this;
}
public Image getImage() {
return image;
}
public ProductNews setImage(Image image) {
this.image = image;
return this;
}
public Date getPushDate() {
return pushDate;
}
public ProductNews setPushDate(Date pushDate) {
this.pushDate = pushDate;
return this;
}
public int getCreator() {
return creator;
}
public ProductNews setCreator(int creator) {
this.creator = creator;
return this;
}
interface CodeParser {
int getCode();
}
public enum Status implements CodeParser {
STOP(0), START(1);
private final int code;
Status(int code) {
this.code = code;
}
@Override
public int getCode() {
return code;
}
public static Status parseCode(int code) {
for (Status status : values()) {
if (code == status.code) {
return status;
}
}
throw new IllegalArgumentException();
}
}
public enum Tag {
SOLUTION(1, Toolkit.i18nText("Fine-Design_Report_AlphaFine_Solution")),
MATERIAL(2, Toolkit.i18nText("Fine-Design_Report_AlphaFine_Material")),
NEW_PRODUCT(3, Toolkit.i18nText("Fine-Design_Report_AlphaFine_New_Product"));
private final int code;
private final String desc;
Tag(int code, String desc) {
this.code = code;
this.desc = desc;
}
public static Tag parseCode(int code) {
for (Tag tag :values()) {
if (tag.code == code) {
return tag;
}
}
throw new IllegalArgumentException();
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
public enum Target {
ALL_USER(0);
private final int code;
Target(int code) {
this.code = code;
}
public int getCode() {
return code;
}
public static Target parseCode(int code) {
for (Target target : values()) {
if (target.code == code) {
return target;
}
}
throw new IllegalArgumentException();
}
}
}

79
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.component.ProductNewsContentCellRender;
import com.fr.design.mainframe.alphafine.component.ProductNewsList;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.log.FineLoggerFactory;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/14
*/
public class DefaultProductNewsPane extends JPanel {
private static final String LOADING = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Loading");
public DefaultProductNewsPane() {
setLayout(new BorderLayout());
JPanel loadingPane = new JPanel(new BorderLayout());
loadingPane.setBorder(BorderFactory.createEmptyBorder(0, 280, 0, 0));
loadingPane.add(new UILabel(LOADING));
loadingPane.setBackground(Color.WHITE);
this.add(loadingPane);
this.setPreferredSize(new Dimension(680, 305));
new SwingWorker<List<ProductNews>, Void>() {
@Override
protected List<ProductNews> doInBackground() throws Exception {
return ProductNewsSearchManager.getInstance().getProductNewsList();
}
@Override
protected void done() {
DefaultProductNewsPane.this.remove(loadingPane);
try {
DefaultProductNewsPane.this.add(createContentPane(get()));
DefaultProductNewsPane.this.validate();
DefaultProductNewsPane.this.repaint();
AlphaFineHelper.getAlphaFineDialog().repaint();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private UIScrollPane createContentPane(List<ProductNews> productNewsList) {
DefaultListModel<ProductNews> productNewsDefaultListModel = new DefaultListModel<>();
for (ProductNews productNews : productNewsList) {
productNewsDefaultListModel.addElement(productNews);
}
ProductNewsList productNewsJList = new ProductNewsList(productNewsDefaultListModel);
productNewsJList.setBackground(Color.WHITE);
productNewsJList.setCellRenderer(new ProductNewsContentCellRender());
UIScrollPane scrollPane = new UIScrollPane(productNewsJList);
scrollPane.setBackground(Color.WHITE);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20));
return scrollPane;
}
}

94
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java

@ -0,0 +1,94 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/13
*/
public class HelpDocumentNoResultPane extends JPanel {
private static final String RECOMMEND = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend_For_You");
private static final Color DOT_COLOR = new Color(200, 201, 205);
public HelpDocumentNoResultPane(String title, Icon icon, Map<String, String> linkMap) {
setLayout(new BorderLayout());
add(new NoResultPane(title, icon, 150), BorderLayout.CENTER);
add(createRecommendPane(linkMap), BorderLayout.EAST);
}
private JPanel createRecommendPane(Map<String, String> linkMap) {
JPanel wrapRecommendPane = new JPanel(new BorderLayout());
wrapRecommendPane.setPreferredSize(new Dimension(200, 305));
JPanel recommendPane = new JPanel();
recommendPane.setLayout(new GridLayout(0, 1));
recommendPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 130, 0));
recommendPane.setBackground(Color.WHITE);
recommendPane.add(new UILabel(RECOMMEND));
for (Map.Entry<String, String> entry : linkMap.entrySet()) {
recommendPane.add(createListLabel(entry.getKey(), entry.getValue()));
}
// 分割线
JSeparator sep = new JSeparator();
sep.setOrientation(JSeparator.VERTICAL);
sep.setLayout(new GridLayout(0, 1));
sep.setPreferredSize(new Dimension(1, 285));
sep.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
sep.add(new UILabel());
wrapRecommendPane.add(sep, BorderLayout.WEST);
wrapRecommendPane.add(recommendPane, BorderLayout.CENTER);
return wrapRecommendPane;
}
private JPanel createListLabel(String text, String link) {
UILabel listLabel = new UILabel(String.format("%s", text));
listLabel.setForeground(UIConstants.FLESH_BLUE);
listLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
listLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
try {
Desktop.getDesktop().browse(URI.create(link));
} catch (IOException exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
});
JPanel listPane = new JPanel(new BorderLayout());
listPane.setBackground(Color.WHITE);
UILabel dotLabel = new UILabel("·");
dotLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
dotLabel.setFont(DesignUtils.getDefaultGUIFont().applySize(14));
dotLabel.setHorizontalAlignment(SwingConstants.LEADING);
dotLabel.setForeground(DOT_COLOR);
listPane.add(dotLabel, BorderLayout.WEST);
listPane.add(listLabel, BorderLayout.CENTER);
listPane.setPreferredSize(new Dimension(100, 20));
return listPane;
}
}

167
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java

@ -0,0 +1,167 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
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.PluginModel;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.exporter.LocalExportOperator;
import com.fr.workspace.server.exporter.TemplateExportOperator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.ExecutionException;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.SwingWorker;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/20
*/
public class LoadingRightSearchResultPane extends ResultShowPane {
private SwingWorker<BufferedImage, Void> showWorker;
public LoadingRightSearchResultPane() {
this.setBackground(Color.WHITE);
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH - 1, AlphaFineConstants.CONTENT_HEIGHT));
initLoadingLabel();
}
private void initLoadingLabel() {
UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif")));
label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0));
this.add(label, BorderLayout.CENTER);
}
private void showDefaultPreviewPane() {
this.removeAll();
initLoadingLabel();
validate();
repaint();
revalidate();
}
@Override
public void showResult(AlphaCellModel selectedValue) {
showDefaultPreviewPane();
checkWorker();
if (selectedValue.getType() == CellType.FILE) {
fileShowWorker(selectedValue);
}
if (selectedValue.getType() == CellType.PLUGIN) {
pluginShowWorker(selectedValue);
}
this.showWorker.execute();
}
private void fileShowWorker(AlphaCellModel selectedValue) {
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
return frmToImage(fileName);
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) {
return cptToImage(fileName);
} else {
return null;
}
}
@Override
protected void done() {
if (!isCancelled()) {
LoadingRightSearchResultPane.this.removeAll();
try {
LoadingRightSearchResultPane.this.add(new FilePreviewPane(get()));
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
validate();
repaint();
}
}
};
}
private void pluginShowWorker(AlphaCellModel selectedValue) {
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() {
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) {
try {
bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png"));
} catch (IOException e1) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return bufferedImage;
}
@Override
protected void done() {
try {
if (!isCancelled()) {
LoadingRightSearchResultPane.this.removeAll();
LoadingRightSearchResultPane.this.add(new PluginPreviewPane((selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
};
}
private BufferedImage frmToImage(String fileName) throws Exception {
byte[] bytes = null;
try {
bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportFormAsImageData(fileName);
} catch (Exception ignored) {
// 兼容下老版本
bytes = new LocalExportOperator().exportFormAsImageData(fileName);
}
return TemplateExportOperator.byteDataToImage(bytes);
}
private BufferedImage cptToImage(String fileName) throws Exception {
byte[] bytes = null;
try {
bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportWorkBookAsImageData(fileName);
} catch (Exception ignored) {
// 兼容下老版本
bytes = new LocalExportOperator().exportWorkBookAsImageData(fileName);
}
return TemplateExportOperator.byteDataToImage(bytes);
}
private void checkWorker() {
if (this.showWorker != null && !this.showWorker.isDone()) {
this.showWorker.cancel(true);
this.showWorker = null;
}
}
}

22
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java

@ -5,7 +5,9 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.utils.DesignUtils;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
@ -16,21 +18,29 @@ import java.awt.Dimension;
* Created by XiaXiang on 2017/8/14.
*/
public class NoResultPane extends JPanel {
public NoResultPane(String title, String iconUrl) {
public NoResultPane(String title, Icon icon) {
this(title, icon, AlphaFineConstants.LEFT_WIDTH);
}
public NoResultPane(String title, Icon icon, int width) {
setLayout(new BorderLayout());
setBackground(Color.white);
setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
setPreferredSize(new Dimension(width, 305));
UILabel image = new UILabel();
image.setPreferredSize(new Dimension(150, 111));
image.setHorizontalAlignment(SwingConstants.CENTER);
image.setIcon(IconLoader.getIcon(iconUrl));
image.setBorder(BorderFactory.createEmptyBorder(100, 0, 0, 0));
image.setIcon(icon);
image.setBorder(BorderFactory.createEmptyBorder(30, 0, 0, 0));
add(image, BorderLayout.CENTER);
add(generateDescription(title), BorderLayout.SOUTH);
}
protected Component generateDescription(String title) {
UILabel description = new UILabel(title);
description.setForeground(AlphaFineConstants.MEDIUM_GRAY);
description.setFont(DesignUtils.getDefaultGUIFont().applySize(14));
description.setBorder(BorderFactory.createEmptyBorder(0, 0, 135, 0));
description.setHorizontalAlignment(SwingConstants.CENTER);
add(image, BorderLayout.CENTER);
add(description, BorderLayout.SOUTH);
return description;
}
}

35
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.utils.DesignUtils;
import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.Icon;
/**
* 带跳转链接的无结果面板
*
* @author hades
* @version 11.0
* Created by hades on 2022/4/12
*/
public class NoResultWithLinkPane extends NoResultPane {
private static final String TAG_A_START = "<a>";
private static final String TAG_A_END = "</a>";
public NoResultWithLinkPane(String title, Icon icon) {
super(title, icon);
}
@Override
protected Component generateDescription(String title) {
String[] para1 = title.split(TAG_A_START);
String[] para2 = para1[1].split(TAG_A_END);
MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineConstants.ALPHA_GO_TO_FORUM, para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY);
messageWithLink.setBorder(BorderFactory.createEmptyBorder(0, AlphaFineConstants.LEFT_WIDTH - 30, 135, 0));
return messageWithLink;
}
}

14
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/ResultShowPane.java

@ -0,0 +1,14 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public abstract class ResultShowPane extends JPanel {
public abstract void showResult(AlphaCellModel selectedValue);
}

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java

@ -0,0 +1,19 @@
package com.fr.design.mainframe.alphafine.preview;
import java.awt.Color;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/21
*/
public class SearchLoadingPane extends JPanel {
public SearchLoadingPane() {
this.setBackground(Color.WHITE);
}
}

32
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/20
*/
public class SimpleRightSearchResultPane extends ResultShowPane {
public SimpleRightSearchResultPane(JPanel contentPane) {
this.add(contentPane);
this.setBackground(Color.WHITE);
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH - 1, AlphaFineConstants.CONTENT_HEIGHT));
}
@Override
public void showResult(AlphaCellModel selectedValue) {
if (selectedValue.getType() == CellType.DOCUMENT) {
this.removeAll();
this.add(new DocumentPreviewPane((selectedValue).getName(), (selectedValue).getContent()));
validate();
repaint();
}
}
}

59
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java

@ -0,0 +1,59 @@
package com.fr.design.mainframe.alphafine.question;
import com.fr.base.svg.SVGLoader;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/15
*/
public class QuestionPane extends JPanel {
private static final Image NEW_MESSAGE_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/group_new.svg");
private static final Image QUESTION_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/group.svg");
private static final Image QUESTION_BACKGROUND_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/groupbackgroud.svg");
/**
* 是否全部已读
*/
private boolean hasRead;
public QuestionPane(boolean hasRead) {
this.setBackground(new Color(0, 0, 0, 0));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
if (AlphaFineUtil.unread()) {
g2.drawImage(NEW_MESSAGE_IMAGE, 0, 0, getWidth(), getHeight(), this);
} else {
g2.drawImage(QUESTION_BACKGROUND_IMAGE, 0, 0, getWidth(), getHeight(), this);
g2.drawImage(QUESTION_IMAGE, (getWidth() - QUESTION_IMAGE.getWidth(this)) / 2, (getHeight() - QUESTION_IMAGE.getHeight(this)) / 2, this);
}
}
public void setHasRead(boolean hasRead) {
this.hasRead = hasRead;
}
@Override
public Dimension getPreferredSize() {
return new Dimension(40, 40);
}
}

86
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionWindow.java

@ -0,0 +1,86 @@
package com.fr.design.mainframe.alphafine.question;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JWindow;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/15
*/
public class QuestionWindow extends JWindow {
private static final QuestionWindow INSTANCE = new QuestionWindow();
private final QuestionPane questionPane = new QuestionPane(true);
private int pressX;
private int pressY;
private QuestionWindow() {
this.setBackground(new Color(0, 0, 0, 0));
questionPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
AlphaFineHelper.showAlphaFineDialog(true);
}
@Override
public void mousePressed(MouseEvent e) {
pressX = e.getX();
pressY = e.getY();
}
});
questionPane.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
int left = getLocation().x;
int top = getLocation().y;
setLocation(left + e.getX() - pressX, top + e.getY() - pressY);
}
});
DesignerContext.getDesignerFrame().addWindowListener(new WindowAdapter() {
@Override
public void windowActivated(WindowEvent e) {
QuestionWindow.getInstance().setVisible(true);
}
@Override
public void windowDeactivated(WindowEvent e) {
QuestionWindow.getInstance().setVisible(false);
}
});
this.getLayeredPane().setToolTipText(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Learn_More_About"));
this.setContentPane(questionPane);
this.setSize(new Dimension(40, 40));
this.setLocation(DesignerContext.getDesignerFrame().getWidth() - 100,
DesignerContext.getDesignerFrame().getHeight() - 100);
}
public static QuestionWindow getInstance() {
return INSTANCE;
}
public void setHasRead(boolean hasRead) {
this.questionPane.setHasRead(hasRead);
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
@Override
public void dispose() {
super.dispose();
}
}

100
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java

@ -0,0 +1,100 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.component.ProductNewsSearchResultPane;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.log.FineLoggerFactory;
import java.util.List;
import java.util.function.Function;
import javax.swing.DefaultListModel;
import javax.swing.SwingWorker;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/22
*/
public class ProductNewsSearchWorkerManager implements SearchManager {
private final CellType cellType;
private SwingWorker<DefaultListModel<ProductNews>, Void> searchWorker;
private Function<SearchTextBean, List<ProductNews>> searchFunction;
private ProductNewsSearchResultPane searchResultPane;
private AlphaFineFrame alphaFineFrame;
private volatile boolean hasSearchResult = true;
public ProductNewsSearchWorkerManager(CellType cellType, Function<SearchTextBean, List<ProductNews>> searchFunction, AlphaFineFrame alphaFineFrame) {
this.cellType = cellType;
this.searchFunction = searchFunction;
this.alphaFineFrame = alphaFineFrame;
}
@Override
public void doSearch(SearchTextBean searchTextBean) {
checkSearchWork();
if (searchResultPane == null) {
searchResultPane = new ProductNewsSearchResultPane(searchTextBean.getSegmentation());
alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result());
}
this.searchWorker = new SwingWorker<DefaultListModel<ProductNews>, Void>() {
@Override
protected DefaultListModel<ProductNews> doInBackground() throws Exception {
List<ProductNews> productNewsList = searchFunction.apply(searchTextBean);
DefaultListModel<ProductNews> productNewsDefaultListModel = new DefaultListModel<>();
for (ProductNews productNews : productNewsList) {
productNewsDefaultListModel.addElement(productNews);
}
return productNewsDefaultListModel;
}
@Override
protected void done() {
if (!isCancelled()) {
try {
DefaultListModel<ProductNews> productNewsDefaultListModel = get();
hasSearchResult = !productNewsDefaultListModel.isEmpty();
searchResultPane.getProductNewsList().setModel(get());
if (alphaFineFrame.getSelectedType() == cellType) {
if (!hasSearchResult) {
alphaFineFrame.showResult(CellType.NO_RESULT.getFlagStr4None());
return;
}
alphaFineFrame.showResult(cellType.getFlagStr4Result());
searchResultPane.getProductNewsList().setSelectedIndex(0);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
};
this.searchWorker.execute();
}
public ProductNewsSearchResultPane getSearchResultPane() {
return searchResultPane;
}
@Override
public boolean hasSearchResult() {
return hasSearchResult;
}
private void checkSearchWork() {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
}
}

13
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java

@ -0,0 +1,13 @@
package com.fr.design.mainframe.alphafine.search;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/17
*/
public interface SearchManager {
void doSearch(SearchTextBean searchTextBean);
boolean hasSearchResult();
}

37
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.alphafine.search;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/17
*/
public class SearchTextBean {
private String searchText;
/**
* 分词搜索
*/
private String[] segmentation;
public SearchTextBean(String searchText, String[] segmentation) {
this.searchText = searchText;
this.segmentation = segmentation;
}
public String getSearchText() {
return searchText;
}
public void setSearchText(String searchText) {
this.searchText = searchText;
}
public String[] getSegmentation() {
return segmentation;
}
public void setSegmentation(String[] segmentation) {
this.segmentation = segmentation;
}
}

119
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java

@ -0,0 +1,119 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.component.AlphaFineList;
import com.fr.design.mainframe.alphafine.component.SearchListModel;
import com.fr.design.mainframe.alphafine.component.SearchResultPane;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.preview.ResultShowPane;
import com.fr.log.FineLoggerFactory;
import java.util.function.Function;
import javax.swing.SwingWorker;
import org.jetbrains.annotations.Nullable;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/16
*/
public class SearchWorkerManager implements SearchManager {
private final CellType cellType;
private SwingWorker<SearchListModel, Void> searchWorker;
private Function<SearchTextBean, SearchResult> searchResultFunction;
private SearchResultPane searchResultPane;
private AlphaFineFrame alphaFineFrame;
private ResultShowPane resultShowPane;
private volatile boolean hasSearchResult = true;
public SearchWorkerManager(CellType cellType, Function<SearchTextBean, SearchResult> function, AlphaFineFrame alphaFineFrame, ResultShowPane resultShowPane) {
this.cellType = cellType;
this.searchResultFunction = function;
this.alphaFineFrame = alphaFineFrame;
this.resultShowPane = resultShowPane;
}
private void initSearchResult(SearchTextBean searchTextBean) {
if (searchResultPane == null) {
searchResultPane = new SearchResultPane(searchTextBean.getSegmentation(), resultShowPane);
alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result());
}
}
private void checkSearchWork() {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
}
private void initSearchWorker(SearchTextBean searchTextBean) {
this.searchWorker = new SwingWorker<SearchListModel, Void>() {
@Override
protected SearchListModel doInBackground() throws Exception {
SearchResult searchResult = searchResultFunction.apply(searchTextBean);
SearchListModel searchListModel = new SearchListModel(new SearchResult(), searchResultPane.getSearchResultList(), searchResultPane.getLeftSearchResultPane());
for (AlphaCellModel object : searchResult) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
return searchListModel;
}
@Override
protected void done() {
if (!isCancelled()) {
try {
SearchListModel searchListModel = get();
hasSearchResult = !searchListModel.isEmpty();
searchResultPane.getSearchResultList().setModel(get());
if (alphaFineFrame.getSelectedType() == cellType) {
if (!hasSearchResult) {
alphaFineFrame.showResult(CellType.NO_RESULT.getFlagStr4None());
return;
}
alphaFineFrame.showResult(cellType.getFlagStr4Result());
searchResultPane.getSearchResultList().setSelectedIndex(0);
searchResultPane.getSearchResultList().requestFocus();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
};
}
@Override
public void doSearch(SearchTextBean searchTextBean) {
initSearchResult(searchTextBean);
checkSearchWork();
initSearchWorker(searchTextBean);
this.searchWorker.execute();
}
@Override
public boolean hasSearchResult() {
return hasSearchResult;
}
@Nullable
public AlphaFineList getSearchResultList() {
if (searchResultPane != null) {
return searchResultPane.getSearchResultList();
}
return null;
}
}

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

@ -0,0 +1,75 @@
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.model.ProductNews;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.imageio.ImageIO;
public class ProductNewsSearchManager {
private static final ProductNewsSearchManager INSTANCE = new ProductNewsSearchManager();
private List<ProductNews> productNewsResultList;
private List<ProductNews> productNewsList = new ArrayList<>();
private ProductNewsSearchManager() {
}
public static ProductNewsSearchManager getInstance() {
return INSTANCE;
}
public List<ProductNews> getSearchResult(String[] searchText) {
productNewsResultList = new ArrayList<>();
try {
List<ProductNews> productNewsList = getProductNewsList();
for (ProductNews productNews : productNewsList) {
for (String str : searchText) {
if (productNews.getTitle().contains(str)) {
productNewsResultList.add(productNews);
break;
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return productNewsResultList;
}
public List<ProductNews> getProductNewsList() throws Exception {
productNewsList = new ArrayList<>();
String jsonStr = HttpToolbox.get(AlphaFineConstants.ALPHA_CID);
AlphaFineHelper.checkCancel();
JSONObject cidJSON = JSONFactory.createJSON(JSON.OBJECT, jsonStr);
JSONArray jsonArray = cidJSON.getJSONArray("data");
for (int i = 0, size = jsonArray.size(); i < size; i++) {
JSONObject obj = jsonArray.getJSONObject(i);
ProductNews productNews = new ProductNews().
setId(obj.getLong("id")).setTitle(obj.getString("title")).
setImage(ImageIO.read(new URL(obj.getString("pic")))).
setUrl(obj.getString("url")).setTag(ProductNews.Tag.parseCode(obj.getInt("tag"))).
setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget(
ProductNews.Target.parseCode(obj.getInt("target"))).
setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time")));
productNewsList.add(productNews);
}
return productNewsList;
}
public List<ProductNews> getCachedProductNewsList() {
return productNewsList;
}
}

22
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -59,6 +59,8 @@ import com.fr.design.mainframe.JTemplateEvent;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.question.QuestionWindow;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
@ -142,6 +144,7 @@ import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.swing.SwingWorker;
/**
* Created by juhaoyu on 2018/1/31.
@ -499,6 +502,25 @@ public class DesignerActivator extends Activator implements Prepare {
LoginAuthServer.getInstance().compatibleStart();
});
ContentReplacerCenter.getInstance().register();
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
// 触发下cid 搜索
ProductNewsSearchManager.getInstance().getProductNewsList();
return null;
}
@Override
protected void done() {
QuestionWindow.getInstance().setVisible(true);
}
}.execute();
}
});
}
private void startLoginAuthServer() {

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/blue_bulb.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="5.40283" y="12.9943" width="5.16667" height="1.20556" rx="0.602778" fill="#1D7ADC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5167 6.53611C11.5167 7.55647 11.0838 8.47574 10.3917 9.1203C10.3917 9.12032 10.3918 9.12035 10.3918 9.12038C10.093 9.39865 9.74589 9.62573 9.36443 9.78764V10.928H6.60888V9.78809C6.22677 9.62605 5.87911 9.39864 5.57993 9.11988C5.57994 9.11985 5.57996 9.11983 5.57998 9.1198C4.88819 8.47527 4.45556 7.55621 4.45556 6.53611C4.45556 4.58624 6.03624 3.00556 7.98611 3.00556C9.93598 3.00556 11.5167 4.58624 11.5167 6.53611ZM5.40332 9.64432C5.40267 9.65911 5.40234 9.67398 5.40234 9.68892V10.506C4.10652 9.66092 3.25 8.19854 3.25 6.53611C3.25 3.92043 5.37043 1.8 7.98611 1.8C10.6018 1.8 12.7222 3.92043 12.7222 6.53611C12.7222 8.1985 11.8657 9.66084 10.57 10.5059V11.2724C10.57 11.748 10.1845 12.1335 9.70888 12.1335H6.26443C5.78885 12.1335 5.40332 11.748 5.40332 11.2724V9.64432Z" fill="#1D7ADC"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/bulb.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="5.40283" y="12.9943" width="5.16667" height="1.20556" rx="0.602778" fill="#C2C2C2"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5167 6.53611C11.5167 7.55647 11.0838 8.47574 10.3917 9.1203C10.3917 9.12032 10.3918 9.12035 10.3918 9.12038C10.093 9.39865 9.74589 9.62573 9.36443 9.78764V10.928H6.60888V9.78809C6.22677 9.62605 5.87911 9.39864 5.57993 9.11988C5.57994 9.11985 5.57996 9.11983 5.57998 9.1198C4.88819 8.47527 4.45556 7.55621 4.45556 6.53611C4.45556 4.58624 6.03624 3.00556 7.98611 3.00556C9.93598 3.00556 11.5167 4.58624 11.5167 6.53611ZM5.40332 9.64432C5.40267 9.65911 5.40234 9.67398 5.40234 9.68892V10.506C4.10652 9.66092 3.25 8.19854 3.25 6.53611C3.25 3.92043 5.37043 1.8 7.98611 1.8C10.6018 1.8 12.7222 3.92043 12.7222 6.53611C12.7222 8.1985 11.8657 9.66084 10.57 10.5059V11.2724C10.57 11.748 10.1845 12.1335 9.70888 12.1335H6.26443C5.78885 12.1335 5.40332 11.748 5.40332 11.2724V9.64432Z" fill="#C2C2C2"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/close.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.8492 2.94974C12.5758 2.67637 12.1326 2.67637 11.8592 2.94974L7.89937 6.90957L3.93959 2.94978C3.66622 2.67641 3.223 2.67641 2.94964 2.94978C2.67627 3.22315 2.67627 3.66636 2.94964 3.93973L6.90942 7.89952L2.94966 11.8593C2.67629 12.1326 2.67629 12.5759 2.94966 12.8492C3.22302 13.1226 3.66624 13.1226 3.93961 12.8492L7.89937 8.88946L11.8592 12.8493C12.1325 13.1226 12.5758 13.1226 12.8491 12.8493C13.1225 12.5759 13.1225 12.1327 12.8491 11.8593L8.88932 7.89952L12.8492 3.93969C13.1225 3.66632 13.1225 3.2231 12.8492 2.94974Z" fill="#AEAEAE"/>
</svg>

After

Width:  |  Height:  |  Size: 697 B

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/group.svg

@ -0,0 +1,4 @@
<svg width="10" height="17" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.18736 0C6.65515 0 7.81846 0.39723 8.70621 1.21669C9.5658 2.00658 10 3.09498 10 4.45996C10 5.48298 9.70553 6.38371 9.11981 7.15654C8.88023 7.44403 8.25107 8.04406 7.3133 8.87524C6.85572 9.27043 6.53305 9.65035 6.31538 10.042C6.04967 10.4917 5.92212 10.9866 5.92212 11.5577V12.0647L5.73843 12.2483H3.97502L3.79133 12.0647V11.5577C3.79133 10.8039 3.92919 10.1376 4.20533 9.56229C4.52788 8.87111 5.27169 8.01628 6.4682 6.95314C6.94413 6.47721 7.09597 6.31877 7.2041 6.17474C7.62189 5.65251 7.82513 5.11901 7.82513 4.54813C7.82513 3.72777 7.58683 3.0854 7.12675 2.62526C6.66719 2.14572 5.99692 1.91036 5.09919 1.91036C4.04615 1.91036 3.29 2.24245 2.7969 2.92025C2.33854 3.50361 2.10874 4.30268 2.10874 5.34166L1.92506 5.52535H0.183688L0 5.34166C0 3.73829 0.443367 2.46503 1.34828 1.51494C2.26686 0.504505 3.55106 0 5.18736 0Z" fill="white"/>
<path d="M4.85732 13.4242C5.29615 13.4242 5.66674 13.5624 5.95708 13.8527C6.23882 14.1345 6.38561 14.4919 6.38561 14.9084C6.38561 15.3529 6.23444 15.7119 5.92928 15.9916C5.62394 16.2715 5.26927 16.4146 4.85732 16.4146C4.44537 16.4146 4.0907 16.2715 3.7796 15.9861C3.48668 15.6932 3.35107 15.3419 3.35107 14.9084C3.35107 14.4706 3.48937 14.1185 3.7796 13.8527C4.07252 13.5598 4.42386 13.4242 4.85732 13.4242Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/group_new.svg

@ -0,0 +1,4 @@
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.9794 8.01574C32.1473 8.63412 31.1164 9 30 9C27.2386 9 25 6.76142 25 4C25 3.15756 25.2083 2.36378 25.5763 1.66737C23.2735 0.597339 20.7065 0 18 0C8.05887 0 0 8.05887 0 18C0 27.9411 8.05887 36 18 36C27.9411 36 36 27.9411 36 18C36 14.3065 34.8875 10.8728 32.9794 8.01574ZM18.1874 10C19.6551 10 20.8185 10.3972 21.7062 11.2167C22.5658 12.0066 23 13.095 23 14.46C23 15.483 22.7055 16.3837 22.1198 17.1565C21.8802 17.444 21.2511 18.0441 20.3133 18.8752C19.8557 19.2704 19.533 19.6504 19.3154 20.042C19.0497 20.4917 18.9221 20.9866 18.9221 21.5577V22.0647L18.7384 22.2483H16.975L16.7913 22.0647V21.5577C16.7913 20.8039 16.9292 20.1376 17.2053 19.5623C17.5279 18.8711 18.2717 18.0163 19.4682 16.9531C19.9441 16.4772 20.096 16.3188 20.2041 16.1747C20.6219 15.6525 20.8251 15.119 20.8251 14.5481C20.8251 13.7278 20.5868 13.0854 20.1267 12.6253C19.6672 12.1457 18.9969 11.9104 18.0992 11.9104C17.0461 11.9104 16.29 12.2425 15.7969 12.9202C15.3385 13.5036 15.1087 14.3027 15.1087 15.3417L14.9251 15.5253H13.1837L13 15.3417C13 13.7383 13.4434 12.465 14.3483 11.5149C15.2669 10.5045 16.5511 10 18.1874 10ZM18.9571 23.8527C18.6667 23.5624 18.2962 23.4242 17.8573 23.4242C17.4239 23.4242 17.0725 23.5598 16.7796 23.8527C16.4894 24.1185 16.3511 24.4706 16.3511 24.9084C16.3511 25.3419 16.4867 25.6932 16.7796 25.9861C17.0907 26.2715 17.4454 26.4146 17.8573 26.4146C18.2693 26.4146 18.6239 26.2715 18.9293 25.9916C19.2344 25.7119 19.3856 25.3529 19.3856 24.9084C19.3856 24.4919 19.2388 24.1345 18.9571 23.8527Z" fill="#419BF9"/>
<circle cx="30" cy="4" r="4" fill="#EB1D1F"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/groupbackgroud.svg

@ -0,0 +1,3 @@
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="18" cy="18" r="18" fill="#419BF9"/>
</svg>

After

Width:  |  Height:  |  Size: 151 B

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/history_search.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 8C2 11.3137 4.68629 14 8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8ZM8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1Z" fill="#AEAEAE"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 3.5C8.27614 3.5 8.5 3.72386 8.5 4V7.79289L10.8536 10.1464C11.0488 10.3417 11.0488 10.6583 10.8536 10.8536C10.6583 11.0488 10.3417 11.0488 10.1464 10.8536L7.5 8.20711V4C7.5 3.72386 7.72386 3.5 8 3.5Z" fill="#AEAEAE"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/hot_search.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.54759 15C6.54759 15 0.338939 13.6343 3.11391 6.8562C3.11391 6.8562 3.74391 7.6094 3.65729 7.97182C3.65729 7.97182 4.15114 6.26102 5.21706 5.23902C6.13231 4.36087 7.06226 1.89215 6.20459 1C6.20459 1 10.4527 1.89215 10.9256 6.35465C10.9256 6.35465 11.4689 4.93277 12.5846 4.79225C12.5846 4.79225 12.2416 5.57345 12.5846 6.74525C12.5846 6.74525 16.1035 12.7688 10.039 14.8047C10.039 14.8047 11.8569 12.7406 8.00166 9.1984C8.00166 9.1984 7.09271 11.0954 6.54916 11.7639C6.54759 11.7656 5.03121 13.4656 6.54759 15Z" fill="#EB1D1F"/>
</svg>

After

Width:  |  Height:  |  Size: 643 B

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/minimize.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.6998 8.7C2.31321 8.7 1.9998 8.3866 1.9998 8C1.9998 7.6134 2.3132 7.3 2.6998 7.3L13.2998 7.3C13.6864 7.3 13.9998 7.6134 13.9998 8C13.9998 8.3866 13.6864 8.7 13.2998 8.7L2.6998 8.7Z" fill="#AEAEAE"/>
</svg>

After

Width:  |  Height:  |  Size: 353 B

25
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/new_tip.svg

@ -0,0 +1,25 @@
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_646_53710)">
<g filter="url(#filter0_d_646_53710)">
<path d="M28 0L0 28V10.5L10.5 0H28Z" fill="#EB1D1F"/>
</g>
<path d="M6.14139 17.6072L1.58594 13.0518L2.20431 12.4334L8.17363 13.6173L4.59701 10.0407L5.17499 9.46271L9.73044 14.0182L9.11207 14.6365L3.13964 13.4495L6.71937 17.0292L6.14139 17.6072Z" fill="white"/>
<path d="M11.8714 9.7517L12.5209 9.24519C12.7674 9.67401 12.8606 10.1049 12.8006 10.5379C12.7405 10.9708 12.5188 11.3789 12.1356 11.7622C11.6529 12.2449 11.1215 12.48 10.5415 12.4676C9.96142 12.451 9.40313 12.1744 8.86658 11.6379C8.31139 11.0827 8.02344 10.5089 8.00272 9.91639C7.98201 9.32391 8.19953 8.7998 8.65528 8.34404C9.09653 7.90279 9.60718 7.69252 10.1872 7.71324C10.7673 7.73396 11.3297 8.01673 11.8745 8.56156C11.9077 8.59471 11.9564 8.64546 12.0206 8.71382L9.55953 11.1749C9.94278 11.5167 10.3229 11.6918 10.6999 11.7C11.077 11.7083 11.4033 11.5747 11.6788 11.2992C11.8839 11.0941 12.0051 10.8652 12.0423 10.6124C12.0796 10.3597 12.0227 10.0728 11.8714 9.7517ZM9.13071 10.6839L10.9734 8.84123C10.6709 8.58849 10.3923 8.45073 10.1375 8.42794C9.7439 8.39065 9.4052 8.51391 9.12139 8.79772C8.86451 9.0546 8.734 9.35706 8.72986 9.70509C8.72778 10.051 8.8614 10.3773 9.13071 10.6839Z" fill="white"/>
<path d="M14.8266 8.92202L10.5166 6.63186L11.0946 6.05389L13.5246 7.43357L14.4288 7.9463C14.4019 7.90279 14.232 7.61898 13.9192 7.09487L12.5116 4.63691L13.0864 4.06204L15.4947 5.48213L16.2902 5.94824L15.8427 5.12167L14.5003 2.64817L15.0441 2.10438L17.3125 6.4361L16.7314 7.01718L14.23 5.56603L13.5401 5.13099L15.4108 8.33783L14.8266 8.92202Z" fill="white"/>
</g>
<defs>
<filter id="filter0_d_646_53710" x="-4" y="-2" width="36" height="36" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="2"/>
<feGaussianBlur stdDeviation="2"/>
<feComposite in2="hardAlpha" operator="out"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_646_53710"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_646_53710" result="shape"/>
</filter>
<clipPath id="clip0_646_53710">
<rect width="36" height="36" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.46447 3.46447C5.41709 1.51184 8.58291 1.51184 10.5355 3.46447C12.3688 5.29776 12.4809 8.20052 10.8716 10.1645L13.364 12.6569C13.5592 12.8521 13.5592 13.1687 13.364 13.364C13.1687 13.5592 12.8521 13.5592 12.6569 13.364L10.1645 10.8716C8.20052 12.4809 5.29776 12.3688 3.46447 10.5355C1.51184 8.58291 1.51184 5.41709 3.46447 3.46447ZM9.82843 9.82843C11.3905 8.26633 11.3905 5.73367 9.82843 4.17157C8.26633 2.60948 5.73367 2.60948 4.17157 4.17157C2.60948 5.73367 2.60948 8.26633 4.17157 9.82843C5.73367 11.3905 8.26633 11.3905 9.82843 9.82843Z" fill="#AEAEAE"/>
</svg>

After

Width:  |  Height:  |  Size: 713 B

Loading…
Cancel
Save