From 0a32b3ac133c5db971156d42276f28d605a89c20 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Fri, 23 Sep 2022 11:56:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-80734=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=91=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8E=92=E5=BA=8F=E4=BA=A4=E4=BA=92=E9=97=AE?= =?UTF-8?q?=E9=A2=98=201=E3=80=81=E4=BA=A4=E4=BA=92=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../help/alphafine/AlphaFineConfigPane.java | 30 +++++++++--------- .../alphafine/component/CustomSortPane.java | 31 ++++++++++++++++--- .../help/alphafine/component/MenuLabel.java | 4 +-- .../com/fr/design/gui/ibutton/UIButton.java | 12 +++++++ 4 files changed, 57 insertions(+), 20 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 2a64eeba6d..dcc20f6ea7 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 @@ -114,7 +114,9 @@ public class AlphaFineConfigPane extends BasicPane { 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()) { @@ -178,25 +180,25 @@ public class AlphaFineConfigPane extends BasicPane { 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")); 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 index 09415d5327..747b8d8ce0 100644 --- 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 @@ -74,10 +74,14 @@ public class CustomSortPane extends JPanel { } private void createToolbarPane() { - top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg")); - bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg")); - up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg")); - down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg")); + 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); @@ -132,6 +136,7 @@ public class CustomSortPane extends JPanel { for (UICheckBox item : sortItems) { MenuLabel label = new MenuLabel(item.getText(), (Function) o -> { selectedLabel = o; + disableButton(); return null; }); sortLabels.add(label); @@ -140,6 +145,24 @@ public class CustomSortPane extends JPanel { sortItemPane = new MenuLabelPane(sortLabels); } + /** + * 如果选中第一个和最后一个,则置灰向上和向下的按钮 + */ + private void disableButton() { + int order = sortItemPane.getComponentZOrder(selectedLabel); + if (order == 0) { + top.setEnabled(false); + up.setEnabled(false); + } else if (order == sortItemPane.getComponentCount() - 1) { + down.setEnabled(false); + bottom.setEnabled(false); + } else { + up.setEnabled(true); + top.setEnabled(true); + down.setEnabled(true); + bottom.setEnabled(true); + } + } private void refreshCurrentOrder() { String[] currentTabOrder = parentPane.getCurrentOrder(); 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 index 96c7a17971..5f3708ed97 100644 --- 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 @@ -61,10 +61,10 @@ public class MenuLabel extends UILabel { parentMenu.setNoneSelected(); setBackground(SELECTED_COLOR); function.apply(this); - selected = true; + this.selected = true; } else { setBackground(BACKGROUND_COLOR); - selected = false; + this.selected = 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..e5f2c03ff8 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); @@ -397,4 +405,8 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { public boolean shouldResponseChangeListener() { return true; } + + + + } From 780f63991c2d0ff31daf11c76134c6b71f0efc1e Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Fri, 23 Sep 2022 14:16:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/alphafine/cell/model/ModelTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 af378b5d4d..2311514d17 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.actions.help.alphafine.AlphaFineConstants; +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; @@ -14,8 +14,8 @@ public class ModelTest { Assert.assertEquals("name", documentModel.getName()); Assert.assertEquals("content", documentModel.getContent()); Assert.assertEquals(1, documentModel.getDocumentId()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); + Assert.assertEquals(AlphaFineCloudConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); + Assert.assertEquals(AlphaFineCloudConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); Assert.assertEquals(true, documentModel.hasAction()); From d04769a9105a47d61d1b1af8abb05c13fa299342 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Fri, 23 Sep 2022 17:39:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-80742=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=91=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=95=86=E5=9F=8E=E7=9A=84=E8=AF=B4=E6=98=8E=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E5=A4=A7=E5=B0=8F=E4=BB=8D=E7=84=B6=E4=B8=8D=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=20=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98=20=E7=BB=9F=E4=B8=80=E8=BD=AC?= =?UTF-8?q?=E4=B8=BA=E7=BA=AF=E6=96=87=E6=9C=AC=EF=BC=8C=E4=BF=9D=E7=95=99?= =?UTF-8?q?a=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/TemplateResourceDetail.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) 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 5065f6a2b4..0a1d98449c 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,9 +8,10 @@ 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; @@ -169,7 +170,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)); @@ -191,7 +192,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)); @@ -214,25 +215,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 htmlPattern = Pattern.compile("

(.+?)

"); - static List parseDetailInfo(String htmlDetailInfo) { - List infos = new ArrayList<>(); - Matcher matcher = htmlPattern.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; } }