Browse Source

REPORT-70452 alphafine搜索后,切换tab,文档tab下的状态不正确 && REPORT-70446 面板交互视觉问题

feature/x
hades 3 years ago
parent
commit
8268130207
  1. 36
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  2. 44
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineShortCutUtil.java
  3. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  4. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/CellType.java
  5. 162
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  6. 21
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  7. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java
  8. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java
  9. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java
  10. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/exception/AlphaFineNetworkException.java
  11. 64
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java
  12. 76
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java
  13. 69
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java
  14. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java
  15. 3
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java
  16. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionWindow.java
  17. 30
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java
  18. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java
  19. 28
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java
  20. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/clear.svg

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

@ -25,31 +25,6 @@ import java.awt.event.MouseEvent;
public class AlphaFineConfigPane extends BasicPane { public class AlphaFineConfigPane extends BasicPane {
private static final String TYPE = "pressed"; private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+"; private static final String DISPLAY_TYPE = "+";
private static final String BACK_SLASH = "BACK_SLASH";
private static final String DISPLAY_BACK_SLASH = "\\";
private static final String SLASH = "SLASH";
private static final String DISPLAY_SLASH = "/";
private static final String CONTROL = "CONTROL";
private static final String DISPLAY_CONTROL = "ctrl";
private static final String OPEN_BRACKET = "OPEN_BRACKET";
private static final String DISPLAY_OPEN_BRACKET = "{";
private static final String CLOSE_BRACKET = "CLOSE_BRACKET";
private static final String DISPLAY_CLOSE_BRACKET = "}";
private static final String COMMA = "COMMA";
private static final String DISPLAY_COMMA = ",";
private static final String PERIOD = "PERIOD";
private static final String DISPLAY_PERIOD = ".";
private static final String SEMICOLON = "SEMICOLON";
private static final String DISPLAY_SEMICOLON = ";";
private static final String QUOTE = "QUOTE";
private static final String DISPLAY_QUOTE = "'";
private static final String EQUALS = "EQUALS";
private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-";
private static final String COMMAND = "META";
private static final String SMALL_COMMAND = "meta";
private static final String DISPLAY_COMMAND = "\u2318";
private static final double COLUMN_GAP = 180; private static final double COLUMN_GAP = 180;
@ -138,7 +113,7 @@ public class AlphaFineConfigPane extends BasicPane {
int keyCode = e.getKeyCode(); int keyCode = e.getKeyCode();
shortCutKeyStore = KeyStroke.getKeyStroke(keyCode, modifier); shortCutKeyStore = KeyStroke.getKeyStroke(keyCode, modifier);
String str = shortCutKeyStore.toString(); String str = shortCutKeyStore.toString();
shortcutsField.setText(getDisplayShortCut(str)); shortcutsField.setText(AlphaFineShortCutUtil.getDisplayShortCut(str));
shortcutsField.selectAll(); shortcutsField.selectAll();
} }
}); });
@ -209,7 +184,7 @@ public class AlphaFineConfigPane extends BasicPane {
this.productDynamicsCheckbox.setSelected(alphaFineConfigManager.isProductDynamics() && enabled4Locale); this.productDynamicsCheckbox.setSelected(alphaFineConfigManager.isProductDynamics() && enabled4Locale);
this.productDynamicsCheckbox.setEnabled(enabled4Locale); this.productDynamicsCheckbox.setEnabled(enabled4Locale);
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); this.shortcutsField.setText(AlphaFineShortCutUtil.getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
@ -244,13 +219,6 @@ public class AlphaFineConfigPane extends BasicPane {
} }
private String getDisplayShortCut(String shortCut) {
return shortCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE)
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND);
}
private KeyStroke convert2KeyStroke(String ks) { private KeyStroke convert2KeyStroke(String ks) {
return KeyStroke.getKeyStroke(ks.replace(DISPLAY_TYPE, TYPE)); return KeyStroke.getKeyStroke(ks.replace(DISPLAY_TYPE, TYPE));

44
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineShortCutUtil.java

@ -0,0 +1,44 @@
package com.fr.design.actions.help.alphafine;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/26
*/
public class AlphaFineShortCutUtil {
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";
private static final String BACK_SLASH = "BACK_SLASH";
private static final String DISPLAY_BACK_SLASH = "\\";
private static final String SLASH = "SLASH";
private static final String DISPLAY_SLASH = "/";
private static final String CONTROL = "CONTROL";
private static final String DISPLAY_CONTROL = "ctrl";
private static final String OPEN_BRACKET = "OPEN_BRACKET";
private static final String DISPLAY_OPEN_BRACKET = "{";
private static final String CLOSE_BRACKET = "CLOSE_BRACKET";
private static final String DISPLAY_CLOSE_BRACKET = "}";
private static final String COMMA = "COMMA";
private static final String DISPLAY_COMMA = ",";
private static final String PERIOD = "PERIOD";
private static final String DISPLAY_PERIOD = ".";
private static final String SEMICOLON = "SEMICOLON";
private static final String DISPLAY_SEMICOLON = ";";
private static final String QUOTE = "QUOTE";
private static final String DISPLAY_QUOTE = "'";
private static final String EQUALS = "EQUALS";
private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-";
private static final String COMMAND = "META";
private static final String SMALL_COMMAND = "meta";
private static final String DISPLAY_COMMAND = "\u2318";
public static String getDisplayShortCut(String shortCut) {
return shortCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE)
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND);
}
}

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

@ -61,6 +61,11 @@ public class AlphaFineConstants {
public static final Dimension HOT_ISSUES_JAPNEL_SIZE = new Dimension(213, 182); public static final Dimension HOT_ISSUES_JAPNEL_SIZE = new Dimension(213, 182);
/**
* 展示面板的尺寸
*/
public static final Dimension PREVIEW_SIZE = new Dimension(680, 305);
public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40); public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40);
public static final Color WHITE = new Color(0xf9f9f9); public static final Color WHITE = new Color(0xf9f9f9);
@ -138,9 +143,11 @@ public class AlphaFineConstants {
public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview"); 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 ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid", "https://cid.fanruan.com/api/nav/alphafine");
public static final String ALPHA_HELP_RECOMMEND = CloudCenter.getInstance().acquireUrlByKind("af.recommend"); private static final String DEFAULT_RECOMMEND = "[ { \"name\":\"快速入门指南\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1335.html?source=3\" }, { \"name\":\"报表应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1336.html?source=3\" }, { \"name\":\"参数应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4219.html?source=3\" }, { \"name\":\"填报学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4103.html?source=3\" }, { \"name\":\"API接口汇总\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4327.html?source=3\" }, { \"name\":\"文档月刊\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4613.html?source=3\" } ]";
public static final String ALPHA_HELP_RECOMMEND = CloudCenter.getInstance().acquireUrlByKind("af.recommend", DEFAULT_RECOMMEND);
public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; public static final String JAVASCRIPT_PREFIX = "javascript:SendJava";
@ -192,4 +199,7 @@ public class AlphaFineConstants {
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_DE")); add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_DE"));
}}; }};
public static final String LOADING = "loading";
public static final String NETWORK_ERROR = "network error";
} }

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

@ -7,17 +7,17 @@ import com.fr.stable.StringUtils;
*/ */
public enum CellType { public enum CellType {
RECOMMEND(0), RECOMMEND(0),
ACTION(1, "action", "actionResult"), ACTION(1, "action", "actionResult", false),
DOCUMENT(2, "document", "documentResult"), DOCUMENT(2, "document", "documentResult", true),
FILE(3, "file", "fileResult"), FILE(3, "file", "fileResult", false),
PLUGIN(4, "plugin", "pluginResult"), PLUGIN(4, "plugin", "pluginResult", true),
REUSE(5), REUSE(5),
NO_RESULT(6, "noResult", StringUtils.EMPTY), NO_RESULT(6, "noResult", StringUtils.EMPTY, false),
MORE(7), MORE(7),
RECOMMEND_ROBOT(8), RECOMMEND_ROBOT(8),
BOTTOM(9), BOTTOM(9),
ROBOT(10), ROBOT(10),
PRODUCT_NEWS(11, "productNews", "productNewsResult"); PRODUCT_NEWS(11, "productNews", "productNewsResult", true);
private int typeValue; private int typeValue;
@ -33,14 +33,17 @@ public enum CellType {
*/ */
private String flagStr4Result; private String flagStr4Result;
CellType(int type, String flagStr4None, String flagStr4Result) { private boolean needNetWork = true;
CellType(int type, String flagStr4None, String flagStr4Result, boolean needNetWork) {
this.typeValue = type; this.typeValue = type;
this.flagStr4None = flagStr4None; this.flagStr4None = flagStr4None;
this.flagStr4Result = flagStr4Result; this.flagStr4Result = flagStr4Result;
this.needNetWork = needNetWork;
} }
CellType(int type) { CellType(int type) {
this(type, StringUtils.EMPTY, StringUtils.EMPTY); this(type, StringUtils.EMPTY, StringUtils.EMPTY, true);
} }
public static CellType parse(int typeValue) { public static CellType parse(int typeValue) {
@ -68,5 +71,9 @@ public enum CellType {
public String getFlagStr4Result() { public String getFlagStr4Result() {
return flagStr4Result; return flagStr4Result;
} }
public boolean isNeedNetWork() {
return needNetWork;
}
} }

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

@ -4,7 +4,9 @@ import com.fr.base.svg.IconUtils;
import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SVGLoader;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.actions.help.alphafine.AlphaFineShortCutUtil;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.borders.UITextFieldBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
@ -15,8 +17,10 @@ import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.preview.DefaultProductNewsPane; import com.fr.design.mainframe.alphafine.preview.DefaultProductNewsPane;
import com.fr.design.mainframe.alphafine.preview.HelpDocumentNoResultPane; import com.fr.design.mainframe.alphafine.preview.HelpDocumentNoResultPane;
import com.fr.design.mainframe.alphafine.preview.LoadingRightSearchResultPane; import com.fr.design.mainframe.alphafine.preview.LoadingRightSearchResultPane;
import com.fr.design.mainframe.alphafine.preview.NetWorkFailedPane;
import com.fr.design.mainframe.alphafine.preview.NoResultPane; import com.fr.design.mainframe.alphafine.preview.NoResultPane;
import com.fr.design.mainframe.alphafine.preview.NoResultWithLinkPane; import com.fr.design.mainframe.alphafine.preview.NoResultWithLinkPane;
import com.fr.design.mainframe.alphafine.preview.SearchLoadingPane;
import com.fr.design.mainframe.alphafine.preview.SimpleRightSearchResultPane; import com.fr.design.mainframe.alphafine.preview.SimpleRightSearchResultPane;
import com.fr.design.mainframe.alphafine.question.QuestionWindow; import com.fr.design.mainframe.alphafine.question.QuestionWindow;
import com.fr.design.mainframe.alphafine.search.ProductNewsSearchWorkerManager; import com.fr.design.mainframe.alphafine.search.ProductNewsSearchWorkerManager;
@ -30,10 +34,6 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchMa
import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
@ -44,6 +44,7 @@ import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.Window; import java.awt.Window;
@ -56,9 +57,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -97,7 +96,7 @@ public class AlphaFineFrame extends JFrame {
private static final String TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"); 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"); public 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 HELP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help");
@ -107,8 +106,12 @@ public class AlphaFineFrame extends JFrame {
private static final String NO_SEARCH_RESULT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_NO_Result"); private static final String NO_SEARCH_RESULT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_NO_Result");
private static final String PRODUCT_DYNAMICS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_Dynamics");
private static final Image SEARCH_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/search.svg"); private static final Image SEARCH_IMAGE = SVGLoader.load("/com/fr/design/mainframe/alphafine/images/search.svg");
private static final Color BORDER_COLOR = new Color(232, 232, 233);
private final CardLayout cardLayout = new CardLayout(); private final CardLayout cardLayout = new CardLayout();
private final JPanel resultPane = new JPanel(cardLayout); private final JPanel resultPane = new JPanel(cardLayout);
@ -125,6 +128,12 @@ public class AlphaFineFrame extends JFrame {
private AlphaFineList searchResultList; private AlphaFineList searchResultList;
private SearchLoadingPane searchLoadingPane;
private JPanel searchTextFieldWrapperPane;
private UILabel clearLabel;
private CellType selectedType; private CellType selectedType;
private String beforeSearchStr = StringUtils.EMPTY; private String beforeSearchStr = StringUtils.EMPTY;
@ -229,7 +238,7 @@ public class AlphaFineFrame extends JFrame {
topRightPane.setBackground(Color.WHITE); topRightPane.setBackground(Color.WHITE);
JPanel tipPane = new JPanel(new BorderLayout()); JPanel tipPane = new JPanel(new BorderLayout());
tipPane.setBackground(Color.WHITE); tipPane.setBackground(Color.WHITE);
String toolTip = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Short_Cut", DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortcuts()); String toolTip = AlphaFineShortCutUtil.getDisplayShortCut(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Short_Cut", DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortcuts()));
tipIconLabel = new UILabel(AlphaFineConstants.BULB_ICON); tipIconLabel = new UILabel(AlphaFineConstants.BULB_ICON);
tipIconLabel.addMouseListener(tipMouseListener); tipIconLabel.addMouseListener(tipMouseListener);
tipIconLabel.setToolTipText(toolTip); tipIconLabel.setToolTipText(toolTip);
@ -268,7 +277,27 @@ public class AlphaFineFrame extends JFrame {
private JPanel createSearchPane() { private JPanel createSearchPane() {
JPanel searchPane = new JPanel(new BorderLayout()); JPanel searchPane = new JPanel(new BorderLayout());
searchPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); searchPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
searchPane.add(searchTextField, BorderLayout.CENTER); searchTextFieldWrapperPane = new JPanel(new BorderLayout()) {
@Override
protected void paintBorder(Graphics g) {
g.setColor(BORDER_COLOR);
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
}
};
searchTextFieldWrapperPane.setBorder(new UITextFieldBorder(new Insets(2, 3, 2, 3)));
searchTextFieldWrapperPane.setBackground(Color.WHITE);
searchTextFieldWrapperPane.add(searchTextField, BorderLayout.CENTER);
clearLabel = new UILabel(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/clear.svg"));
clearLabel.setVisible(false);
clearLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
searchTextField.setText(StringUtils.EMPTY);
clearLabel.setVisible(false);
}
});
searchTextFieldWrapperPane.add(clearLabel, BorderLayout.EAST);
searchPane.add(searchTextFieldWrapperPane, BorderLayout.CENTER);
JButton searchButton = new JButton(SEARCH) { JButton searchButton = new JButton(SEARCH) {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
@ -297,17 +326,18 @@ public class AlphaFineFrame extends JFrame {
private JPanel createShowPane() { private JPanel createShowPane() {
JPanel showPane = new JPanel(new BorderLayout()); JPanel showPane = new JPanel(new BorderLayout());
resultPane.add(new DefaultProductNewsPane(), CellType.PRODUCT_NEWS.getFlagStr4None()); 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 NoResultWithLinkPane(GO_FORUM, AlphaFineConstants.NO_RESULT_ICON), CellType.NO_RESULT.getFlagStr4None());
resultPane.add(new NoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.ACTION.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.FILE.getFlagStr4None());
resultPane.add(new NoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.PLUGIN.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()); resultPane.add(new HelpDocumentNoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.DOCUMENT.getFlagStr4None());
resultPane.add(new NetWorkFailedPane(this::reSearch), AlphaFineConstants.NETWORK_ERROR);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
labelPane.setBackground(Color.WHITE); labelPane.setBackground(Color.WHITE);
JPanel labelContentPane = new JPanel(new BorderLayout()); JPanel labelContentPane = new JPanel(new BorderLayout());
UILabel tabLabel = new UILabel(PRODUCT_NEWS); UILabel tabLabel = new UILabel(PRODUCT_DYNAMICS);
tabLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); tabLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
tabLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); tabLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
tabLabel.setPreferredSize(new Dimension(100, 30)); tabLabel.setPreferredSize(new Dimension(100, 30));
@ -363,7 +393,12 @@ public class AlphaFineFrame extends JFrame {
label.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8); label.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8);
} }
selectedLabel.setSelected(true); selectedLabel.setSelected(true);
tabLabel.setText(selectedLabel.getText()); // 处理产品动态 tab与下方文字展示不一致
if (ComparatorUtils.equals(selectedLabel.getText().trim(), PRODUCT_NEWS)) {
tabLabel.setText(PRODUCT_DYNAMICS);
} else {
tabLabel.setText(selectedLabel.getText());
}
readLabel.setVisible(false); readLabel.setVisible(false);
tabPane.repaint(); tabPane.repaint();
switch (selectedLabel.getCellType()) { switch (selectedLabel.getCellType()) {
@ -372,20 +407,20 @@ public class AlphaFineFrame extends JFrame {
switchType(CellType.PRODUCT_NEWS); switchType(CellType.PRODUCT_NEWS);
break; break;
case ACTION: case ACTION:
switchType(CellType.ACTION);
currentSearchWorkerManager = settingSearchWorkerManager; currentSearchWorkerManager = settingSearchWorkerManager;
switchType(CellType.ACTION);
break; break;
case FILE: case FILE:
switchType(CellType.FILE);
currentSearchWorkerManager = fileSearchWorkerManager; currentSearchWorkerManager = fileSearchWorkerManager;
switchType(CellType.FILE);
break; break;
case DOCUMENT: case DOCUMENT:
switchType(CellType.DOCUMENT);
currentSearchWorkerManager = documentWorkerManager; currentSearchWorkerManager = documentWorkerManager;
switchType(CellType.DOCUMENT);
break; break;
case PLUGIN: case PLUGIN:
switchType(CellType.PLUGIN);
currentSearchWorkerManager = pluginSearchWorkerManager; currentSearchWorkerManager = pluginSearchWorkerManager;
switchType(CellType.PLUGIN);
break; break;
} }
if (currentSearchWorkerManager != null) { if (currentSearchWorkerManager != null) {
@ -425,27 +460,61 @@ public class AlphaFineFrame extends JFrame {
} }
} }
private Map<String, String> generateMap() {
JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineConstants.ALPHA_HELP_RECOMMEND);
Map<String, String> linkMap = new LinkedHashMap<>();
for (int i = 0, len = jsonArray.size(); i < len; i++) {
JSONObject json = jsonArray.getJSONObject(i);
linkMap.put(json.getString("name"), json.getString("link"));
}
return linkMap;
}
private void switchType(CellType cellType) { private void switchType(CellType cellType) {
this.selectedType = cellType; this.selectedType = cellType;
if (StringUtils.isEmpty(searchTextField.getText())) { if (StringUtils.isEmpty(searchTextField.getText())) {
cardLayout.show(resultPane, cellType.getFlagStr4None()); cardLayout.show(resultPane, cellType.getFlagStr4None());
} else { } else {
// 当前搜索未结束 不切换loading
if (!checkSearchLoading()) {
return;
}
// 所有都搜索都结束 移除loading
if (isAllSearchOver()) {
resultPane.remove(searchLoadingPane);
}
// 网络异常
if (checkNetworkError()) {
return;
}
cardLayout.show(resultPane, cellType.getFlagStr4Result()); cardLayout.show(resultPane, cellType.getFlagStr4Result());
checkSearchResult(); checkSearchResult();
} }
} }
private boolean checkNetworkError() {
boolean networkError;
if (selectedType == CellType.PRODUCT_NEWS) {
networkError = productNewsSearchWorkerManager.isNetWorkError();
} else {
networkError = currentSearchWorkerManager.isNetWorkError();
}
cardLayout.show(resultPane, AlphaFineConstants.NETWORK_ERROR);
return networkError;
}
private boolean checkSearchLoading() {
boolean searchOver;
if (selectedType == CellType.PRODUCT_NEWS) {
searchOver = productNewsSearchWorkerManager.isSearchOver();
} else {
searchOver = currentSearchWorkerManager.isSearchOver();
}
cardLayout.show(resultPane, AlphaFineConstants.LOADING);
return searchOver;
}
private boolean isAllSearchOver() {
return productNewsSearchWorkerManager.isSearchOver()
&& pluginSearchWorkerManager.isSearchOver()
&& fileSearchWorkerManager.isSearchOver()
&& settingSearchWorkerManager.isSearchOver()
&& documentWorkerManager.isSearchOver();
}
private void checkSearchResult() { private void checkSearchResult() {
if (currentSearchWorkerManager == null) { if (currentSearchWorkerManager == null) {
return; return;
@ -473,6 +542,7 @@ public class AlphaFineFrame extends JFrame {
searchTextField.setFont(DesignUtils.getDefaultGUIFont().applySize(14)); searchTextField.setFont(DesignUtils.getDefaultGUIFont().applySize(14));
searchTextField.setBackground(Color.WHITE); searchTextField.setBackground(Color.WHITE);
searchTextField.setPreferredSize(new Dimension(300, 60)); searchTextField.setPreferredSize(new Dimension(300, 60));
searchTextField.setBorder(null);
} }
@ -482,7 +552,8 @@ public class AlphaFineFrame extends JFrame {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
// 搜索提示框 // 搜索提示框
if (StringUtils.isNotEmpty(searchTextField.getText())) { if (StringUtils.isNotEmpty(searchTextField.getText())) {
SearchTooltipPopup.getInstance().show(searchTextField); clearLabel.setVisible(true);
SearchTooltipPopup.getInstance().show(searchTextFieldWrapperPane);
} }
AlphaFineToolTipList alphaFineToolTipList = SearchTooltipPopup.getInstance().getAlphaFineToolTipList(); AlphaFineToolTipList alphaFineToolTipList = SearchTooltipPopup.getInstance().getAlphaFineToolTipList();
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
@ -507,7 +578,7 @@ public class AlphaFineFrame extends JFrame {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
if (StringUtils.isNotEmpty(searchTextField.getText())) { if (StringUtils.isNotEmpty(searchTextField.getText())) {
SearchTooltipPopup.getInstance().show(searchTextField); SearchTooltipPopup.getInstance().show(searchTextFieldWrapperPane);
} }
} }
@ -531,7 +602,7 @@ public class AlphaFineFrame extends JFrame {
switchType(selectedType); switchType(selectedType);
} }
else if (searchTextField.hasFocus()) { else if (searchTextField.hasFocus()) {
SearchTooltipPopup.getInstance().show(searchTextField); SearchTooltipPopup.getInstance().show(searchTextFieldWrapperPane);
} }
}); });
@ -593,6 +664,7 @@ public class AlphaFineFrame extends JFrame {
private void doSearch(String text) { private void doSearch(String text) {
initSearchLoadingPane();
SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult); SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult);
this.productNewsSearchWorkerManager.doSearch(searchTextBean); this.productNewsSearchWorkerManager.doSearch(searchTextBean);
this.settingSearchWorkerManager.doSearch(searchTextBean); this.settingSearchWorkerManager.doSearch(searchTextBean);
@ -601,6 +673,34 @@ public class AlphaFineFrame extends JFrame {
this.pluginSearchWorkerManager.doSearch(searchTextBean); this.pluginSearchWorkerManager.doSearch(searchTextBean);
} }
/**
* 仅搜索依赖网络的搜索项
*
*/
private void reSearch() {
String text = this.searchTextField.getText().toLowerCase();
if (StringUtils.isEmpty(text)) {
return;
}
searchLoadingPane = new SearchLoadingPane();
SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult);
this.productNewsSearchWorkerManager.doSearch(searchTextBean);
this.documentWorkerManager.doSearch(searchTextBean);
this.pluginSearchWorkerManager.doSearch(searchTextBean);
}
private void initSearchLoadingPane() {
if (searchLoadingPane == null) {
searchLoadingPane = new SearchLoadingPane();
}
resultPane.add(searchLoadingPane, AlphaFineConstants.LOADING);
cardLayout.show(resultPane, AlphaFineConstants.LOADING);
}
public String getSearchText() {
return searchTextField.getText();
}
public CellType getSelectedType() { public CellType getSelectedType() {
return selectedType; return selectedType;

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

@ -2,8 +2,6 @@ package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; 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.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
@ -14,11 +12,10 @@ import java.awt.RenderingHints;
*/ */
public class AlphaFineTextField extends UITextField { public class AlphaFineTextField extends UITextField {
private static final Color BORDER_COLOR = new Color(232, 232, 233); private static final int PLACE_HOLDER_GAP = 3;
private String placeHolder; private String placeHolder;
private Image image;
public AlphaFineTextField(String placeHolder) { public AlphaFineTextField(String placeHolder) {
this.placeHolder = placeHolder; this.placeHolder = placeHolder;
@ -40,21 +37,7 @@ public class AlphaFineTextField extends UITextField {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(AlphaFineConstants.FOREGROUND_COLOR_5); g2.setColor(AlphaFineConstants.FOREGROUND_COLOR_5);
g2.drawString(placeHolder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top + 6); g2.drawString(placeHolder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top + PLACE_HOLDER_GAP);
}
@Override
protected void paintBorder(Graphics g) {
g.setColor(BORDER_COLOR);
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
} }
public String getPlaceHolder() { public String getPlaceHolder() {

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

@ -1,6 +1,8 @@
package com.fr.design.mainframe.alphafine.component; package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -26,7 +28,7 @@ public class ProductNewsSearchResultPane extends JPanel {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.add(scrollPane); this.add(scrollPane);
this.setPreferredSize(new Dimension(680, 305)); this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
} }
public ProductNewsList getProductNewsList() { public ProductNewsList getProductNewsList() {

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

@ -38,7 +38,7 @@ public class SearchResultPane extends JPanel {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(leftSearchResultPane, BorderLayout.WEST); this.add(leftSearchResultPane, BorderLayout.WEST);
this.add(rightSearchResultPane, BorderLayout.EAST); this.add(rightSearchResultPane, BorderLayout.EAST);
this.setPreferredSize(new Dimension(680, 305)); this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
} }
public AlphaFineList getSearchResultList() { public AlphaFineList getSearchResultList() {

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

@ -5,6 +5,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil; import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import javax.swing.BorderFactory;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@ -19,7 +21,9 @@ public class SelectedLabel extends UILabel {
private static final int WIDTH = 4; private static final int WIDTH = 4;
private static final int HEIGHT = 4; private static final int HEIGHT = 4;
private static final int GAP = 2; private static final int GAP = 0;
private static final int BORDER_RIGHT = 5;
private static final int BORDER_TOP = 2;
private boolean selected; private boolean selected;
private CellType cellType; private CellType cellType;
@ -27,6 +31,7 @@ public class SelectedLabel extends UILabel {
public SelectedLabel(String text, CellType cellType, boolean selected) { public SelectedLabel(String text, CellType cellType, boolean selected) {
super(text); super(text);
this.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8); this.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8);
this.setBorder(BorderFactory.createEmptyBorder(BORDER_TOP, 0, 0, BORDER_RIGHT));
this.selected = selected; this.selected = selected;
this.cellType = cellType; this.cellType = cellType;
} }
@ -43,20 +48,25 @@ public class SelectedLabel extends UILabel {
if (selected) { if (selected) {
g2d.setColor(UIConstants.FLESH_BLUE); g2d.setColor(UIConstants.FLESH_BLUE);
setForeground(UIConstants.FLESH_BLUE); setForeground(UIConstants.FLESH_BLUE);
g2d.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1); g2d.drawLine(0, this.getHeight() - 1, this.getWidth() - BORDER_RIGHT, this.getHeight() - 1);
} }
super.paintComponent(g);
}
@Override
protected void paintBorder(Graphics g) {
super.paintBorder(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (cellType == CellType.PRODUCT_NEWS && AlphaFineUtil.unread()) { if (cellType == CellType.PRODUCT_NEWS && AlphaFineUtil.unread()) {
Color oldColor = g.getColor(); Color oldColor = g.getColor();
g2d.setColor(Color.RED); g2d.setColor(Color.RED);
g2d.fillOval(getWidth() - WIDTH, GAP, WIDTH, HEIGHT); g2d.fillOval(getWidth() - WIDTH, GAP, WIDTH, HEIGHT);
g2d.setColor(oldColor); g2d.setColor(oldColor);
} }
super.paintComponent(g);
} }
public boolean isSelected() { public boolean isSelected() {
return selected; return selected;
} }

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

@ -0,0 +1,14 @@
package com.fr.design.mainframe.alphafine.exception;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/27
*/
public class AlphaFineNetworkException extends RuntimeException {
public AlphaFineNetworkException() {
super("NetWork Error");
}
}

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

@ -3,18 +3,21 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.component.ProductNewsContentCellRender; import com.fr.design.mainframe.alphafine.component.ProductNewsContentCellRender;
import com.fr.design.mainframe.alphafine.component.ProductNewsList; import com.fr.design.mainframe.alphafine.component.ProductNewsList;
import com.fr.design.mainframe.alphafine.exception.AlphaFineNetworkException;
import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.util.List; import java.util.List;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
@ -27,39 +30,78 @@ public class DefaultProductNewsPane extends JPanel {
private static final String LOADING = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Loading"); private static final String LOADING = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Loading");
private static final ImageIcon LOADING_ICON = new ImageIcon(DefaultProductNewsPane.class.getResource("/com/fr/web/images/loading-local.gif"));
private SwingWorker<List<ProductNews>, Void> worker;
public DefaultProductNewsPane() { public DefaultProductNewsPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
this.add(createLoadingPane());
this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
this.worker = createWorker();
this.worker.execute();
}
private JPanel createLoadingPane() {
JPanel loadingPane = new JPanel(new BorderLayout()); JPanel loadingPane = new JPanel(new BorderLayout());
loadingPane.setBorder(BorderFactory.createEmptyBorder(0, 280, 0, 0)); UILabel loadingLabel = new UILabel(LOADING);
loadingPane.add(new UILabel(LOADING)); loadingLabel.setForeground(AlphaFineConstants.MEDIUM_GRAY);
loadingLabel.setFont(DesignUtils.getDefaultGUIFont().applySize(14));
loadingLabel.setBorder(BorderFactory.createEmptyBorder(0, 280, 0, 0));
UILabel loadingIconLabel = new UILabel(LOADING_ICON);
loadingIconLabel.setBorder(BorderFactory.createEmptyBorder(100, 0, 0, 0));
loadingPane.add(loadingIconLabel, BorderLayout.NORTH);
loadingPane.add(loadingLabel, BorderLayout.CENTER);
loadingPane.setBackground(Color.WHITE); loadingPane.setBackground(Color.WHITE);
return loadingPane;
}
this.add(loadingPane); private SwingWorker<List<ProductNews>, Void> createWorker() {
this.setPreferredSize(new Dimension(680, 305)); if (this.worker != null && !this.worker.isDone()) {
new SwingWorker<List<ProductNews>, Void>() { this.worker.cancel(true);
this.worker = null;
}
return new SwingWorker<List<ProductNews>, Void>() {
@Override @Override
protected List<ProductNews> doInBackground() throws Exception { protected List<ProductNews> doInBackground() throws Exception {
if (!AlphaFineHelper.isNetworkOk()) {
throw new AlphaFineNetworkException();
}
return ProductNewsSearchManager.getInstance().getProductNewsList(); return ProductNewsSearchManager.getInstance().getProductNewsList();
} }
@Override @Override
protected void done() { protected void done() {
DefaultProductNewsPane.this.remove(loadingPane); DefaultProductNewsPane.this.removeAll();
try { try {
DefaultProductNewsPane.this.add(createContentPane(get())); DefaultProductNewsPane.this.add(createContentPane(get()));
DefaultProductNewsPane.this.validate();
DefaultProductNewsPane.this.repaint();
AlphaFineHelper.getAlphaFineDialog().repaint();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (e.getCause() instanceof AlphaFineNetworkException) {
DefaultProductNewsPane.this.add(new NetWorkFailedPane(() -> {
DefaultProductNewsPane.this.removeAll();
add(createLoadingPane());
refresh();
worker = createWorker();
worker.execute();
}));
}
} }
refresh();
} }
}.execute(); };
}
private void refresh() {
this.validate();
this.repaint();
if (AlphaFineHelper.getAlphaFineDialog() != null) {
AlphaFineHelper.getAlphaFineDialog().repaint();
}
} }
private UIScrollPane createContentPane(List<ProductNews> productNewsList) { private UIScrollPane createContentPane(List<ProductNews> productNewsList) {

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

@ -3,20 +3,30 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
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.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
/** /**
* @author hades * @author hades
@ -29,11 +39,71 @@ public class HelpDocumentNoResultPane extends JPanel {
private static final Color DOT_COLOR = new Color(200, 201, 205); private static final Color DOT_COLOR = new Color(200, 201, 205);
public HelpDocumentNoResultPane(String title, Icon icon, Map<String, String> linkMap) { private SwingWorker<Boolean, Void> worker;
private String title;
private Icon icon;
private Map<String, String> linkMap;
public HelpDocumentNoResultPane(String title, Icon icon) {
this.title = title;
this.icon = icon;
this.linkMap = generateMap();
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(new NoResultPane(title, icon, 150), BorderLayout.CENTER); worker = createWorker();
add(createRecommendPane(linkMap), BorderLayout.EAST); worker.execute();
}
private SwingWorker<Boolean, Void> createWorker() {
if (this.worker != null && !this.worker.isDone()) {
this.worker.cancel(true);
this.worker = null;
}
return new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
return AlphaFineHelper.isNetworkOk();
}
@Override
protected void done() {
HelpDocumentNoResultPane.this.removeAll();
try {
if (get()) {
add(new NoResultPane(title, icon, 150), BorderLayout.CENTER);
add(createRecommendPane(linkMap), BorderLayout.EAST);
} else {
add(new NetWorkFailedPane(() -> {
worker = createWorker();
worker.execute();
}));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
refresh();
}
};
}
private void refresh() {
this.validate();
this.repaint();
}
private Map<String, String> generateMap() {
JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineConstants.ALPHA_HELP_RECOMMEND);
Map<String, String> linkMap = new LinkedHashMap<>();
for (int i = 0, len = jsonArray.size(); i < len; i++) {
JSONObject json = jsonArray.getJSONObject(i);
linkMap.put(json.getString("name"), json.getString("link"));
}
return linkMap;
} }
private JPanel createRecommendPane(Map<String, String> linkMap) { private JPanel createRecommendPane(Map<String, String> linkMap) {

69
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.FlowLayout;
import java.awt.event.MouseEvent;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/4/28
*/
public class NetWorkFailedPane extends JPanel {
private Runnable reload;
public NetWorkFailedPane() {
this(() -> {});
}
public NetWorkFailedPane(Runnable reload) {
this.reload = reload;
this.setLayout(new BorderLayout());
this.add(createInternetErrorPane());
this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
this.setBackground(Color.WHITE);
}
private JPanel createInternetErrorPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5);
panel.setBackground(Color.WHITE);
UILabel imagePanel = new UILabel(IOUtils.readIcon("/com/fr/base/images/share/internet_error.png"));
imagePanel.setBorder(BorderFactory.createEmptyBorder(50, 280, 0, 0));
panel.add(imagePanel);
UILabel uiLabel = tipLabel(Toolkit.i18nText("Fine-Design_Share_Internet_Connect_Failed"));
uiLabel.setBorder(BorderFactory.createEmptyBorder(0, 300, 0, 0));
uiLabel.setForeground(Color.decode("#8F8F92"));
UILabel reloadLabel = tipLabel(Toolkit.i18nText("Fine-Design_Share_Online_Reload"));
reloadLabel.setBorder(BorderFactory.createEmptyBorder(0, 310, 0, 0));
reloadLabel.setForeground(Color.decode("#419BF9"));
reloadLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
reloadLabel.addMouseListener(new MouseClickListener() {
@Override
public void mousePressed(MouseEvent e) {
reload.run();
}
});
panel.add(uiLabel);
panel.add(reloadLabel);
return panel;
}
private UILabel tipLabel(String text) {
UILabel tipLabel = new UILabel(text);
tipLabel.setHorizontalAlignment(SwingConstants.CENTER);
return tipLabel;
}
}

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

@ -1,6 +1,12 @@
package com.fr.design.mainframe.alphafine.preview; package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JPanel; import javax.swing.JPanel;
/** /**
@ -10,9 +16,12 @@ import javax.swing.JPanel;
*/ */
public class SearchLoadingPane extends JPanel { public class SearchLoadingPane extends JPanel {
private static final ImageIcon LOADING_ICON = new ImageIcon(SearchLoadingPane.class.getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"));
public SearchLoadingPane() { public SearchLoadingPane() {
setLayout(new BorderLayout());
this.add(new UILabel(LOADING_ICON));
this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
} }

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

@ -38,9 +38,8 @@ public class QuestionPane extends JPanel {
g2.drawImage(NEW_MESSAGE_IMAGE, 0, 0, getWidth(), getHeight(), this); g2.drawImage(NEW_MESSAGE_IMAGE, 0, 0, getWidth(), getHeight(), this);
} else { } else {
g2.drawImage(QUESTION_BACKGROUND_IMAGE, 0, 0, getWidth(), getHeight(), this); 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);
} }
g2.drawImage(QUESTION_IMAGE, (getWidth() - QUESTION_IMAGE.getWidth(this)) / 2, (getHeight() - QUESTION_IMAGE.getHeight(this)) / 2, this);
} }

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

@ -59,7 +59,7 @@ public class QuestionWindow extends JWindow {
} }
}); });
this.getLayeredPane().setToolTipText(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Learn_More_About")); questionPane.setToolTipText(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Learn_More_About"));
this.setContentPane(questionPane); this.setContentPane(questionPane);
this.setSize(new Dimension(40, 40)); this.setSize(new Dimension(40, 40));
// 这个地方可以设置alwaysOnTop 弹窗会跟随主页面失去激活状态而隐藏 不会与其他弹窗冲突 // 这个地方可以设置alwaysOnTop 弹窗会跟随主页面失去激活状态而隐藏 不会与其他弹窗冲突

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

@ -1,5 +1,7 @@
package com.fr.design.mainframe.alphafine.search; package com.fr.design.mainframe.alphafine.search;
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.CellType;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame; import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.component.ProductNewsSearchResultPane; import com.fr.design.mainframe.alphafine.component.ProductNewsSearchResultPane;
@ -29,6 +31,10 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
private volatile boolean hasSearchResult = true; private volatile boolean hasSearchResult = true;
private volatile boolean searchOver = false;
private volatile boolean networkError = false;
public ProductNewsSearchWorkerManager(CellType cellType, Function<SearchTextBean, List<ProductNews>> searchFunction, AlphaFineFrame alphaFineFrame) { public ProductNewsSearchWorkerManager(CellType cellType, Function<SearchTextBean, List<ProductNews>> searchFunction, AlphaFineFrame alphaFineFrame) {
this.cellType = cellType; this.cellType = cellType;
this.searchFunction = searchFunction; this.searchFunction = searchFunction;
@ -40,7 +46,8 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
@Override @Override
public void doSearch(SearchTextBean searchTextBean) { public void doSearch(SearchTextBean searchTextBean) {
checkSearchWork(); checkSearchWork();
searchOver = false;
networkError = false;
if (searchResultPane == null) { if (searchResultPane == null) {
searchResultPane = new ProductNewsSearchResultPane(searchTextBean.getSegmentation()); searchResultPane = new ProductNewsSearchResultPane(searchTextBean.getSegmentation());
alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result()); alphaFineFrame.addResult(searchResultPane, cellType.getFlagStr4Result());
@ -49,8 +56,13 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
this.searchWorker = new SwingWorker<DefaultListModel<ProductNews>, Void>() { this.searchWorker = new SwingWorker<DefaultListModel<ProductNews>, Void>() {
@Override @Override
protected DefaultListModel<ProductNews> doInBackground() throws Exception { protected DefaultListModel<ProductNews> doInBackground() throws Exception {
List<ProductNews> productNewsList = searchFunction.apply(searchTextBean);
DefaultListModel<ProductNews> productNewsDefaultListModel = new DefaultListModel<>(); DefaultListModel<ProductNews> productNewsDefaultListModel = new DefaultListModel<>();
if (!AlphaFineHelper.isNetworkOk() && cellType.isNeedNetWork()) {
networkError = true;
FineLoggerFactory.getLogger().warn("alphaFine network error");
return productNewsDefaultListModel;
}
List<ProductNews> productNewsList = searchFunction.apply(searchTextBean);
for (ProductNews productNews : productNewsList) { for (ProductNews productNews : productNewsList) {
productNewsDefaultListModel.addElement(productNews); productNewsDefaultListModel.addElement(productNews);
} }
@ -59,8 +71,13 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
@Override @Override
protected void done() { protected void done() {
searchOver = true;
if (!isCancelled()) { if (!isCancelled()) {
try { try {
if (networkError) {
alphaFineFrame.showResult(AlphaFineConstants.NETWORK_ERROR);
return;
}
DefaultListModel<ProductNews> productNewsDefaultListModel = get(); DefaultListModel<ProductNews> productNewsDefaultListModel = get();
hasSearchResult = !productNewsDefaultListModel.isEmpty(); hasSearchResult = !productNewsDefaultListModel.isEmpty();
searchResultPane.getProductNewsList().setModel(get()); searchResultPane.getProductNewsList().setModel(get());
@ -90,6 +107,11 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
return hasSearchResult; return hasSearchResult;
} }
@Override
public boolean isSearchOver() {
return searchOver;
}
private void checkSearchWork() { private void checkSearchWork() {
if (this.searchWorker != null && !this.searchWorker.isDone()) { if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true); this.searchWorker.cancel(true);
@ -97,4 +119,8 @@ public class ProductNewsSearchWorkerManager implements SearchManager {
} }
} }
@Override
public boolean isNetWorkError() {
return networkError;
}
} }

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

@ -10,4 +10,8 @@ public interface SearchManager {
void doSearch(SearchTextBean searchTextBean); void doSearch(SearchTextBean searchTextBean);
boolean hasSearchResult(); boolean hasSearchResult();
boolean isSearchOver();
boolean isNetWorkError();
} }

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.alphafine.search; package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
@ -35,6 +36,9 @@ public class SearchWorkerManager implements SearchManager {
private volatile boolean hasSearchResult = true; private volatile boolean hasSearchResult = true;
private volatile boolean searchOver = false;
private volatile boolean networkError = false;
public SearchWorkerManager(CellType cellType, Function<SearchTextBean, SearchResult> function, AlphaFineFrame alphaFineFrame, ResultShowPane resultShowPane) { public SearchWorkerManager(CellType cellType, Function<SearchTextBean, SearchResult> function, AlphaFineFrame alphaFineFrame, ResultShowPane resultShowPane) {
this.cellType = cellType; this.cellType = cellType;
@ -59,11 +63,18 @@ public class SearchWorkerManager implements SearchManager {
} }
private void initSearchWorker(SearchTextBean searchTextBean) { private void initSearchWorker(SearchTextBean searchTextBean) {
this.searchOver = false;
this.networkError = false;
this.searchWorker = new SwingWorker<SearchListModel, Void>() { this.searchWorker = new SwingWorker<SearchListModel, Void>() {
@Override @Override
protected SearchListModel doInBackground() throws Exception { protected SearchListModel doInBackground() throws Exception {
SearchResult searchResult = searchResultFunction.apply(searchTextBean);
SearchListModel searchListModel = new SearchListModel(new SearchResult(), searchResultPane.getSearchResultList(), searchResultPane.getLeftSearchResultPane()); SearchListModel searchListModel = new SearchListModel(new SearchResult(), searchResultPane.getSearchResultList(), searchResultPane.getLeftSearchResultPane());
if (!AlphaFineHelper.isNetworkOk() && cellType.isNeedNetWork()) {
networkError = true;
FineLoggerFactory.getLogger().warn("alphaFine network error");
return searchListModel;
}
SearchResult searchResult = searchResultFunction.apply(searchTextBean);
for (AlphaCellModel object : searchResult) { for (AlphaCellModel object : searchResult) {
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
searchListModel.addElement(object); searchListModel.addElement(object);
@ -73,8 +84,13 @@ public class SearchWorkerManager implements SearchManager {
@Override @Override
protected void done() { protected void done() {
searchOver = true;
if (!isCancelled()) { if (!isCancelled()) {
try { try {
if (networkError) {
alphaFineFrame.showResult(AlphaFineConstants.NETWORK_ERROR);
return;
}
SearchListModel searchListModel = get(); SearchListModel searchListModel = get();
hasSearchResult = !searchListModel.isEmpty(); hasSearchResult = !searchListModel.isEmpty();
searchResultPane.getSearchResultList().setModel(get()); searchResultPane.getSearchResultList().setModel(get());
@ -108,6 +124,16 @@ public class SearchWorkerManager implements SearchManager {
return hasSearchResult; return hasSearchResult;
} }
@Override
public boolean isSearchOver() {
return searchOver;
}
@Override
public boolean isNetWorkError() {
return networkError;
}
@Nullable @Nullable
public AlphaFineList getSearchResultList() { public AlphaFineList getSearchResultList() {
if (searchResultPane != null) { if (searchResultPane != null) {

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

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="8" fill="#DADADD"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.2998 4.70021C11.1176 4.51797 10.8221 4.51797 10.6399 4.70021L7.99997 7.3401L5.36011 4.70024C5.17787 4.518 4.88239 4.518 4.70015 4.70024C4.5179 4.88249 4.5179 5.17796 4.70015 5.36021L7.34001 8.00007L4.70016 10.6399C4.51792 10.8222 4.51792 11.1176 4.70016 11.2999C4.88241 11.4821 5.17788 11.4821 5.36013 11.2999L7.99997 8.66003L10.6398 11.2999C10.8221 11.4822 11.1176 11.4822 11.2998 11.2999C11.4821 11.1177 11.4821 10.8222 11.2998 10.6399L8.65994 8.00007L11.2998 5.36018C11.4821 5.17794 11.4821 4.88246 11.2998 4.70021Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 736 B

Loading…
Cancel
Save