Browse Source

REPORT-82937 运营产品化二期的二期,同步到10.0

代码从11合到10
security/10.0
Link.Zhao 2 years ago
parent
commit
e00f50e3ec
  1. 45
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java
  2. 79
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  3. 126
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  4. 19
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java
  5. 229
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java
  6. 96
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java
  7. 34
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java
  8. 8
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  9. 23
      designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java
  10. 10
      designer-base/src/main/java/com/fr/design/remote/button/IconButton.java
  11. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  12. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java
  13. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java
  14. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java
  15. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java
  16. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  17. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  18. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java
  19. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  20. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  21. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  22. 58
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  23. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java
  24. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  25. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java
  26. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java
  27. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java
  28. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java
  29. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java
  30. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java
  31. 57
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java
  32. 37
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java
  33. 80
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java
  34. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java
  35. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java
  36. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java
  37. 28
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java
  38. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java
  39. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java
  40. 25
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java
  41. 55
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java
  42. 57
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java
  43. 120
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java
  44. 9
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java
  45. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java
  46. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java
  47. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java
  48. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java
  49. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java
  50. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java
  51. 9
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java
  52. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java
  53. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  54. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java
  55. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java
  56. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  57. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java
  58. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java
  59. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java
  60. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java
  61. 24
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java
  62. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java
  63. 35
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java
  64. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java
  65. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java
  66. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  67. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  68. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  69. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java
  70. 74
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  71. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java
  72. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  73. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  74. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  75. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java
  76. 22
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java
  77. 37
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg
  78. 2
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

45
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java → designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine;
package com.fr.design.actions.help.alphafine;
import com.fr.design.i18n.Toolkit;
import com.fr.general.CloudCenter;
@ -8,8 +8,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 需要从云端获取的常量单独放一起
* 每次获取的时候都去加载一次
* 云端变量统一管理
*
* @author Link
* @version 11.0
@ -17,8 +16,8 @@ import java.util.Map;
*/
public class AlphaFineCloudConstants {
private static final String PLUGIN_SEARCH_API = "plugin.searchAPI";
private static final String PLUGIN_ALL_SEARCH_API = "plugin.all.searchAPI";
private static final String AF_PLUGIN_INFO = "af.pluginInfo";
private static final String AF_REUSE_INFO = "af.reuseInfo";
private static final String AF_DOC_VIEW = "af.doc_view";
@ -47,14 +46,21 @@ public class AlphaFineCloudConstants {
private static final String LINK_URL = "link";
/**
* 插件搜索api
* 获取插件搜索api
*/
public static String getPluginSearchUrl() {
return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_SEARCH_API);
};
/**
* 帆软市场里全部插件api
*/
public static String getSearchAllPluginUrl() {
return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_ALL_SEARCH_API);
}
/**
* 插件信息api
* 获取插件信息api
*/
public static String getPluginUrl() {
return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_INFO);
@ -75,21 +81,21 @@ public class AlphaFineCloudConstants {
}
/**
* 获取文档搜索api
* 帮助文档搜索api
*/
public static String getDocumentSearchUrl() {
return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_SEARCH);
}
/**
* 文档信息api
* 帮助文档信息api
*/
public static String getDocumentInformationUrl() {
return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_INFO);
}
/**
* 插件图api
* 插件图api
*/
public static String getPluginImageUrl() {
return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_IMAGE);
@ -127,11 +133,11 @@ public class AlphaFineCloudConstants {
* 获取热门问题
*/
public static String getAlphaHotSearch() {
return CloudCenter.getInstance().acquireUrlByKind(AF_HOT_SEARCH);
return CloudCenter.getInstance().acquireUrlByKind(AF_HOT_SEARCH);
}
/**
* 跳转论坛api
* 跳转论坛url
*/
public static String getAlphaGoToForum() {
return CloudCenter.getInstance().acquireUrlByKind(AF_GO_FORUM);
@ -159,16 +165,13 @@ public class AlphaFineCloudConstants {
}
/**
* cid系统的用户组信息api
* cid系统的 用户组信息api
*/
public static String getAlphaCidUserGroupInfo() {
return CloudCenter.getInstance().acquireUrlByKind(AF_CID_USER_GROUP_INFO);
}
/**
* 获取默认推荐的帮助文档
*/
public static String getAlphaHelpRecommend() {
private static String getDefaultRecommend() {
String[][] links = new String[][]{
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Quick_Start"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_QUICK_START)},
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Report_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_REPORT_LEARNING_PATH)},
@ -185,7 +188,13 @@ public class AlphaFineCloudConstants {
jsonArray.put(map);
}
return CloudCenter.getInstance().acquireUrlByKind(AF_RECOMMEND, jsonArray.toString());
return jsonArray.toString();
}
}
/**
* 获取默认推荐帮助文档url
*/
public static String getAlphaHelpRecommend() {
return CloudCenter.getInstance().acquireUrlByKind(AF_RECOMMEND, getDefaultRecommend());
}
}

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

@ -29,6 +29,7 @@ import java.util.Stack;
*/
public class AlphaFineConfigManager implements XMLable {
public static final String COMMA = ",";
private static final long serialVersionUID = -8170289826729582122L;
private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
/**
@ -91,21 +92,24 @@ public class AlphaFineConfigManager implements XMLable {
* 是否提醒
*/
private boolean needRemind = true;
/**
* 产品动态
*/
private boolean productDynamics = true;
/**
* 模板商城是否展示
* */
*/
private boolean showTemplateShop = true;
/**
* tab页排序
* 默认排序动态模板商城帮助文档插件中心功能我的模板
*/
private String[] tabOrder;
private Map<String, String> actionSearchTextCache = new HashMap<>(8);
private String cacheBuildNO;
private static final String CONTAIN_TEMPLATE_SHOP = "isContainTemplateShop";
private static final String TAB_ORDER = "tabOrder";
/**
* key: 登录的bbs用户
@ -149,6 +153,7 @@ public class AlphaFineConfigManager implements XMLable {
this.setContainPlugin(reader.getAttrAsBoolean("isContainDocument", true));
this.setContainDocument(reader.getAttrAsBoolean("isContainDocument", true));
this.setContainRecommend(reader.getAttrAsBoolean("isContainRecommend", true));
this.setShowTemplateShop(reader.getAttrAsBoolean(CONTAIN_TEMPLATE_SHOP, true));
this.setContainAction(reader.getAttrAsBoolean("isContainAction", true));
this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true));
this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false));
@ -158,6 +163,7 @@ public class AlphaFineConfigManager implements XMLable {
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
this.setTabOrder(reader.getAttrAsString(TAB_ORDER, getDefaultTabOrder()).split(COMMA));
} else if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
readActionSearchTextCacheXML(reader);
@ -198,7 +204,7 @@ public class AlphaFineConfigManager implements XMLable {
if (ComparatorUtils.equals(reader.getTagName(), "history")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY);
tmpVal = tmpVal.replace("[", StringUtils.EMPTY).replace("]", StringUtils.EMPTY);
Stack<String> stack = new SizedStack<>(3);
String[] historyList = tmpVal.split(",");
for (String history : historyList) {
@ -222,7 +228,7 @@ public class AlphaFineConfigManager implements XMLable {
if (ComparatorUtils.equals(reader.getTagName(), "readId")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY);
tmpVal = tmpVal.replace("[", StringUtils.EMPTY).replace("]", StringUtils.EMPTY);
String[] idArr = tmpVal.split(",");
Set<Long> setId = new HashSet<>();
for (String id : idArr) {
@ -254,7 +260,9 @@ public class AlphaFineConfigManager implements XMLable {
.attr("operateCount", this.getOperateCount())
.attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService())
.attr("productDynamics", this.isProductDynamics());
.attr("productDynamics", this.isProductDynamics())
.attr(CONTAIN_TEMPLATE_SHOP, this.showTemplateShop)
.attr(TAB_ORDER, this.getTabOrderString());
writeActionSearchTextCacheXML(writer);
writeSearchHistory(writer);
writeReadSet(writer);
@ -317,6 +325,13 @@ public class AlphaFineConfigManager implements XMLable {
return OperatingSystem.isMacOS() ? "meta + D" : "ctrl + D";
}
/**
* 返回默认排序
*/
private String getDefaultTabOrder() {
return AlphaFineConstants.PRODUCT_NEWS + COMMA + AlphaFineConstants.TEMPLATE_SHOP + COMMA + AlphaFineConstants.HELP + COMMA + AlphaFineConstants.PLUGIN + COMMA + AlphaFineConstants.FUNCTION + COMMA + AlphaFineConstants.MY_TEMPLATES;
}
public boolean isContainAction() {
return containAction;
}
@ -333,14 +348,14 @@ public class AlphaFineConfigManager implements XMLable {
this.containDocument = containDocument;
}
public void setContainMyTemplate(boolean containMyTemplate) {
this.containMyTemplate = containMyTemplate;
}
public boolean isContainMyTemplate() {
return containMyTemplate;
}
public void setContainMyTemplate(boolean containMyTemplate) {
this.containMyTemplate = containMyTemplate;
}
public boolean isContainTemplate() {
return containTemplate;
}
@ -461,9 +476,10 @@ public class AlphaFineConfigManager implements XMLable {
return productDynamics && FRContext.isChineseEnv();
}
/**
* 有无模板商城
* */
public void setProductDynamics(boolean productDynamics) {
this.productDynamics = productDynamics;
}
public boolean hasTemplateShop() {
return showTemplateShop && FRContext.isChineseEnv();
}
@ -472,7 +488,36 @@ public class AlphaFineConfigManager implements XMLable {
this.showTemplateShop = showTemplateShop;
}
public void setProductDynamics(boolean productDynamics) {
this.productDynamics = productDynamics;
/**
* 是否展示alphafine窗口设置-搜索范围 0勾选则不显示
*/
public boolean needShowAlphaFineDialog() {
return hasTemplateShop() || isContainDocument() || isContainPlugin() ||
isContainAction() || isProductDynamics() || isContainMyTemplate();
}
/**
* 返回tab显示顺序
*/
public String[] getTabOrder() {
if (tabOrder == null) {
tabOrder = getDefaultTabOrder().split(COMMA);
}
return tabOrder;
}
public void setTabOrder(String[] tabOrder) {
this.tabOrder = tabOrder;
}
/**
* getTabOrder的tostring
*/
public String getTabOrderString() {
StringBuilder sb = new StringBuilder();
for (String s : getTabOrder()) {
sb.append(s + COMMA);
}
return sb.toString();
}
}

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

@ -3,8 +3,11 @@ package com.fr.design.actions.help.alphafine;
import com.fr.base.FRContext;
import com.fr.base.svg.IconUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.component.CustomSortPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itextfield.UITextField;
@ -17,6 +20,7 @@ import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import java.awt.BorderLayout;
import java.awt.Color;
@ -30,6 +34,8 @@ 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.List;
/**
* Created by XiaXiang on 2017/4/6.
@ -39,14 +45,24 @@ public class AlphaFineConfigPane extends BasicPane {
private static final String DISPLAY_TYPE = "+";
private static final Color LABEL_TEXT = new Color(0x919193);
private static final int SEARCH_CONFIG_PANE_HEIGHT = 70;
private static final int SEARCH_CONFIG_PANE_WIDTH = 87;
private static final double COLUMN_WIDTH = 150;
private static final double ROW_HEIGHT = 25;
private KeyStroke shortCutKeyStore = null;
private UICheckBox enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox;
private UICheckBox productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox,
containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox;
containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox;
// 自定义排序按钮
private ActionLabel customSortLabel;
private UITextField shortcutsField;
// 当前tab排序。点击确定后会保存到配置文件中
private String[] currentOrder;
// 搜索范围-我的模板,相关组件
private JPanel containMyTemplatePane;
private JButton myTemplateSearchConfigButton;
@ -74,14 +90,13 @@ public class AlphaFineConfigPane extends BasicPane {
return components;
}
/**
* 搜索范围
* */
// 搜索范围
private void createSearchConfigPane(JPanel contentPane) {
double[] rowSize = {ROW_HEIGHT, ROW_HEIGHT, ROW_HEIGHT};
double[] columnSize = {COLUMN_WIDTH, COLUMN_WIDTH, COLUMN_WIDTH};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range"));
JPanel searchConfigWrapperPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range"));
// 搜索选项
productDynamicsCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News"));
containActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function"));
containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"));
@ -91,10 +106,39 @@ public class AlphaFineConfigPane extends BasicPane {
containTemplateShopCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop"));
containMyTemplateCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_My_Templates"));
JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize);
northPane.add(searchConfigPane);
contentPane.add(northPane);
// 自定义排序
JPanel customSortWrapperPane = new JPanel();
customSortWrapperPane.setPreferredSize(new Dimension(SEARCH_CONFIG_PANE_HEIGHT, SEARCH_CONFIG_PANE_WIDTH));
customSortWrapperPane.setAlignmentY(JPanel.TOP_ALIGNMENT);
customSortLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Config_Custom_Sort"), false);
customSortLabel.setForeground(UIConstants.NORMAL_BLUE);
customSortLabel.addActionListener((event)->{
if (customSortLabel.isEnabled()) {
openCustomSortMenu();
}
});
customSortWrapperPane.add(customSortLabel);
if (!hasSelectedSearchRangeCheckBox()) {
customSortLabel.setEnabled(false);
}
searchConfigWrapperPane.add(searchConfigPane);
searchConfigWrapperPane.add(customSortWrapperPane);
contentPane.add(searchConfigWrapperPane);
}
/**
* 打开自定义排序面板
* */
private void openCustomSortMenu() {
CustomSortPane customSortPane = new CustomSortPane(getSelectedSearchRangeCheckBox(), this);
JPopupMenu popupMenu = new JPopupMenu();
popupMenu.add(customSortPane);
GUICoreUtils.showPopupMenu(popupMenu, customSortLabel, 0, customSortLabel.getHeight());
}
private Component[][] initSearchRangeComponents() {
// 我的模板checkbox设置,点击后
initMyTemplateSearchPane();
@ -104,12 +148,12 @@ public class AlphaFineConfigPane extends BasicPane {
new Component[]{containPluginCheckbox, containActionCheckbox, containMyTemplatePane},
};
for (int i = 0; i < components.length; i++) {
for (int j = 0; j < components[i].length; j++) {
if (components[i][j] instanceof UICheckBox) {
UICheckBox box = (UICheckBox) components[i][j];
}
}
// 添加选项点事件,无选中选项时自定排序按钮置灰
UICheckBox[] checkBoxes = new UICheckBox[]{productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox, containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox};
for (UICheckBox box : checkBoxes) {
box.addActionListener((e)->{
customSortLabel.setEnabled(hasSelectedSearchRangeCheckBox());
});
}
return components;
}
@ -122,27 +166,39 @@ public class AlphaFineConfigPane extends BasicPane {
|| containPluginCheckbox.isSelected() || containActionCheckbox.isSelected() || containMyTemplateCheckbox.isSelected();
}
/**
* 获取当前选中的搜索范围选项
* */
private List<UICheckBox> getSelectedSearchRangeCheckBox() {
List<UICheckBox> res = new ArrayList<>();
UICheckBox[] checkBoxes = new UICheckBox[]{productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox, containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox};
for (UICheckBox c : checkBoxes) {
if (c.isSelected()) {
res.add(c);
}
}
return res;
}
/**
* 搜索范围-我的模板
*/
private void initMyTemplateSearchPane() {
containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT,4,5));
containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 5));
containMyTemplateCheckbox.setBorder(BorderFactory.createEmptyBorder());
containMyTemplateCheckbox.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (containMyTemplateCheckbox.isSelected()) {
myTemplateSearchConfigButton.setVisible(true);
} else {
myTemplateSearchConfigButton.setVisible(false);
}
}
containMyTemplateCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (containMyTemplateCheckbox.isSelected()) {
myTemplateSearchConfigButton.setVisible(true);
} else {
myTemplateSearchConfigButton.setVisible(false);
}
);
}
});
myTemplateSearchConfigButton = new JButton();
myTemplateSearchConfigButton.setBorder(BorderFactory.createEmptyBorder());
myTemplateSearchConfigButton.setMargin(new Insets(0,0,0,0));
myTemplateSearchConfigButton.setMargin(new Insets(0, 0, 0, 0));
myTemplateSearchConfigButton.setIcon(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/config.svg"));
myTemplateSearchMenu = new UIPopupMenu();
containTemplateNameSearchCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_AlphaFine_Config_Name_Search"));
@ -284,6 +340,14 @@ public class AlphaFineConfigPane extends BasicPane {
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
this.currentOrder = alphaFineConfigManager.getTabOrder().clone();
if (!hasSelectedSearchRangeCheckBox()) {
customSortLabel.setEnabled(false);
} else {
customSortLabel.setEnabled(true);
}
}
public void update() {
@ -300,6 +364,8 @@ public class AlphaFineConfigPane extends BasicPane {
alphaFineConfigManager.setContainFileContent(this.containFileContentSearchCheckbox.isSelected());
alphaFineConfigManager.setNeedSegmentationCheckbox(this.needSegmentationCheckbox.isSelected());
alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText());
alphaFineConfigManager.setTabOrder(currentOrder);
designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager);
try {
DesignerEnvManager.loadLogSetting();
@ -331,4 +397,12 @@ public class AlphaFineConfigPane extends BasicPane {
public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) {
this.containFileContentSearchCheckbox = isContainFileContentCheckbox;
}
public String[] getCurrentOrder() {
return currentOrder;
}
public void setCurrentOrder(String[] currentOrder) {
this.currentOrder = currentOrder;
}
}

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java → designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.alphafine;
package com.fr.design.actions.help.alphafine;
import com.fr.base.extension.FileExtension;
import com.fr.base.svg.IconUtils;
@ -21,6 +21,19 @@ import java.util.Set;
*/
public class AlphaFineConstants {
public static final String FUNCTION = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function");
public static final String MY_TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_My_Templates");
public static final String PRODUCT_NEWS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News");
public static final String HELP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help");
public static final String PLUGIN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon");
public static final String TEMPLATE_SHOP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop");
public static final int SHOW_SIZE = 5;
public static final int MAX_FILE_SIZE = 1000;
@ -39,7 +52,7 @@ public class AlphaFineConstants {
public static final int CONTENT_HEIGHT = 405;
public static final int CELL_HEIGHT = 32;
public static final int CELL_HEIGHT = 29;
public static final int CELL_TITLE_HEIGHT = 24;
@ -54,11 +67,9 @@ public class AlphaFineConstants {
/**
* 帮助文档搜索间隔ms api限制了1s之内只能搜索一次
*
*/
public static final long DOCUMENT_SEARCH_GAP = 1000;
public static final Dimension FULL_SIZE = new Dimension(680, 460);
public static final Dimension CONTENT_SIZE = new Dimension(680, 405);

229
designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java

@ -0,0 +1,229 @@
package com.fr.design.actions.help.alphafine.component;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.help.alphafine.AlphaFineConfigPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.plaf.PanelUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* alphafine设置 - 搜索范围 - 自定义排序 - 弹出面板
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class CustomSortPane extends JPanel {
private static final int WIDTH = 147;
private static final int ITEM_HEIGHT = 23;
private static final int GAP = 1;
private static final Color BACKGROUND_COLOR = new Color(0xdadadd);
private UIButton top;
private UIButton bottom;
private UIButton up;
private UIButton down;
private JPanel toolbarPane;
private MenuLabelPane sortItemPane;
private List<UICheckBox> sortItems;
private MenuLabel selectedLabel;
private AlphaFineConfigPane parentPane;
public CustomSortPane(List<UICheckBox> items, AlphaFineConfigPane parentPane) {
this.sortItems = items;
this.parentPane = parentPane;
setLayout(new BorderLayout(GAP, GAP));
int height = (sortItems.size() + 1) * (ITEM_HEIGHT + GAP) + GAP;
setPreferredSize(new Dimension(WIDTH, height));
initComponent();
add(toolbarPane, BorderLayout.NORTH);
add(sortItemPane, BorderLayout.CENTER);
revalidate();
this.setVisible(true);
}
@Override
public void setUI(PanelUI ui) {
super.setUI(ui);
setBackground(BACKGROUND_COLOR);
}
private void initComponent() {
createToolbarPane();
createSortItemPane();
}
private void createToolbarPane() {
top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg"), false);
bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg"), false);
up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg"), false);
down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg"), false);
top.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top_disable.svg"));
bottom.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom_disable.svg"));
up.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up_disable.svg"));
down.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down_disable.svg"));
top.addActionListener(e -> {
SwingUtilities.invokeLater(() -> {
sortItemPane.setComponentZOrder(selectedLabel, 0);
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount());
CustomSortPane.this.revalidate();
CustomSortPane.this.repaint();
refreshCurrentOrder();
});
});
bottom.addActionListener(e -> {
SwingUtilities.invokeLater(() -> {
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentCount() - 1);
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount());
CustomSortPane.this.revalidate();
CustomSortPane.this.repaint();
refreshCurrentOrder();
});
});
up.addActionListener(e -> {
SwingUtilities.invokeLater(() -> {
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) - 1);
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount());
CustomSortPane.this.revalidate();
CustomSortPane.this.repaint();
refreshCurrentOrder();
});
});
down.addActionListener(e -> {
SwingUtilities.invokeLater(() -> {
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) + 1);
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount());
CustomSortPane.this.revalidate();
CustomSortPane.this.repaint();
refreshCurrentOrder();
});
});
toolbarPane = new JPanel(new FlowLayout(FlowLayout.TRAILING, GAP, GAP));
toolbarPane.setBorder(BorderFactory.createEmptyBorder());
toolbarPane.add(top);
toolbarPane.add(bottom);
toolbarPane.add(up);
toolbarPane.add(down);
}
private void createSortItemPane() {
String[] currentTabOrder = parentPane.getCurrentOrder();
Map<String, Integer> sortMap = new HashMap<>();
for (int i = 0; i < currentTabOrder.length; i++) {
sortMap.put(currentTabOrder[i], i);
}
List<MenuLabel> sortLabels = new ArrayList<>();
for (UICheckBox item : sortItems) {
MenuLabel label = new MenuLabel(item.getText(), (Function<MenuLabel, Object>) o -> {
selectedLabel = o;
disableButton();
return null;
});
sortLabels.add(label);
}
sortLabels.sort(Comparator.comparingInt(tab -> sortMap.get(tab.getText())));
sortItemPane = new MenuLabelPane(sortLabels);
}
/**
* 如果选中第一个和最后一个则置灰向上和向下的按钮
*/
private void disableButton() {
int order = sortItemPane.getComponentZOrder(selectedLabel);
if (order == 0) {
setToolbarEnable(false, false, true, true);
} else if (order == sortItemPane.getComponentCount() - 1) {
setToolbarEnable(true, true, false, false);
} else {
setToolbarEnable(true, true, true, true);
}
}
/**
* 设置 置顶上移下移置底 按钮的状态
* true启用
* false关闭
*/
private void setToolbarEnable(boolean top, boolean up, boolean down, boolean bottom) {
this.top.setEnabled(top);
this.up.setEnabled(up);
this.down.setEnabled(down);
this.bottom.setEnabled(bottom);
}
/**
* 根据选项当前位置以及菜单大小设置 置顶上移下移置底 按钮的状态
*/
private void setToolbarEnable(int order, int maxOrder) {
this.top.setEnabled(true);
this.up.setEnabled(true);
this.down.setEnabled(true);
this.bottom.setEnabled(true);
// 选项处于顶端,则置灰上移和置顶按钮
if (order == 0) {
this.top.setEnabled(false);
this.up.setEnabled(false);
}
// 选项处于底端,则置灰下移和置底按钮
if (order == maxOrder - 1) {
this.down.setEnabled(false);
this.bottom.setEnabled(false);
}
}
private void refreshCurrentOrder() {
String[] currentTabOrder = parentPane.getCurrentOrder();
HashSet<String> selectedTab = new HashSet<>();
for (UICheckBox item : sortItems) {
selectedTab.add(item.getText());
}
// 未选中的tab,保持原排序不变
Map<String, Integer> exTab = new HashMap<>();
for (int i = 0; i < currentTabOrder.length; i++) {
if (!selectedTab.contains(currentTabOrder[i])) {
exTab.put(currentTabOrder[i], i);
}
}
// 计算当前排序
String[] newOrder = new String[currentTabOrder.length];
Component[] components = sortItemPane.getComponents();
for (String s : exTab.keySet()) {
newOrder[exTab.get(s)] = s;
}
int t = 0;
for (int i = 0; i < newOrder.length; i++) {
if (StringUtils.isEmpty(newOrder[i])) {
newOrder[i] = ((MenuLabel) components[t++]).getText();
}
}
parentPane.setCurrentOrder(newOrder);
}
}

96
designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java

@ -0,0 +1,96 @@
package com.fr.design.actions.help.alphafine.component;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils;
import javax.swing.BorderFactory;
import javax.swing.plaf.LabelUI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.function.Function;
/**
* 菜单选项label
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class MenuLabel extends UILabel {
private static final Color BACKGROUND_COLOR = Color.white;
private static final Color SELECTED_COLOR = new Color(0x419BF9);
private static final Color HOVERED_COLOR = new Color(0xd9ebfe);
private static final int HEIGHT = 23;
private static final int WIDTH = 147;
private MenuLabelPane parentMenu;
private final Function function;
private boolean selected;
public MenuLabel(String text, Function function) {
super(text);
this.function = function;
setOpaque(true);
addMouseListener(createMouseListener());
}
public void setParentMenu(MenuLabelPane menu) {
this.parentMenu = menu;
}
@Override
public void setUI(LabelUI ui) {
super.setUI(ui);
this.setBackground(BACKGROUND_COLOR);
this.setBorder(BorderFactory.createEmptyBorder(2, 10, 1, 10));
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setFont(DesignUtils.getDefaultGUIFont().applySize(12));
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
if (selected) {
parentMenu.setNoneSelected();
setBackground(SELECTED_COLOR);
function.apply(this);
this.selected = true;
} else {
setBackground(BACKGROUND_COLOR);
this.selected = false;
}
}
MouseListener createMouseListener() {
return new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
setSelected(true);
}
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
if (!selected) {
setBackground(HOVERED_COLOR);
}
}
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
if (!selected) {
setBackground(BACKGROUND_COLOR);
}
}
};
}
}

34
designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java

@ -0,0 +1,34 @@
package com.fr.design.actions.help.alphafine.component;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import java.util.List;
/**
* 简单菜单面板
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class MenuLabelPane extends JPanel {
private static final int GAP = 1;
private List<MenuLabel> labels;
public MenuLabelPane(List<MenuLabel> labels) {
this.labels = labels;
setLayout(new FlowLayout(FlowLayout.CENTER, GAP, GAP));
for (MenuLabel label : labels) {
label.setParentMenu(this);
add(label);
}
}
public void setNoneSelected() {
for (MenuLabel label : labels) {
label.setSelected(false);
}
}
}

8
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java

@ -61,6 +61,14 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
init();
}
public UIButton(Icon icon, boolean decorate) {
this(icon);
if (!decorate) {
setContentAreaFilled(false);
setFocusPainted(false);
setBorderPainted(false);
}
}
public UIButton(Icon icon) {
super(icon);

23
designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java

@ -14,9 +14,16 @@ import java.awt.event.MouseEvent;
public class ActionLabel extends UILabel {
private ActionListener actionListener;
private Color color;
// 文字是否有下划线
private boolean drawUnderLine = true;
public ActionLabel(String text) {
this(text, Color.blue);
this(text, Color.blue);
}
public ActionLabel(String text, boolean drawUnderLine) {
this(text, Color.blue);
this.drawUnderLine = drawUnderLine;
}
public ActionLabel(String text, Color color) {
@ -39,7 +46,9 @@ public class ActionLabel extends UILabel {
super.paintComponent(_gfx);
_gfx.setColor(this.color);
_gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
if (drawUnderLine) {
_gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
}
}
private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() {
@ -95,4 +104,12 @@ public class ActionLabel extends UILabel {
}
}
};
}
public boolean isDrawUnderLine() {
return drawUnderLine;
}
public void setDrawUnderLine(boolean drawUnderLine) {
this.drawUnderLine = drawUnderLine;
}
}

10
designer-base/src/main/java/com/fr/design/remote/button/IconButton.java

@ -4,6 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@ -15,14 +16,19 @@ import java.awt.Graphics2D;
import java.awt.Point;
public final class IconButton extends JButton {
public IconButton() {
public IconButton(Icon icon) {
super(StringUtils.EMPTY);
setContentAreaFilled(false);
setFocusPainted(false);
setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_tab_close_normal.png"));
setIcon(icon);
setBorder(null);
}
public IconButton() {
this(BaseUtils.readIcon("com/fr/design/remote/images/icon_tab_close_normal.png"));
}
@Override
protected void paintBorder(Graphics g) {
}

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

@ -58,7 +58,7 @@ public class AlphaFineHelper {
* 弹出alphafine搜索面板
*/
public static void showAlphaFineDialog(boolean forceOpen) {
if (!AlphaFineConfigManager.isALPHALicAvailable()) {
if (!AlphaFineConfigManager.isALPHALicAvailable() || !AlphaFineConfigManager.getInstance().needShowAlphaFineDialog()) {
return;
}
if (alphaFineDialog == null) {

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;

8
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java

@ -75,7 +75,7 @@ public class StartUseAction implements ActionListener {
File fileNeedOpen = new File(fileName);
if (fileName.endsWith(FineMarketConstants.ZIP)) {
File[] files = fileNeedOpen.getParentFile().listFiles();
fileNeedOpen = getFirstCptOrFrm(files);
fileNeedOpen = getFirstTemplate(files);
} else if (fileName.endsWith(FineMarketConstants.RAR)) {
// rar资源没有解压,所以不用打开模板
return;
@ -91,9 +91,11 @@ public class StartUseAction implements ActionListener {
}
private File getFirstCptOrFrm(File[] files) {
private File getFirstTemplate(File[] files) {
for (File f : files) {
if (f.getName().endsWith(FineMarketConstants.CPT) || f.getName().endsWith(FineMarketConstants.FRM)) {
if (f.getName().endsWith(FineMarketConstants.CPT) ||
f.getName().endsWith(FineMarketConstants.FRM) ||
f.getName().endsWith(FineMarketConstants.FVS)) {
return f;
}
}

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

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;

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

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;

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

@ -1,11 +1,10 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
/**
* Created by XiaXiang on 2017/4/20.
@ -98,8 +97,7 @@ public class PluginModel extends AlphaCellModel {
@Override
public void doAction() {
if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) {
if (StringUtils.isBlank(this.pluginId) && StringUtils.isBlank(this.getName())) {
return;
}
openPluginStore(getName());

8
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java

@ -1,7 +1,8 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.base.login.ClientHelper;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException;
@ -46,8 +47,9 @@ public class RobotModel extends AlphaCellModel {
}
public static String getContent(String titleStr) {
String encodedTitleStr = ClientHelper.urlEncode(titleStr, EncodeConstants.ENCODING_UTF_8);
String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr);
String url = AlphaFineCloudConstants.getAlphaGoToWeb() + titleStr + "&token=" + token;
String url = AlphaFineCloudConstants.getAlphaGoToWeb() + encodedTitleStr + "&token=" + token;
try {
String result = HttpToolbox.get(url);

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.BottomModel;
import javax.swing.*;

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.cell.render;
import com.bulenkov.iconloader.IconLoader;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.BottomModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import javax.swing.*;

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

@ -2,13 +2,13 @@ package com.fr.design.mainframe.alphafine.component;
import com.bulenkov.iconloader.IconLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
@ -40,10 +40,10 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
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 javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;

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

@ -4,16 +4,18 @@ 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.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineShortCutUtil;
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.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.DefaultContentPane;
import com.fr.design.mainframe.alphafine.preview.DefaultPluginContentPane;
import com.fr.design.mainframe.alphafine.preview.DefaultProductNewsPane;
import com.fr.design.mainframe.alphafine.preview.HelpDocumentNoResultPane;
import com.fr.design.mainframe.alphafine.preview.LoadingRightSearchResultPane;
@ -72,7 +74,10 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -102,8 +107,6 @@ public class AlphaFineFrame extends JFrame {
private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine");
private static final String FUNCTION = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function");
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");
@ -114,20 +117,10 @@ public class AlphaFineFrame extends JFrame {
private static final String GO_FORUM = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Go_Forum");
private static final String MY_TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_My_Templates");
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 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 String TEMPLATE_SHOP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop");
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);
@ -434,9 +427,9 @@ public class AlphaFineFrame extends JFrame {
// 内容区,card layout
resultPane.add(new DefaultProductNewsPane(), CellType.PRODUCT_NEWS.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.FILE.getFlagStr4None());
resultPane.add(new NoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.PLUGIN.getFlagStr4None());
resultPane.add(new DefaultContentPane(CellType.ACTION, this), CellType.ACTION.getFlagStr4None());
resultPane.add(new DefaultContentPane(CellType.FILE, this), CellType.FILE.getFlagStr4None());
resultPane.add(new DefaultPluginContentPane(CellType.PLUGIN, this), CellType.PLUGIN.getFlagStr4None());
resultPane.add(new HelpDocumentNoResultPane(SEARCH_TERM, AlphaFineConstants.NO_RESULT_ICON), CellType.DOCUMENT.getFlagStr4None());
resultPane.add(TemplateShopPane.getInstance(), CellType.TEMPLATE_SHOP.getFlagStr4None());
resultPane.add(new NetWorkFailedPane(this::reSearch), AlphaFineConstants.NETWORK_ERROR);
@ -447,7 +440,7 @@ public class AlphaFineFrame extends JFrame {
labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
labelPane.setBackground(Color.WHITE);
labelContentPane = new JPanel(new BorderLayout());
tabLabel = createTabLabel(PRODUCT_NEWS);
tabLabel = createTabLabel(AlphaFineConstants.PRODUCT_NEWS);
labelWestPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
labelWestPane.add(tabLabel);
labelContentPane.add(labelWestPane, BorderLayout.WEST);
@ -527,8 +520,8 @@ public class AlphaFineFrame extends JFrame {
AlphaFineFrame.this.selectedTab = selectedLabel;
// 处理产品动态 tab与下方文字展示不一致
if (ComparatorUtils.equals(selectedLabel.getText().trim(), PRODUCT_NEWS)) {
tabLabel.setText(PRODUCT_NEWS);
if (ComparatorUtils.equals(selectedLabel.getText().trim(), AlphaFineConstants.PRODUCT_NEWS)) {
tabLabel.setText(AlphaFineConstants.PRODUCT_NEWS);
} else {
tabLabel.setText(selectedLabel.getText());
}
@ -613,25 +606,27 @@ public class AlphaFineFrame extends JFrame {
List<SelectedLabel> selectedLabelList = new ArrayList<>();
AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (alphaFineConfigManager.isProductDynamics()) {
selectedLabelList.add(new SelectedLabel(PRODUCT_NEWS, CellType.PRODUCT_NEWS));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.PRODUCT_NEWS, CellType.PRODUCT_NEWS));
}
if (alphaFineConfigManager.hasTemplateShop()) {
selectedLabelList.add(new SelectedLabel(TEMPLATE_SHOP, CellType.TEMPLATE_SHOP));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.TEMPLATE_SHOP, CellType.TEMPLATE_SHOP));
}
if (alphaFineConfigManager.isContainDocument()) {
selectedLabelList.add(new SelectedLabel(HELP, CellType.DOCUMENT));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.HELP, CellType.DOCUMENT));
}
if (alphaFineConfigManager.isContainPlugin()) {
selectedLabelList.add(new SelectedLabel(PLUGIN, CellType.PLUGIN));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.PLUGIN, CellType.PLUGIN));
}
if (alphaFineConfigManager.isContainAction()) {
selectedLabelList.add(new SelectedLabel(FUNCTION, CellType.ACTION));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.FUNCTION, CellType.ACTION));
}
if (alphaFineConfigManager.isContainMyTemplate()) {
selectedLabelList.add(new SelectedLabel(MY_TEMPLATES, CellType.FILE));
selectedLabelList.add(new SelectedLabel(AlphaFineConstants.MY_TEMPLATES, CellType.FILE));
}
// 根据设置排序
sortList(selectedLabelList);
// 默认选中第一个tab
if (!selectedLabelList.isEmpty()) {
selectedLabelList.get(0).setSelected(true);
@ -640,6 +635,19 @@ public class AlphaFineFrame extends JFrame {
return selectedLabelList;
}
/**
* 根据用户自定义的顺序排序
* */
private void sortList(List<SelectedLabel> list) {
AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
String[] tabOrder = alphaFineConfigManager.getTabOrder();
Map<String, Integer> orderMap = new HashMap<>();
for (int i = 0; i < tabOrder.length; i++) {
orderMap.put(tabOrder[i], i);
}
list.sort(Comparator.comparingInt(tab -> orderMap.get(tab.getText())));
}
private void fireOneClickRead() {
List<ProductNews> productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList();
Set<Long> readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet();

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

@ -1,15 +1,16 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.DocumentModel;
import com.fr.design.mainframe.alphafine.preview.ResultShowPane;
import javax.swing.JList;
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

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

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

@ -1,20 +1,21 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
/**
* @author hades

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

@ -1,13 +1,14 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.general.ComparatorUtils;
import javax.swing.JList;
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

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

@ -1,13 +1,14 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.util.Stack;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
/**
* @author hades

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

@ -1,21 +1,22 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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.model.ProductNews;
import com.fr.design.utils.DesignUtils;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.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

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.utils.BrowseUtils;

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import java.awt.BorderLayout;
import java.awt.Color;

57
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java

@ -0,0 +1,57 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import org.jetbrains.annotations.NotNull;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
/**
* alphaFine - 推荐搜索词标签
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/19
*/
public class RecommendSearchLabel extends JPanel {
private static final Color RECOMMEND_SEARCH_KEY_BLUE = new Color(0x419bf9);
public RecommendSearchLabel(String title, @NotNull List<String> tips) {
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setBackground(Color.WHITE);
JLabel recommend = new JLabel(title);
this.add(recommend);
for (String key : tips) {
JLabel keyLabel = new SearchKeyLabel(key);
this.add(keyLabel);
}
}
/**
* 推荐搜索词绑定alphaFine搜索事件
*/
public class SearchKeyLabel extends JLabel {
String searchKey;
SearchKeyLabel(String searchKey) {
this.searchKey = searchKey;
setText(searchKey);
setBackground(Color.WHITE);
setForeground(RECOMMEND_SEARCH_KEY_BLUE);
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
AlphaFineHelper.getAlphaFineDialog().fireSearch(searchKey);
}
});
}
}
}

37
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java

@ -1,17 +1,11 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
/**
@ -25,7 +19,6 @@ import java.util.List;
public class RecommendSearchPane extends TemplateResourcePanel {
private static final Color BORDER_WHITE = new Color(0xe8e8e9);
private static final Color RECOMMEND_SEARCH_KEY_BLUE = new Color(0x419bf9);
public RecommendSearchPane(TemplateResource templateResource) {
super();
@ -45,37 +38,11 @@ public class RecommendSearchPane extends TemplateResourcePanel {
private void createCenterPane() {
setCenterPane(new JPanel(new FlowLayout(FlowLayout.LEFT)));
JPanel centerPane = getCenterPane();
centerPane.setBackground(Color.WHITE);
JLabel recommend = new JLabel(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You"));
centerPane.add(recommend);
String recommend = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You");
List<String> searchKeys = getTemplateResource().getRecommendSearchKey();
for (String key : searchKeys) {
JLabel keyLabel = new SearchKeyLabel(key);
centerPane.add(keyLabel);
}
}
class SearchKeyLabel extends JLabel {
String searchKey;
SearchKeyLabel(String searchKey) {
this.searchKey = searchKey;
setText(searchKey);
setBackground(Color.WHITE);
setForeground(RECOMMEND_SEARCH_KEY_BLUE);
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
AlphaFineHelper.getAlphaFineDialog().fireSearch(searchKey);
}
});
}
setCenterPane(new RecommendSearchLabel(recommend, searchKeys));
}

80
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java

@ -0,0 +1,80 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.svg.IconUtils;
import com.fr.common.util.Collections;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
/**
* alphafine - 搜索提示面板
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class SearchHintPane extends JPanel {
private static final String TITLE = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Search_Title");
private static final String RECOMMEND = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend_Search");
private static final Icon ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/search_hint.svg");
private static final int HEIGHT = 200;
private static final int WIDTH = 300;
private static final int TITLE_LABEL_HEIGHT = 30;
private static final int TITLE_FONT_SIZE = 14;
public SearchHintPane() {
this(new ArrayList<>());
}
public SearchHintPane(List<String> hints) {
this(hints, ICON, TITLE);
}
public SearchHintPane(List<String> hints, Icon icon, String title) {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(40,0,0,0));
setBackground(Color.white);
setPreferredSize(new Dimension(WIDTH, HEIGHT));
setAlignmentY(SwingConstants.CENTER);
UILabel image = new UILabel();
image.setPreferredSize(new Dimension(150, 111));
image.setHorizontalAlignment(SwingConstants.CENTER);
image.setIcon(icon);
image.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
add(image, BorderLayout.NORTH);
add(generateDescription(title), BorderLayout.CENTER);
add(generateHintsLabel(hints), BorderLayout.SOUTH);
}
protected Component generateDescription(String title) {
JLabel description = new JLabel(title);
description.setForeground(AlphaFineConstants.MEDIUM_GRAY);
description.setFont(DesignUtils.getDefaultGUIFont().applySize(TITLE_FONT_SIZE));
description.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
description.setHorizontalAlignment(SwingConstants.CENTER);
description.setPreferredSize(new Dimension(WIDTH, TITLE_LABEL_HEIGHT));
return description;
}
private Component generateHintsLabel(List<String> hints) {
if (Collections.isEmpty(hints)) {
return new JLabel();
}
return new RecommendSearchLabel(RECOMMEND, hints);
}
}

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

@ -1,19 +1,20 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
/**
* @author hades

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

@ -1,13 +1,14 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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 javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
/**
* @author hades

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

@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.component;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineUtil;
import com.fr.design.mainframe.alphafine.CellType;

28
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.common.util.Strings;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.mainframe.alphafine.preview.TemplateShopPane;
@ -103,11 +104,8 @@ public class TemplateResourcePanel extends JPanel {
}
private void createCenterPane() {
JLabel nameLabel = new JLabel(templateResource.getName());
nameLabel.setFont(RESOURCE_NAME_FONT);
nameLabel.setForeground(RESOURCE_NAME_COLOR);
nameLabel.setBackground(Color.WHITE);
nameLabel.setBorder(BorderFactory.createEmptyBorder());
JLabel nameLabel = createHtmlNameLabel();
JLabel demoLabel = new JLabel();
if (templateResource.hasDemoUrl()) {
@ -131,6 +129,26 @@ public class TemplateResourcePanel extends JPanel {
centerPane.add(demoLabel, BorderLayout.EAST);
}
private static final String SEARCH_WORD_FORMAT = "<span style=\"color:#419BF9\">%s</span>";
private static final String HTML_JLABEL_FORMAT = "<html>%s</html>";
private JLabel createHtmlNameLabel() {
JLabel label = new JLabel();
String htmlText = templateResource.getName();
String searchWord = templateResource.getSearchWord();
if (!Strings.isEmpty(searchWord) && htmlText.contains(searchWord)) {
htmlText = htmlText.replace(searchWord, String.format(SEARCH_WORD_FORMAT, searchWord));
}
htmlText = String.format(HTML_JLABEL_FORMAT, htmlText);
label.setText(htmlText);
label.setFont(RESOURCE_NAME_FONT);
label.setForeground(RESOURCE_NAME_COLOR);
label.setBackground(Color.WHITE);
label.setBorder(BorderFactory.createEmptyBorder());
return label;
}
@Override
public Dimension getPreferredSize() {
return new Dimension(180, 90);

1
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java

@ -16,4 +16,5 @@ public class FineMarketConstants {
public static final String RAR = ".rar";
public static final String CPT = ".cpt";
public static final String FRM = ".frm";
public static final String FVS = ".fvs";
}

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java

@ -11,8 +11,9 @@ import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.mainframe.alphafine.search.helper.FineMarketClientHelper;
import com.fr.design.mainframe.toast.SimpleToast;
import com.fr.file.FileCommonUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.third.jodd.io.ZipUtil;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileSystemView;
@ -84,7 +85,8 @@ public class FineMarketDownloadManager {
if (fileName.endsWith(FineMarketConstants.ZIP)) {
File file = new File(fileName);
File parentDir = file.getParentFile();
ZipUtil.unzip(file, parentDir);
// TODO:之前用的gbk解码太容易乱码了。这里应该自动识别编码,然后解压,但是要添加1个三方包,可能会赶不上发布。所以先暂时用utf8顶着。
IOUtils.unzip(file, FileCommonUtils.getAbsolutePath(parentDir), "UTF-8");
}
}

25
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java

@ -28,11 +28,8 @@ public class TemplateResource {
* 模板资源类型模板解决方案推荐搜索
*/
public enum Type {
// 单个模板
SINGLE_TEMPLATE(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Single_Template")),
// 场景解决方案
SCENARIO_SOLUTION(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Scenario_Solution")),
// 推荐搜索
RECOMMEND_SEARCH;
private String name;
@ -73,9 +70,12 @@ public class TemplateResource {
private List<String> recommendSearchKey;
private boolean embed;
/**
* json转obj
* */
/// 其他属性
// 当前搜索词
private String searchWord;
public static List<TemplateResource> createByJson(JSONArray jsonArray) {
List<TemplateResource> list = new ArrayList<>();
if (jsonArray != null) {
@ -92,7 +92,7 @@ public class TemplateResource {
public static TemplateResource createByJson(JSONObject jsonObject) {
TemplateResource templateResource = new TemplateResource().setId(jsonObject.getString(ID)).setUuid(jsonObject.getString(UUID)).setName(jsonObject.getString(NAME))
.setDemoUrl(jsonObject.getString(DEMO_URL)).setPkgSize(jsonObject.getInt(PKG_SIZE)).setFileName(jsonObject.getString(FILE_NAME));
.setDemoUrl(jsonObject.getString(DEMO_URL)).setPkgSize(jsonObject.getInt(PKG_SIZE)).setFileName(jsonObject.getString(FILE_NAME));
int pkgSize = templateResource.getPkgSize();
if (pkgSize == 0) {
templateResource.type = Type.SINGLE_TEMPLATE;
@ -197,9 +197,6 @@ public class TemplateResource {
return demoUrl;
}
/**
* 有无在线演示
* */
public boolean hasDemoUrl() {
return !StringUtil.isEmpty(demoUrl);
}
@ -235,4 +232,12 @@ public class TemplateResource {
this.uuid = uuid;
return this;
}
public String getSearchWord() {
return searchWord;
}
public void setSearchWord(String searchWord) {
this.searchWord = searchWord;
}
}

55
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java

@ -8,13 +8,13 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* alphafine - 模板资源详细数据
@ -155,16 +155,10 @@ public class TemplateResourceDetail {
this.parentPkgUrl = parentPkgUrl;
}
/**
* 通过模板资源数据构建详细数据
* */
public static TemplateResourceDetail createByTemplateResource(TemplateResource root) {
return Builder.buildByResource(root);
}
/**
* 通过内置模板资源数据构建详细数据
* */
public static TemplateResourceDetail createFromEmbedResource(TemplateResource root) {
return Builder.buildFromEmbedResource(root);
}
@ -181,7 +175,7 @@ public class TemplateResourceDetail {
JSONObject resource = embedResources.getJSONObject(i);
if (resourceId.equals(resource.getString(ID))) {
detail.setInfo(resource.getString(INFO));
detail.setHtmlText(resource.getString(DETAIL_INFO));
detail.setHtmlText(reformat(resource.getString(DETAIL_INFO)));
detail.setVendor(resource.getString(VENDOR));
detail.setPrice(resource.getDouble(PRICE));
detail.setResourceUrl(resource.getString(URL));
@ -203,7 +197,7 @@ public class TemplateResourceDetail {
// 1请求详细信息
JSONObject info = helper.getTemplateInfoById(resourceId);
detail.setInfo(info.getString(INFO));
detail.setHtmlText(info.getString(DETAIL_INFO));
detail.setHtmlText(reformat(info.getString(DETAIL_INFO)));
detail.setVendor(info.getString(VENDOR));
detail.setTagsId(info.getString(TAGS_ID).split(","));
detail.setPrice(info.getDouble(PRICE));
@ -226,25 +220,36 @@ public class TemplateResourceDetail {
return null;
}
static final String A_TAG_FORMAT = "<a href=%s>%s</a>";
static final String HTML_TAG_REGX="<[^>]+>";
static final Pattern A_TAG_PATTERN = Pattern.compile("<a[^>]*href=(\\\"([^\\\"]*)\\\"|\\'([^\\']*)\\'|([^\\\\s>]*))[^>]*>(.*?)</a>");
static final Pattern HTML_TAG_PATTERN = Pattern.compile(HTML_TAG_REGX);
/**
* 这里做下数据转换
* 原始数据是html标签写的如下
* "<ol style="list-style-type: decimal;" class=" list-paddingleft-2"><li><p>该模板需用10.0及以上版本设计器预览<br/></p></li><li><p>该模板为库存场景解决方案的部分内容,全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p></li><li><p>为保障模板预览效果,建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询<br/></p></li></ol>",
*
* 转换的后的数据 是原始数据中所有<p></p>标签内的包括标签的字符串List<String>,如上字符串会转为如下
* List [<p>该模板需用10.0及以上版本设计器预览<br/></p>,
* <p>该模板为库存场景解决方案的部分内容全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p>,
* <p>为保障模板预览效果建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>FR11.0版本插件已内置无需手动安装有使用需求或疑问请联系帆软技术支持咨询<br/></p>
* ]
* 数据格式转换
* 原始数据的格式不统一纯文本html都有; 统一转为纯文本如果有a标签则保留
* */
static final Pattern HTML_PATTERN = Pattern.compile("<p>(.+?)</p>");
static List<String> parseDetailInfo(String htmlDetailInfo) {
List<String> infos = new ArrayList<>();
Matcher matcher = HTML_PATTERN.matcher(htmlDetailInfo);
static String reformat(String htmlDetailInfo) {
String result = HTML_TAG_PATTERN.matcher(htmlDetailInfo).replaceAll("");
Map<String, String> aMap = getLink(htmlDetailInfo);
for (Map.Entry<String, String> entry : aMap.entrySet()) {
String aTag = String.format(A_TAG_FORMAT, entry.getValue(), entry.getKey());
result = result.replace(entry.getKey(), aTag);
}
return result;
}
/**
* 读取dom中的a标签转换为map
*/
static Map<String, String> getLink(String html) {
Map<String, String> map = new HashMap<>();
Matcher matcher = A_TAG_PATTERN.matcher(html);
while (matcher.find()) {
infos.add(matcher.group());
map.put(matcher.group(5), matcher.group(1));
}
return infos;
return map;
}
}

57
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java

@ -0,0 +1,57 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.component.SearchHintPane;
import com.fr.design.mainframe.alphafine.search.SearchWorkerManager;
import com.fr.design.mainframe.alphafine.search.manager.SearchProviderRegistry;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* alphaFine - 默认展示页面
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class DefaultContentPane extends JPanel {
// 左边展示内容,右边展示搜索提示
private SearchWorkerManager searchWorkerManager;
private CellType cellType;
public DefaultContentPane(CellType cellType, AlphaFineFrame parentWindow) {
this.setLayout(new BorderLayout());
this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
this.searchWorkerManager = new SearchWorkerManager(
cellType,
searchTextBean -> SearchProviderRegistry.getSearchProvider(cellType).getDefaultResult(),
parentWindow,
new SimpleRightSearchResultPane(new SearchHintPane())
);
this.searchWorkerManager.showDefault(this);
}
/**
* 显示搜索结果
*/
public void showResult(JPanel result) {
add(result);
repaint();
}
public DefaultContentPane() {
}
public CellType getCellType() {
return cellType;
}
public void setCellType(CellType cellType) {
this.cellType = cellType;
}
}

120
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java

@ -0,0 +1,120 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;
import com.fr.design.mainframe.alphafine.component.SearchHintPane;
import com.fr.design.mainframe.alphafine.search.SearchWorkerManager;
import com.fr.design.mainframe.alphafine.search.manager.SearchProviderRegistry;
import com.fr.general.CloudCenter;
import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import java.awt.CardLayout;
import java.util.ArrayList;
import java.util.List;
/**
* alphafine插件默认页
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class DefaultPluginContentPane extends DefaultContentPane {
private static final String[] HINTS = CloudCenter.getInstance().acquireConf("alphafine.plugin.recommend", "JS,API,JSON").split(",");
private static final String LOADING_PANE = "loading";
private static final String NETWORK_ERROR = "networkError";
private static final String RESULT_PANE = "result";
private SearchWorkerManager searchWorkerManager;
private CellType cellType;
private AlphaFineFrame parentWindow;
private CardLayout cardLayout;
private SearchLoadingPane searchLoadingPane;
private NetWorkFailedPane netWorkFailedPane;
private SwingWorker<Boolean, Void> worker;
public DefaultPluginContentPane(CellType cellType, AlphaFineFrame parentWindow) {
super();
this.cellType = cellType;
this.parentWindow = parentWindow;
this.cardLayout = new CardLayout();
this.setLayout(cardLayout);
this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE);
initPanel();
add(searchLoadingPane, LOADING_PANE);
add(netWorkFailedPane, NETWORK_ERROR);
worker = createWorker();
worker.execute();
}
private void initPanel() {
this.searchLoadingPane = new SearchLoadingPane();
this.netWorkFailedPane = new NetWorkFailedPane(()-> reload());
}
private void switchPane(String tag) {
cardLayout.show(this, tag);
}
private SwingWorker<Boolean, Void> createWorker() {
return new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
switchPane(LOADING_PANE);
return AlphaFineHelper.isNetworkOk();
}
@Override
protected void done() {
super.done();
try {
boolean networkOk = get();
if (!networkOk) {
switchPane(NETWORK_ERROR);
} else {
List<String> searchKeys = new ArrayList<>();
for (String s : HINTS) {
searchKeys.add(s);
}
searchWorkerManager = new SearchWorkerManager(
cellType,
searchTextBean -> SearchProviderRegistry.getSearchProvider(cellType).getDefaultResult(),
parentWindow,
new SimpleRightSearchResultPane(new SearchHintPane(searchKeys))
);
searchWorkerManager.showDefault(DefaultPluginContentPane.this);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
}
};
}
@Override
public void showResult(JPanel result) {
add(result, RESULT_PANE);
switchPane(RESULT_PANE);
}
/**
* 网络异常时重新加载
*/
public void reload() {
worker = createWorker();
worker.execute();
}
public CellType getCellType() {
return cellType;
}
public void setCellType(CellType cellType) {
this.cellType = cellType;
}
}

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

@ -1,9 +1,9 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.component.ProductNewsContentCellRender;
import com.fr.design.mainframe.alphafine.component.ProductNewsList;
@ -12,14 +12,15 @@ import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.List;
/**
* @author hades

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

@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import javax.swing.*;
import java.awt.*;

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java

@ -1,7 +1,7 @@
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.actions.help.alphafine.AlphaFineConstants;
import javax.swing.*;
import java.awt.*;

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

@ -1,9 +1,9 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
@ -13,6 +13,12 @@ import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
@ -22,12 +28,6 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
/**
* @author hades

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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;
@ -11,6 +11,11 @@ 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 javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -18,10 +23,6 @@ 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

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

@ -3,7 +3,7 @@ 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.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.general.IOUtils;

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

@ -1,16 +1,16 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
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;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
/**

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

@ -1,16 +1,17 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.Color;
import java.awt.Component;
/**
* 带跳转链接的无结果面板

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java

@ -1,7 +1,7 @@
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.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.log.FineLoggerFactory;

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import java.awt.BorderLayout;
import java.awt.Color;

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

@ -1,11 +1,12 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
/**
* @author hades

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.action.StartUseAction;
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel;
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail;
@ -78,8 +78,8 @@ public class TemplateResourceDetailPane extends JPanel {
private static final Font HTML_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color HTML_COLOR = new Color(0x5c5c5d);
private static final String HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;"+ LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) +"\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;" + LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) + "\"><p>" + DETAIL_INFO + "</p>%s</body></html>";
private static final String HTML_FORMAT = "<html><style>a {color: #419BF9 !important;text-decoration:none !important;}</style><body style=\"line-height: 20px;"+ LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) + "\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><style>a {color: #419BF9 !important;text-decoration:none !important;}</style><body style=\"line-height: 20px;" + LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) + "\"><p>" + DETAIL_INFO + "</p>%s</body></html>";
private static final String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>";

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.common.util.Strings;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.component.TemplateResourcePageGridPane;
import com.fr.design.mainframe.alphafine.model.TemplateResource;

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

@ -1,16 +1,17 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
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;
import java.util.List;
import java.util.function.Function;
/**
* @author hades

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

@ -1,5 +1,7 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.preview.DefaultContentPane;
/**
* @author hades
* @version 11.0
@ -7,7 +9,17 @@ package com.fr.design.mainframe.alphafine.search;
*/
public interface SearchManager {
void doSearch(SearchTextBean searchTextBean);
/**
* 搜索
* */
void doSearch(SearchTextBean searchTextBean);
/**
* 展示默认内容
* */
default void showDefault(DefaultContentPane defaultContentPane) {
};
boolean hasSearchResult();

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

@ -7,6 +7,8 @@ package com.fr.design.mainframe.alphafine.search;
*/
public class SearchTextBean {
public static SearchTextBean EMPTY = new SearchTextBean("", new String[0]);
private String searchText;
/**

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

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.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;
@ -9,12 +9,15 @@ 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.DefaultContentPane;
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;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import java.util.function.Function;
/**
* @author hades
* @version 11.0
@ -120,6 +123,21 @@ public class SearchWorkerManager implements SearchManager {
this.searchWorker.execute();
}
@Override
public void showDefault(DefaultContentPane defaultContentPane) {
searchResultPane = new SearchResultPane(SearchTextBean.EMPTY.getSegmentation(), resultShowPane);
SearchListModel searchListModel = new SearchListModel(new SearchResult(), searchResultPane.getSearchResultList(), searchResultPane.getLeftSearchResultPane());
SearchResult searchResult = searchResultFunction.apply(SearchTextBean.EMPTY);
for (AlphaCellModel object : searchResult) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
searchResultPane.getSearchResultList().setModel(searchListModel);
searchResultPane.getSearchResultList().setSelectedIndex(0);
searchResultPane.getSearchResultList().requestFocus();
SwingUtilities.invokeLater(()->defaultContentPane.showResult(searchResultPane));
}
@Override
public boolean hasSearchResult() {
return hasSearchResult;

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.search;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.component.AlphaFineFrame;

35
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import java.util.HashMap;
import java.util.Map;
/**
* alphafine搜索提供者注册到这里
*
* @author Link
* @version 11.0
* Created by Link on 2022/9/18
*/
public class SearchProviderRegistry {
private static Map<CellType, AlphaFineSearchProvider> map;
static {
map = new HashMap<>();
map.put(CellType.PLUGIN, PluginSearchManager.getInstance());
map.put(CellType.ACTION, ActionSearchManager.getInstance());
map.put(CellType.FILE, FileSearchManager.getInstance());
}
/**
* 根据celltype获得对应searchProvider
*/
public static AlphaFineSearchProvider getSearchProvider(CellType cellType) {
return map.get(cellType);
}
}

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java

@ -22,6 +22,12 @@ public interface AlphaFineSearchProvider {
*/
SearchResult getMoreSearchResult(String searchText);
/**
* 不搜索的情况下获取显示结果
* */
default SearchResult getDefaultResult() {
return new SearchResult();
}
/**
* 获取所有搜索结果 取决于具体实现

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
@ -29,6 +29,7 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
private SearchResult defaultModelList;
public static ActionSearchManager getInstance() {
if (instance == null) {
@ -41,6 +42,17 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
return instance;
}
/**
* 初始化的时候初始化默认功能列表
* */
private ActionSearchManager() {
defaultModelList = new SearchResult();
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) {
defaultModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()));
}
}
/**
* 根据类名获取对象
*
@ -115,4 +127,10 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
getLessSearchResult(searchTextBean.getSegmentation());
return filterModelList;
}
@Override
public SearchResult getDefaultResult() {
return defaultModelList;
}
}

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

@ -2,8 +2,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.login.ClientHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.http.HttpToolbox;

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

@ -1,8 +1,8 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.DocumentModel;
@ -16,6 +16,7 @@ import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import java.util.concurrent.TimeUnit;

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

@ -3,7 +3,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.FileModel;
@ -21,6 +21,8 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
@ -33,9 +35,11 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private static volatile FileSearchManager instance;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult defaultModelList;
private SearchResult moreModelList;
private String searchText;
private FileNode[] fileNodes = null;
private static final int DEFAULT_LIST_SIZE = 10;
//停止搜索
//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类
@ -137,6 +141,19 @@ public class FileSearchManager implements AlphaFineSearchProvider {
}
}
@Override
public SearchResult getDefaultResult() {
List<String> list = DesignerEnvManager.getEnvManager().getRecentOpenedFilePathList();
defaultModelList = new SearchResult();
for (int i = 0; i < Math.min(DEFAULT_LIST_SIZE, list.size()); i++) {
String name = list.get(i).toLowerCase();
name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
FileModel model = new FileModel(name, name);
defaultModelList.add(model);
}
return defaultModelList;
}
/**
* 搜索模板内容
*

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

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
@ -13,13 +13,13 @@ import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**

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

@ -1,8 +1,9 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.common.util.Collections;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
@ -22,6 +23,13 @@ import com.fr.stable.EncodeConstants;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.ToLongFunction;
/**
* Created by XiaXiang on 2017/3/27.
@ -30,6 +38,12 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
private SearchResult lessModelList;
private SearchResult moreModelList;
private SearchResult searchResult;
private SearchResult defaultModelList;
private static final int DEFAULT_LIST_SIZE = 10;
private static final String TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
private static final String UPLOAD_TIME = "uploadTime";
private PluginSearchManager() {
@ -155,4 +169,60 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
getLessSearchResult(searchTextBean.getSegmentation());
return searchResult;
}
@Override
public SearchResult getDefaultResult() {
this.defaultModelList = new SearchResult();
try {
String url = AlphaFineCloudConstants.getSearchAllPluginUrl();
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = jsonObject.optJSONArray("result");
List<Map> plugins = jsonArray.getList();
List<PluginModel> pluginModels = new ArrayList<>();
pluginModels.addAll(parseDefaultPluginModel(plugins));
pluginModels.forEach(m->this.defaultModelList.add(m));
} catch (Exception e) {
FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage());
}
return this.defaultModelList;
}
/**
* 将jsonobject转化为PluginModel
* 并按照更新时间排序取最新的10个
* */
List<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) {
List<PluginModel> pluginModels = new ArrayList<>();
if (!Collections.isEmpty(jsonObjects)) {
SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT);
try {
jsonObjects.sort(Comparator.comparingLong(new ToLongFunction<Map>() {
@Override
public long applyAsLong(Map value) {
long time = 0L;
try {
time = format.parse((String) value.get(UPLOAD_TIME)).getTime();
} catch (ParseException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return time;
}
}));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
for (int i = 0; i < DEFAULT_LIST_SIZE; i++) {
pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false));
}
}
return pluginModels;
}
}

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

@ -2,8 +2,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.general.http.HttpToolbox;

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.ActionModel;

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

@ -1,8 +1,8 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;

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

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.stable.StringUtils;
import com.fr.third.ibm.icu.text.BreakIterator;

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

@ -2,8 +2,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.login.ClientHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;

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

@ -38,7 +38,19 @@ public class TemplateResourceSearchManager {
public List<TemplateResource> getSearchResult(String searchText) {
List<TemplateResource> resourceList = new ArrayList<>();
// 联网搜索
resourceList.addAll(searchOnline(searchText));
resourceList.addAll(searchLocal(searchText));
resourceList.stream().forEach(resource -> {resource.setSearchWord(searchText);});
return resourceList;
}
/**
* 联网搜索
* */
private List<TemplateResource> searchOnline(String searchText) {
List<TemplateResource> resourceList = new ArrayList<>();
try {
JSONArray jsonArray = HELPER.getTemplateInfoByName(searchText);
if (jsonArray != null && !jsonArray.isEmpty()) {
@ -47,8 +59,14 @@ public class TemplateResourceSearchManager {
} catch (Exception e) {
}
return resourceList;
}
// 本地搜索
/**
* 本地搜索
* */
private List<TemplateResource> searchLocal(String searchText) {
List<TemplateResource> resourceList = new ArrayList<>();
if (resourceList.isEmpty()) {
List<TemplateResource> localResource = getEmbedResourceList();
localResource.stream().forEach(resource->{

37
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg

@ -0,0 +1,37 @@
<svg width="112" height="100" viewBox="0 0 112 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="55.5" cy="57.5" r="42.5" fill="#EFEFF1"/>
<circle cx="19.3947" cy="12.2012" r="2.72659" fill="#E7E7EA"/>
<circle cx="11.2149" cy="35.9614" r="1.55805" fill="#DADAE0"/>
<circle cx="101.971" cy="39.4671" r="1.94756" fill="#E7E7EA"/>
<path opacity="0.593564" fill-rule="evenodd" clip-rule="evenodd" d="M107.866 26.5612L105.477 25.8341L107.866 25.107L108.593 22.718L109.32 25.107L111.709 25.8341L109.32 26.5612L108.593 28.9502L107.866 26.5612Z" fill="#D8D8D8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M87.91 13.0191L85.2224 12.2011L87.91 11.3831L88.728 8.69548L89.546 11.3831L92.2336 12.2011L89.546 13.0191L88.728 15.7067L87.91 13.0191Z" fill="#D8D8D8"/>
<g filter="url(#filter0_d_2271_72853)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M32 37C30.3431 37 29 38.3431 29 40V74C29 75.6569 30.3431 77 32 77H81C82.6569 77 84 75.6569 84 74V49L72 37H32Z" fill="white"/>
</g>
<path d="M72 37L84 49H75C73.3431 49 72 47.6569 72 46V37Z" fill="#F0F0F0"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35 47C35 46.4477 35.4477 46 36 46H68C68.5523 46 69 46.4477 69 47V48C69 48.5523 68.5523 49 68 49H36C35.4477 49 35 48.5523 35 48V47Z" fill="#ECECEC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35 55C35 54.4477 35.4477 54 36 54H54C54.5523 54 55 54.4477 55 55V56C55 56.5523 54.5523 57 54 57H36C35.4477 57 35 56.5523 35 56V55Z" fill="#ECECEC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35 63C35 62.4477 35.4477 62 36 62H51C51.5523 62 52 62.4477 52 63V64C52 64.5523 51.5523 65 51 65H36C35.4477 65 35 64.5523 35 64V63Z" fill="#ECECEC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M69.8212 68.6844V68.9847H67.9316V68.6844C67.9316 68.031 68.0375 67.4659 68.2848 67.0067C68.5143 66.5122 69.1854 65.7882 70.2803 64.8169L70.5806 64.4813C70.8984 64.0752 71.075 63.6513 71.075 63.1922C71.075 62.5741 70.8984 62.0972 70.5629 61.744C70.2097 61.3908 69.6976 61.2142 69.0618 61.2142C68.2671 61.2142 67.6843 61.4615 67.3311 61.9736C67.0132 62.3975 66.8543 62.9979 66.8543 63.7749H65C65 62.4858 65.3709 61.4791 66.1126 60.7374C66.8543 59.978 67.8786 59.6072 69.1854 59.6072C70.3157 59.6072 71.234 59.9074 71.9404 60.5432C72.6468 61.1613 73 62.0089 73 63.0685C73 63.9339 72.7704 64.6579 72.3289 65.2231C72.17 65.4173 71.6755 65.8765 70.8455 66.6005C70.5099 66.8831 70.2627 67.201 70.1037 67.5189C69.9095 67.8721 69.8212 68.2606 69.8212 68.6844ZM69.7859 72.1106C69.5386 72.3401 69.2207 72.4638 68.8675 72.4638C68.5143 72.4638 68.1965 72.3401 67.9492 72.0929C67.702 71.8457 67.5784 71.5454 67.5784 71.1922C67.5784 70.8214 67.702 70.5212 67.9492 70.2916C68.1965 70.0443 68.5143 69.9384 68.8675 69.9384C69.2384 69.9384 69.5563 70.0443 69.8035 70.2916C70.0508 70.5212 70.1744 70.8214 70.1744 71.1922C70.1744 71.5631 70.0331 71.8633 69.7859 72.1106Z" fill="#DCDCDF"/>
<circle cx="69" cy="65" r="11.935" transform="rotate(-45 69 65)" stroke="#DADADD" stroke-width="3"/>
<circle cx="69" cy="65" r="10.6067" transform="rotate(-45 69 65)" fill="#D9DADD" fill-opacity="0.22"/>
<rect x="76.1232" y="74.7715" width="3.74565" height="5.45555" transform="rotate(-45 76.1232 74.7715)" fill="#DADADD"/>
<rect x="78.4767" y="78.7192" width="6" height="1" transform="rotate(-45 78.4767 78.7192)" fill="#C8C9CD"/>
<mask id="mask0_2271_72853" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="13" y="15" width="85" height="85">
<circle cx="55.5" cy="57.5" r="42.5" fill="#EBEBED"/>
</mask>
<g mask="url(#mask0_2271_72853)">
<path d="M79.1838 79.4263L83.4265 75.1836L89.7904 81.5476C90.962 82.7192 90.962 84.6187 89.7904 85.7902C88.6189 86.9618 86.7194 86.9618 85.5478 85.7902L79.1838 79.4263Z" fill="#D3D3D8"/>
</g>
<defs>
<filter id="filter0_d_2271_72853" x="25" y="33" width="63" height="48" 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/>
<feGaussianBlur stdDeviation="2"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.867956 0 0 0 0 0.867956 0 0 0 0 0.886124 0 0 0 1 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_2271_72853"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_2271_72853" result="shape"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

2
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;

Loading…
Cancel
Save