diff --git a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java index d412fb682d..3e41750585 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java +++ b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java @@ -22,7 +22,12 @@ import static com.fr.design.utils.LinkStrUtils.LABEL; * Created by hades on 2020/10/23 */ public class MessageWithLink extends JEditorPane { - + + private static final String HTML_BODY = "
的话,将会自动点击匹配 url @@ -69,6 +74,34 @@ public class MessageWithLink extends JEditorPane { this(frontMessage, linkName, link, backMessage, color, font, LABEL.getForeground()); } + public MessageWithLink(String htmlText, Font font) { + this(setHtmlFont(htmlText, font)); + } + + + + /** + * 将指定的字体赋给html文本 + * 任何失败,返回原html文本 + * */ + private static String setHtmlFont(String htmlText, Font font) { + + try { + int bodyIndex = htmlText.indexOf(HTML_BODY); + StringBuilder sb = new StringBuilder(); + String left = htmlText.substring(0, bodyIndex + HTML_BODY.length()); + String right = htmlText.substring(bodyIndex + HTML_BODY.length()); + sb.append(left); + sb.append(String.format(HTML_STYLE_FORMAT, LinkStrUtils.generateStyle(Color.WHITE, font, Color.BLACK))); + sb.append(right); + return sb.toString(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + + return htmlText; + } + public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color backgroundColor, Font font, Color fontColor) { super("text/html", "" + frontMessage + "" + linkName + "" + backMessage + ""); diff --git a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java index b7f8217b44..2bb245b449 100644 --- a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java @@ -42,6 +42,10 @@ public class LinkStrUtils { return "" + text + ""; } + + public static String generateLinkTagWithoutUnderLine(String link, String text) { + return "" + text + ""; + } public static String generateStyle(Color backgroundColor, Font font, Color fontColor) { 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 09cfbaf8a8..bfd40aea32 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 @@ -438,11 +438,7 @@ public class AlphaFineFrame extends JFrame { labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); labelPane.setBackground(Color.WHITE); labelContentPane = new JPanel(new BorderLayout()); - tabLabel = new UILabel(PRODUCT_NEWS); - tabLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); - tabLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); - tabLabel.setPreferredSize(new Dimension(60, 30)); - tabLabel.setForeground(AlphaFineConstants.LABEL_SELECTED); + tabLabel = createTabLabel(PRODUCT_NEWS); labelWestPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); labelWestPane.add(tabLabel); labelContentPane.add(labelWestPane, BorderLayout.WEST); @@ -491,6 +487,14 @@ public class AlphaFineFrame extends JFrame { return showPane; } + private UILabel createTabLabel(String labelName) { + UILabel label = new UILabel(labelName); + label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + label.setPreferredSize(new Dimension(60, 30)); + label.setForeground(AlphaFineConstants.LABEL_SELECTED); + return label; + } + public JPanel getLabelWestPane() { return labelWestPane; } @@ -588,6 +592,7 @@ public class AlphaFineFrame extends JFrame { private void refreshLabelPane() { labelWestPane.removeAll(); + tabLabel.setForeground(AlphaFineConstants.LABEL_SELECTED); labelWestPane.add(tabLabel); } @@ -696,17 +701,20 @@ public class AlphaFineFrame extends JFrame { if (searchResultList != null) { searchResultList.requestFocus(); } - boolean hasSearchResult = true; - if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) { - hasSearchResult = productNewsSearchWorkerManager.hasSearchResult(); - } else { - hasSearchResult = currentSearchWorkerManager.hasSearchResult(); - } - if (!hasSearchResult) { + if (!hasSearchResult()) { showResult(CellType.NO_RESULT.getFlagStr4None()); } + } + private boolean hasSearchResult() { + if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) { + return productNewsSearchWorkerManager.hasSearchResult(); + } else if (selectedTab.getCellType() == CellType.TEMPLATE_SHOP) { + return templateResourceSearchWorkerManager.hasSearchResult(); + } else { + return currentSearchWorkerManager.hasSearchResult(); + } } private void initSearchTextField() { 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 2f34534406..5065f6a2b4 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 @@ -23,11 +23,13 @@ public class TemplateResourceDetail { private final TemplateResource root; private String info; private String vendor; + private String htmlText; private List%s
"; + + public TemplateResourceDetailPane(TemplateResourceDetail detail) { this.data = detail; initComponent(); this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.setBorder(BorderFactory.createEmptyBorder(10,20,0,20)); + this.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20)); this.add(imagePane); this.add(contentPane); this.add(detailInfoPane); this.setBackground(Color.WHITE); + SwingUtilities.invokeLater(()->{scrollToTop();}); } - public void refresh() { - + /** + * scrollPane创建后会拉到最底下,初始化的时候手动拉到顶 + */ + public void scrollToTop() { + infoScrollPane.getVerticalScrollBar().setValue(0); + detailInfoPane.getVerticalScrollBar().setValue(0); } private void initComponent() { createImagePane(); createContentPane(); - createDetailInfoPane(); + createDetailInfoScrollPane(); } private void createContentPane() { @@ -97,6 +109,9 @@ public class TemplateResourceDetailPane extends JPanel { contentPane.setBackground(Color.WHITE); } + /** + * 操作区:查看详情,立即使用 + */ private void createOperatePane() { operatePane = new JPanel(new FlowLayout(FlowLayout.LEFT)); @@ -118,6 +133,9 @@ public class TemplateResourceDetailPane extends JPanel { } + /** + * 查看详情 + */ JLabel createLinkLabel() { JLabel linkLabel = new JLabel(GOTO_DETAIL); linkLabel.setBackground(Color.WHITE); @@ -132,11 +150,17 @@ public class TemplateResourceDetailPane extends JPanel { return linkLabel; } - // 方便埋点 + /** + * 方便埋点 + */ void openResourceUrl(String url) { BrowseUtils.browser(url); } + + /** + * “立即使用” 按钮 + */ JButton createStartUseButton() { JButton starUseButton = new JButton(START_USE) { @Override @@ -148,7 +172,7 @@ public class TemplateResourceDetailPane extends JPanel { super.paintComponent(g2d); } }; - starUseButton.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); + starUseButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); starUseButton.setForeground(Color.WHITE); starUseButton.setFont(AlphaFineConstants.MEDIUM_FONT); starUseButton.addActionListener(new StartUseAction(data)); @@ -157,62 +181,48 @@ public class TemplateResourceDetailPane extends JPanel { return starUseButton; } + private void createImagePane() { + imagePane = new TemplateResourceImagePanel(data.getRoot(), IMAGE_WIDTH, IMAGE_HEIGHT); + } + /** + * 基本信息页 + */ private void createInfoScrollPane() { - JLabel content = new JLabel(); - content.setHorizontalAlignment(SwingConstants.LEFT); - content.setVerticalAlignment(SwingConstants.TOP); - StringBuilder sb = new StringBuilder(); - sb.append("");
- sb.append(VENDOR + data.getVendor() + LF);
+ StringBuilder sb = new StringBuilder();
- List
");
- sb.append(DETAIL_INFO + LF);
-
- List