|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.fr.design.mainframe.alphafine.preview; |
|
|
|
package com.fr.design.mainframe.alphafine.preview; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.design.dialog.link.MessageWithLink; |
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
|
|
@ -8,12 +9,14 @@ import com.fr.design.mainframe.alphafine.action.StartUseAction; |
|
|
|
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel; |
|
|
|
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel; |
|
|
|
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail; |
|
|
|
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail; |
|
|
|
import com.fr.design.utils.BrowseUtils; |
|
|
|
import com.fr.design.utils.BrowseUtils; |
|
|
|
|
|
|
|
import com.fr.design.utils.LinkStrUtils; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.SwingConstants; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.FlowLayout; |
|
|
|
import java.awt.FlowLayout; |
|
|
@ -22,7 +25,6 @@ import java.awt.Graphics2D; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TemplateResourceDetailPane extends JPanel { |
|
|
|
public class TemplateResourceDetailPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
@ -37,12 +39,12 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int IMAGE_HEIGHT = 170; |
|
|
|
private static final int IMAGE_HEIGHT = 170; |
|
|
|
private static final int IMAGE_WIDTH= 310; |
|
|
|
private static final int IMAGE_WIDTH = 310; |
|
|
|
private static final int SCROLL_PANE_WIDTH = 315; |
|
|
|
private static final int SCROLL_PANE_WIDTH = 315; |
|
|
|
private static final int SCROLL_PANE_HEIGHT = 135; |
|
|
|
private static final int SCROLL_PANE_HEIGHT = 135; |
|
|
|
private static final int CONTENT_PANE_WIDTH = 320; |
|
|
|
private static final int CONTENT_PANE_WIDTH = 320; |
|
|
|
private static final int CONTENT_PANE_HEIGHT = 180; |
|
|
|
private static final int CONTENT_PANE_HEIGHT = 180; |
|
|
|
private static final int DETAIL_PANE_HEIGHT = 110; |
|
|
|
private static final int DETAIL_PANE_HEIGHT = 95; |
|
|
|
private static final int TEXT_SCROLL_PANE_HEIGHT = 500; |
|
|
|
private static final int TEXT_SCROLL_PANE_HEIGHT = 500; |
|
|
|
private static final int PANE_WIDTH = 635; |
|
|
|
private static final int PANE_WIDTH = 635; |
|
|
|
private static final int BUTTON_WIDTH = 68; |
|
|
|
private static final int BUTTON_WIDTH = 68; |
|
|
@ -64,26 +66,36 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c); |
|
|
|
private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c); |
|
|
|
private static final Color MORE_INFO_LINK = new Color(0x419bf9); |
|
|
|
private static final Color MORE_INFO_LINK = new Color(0x419bf9); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String HTML_FORMAT = "<html><body style=\"font-size: 12pt\">%s</body></html>"; |
|
|
|
|
|
|
|
private static final String DETAIL_INFO_HTML_FORMAT = "<html><body style=\"font-size: 12pt\"><h3>" + DETAIL_INFO + "</h3>%s</body></html>"; |
|
|
|
|
|
|
|
private static final String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TemplateResourceDetailPane(TemplateResourceDetail detail) { |
|
|
|
public TemplateResourceDetailPane(TemplateResourceDetail detail) { |
|
|
|
this.data = detail; |
|
|
|
this.data = detail; |
|
|
|
initComponent(); |
|
|
|
initComponent(); |
|
|
|
this.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
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(imagePane); |
|
|
|
this.add(contentPane); |
|
|
|
this.add(contentPane); |
|
|
|
this.add(detailInfoPane); |
|
|
|
this.add(detailInfoPane); |
|
|
|
this.setBackground(Color.WHITE); |
|
|
|
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() { |
|
|
|
private void initComponent() { |
|
|
|
createImagePane(); |
|
|
|
createImagePane(); |
|
|
|
createContentPane(); |
|
|
|
createContentPane(); |
|
|
|
createDetailInfoPane(); |
|
|
|
createDetailInfoScrollPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void createContentPane() { |
|
|
|
private void createContentPane() { |
|
|
@ -97,6 +109,9 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
contentPane.setBackground(Color.WHITE); |
|
|
|
contentPane.setBackground(Color.WHITE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 操作区:查看详情,立即使用 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void createOperatePane() { |
|
|
|
private void createOperatePane() { |
|
|
|
operatePane = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
operatePane = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
|
|
|
|
|
|
|
@ -118,6 +133,9 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查看详情 |
|
|
|
|
|
|
|
*/ |
|
|
|
JLabel createLinkLabel() { |
|
|
|
JLabel createLinkLabel() { |
|
|
|
JLabel linkLabel = new JLabel(GOTO_DETAIL); |
|
|
|
JLabel linkLabel = new JLabel(GOTO_DETAIL); |
|
|
|
linkLabel.setBackground(Color.WHITE); |
|
|
|
linkLabel.setBackground(Color.WHITE); |
|
|
@ -132,11 +150,17 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
return linkLabel; |
|
|
|
return linkLabel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 方便埋点
|
|
|
|
/** |
|
|
|
|
|
|
|
* 方便埋点 |
|
|
|
|
|
|
|
*/ |
|
|
|
void openResourceUrl(String url) { |
|
|
|
void openResourceUrl(String url) { |
|
|
|
BrowseUtils.browser(url); |
|
|
|
BrowseUtils.browser(url); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* “立即使用” 按钮 |
|
|
|
|
|
|
|
*/ |
|
|
|
JButton createStartUseButton() { |
|
|
|
JButton createStartUseButton() { |
|
|
|
JButton starUseButton = new JButton(START_USE) { |
|
|
|
JButton starUseButton = new JButton(START_USE) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -148,7 +172,7 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
super.paintComponent(g2d); |
|
|
|
super.paintComponent(g2d); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
starUseButton.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); |
|
|
|
starUseButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
starUseButton.setForeground(Color.WHITE); |
|
|
|
starUseButton.setForeground(Color.WHITE); |
|
|
|
starUseButton.setFont(AlphaFineConstants.MEDIUM_FONT); |
|
|
|
starUseButton.setFont(AlphaFineConstants.MEDIUM_FONT); |
|
|
|
starUseButton.addActionListener(new StartUseAction(data)); |
|
|
|
starUseButton.addActionListener(new StartUseAction(data)); |
|
|
@ -157,62 +181,48 @@ public class TemplateResourceDetailPane extends JPanel { |
|
|
|
return starUseButton; |
|
|
|
return starUseButton; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createImagePane() { |
|
|
|
|
|
|
|
imagePane = new TemplateResourceImagePanel(data.getRoot(), IMAGE_WIDTH, IMAGE_HEIGHT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 基本信息页 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void createInfoScrollPane() { |
|
|
|
private void createInfoScrollPane() { |
|
|
|
JLabel content = new JLabel(); |
|
|
|
|
|
|
|
content.setHorizontalAlignment(SwingConstants.LEFT); |
|
|
|
|
|
|
|
content.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
|
|
sb.append("<html><body><p>"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append(VENDOR + data.getVendor() + LF); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
|
|
List<String> tags = data.getTagsName(); |
|
|
|
// 开发者
|
|
|
|
sb.append(TAGS); |
|
|
|
sb.append(String.format(HTML_P_TAG_FORMAT, VENDOR + data.getVendor())); |
|
|
|
for (String tag : tags) { |
|
|
|
// 标签
|
|
|
|
sb.append(tag + SPACE); |
|
|
|
sb.append(String.format(HTML_P_TAG_FORMAT, TAGS + data.getTagsString())); |
|
|
|
|
|
|
|
// 所属模板包
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(data.getParentPkgName())) { |
|
|
|
|
|
|
|
sb.append(String.format(HTML_P_TAG_FORMAT, PARENT_PACKAGE + LinkStrUtils.generateLinkTagWithoutUnderLine(data.getParentPkgUrl(), data.getParentPkgName()))); |
|
|
|
} |
|
|
|
} |
|
|
|
sb.append(LF); |
|
|
|
// 信息
|
|
|
|
|
|
|
|
sb.append(String.format(HTML_P_TAG_FORMAT, data.getInfo())); |
|
|
|
|
|
|
|
|
|
|
|
sb.append(PARENT_PACKAGE + data.getParentPkgName() + LF); |
|
|
|
|
|
|
|
sb.append(data.getInfo()); |
|
|
|
MessageWithLink content = new MessageWithLink(String.format(HTML_FORMAT, sb)); |
|
|
|
sb.append("</p></body></html>"); |
|
|
|
|
|
|
|
content.setText(sb.toString()); |
|
|
|
|
|
|
|
content.setBackground(INFO_PANE_BACKGROUND); |
|
|
|
content.setBackground(INFO_PANE_BACKGROUND); |
|
|
|
content.setForeground(INFO_PANE_FOREGROUND); |
|
|
|
content.setForeground(INFO_PANE_FOREGROUND); |
|
|
|
content.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH - 10, TEXT_SCROLL_PANE_HEIGHT)); |
|
|
|
|
|
|
|
infoScrollPane = new UIScrollPane(content); |
|
|
|
infoScrollPane = new UIScrollPane(content); |
|
|
|
infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT)); |
|
|
|
infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT)); |
|
|
|
infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); |
|
|
|
infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createImagePane() { |
|
|
|
|
|
|
|
imagePane = new TemplateResourceImagePanel(data.getRoot(), IMAGE_WIDTH, IMAGE_HEIGHT); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void createDetailInfoPane() { |
|
|
|
/** |
|
|
|
|
|
|
|
* 详细信息页 |
|
|
|
JLabel content = new JLabel(); |
|
|
|
*/ |
|
|
|
content.setHorizontalAlignment(SwingConstants.LEFT); |
|
|
|
private void createDetailInfoScrollPane() { |
|
|
|
content.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
MessageWithLink content = new MessageWithLink(String.format(DETAIL_INFO_HTML_FORMAT, data.getHtmlText())); |
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
|
|
sb.append("<html><body><p>"); |
|
|
|
|
|
|
|
sb.append(DETAIL_INFO + LF); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> detailInfos = data.getDetailInfo(); |
|
|
|
|
|
|
|
for (String info : detailInfos) { |
|
|
|
|
|
|
|
sb.append(info); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sb.append("</p></body></html>"); |
|
|
|
|
|
|
|
content.setText(sb.toString()); |
|
|
|
|
|
|
|
content.setPreferredSize(new Dimension(PANE_WIDTH - 20, TEXT_SCROLL_PANE_HEIGHT)); |
|
|
|
|
|
|
|
content.setBackground(Color.WHITE); |
|
|
|
|
|
|
|
detailInfoPane = new UIScrollPane(content); |
|
|
|
detailInfoPane = new UIScrollPane(content); |
|
|
|
detailInfoPane.setPreferredSize(new Dimension(PANE_WIDTH, DETAIL_PANE_HEIGHT)); |
|
|
|
detailInfoPane.setPreferredSize(new Dimension(PANE_WIDTH, DETAIL_PANE_HEIGHT)); |
|
|
|
detailInfoPane.setBackground(Color.WHITE); |
|
|
|
detailInfoPane.setBackground(Color.WHITE); |
|
|
|
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); |
|
|
|
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |