From e00f50e3ec9304a380b5acd98447664bd7f9d998 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Wed, 26 Oct 2022 18:08:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-82937=20=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=8C=96=E4=BA=8C=E6=9C=9F=E7=9A=84=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=AD=A5=E5=88=B010.0=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BB=8E11=E5=90=88=E5=88=B010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineCloudConstants.java | 45 ++-- .../alphafine/AlphaFineConfigManager.java | 79 ++++-- .../help/alphafine/AlphaFineConfigPane.java | 126 ++++++++-- .../help}/alphafine/AlphaFineConstants.java | 19 +- .../alphafine/component/CustomSortPane.java | 229 ++++++++++++++++++ .../help/alphafine/component/MenuLabel.java | 96 ++++++++ .../alphafine/component/MenuLabelPane.java | 34 +++ .../com/fr/design/gui/ibutton/UIButton.java | 8 + .../com/fr/design/gui/ilable/ActionLabel.java | 23 +- .../fr/design/remote/button/IconButton.java | 10 +- .../mainframe/alphafine/AlphaFineHelper.java | 2 +- .../mainframe/alphafine/AlphaFineUtil.java | 1 + .../alphafine/action/StartUseAction.java | 8 +- .../alphafine/cell/model/BottomModel.java | 2 +- .../alphafine/cell/model/DocumentModel.java | 2 +- .../alphafine/cell/model/PluginModel.java | 6 +- .../alphafine/cell/model/RobotModel.java | 8 +- .../cell/render/BottomCellRender.java | 2 +- .../cell/render/ContentCellRender.java | 2 +- .../cell/render/TitleCellRender.java | 2 +- .../alphafine/component/AlphaFineDialog.java | 6 +- .../alphafine/component/AlphaFineFrame.java | 58 +++-- .../alphafine/component/AlphaFineList.java | 5 +- .../component/AlphaFineTextField.java | 2 +- .../AlphaFineToolTipContentCellRender.java | 11 +- .../component/AlphaFineToolTipList.java | 5 +- .../component/AlphaSearchTooltipPane.java | 7 +- .../ProductNewsContentCellRender.java | 11 +- .../alphafine/component/ProductNewsList.java | 2 +- .../ProductNewsSearchResultPane.java | 2 +- .../component/RecommendSearchLabel.java | 57 +++++ .../component/RecommendSearchPane.java | 37 +-- .../alphafine/component/SearchHintPane.java | 80 ++++++ .../SearchResultContentCellRender.java | 11 +- .../alphafine/component/SearchResultPane.java | 5 +- .../alphafine/component/SelectedLabel.java | 2 +- .../component/TemplateResourcePanel.java | 28 ++- .../download/FineMarketConstants.java | 1 + .../download/FineMarketDownloadManager.java | 6 +- .../alphafine/model/TemplateResource.java | 25 +- .../model/TemplateResourceDetail.java | 55 +++-- .../alphafine/preview/DefaultContentPane.java | 57 +++++ .../preview/DefaultPluginContentPane.java | 120 +++++++++ .../preview/DefaultProductNewsPane.java | 9 +- .../preview/DocumentPreviewPane.java | 2 +- .../alphafine/preview/FilePreviewPane.java | 2 +- .../preview/HelpDocumentNoResultPane.java | 14 +- .../preview/LoadingRightSearchResultPane.java | 11 +- .../alphafine/preview/NetWorkFailedPane.java | 2 +- .../alphafine/preview/NoResultPane.java | 4 +- .../preview/NoResultWithLinkPane.java | 9 +- .../alphafine/preview/PluginPreviewPane.java | 2 +- .../alphafine/preview/RobotPreviewPane.java | 4 +- .../alphafine/preview/SearchLoadingPane.java | 2 +- .../preview/SimpleRightSearchResultPane.java | 5 +- .../preview/TemplateResourceDetailPane.java | 6 +- .../alphafine/preview/TemplateShopPane.java | 2 +- .../ProductNewsSearchWorkerManager.java | 7 +- .../alphafine/search/SearchManager.java | 14 +- .../alphafine/search/SearchTextBean.java | 2 + .../alphafine/search/SearchWorkerManager.java | 24 +- .../TemplateResourceSearchWorkerManager.java | 2 +- .../manager/SearchProviderRegistry.java | 35 +++ .../manager/fun/AlphaFineSearchProvider.java | 6 + .../manager/impl/ActionSearchManager.java | 20 +- .../manager/impl/ComplementAdviceManager.java | 4 +- .../manager/impl/DocumentSearchManager.java | 5 +- .../manager/impl/FileSearchManager.java | 19 +- .../search/manager/impl/HotIssuesManager.java | 4 +- .../manager/impl/PluginSearchManager.java | 74 +++++- .../impl/ProductNewsSearchManager.java | 4 +- .../manager/impl/RecentSearchManager.java | 2 +- .../manager/impl/RecommendSearchManager.java | 4 +- .../manager/impl/SegmentationManager.java | 2 +- .../manager/impl/SimilarSearchManager.java | 4 +- .../impl/TemplateResourceSearchManager.java | 22 +- .../alphafine/images/search_hint.svg | 37 +++ .../alphafine/cell/model/ModelTest.java | 2 +- 78 files changed, 1381 insertions(+), 283 deletions(-) rename {designer-realize/src/main/java/com/fr/design/mainframe => designer-base/src/main/java/com/fr/design/actions/help}/alphafine/AlphaFineCloudConstants.java (89%) rename {designer-realize/src/main/java/com/fr/design/mainframe => designer-base/src/main/java/com/fr/design/actions/help}/alphafine/AlphaFineConstants.java (88%) create mode 100644 designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java create mode 100644 designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java create mode 100644 designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java create mode 100644 designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java similarity index 89% rename from designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java rename to designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java index 537984470c..714c1f481d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java +++ b/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()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index a9db9cf934..79e52f51d7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -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 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 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 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(); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index 90d39b11ed..b9eddbc4f7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -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 getSelectedSearchRangeCheckBox() { + List 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; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java similarity index 88% rename from designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java rename to designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java index 0fffe30b2d..b723e08b16 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/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); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java new file mode 100644 index 0000000000..9e2af09379 --- /dev/null +++ b/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 sortItems; + private MenuLabel selectedLabel; + private AlphaFineConfigPane parentPane; + + public CustomSortPane(List 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 sortMap = new HashMap<>(); + for (int i = 0; i < currentTabOrder.length; i++) { + sortMap.put(currentTabOrder[i], i); + } + List sortLabels = new ArrayList<>(); + for (UICheckBox item : sortItems) { + MenuLabel label = new MenuLabel(item.getText(), (Function) 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 selectedTab = new HashSet<>(); + for (UICheckBox item : sortItems) { + selectedTab.add(item.getText()); + } + + // 未选中的tab,保持原排序不变 + Map 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); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java new file mode 100644 index 0000000000..5f3708ed97 --- /dev/null +++ b/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); + } + } + }; + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java new file mode 100644 index 0000000000..929f54837c --- /dev/null +++ b/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 labels; + + public MenuLabelPane(List 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); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java index 335397d908..fd3fac7bca 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java +++ b/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); diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java index 85d73515e5..38b559c88d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java +++ b/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 { } } }; -} \ No newline at end of file + + public boolean isDrawUnderLine() { + return drawUnderLine; + } + + public void setDrawUnderLine(boolean drawUnderLine) { + this.drawUnderLine = drawUnderLine; + } +} diff --git a/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java b/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java index 598ec7f057..d2d04b8d4c 100644 --- a/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java +++ b/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) { } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 441bd03ac6..126e883d9b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/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) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java index 5648ab98d6..bdc1d18d79 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineUtil.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java index 0422626093..b21f0e433d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java +++ b/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; } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java index 800c3f71d5..7699879484 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java index a61f5d9579..e5c1638f75 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java index 84ee2e30f9..2161e3f875 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java +++ b/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()); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java index 80f610f4eb..493bf0de7b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java @@ -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); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java index 43aca2cae8..3a22d8cad7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/BottomCellRender.java @@ -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.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index 4f57b92b28..07661ac4fb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java index 8d1d5a5f9b..4a1fee43fb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java +++ b/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.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index e1b4dcbd19..298efcc953 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 5d984dca39..860810b24f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/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 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 list) { + AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); + String[] tabOrder = alphaFineConfigManager.getTabOrder(); + Map 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 productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList(); Set readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java index f4ffe50e39..6cad0e2e26 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index b745b0de96..ccf6e6d5f0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java index 1b439f1a83..395dec800f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java index 3d33337724..7f9edfaffc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java index e803b647b5..6682618766 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java index c6b5983d68..a8f51641c6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java index 91c4825797..4231e5c99e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java index 3efba5fd14..6cfba8b491 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java new file mode 100644 index 0000000000..f7e017024f --- /dev/null +++ b/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 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); + } + }); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java index bd1abe5109..9be8aa7448 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java +++ b/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 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)); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java new file mode 100644 index 0000000000..83a2fdffcd --- /dev/null +++ b/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 hints) { + this(hints, ICON, TITLE); + } + + public SearchHintPane(List 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 hints) { + if (Collections.isEmpty(hints)) { + return new JLabel(); + } + return new RecommendSearchLabel(RECOMMEND, hints); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java index dd65d36a2f..b3fe2dc5b7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java index d4f6c18027..642a0da2b2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java index 9bf151adc9..4bc59fd935 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java index 4985f9c11d..20ac4b04f6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java +++ b/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 = "%s"; + private static final String HTML_JLABEL_FORMAT = "%s"; + + 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); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java index d5a45ad637..73a37ee9de 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java +++ b/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"; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java index 6ec224d0ed..601a8a15c3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java +++ b/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"); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java index d81d7b2805..6db81c1bc4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java +++ b/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 recommendSearchKey; private boolean embed; - /** - * json转obj - * */ + + + /// 其他属性 + // 当前搜索词 + private String searchWord; + public static List createByJson(JSONArray jsonArray) { List 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; + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java index 5ef5f8c834..fd5381f6a3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java +++ b/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 = "%s"; + static final String HTML_TAG_REGX="<[^>]+>"; + static final Pattern A_TAG_PATTERN = Pattern.compile("]*href=(\\\"([^\\\"]*)\\\"|\\'([^\\']*)\\'|([^\\\\s>]*))[^>]*>(.*?)"); + static final Pattern HTML_TAG_PATTERN = Pattern.compile(HTML_TAG_REGX); + /** - * 这里做下数据转换 - * 原始数据是html标签写的,如下 - * "
  1. 该模板需用10.0及以上版本设计器预览

  2. 该模板为库存场景解决方案的部分内容,全部内容可下载库存场景解决方案查看

  3. 为保障模板预览效果,建议安装新自适应插件(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询

", - * - * 转换的后的数据 是原始数据中所有

标签内的(包括标签)的字符串(List),如上字符串会转为如下 - * List [

该模板需用10.0及以上版本设计器预览

, - *

该模板为库存场景解决方案的部分内容,全部内容可下载库存场景解决方案查看

, - *

为保障模板预览效果,建议安装新自适应插件(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询

- * ] + * 数据格式转换 + * 原始数据的格式不统一,纯文本、html都有; 统一转为纯文本,如果有a标签则保留 * */ - static final Pattern HTML_PATTERN = Pattern.compile("

(.+?)

"); - static List parseDetailInfo(String htmlDetailInfo) { - List infos = new ArrayList<>(); - Matcher matcher = HTML_PATTERN.matcher(htmlDetailInfo); + static String reformat(String htmlDetailInfo) { + String result = HTML_TAG_PATTERN.matcher(htmlDetailInfo).replaceAll(""); + Map aMap = getLink(htmlDetailInfo); + for (Map.Entry 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 getLink(String html) { + Map 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; } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java new file mode 100644 index 0000000000..99c312e882 --- /dev/null +++ b/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; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java new file mode 100644 index 0000000000..9ed5003d36 --- /dev/null +++ b/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 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 createWorker() { + return new SwingWorker() { + @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 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; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java index d70e37ec04..e32e6dd249 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java index 6aa46f1a63..70e69f57f2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java +++ b/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.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java index 1ba7a5b915..1548aeb7b9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java +++ b/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.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java index b793cf52c9..bee71f5859 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java index 6201c25e58..916c7307a6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java index eb4c107c46..1dda65942c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java index 2187695f95..33fb600f1a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java +++ b/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; /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java index ebfdd99c4c..0159959de2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java +++ b/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; /** * 带跳转链接的无结果面板 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java index 6f659055e4..dbe3126647 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java index 6732e2205e..2340766925 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java index 112a5d2d02..66f61f1a4c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java index 6d94bd9ed8..656e80b6ec 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java index 48b684cf89..5ee312c021 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java +++ b/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 = "%s"; - private static final String DETAIL_INFO_HTML_FORMAT = "

" + DETAIL_INFO + "

%s"; + private static final String HTML_FORMAT = "%s"; + private static final String DETAIL_INFO_HTML_FORMAT = "

" + DETAIL_INFO + "

%s"; private static final String HTML_P_TAG_FORMAT = "

%s

"; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java index a1dbebd960..9060f1fb57 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java index 40161e9baa..b701abdf8b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java index f9f7893955..d8132c6871 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java +++ b/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(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java index f7148363c2..25fb64f9c6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java +++ b/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; /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java index 0b25c3ca1e..cdacd681d7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java index f99d22a5f9..bd007acff0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java new file mode 100644 index 0000000000..02d1fc35c2 --- /dev/null +++ b/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 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); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java index 631fce88ea..420762b87a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java @@ -22,6 +22,12 @@ public interface AlphaFineSearchProvider { */ SearchResult getMoreSearchResult(String searchText); + /** + * 不搜索的情况下,获取显示结果 + * */ + default SearchResult getDefaultResult() { + return new SearchResult(); + } /** * 获取所有搜索结果 取决于具体实现 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index 54d6d14025..4d2f93d295 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -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 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; + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java index 55c153f364..b9f4c31c4d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 9ef4c7c3df..69c34ba61c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 744b5a8399..5f358bbb5e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -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 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; + } + /** * 搜索模板内容 * diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java index 0e29a44c63..a0815c2e3b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -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; /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index ea4f359370..babf9f4865 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -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 plugins = jsonArray.getList(); + + List 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 parseDefaultPluginModel(List jsonObjects) { + List pluginModels = new ArrayList<>(); + if (!Collections.isEmpty(jsonObjects)) { + SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); + try { + jsonObjects.sort(Comparator.comparingLong(new ToLongFunction() { + @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; + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java index 1ee765c5a6..d694b97cae 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index d9b93fb556..992b429406 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index 11dc5424f9..d0fcbd3b0c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java index a953b70fe6..9e3d4bb679 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java @@ -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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java index 0689d24ea8..102ead1bb2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java +++ b/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; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java index 60f8467597..c4e7350d10 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java @@ -38,7 +38,19 @@ public class TemplateResourceSearchManager { public List getSearchResult(String searchText) { List resourceList = new ArrayList<>(); - // 联网搜索 + resourceList.addAll(searchOnline(searchText)); + resourceList.addAll(searchLocal(searchText)); + + resourceList.stream().forEach(resource -> {resource.setSearchWord(searchText);}); + + return resourceList; + } + + /** + * 联网搜索 + * */ + private List searchOnline(String searchText) { + List 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 searchLocal(String searchText) { + List resourceList = new ArrayList<>(); if (resourceList.isEmpty()) { List localResource = getEmbedResourceList(); localResource.stream().forEach(resource->{ diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg new file mode 100644 index 0000000000..767729dad5 --- /dev/null +++ b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java index 8de69db5c0..8c62b827ee 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java +++ b/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; From ee5ab02296e5a288afb4278bae231c0ee46ece52 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Thu, 27 Oct 2022 09:22:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-82937=20=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=8C=96=E4=BA=8C=E6=9C=9F=E7=9A=84=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=AD=A5=E5=88=B010.0=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BB=8E11=E5=90=88=E5=88=B010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/help/alphafine/AlphaFineConfigPane.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index b9eddbc4f7..4ee2eb5d42 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -90,7 +90,9 @@ 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}; From 1ff614a42a7493d37e0b4d6a0d42461c7df693f7 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Thu, 27 Oct 2022 16:05:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-83064=E3=80=90=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=8C=96=E4=BA=8C=E6=9C=9F=E3=80=9110.0?= =?UTF-8?q?=E4=BB=8D=E6=98=BE=E7=A4=BA=E4=B8=BA=E5=BA=94=E7=94=A8=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=EF=BC=8C=E5=BA=94=E8=AF=A5=E6=94=B9=E5=90=8D=E4=B8=BA?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=AD=E5=BF=83=201=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=9B=BD=E9=99=85=E5=8C=96=202=E3=80=81=E6=8E=92?= =?UTF-8?q?=E5=BA=8Fbug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/help/alphafine/AlphaFineConfigPane.java | 2 +- .../design/actions/help/alphafine/AlphaFineConstants.java | 2 +- .../fr/design/mainframe/alphafine/AlphaFineHelper.java | 2 +- .../mainframe/alphafine/component/AlphaFineFrame.java | 8 +++++++- .../search/manager/impl/PluginSearchManager.java | 6 +++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index 4ee2eb5d42..64ae6c8774 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -101,7 +101,7 @@ public class AlphaFineConfigPane extends BasicPane { // 搜索选项 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")); + containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon")); containDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); containMyTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_My_Templates")); containFileContentSearchCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java index b723e08b16..a6eb88ef8e 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java @@ -30,7 +30,7 @@ public class AlphaFineConstants { 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 PLUGIN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"); public static final String TEMPLATE_SHOP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop"); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 126e883d9b..4958dee645 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -176,7 +176,7 @@ public class AlphaFineHelper { } else if (object instanceof DocumentSearchManager) { result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); } else if (object instanceof PluginSearchManager) { - result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"))); } else if (object instanceof SimilarSearchManager) { result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"))); } else if (object instanceof HotIssuesManager) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 860810b24f..2f42289294 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -645,7 +645,13 @@ public class AlphaFineFrame extends JFrame { for (int i = 0; i < tabOrder.length; i++) { orderMap.put(tabOrder[i], i); } - list.sort(Comparator.comparingInt(tab -> orderMap.get(tab.getText()))); + list.sort(Comparator.comparingInt(tab -> { + Integer order = orderMap.get(tab.getText()); + if (order == null) { + order = list.size() - 1; + } + return order; + })); } private void fireOneClickRead() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index babf9f4865..520d396f1e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -116,7 +116,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { this.searchResult = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainPlugin()) { if (ArrayUtils.isEmpty(searchText)) { - lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"))); return lessModelList; } SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); @@ -147,10 +147,10 @@ public class PluginSearchManager implements AlphaFineSearchProvider { if (searchResult.isEmpty()) { return this.lessModelList; } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"))); lessModelList.addAll(searchResult); } else { - lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); + lessModelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.PLUGIN)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); }