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 a0b0ef4bff..41d4881605 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 @@ -27,27 +27,27 @@ public class RecommendSearchPane extends TemplateResourcePanel { this.setBorder(BorderFactory.createLineBorder(BORDER_WHITE, 1)); this.add(getNorthPane(), BorderLayout.NORTH); - this.add(getSouthPane(), BorderLayout.SOUTH); + this.add(getCenterPane(), BorderLayout.CENTER); } private void initComponent() { createNorthPane(); - createSouthPane(); + createCenterPane(); } - private void createSouthPane() { - setSouthPane(new JPanel(new FlowLayout(FlowLayout.LEFT))); - JPanel southPane = getSouthPane(); - southPane.setBackground(Color.WHITE); + 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")); - southPane.add(recommend); + centerPane.add(recommend); List searchKeys = getTemplateResource().getRecommendSearchKey(); for (String key : searchKeys) { JLabel keyLabel = new SearchKeyLabel(key); - southPane.add(keyLabel); + centerPane.add(keyLabel); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java index 13d29d76f7..2c70e06c46 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java @@ -5,8 +5,10 @@ import com.fr.design.mainframe.alphafine.model.TemplateResource; import com.fr.third.jodd.util.StringUtil; import javax.swing.JPanel; +import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; @@ -17,7 +19,9 @@ public class TemplateResourceImagePanel extends JPanel { private static final int BACKGROUND_HEIGHT = 20; - private static final Color BACKGROUND_COLOR = new Color(116, 181, 249); + private static final Color BACKGROUND_COLOR = new Color(0x419BF9); + + private static final Font TAG_FONT = new Font("PingFang SC", Font.PLAIN, 12); private static final Color COVER_COLOR = new Color(116, 181, 249, 26); @@ -56,10 +60,12 @@ public class TemplateResourceImagePanel extends JPanel { String tagName = templateResource.getType().getName(); if (!StringUtil.isEmpty(tagName)) { + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, .8f)); g2.setColor(BACKGROUND_COLOR); g2.fillRect(0, getHeight() - BACKGROUND_HEIGHT, getWidth(), BACKGROUND_HEIGHT); g2.setColor(Color.WHITE); int x = (getWidth() - GraphHelper.getWidth(tagName, g2.getFont())) / 2; + g2.setFont(TAG_FONT); g2.drawString(tagName, x, getHeight() - 5); } g2.setColor(defaultColor); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java index 2bafebc566..fc04587690 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java @@ -126,6 +126,7 @@ public class TemplateResourcePageGridPane extends JPanel { this.add(pageButtonPane, BorderLayout.SOUTH); } this.setBackground(Color.WHITE); + this.setBorder(BorderFactory.createEmptyBorder()); } private void initComponents() { 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 4eba18c63c..8447d9dbdf 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 @@ -12,6 +12,7 @@ import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -19,11 +20,13 @@ import java.awt.event.MouseEvent; public class TemplateResourcePanel extends JPanel { private JPanel northPane; - private JPanel southPane; + private JPanel centerPane; private TemplateResource templateResource; private static final Color PANEL_BORDER_COLOR = new Color(0xe8e8e9); private static final Color DEMO_LABEL_FOREGROUND = new Color(0x419bf9); + private static final Font RESOURCE_NAME_FONT = new Font("PingFang SC", Font.PLAIN, 12); + private static final Color RESOURCE_NAME_COLOR = new Color(0x5c5c5d); protected TemplateResourcePanel() { @@ -35,7 +38,7 @@ public class TemplateResourcePanel extends JPanel { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createLineBorder(PANEL_BORDER_COLOR, 1)); this.add(northPane, BorderLayout.NORTH); - this.add(southPane, BorderLayout.SOUTH); + this.add(centerPane, BorderLayout.CENTER); addAction(); } @@ -60,8 +63,8 @@ public class TemplateResourcePanel extends JPanel { public JPanel getNorthPane() { return northPane; } - public JPanel getSouthPane() { - return southPane; + public JPanel getCenterPane() { + return centerPane; } public TemplateResource getTemplateResource() { return templateResource; @@ -71,8 +74,8 @@ public class TemplateResourcePanel extends JPanel { this.northPane = northPane; } - public void setSouthPane(JPanel southPane) { - this.southPane = southPane; + public void setCenterPane(JPanel centerPane) { + this.centerPane = centerPane; } public void setTemplateResource(TemplateResource templateResource) { @@ -81,15 +84,17 @@ public class TemplateResourcePanel extends JPanel { private void initComponent() { createNorthPane(); - createSouthPane(); + createCenterPane(); } protected void createNorthPane() { northPane = new TemplateResourceImagePanel(templateResource); } - private void createSouthPane() { + 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()); @@ -109,10 +114,10 @@ public class TemplateResourcePanel extends JPanel { }); } - southPane = new JPanel(new BorderLayout()); - southPane.setBackground(Color.WHITE); - southPane.add(nameLabel, BorderLayout.WEST); - southPane.add(demoLabel, BorderLayout.EAST); + centerPane = new JPanel(new BorderLayout()); + centerPane.setBackground(Color.WHITE); + centerPane.add(nameLabel, BorderLayout.WEST); + centerPane.add(demoLabel, BorderLayout.EAST); } @Override 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 8d0ef703bf..74de64329a 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 @@ -66,8 +66,8 @@ public class TemplateResourceDetailPane extends JPanel { private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c); private static final Color MORE_INFO_LINK = new Color(0x419bf9); - 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

"; @@ -208,6 +208,7 @@ public class TemplateResourceDetailPane extends JPanel { content.setBackground(INFO_PANE_BACKGROUND); content.setForeground(INFO_PANE_FOREGROUND); infoScrollPane = new UIScrollPane(content); + infoScrollPane.setForeground(INFO_PANE_FOREGROUND); infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT)); infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java index 07fd402fb5..0767df4e6e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java @@ -161,17 +161,36 @@ public class FineMarketClientHelper { finalDir.mkdir(); } - // 获取文件名(含后缀) fileName = resource.getFileName(); - String prefix = fileName.substring(0, fileName.length() - 4); - String suffix = fileName.substring(fileName.length() - 4); + fileName = rename(fileName, finalDir); - // 处理重复文件名 + File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName)); + return destFile; + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + fileName = UUID.randomUUID() + fileName; + File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName)); + return dest; + } + + /** + * 处理下文件名,比如重复下载需要处理重名的情况 + * */ + String rename(String fileName, File parentDir) { + // 获取文件名(含后缀) + String prefix = fileName.substring(0, fileName.length() - 4); + String suffix = fileName.substring(fileName.length() - 4); + + + File file = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(parentDir), fileName)); + // 处理重复文件名 + if (file.exists()) { String fileNameFormat = prefix + "(%d)" + suffix; Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix); int cnt = 0; - File[] files = finalDir.listFiles(); + File[] files = parentDir.listFiles(); for (File f : files) { Matcher matcher = pattern.matcher(f.getName()); if (matcher.find()) { @@ -180,15 +199,9 @@ public class FineMarketClientHelper { } cnt++; fileName = String.format(fileNameFormat, cnt); - - File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName)); - return destFile; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); } - fileName = UUID.randomUUID() + fileName; - File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName)); - return dest; + return fileName; + } private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {