Browse Source

Pull request #10149: REPORT-80734【运营产品化二期】自定义排序交互问题

Merge in DESIGN/design from ~LINK.ZHAO/design:feature/x to feature/x

* commit 'd04769a9105a47d61d1b1af8abb05c13fa299342':
  REPORT-80742【运营产品化二期】模板商城的说明字体大小仍然不统一 接口数据格式问题 统一转为纯文本,保留a标签
  无jira任务 解决报错
  REPORT-80734【运营产品化二期】自定义排序交互问题 1、交互修改一下
feature/x
Link.Zhao-赵展 2 years ago
parent
commit
e1b6ce4035
  1. 30
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  2. 31
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java
  3. 4
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java
  4. 12
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  5. 48
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java
  6. 6
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

30
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"));

31
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<MenuLabel, Object>) 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();

4
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;
}
}

12
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;
}
}

48
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 = "<a href=%s>%s</a>";
static final String HTML_TAG_REGX="<[^>]+>";
static final Pattern A_TAG_PATTERN = Pattern.compile("<a[^>]*href=(\\\"([^\\\"]*)\\\"|\\'([^\\']*)\\'|([^\\\\s>]*))[^>]*>(.*?)</a>");
static final Pattern HTML_TAG_PATTERN = Pattern.compile(HTML_TAG_REGX);
/**
* 这里做下数据转换
* 原始数据是html标签写的如下
* "<ol style="list-style-type: decimal;" class=" list-paddingleft-2"><li><p>该模板需用10.0及以上版本设计器预览<br/></p></li><li><p>该模板为库存场景解决方案的部分内容,全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p></li><li><p>为保障模板预览效果,建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询<br/></p></li></ol>",
*
* 转换的后的数据 是原始数据中所有<p></p>标签内的包括标签的字符串List<String>,如上字符串会转为如下
* List [<p>该模板需用10.0及以上版本设计器预览<br/></p>,
* <p>该模板为库存场景解决方案的部分内容全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p>,
* <p>为保障模板预览效果建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>FR11.0版本插件已内置无需手动安装有使用需求或疑问请联系帆软技术支持咨询<br/></p>
* ]
* 数据格式转换
* 原始数据的格式不统一纯文本html都有; 统一转为纯文本如果有a标签则保留
* */
static final Pattern htmlPattern = Pattern.compile("<p>(.+?)</p>");
static List<String> parseDetailInfo(String htmlDetailInfo) {
List<String> infos = new ArrayList<>();
Matcher matcher = htmlPattern.matcher(htmlDetailInfo);
static String reformat(String htmlDetailInfo) {
String result = HTML_TAG_PATTERN.matcher(htmlDetailInfo).replaceAll("");
Map<String, String> aMap = getLink(htmlDetailInfo);
for (Map.Entry<String, String> entry : aMap.entrySet()) {
String aTag = String.format(A_TAG_FORMAT, entry.getValue(), entry.getKey());
result = result.replace(entry.getKey(), aTag);
}
return result;
}
/**
* 读取dom中的a标签转换为map
*/
static Map<String, String> getLink(String html) {
Map<String, String> map = new HashMap<>();
Matcher matcher = A_TAG_PATTERN.matcher(html);
while (matcher.find()) {
infos.add(matcher.group());
map.put(matcher.group(5), matcher.group(1));
}
return infos;
return map;
}
}

6
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());

Loading…
Cancel
Save