|
|
|
@ -7,6 +7,7 @@ import com.fr.design.gui.ibutton.UIButtonUI;
|
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.share.collect.ComponentCollector; |
|
|
|
|
import com.fr.design.mainframe.share.ui.widgetfilter.FilterConfigPane; |
|
|
|
|
import com.fr.design.mainframe.share.util.OnlineShopUtils; |
|
|
|
@ -18,10 +19,13 @@ import com.fr.stable.StringUtils;
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.UIManager; |
|
|
|
|
import java.awt.AlphaComposite; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.FontMetrics; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.Image; |
|
|
|
|
import java.awt.Point; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
@ -41,7 +45,9 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
private static final String EMBED_PANE_TIMER = "EMBED_PANE_TIMER"; |
|
|
|
|
private static final Color BORDER_COLOR = Color.decode("#D9DADD"); |
|
|
|
|
private static final Color SEARCH_BUTTON_COLOR = Color.decode("#419BF9"); |
|
|
|
|
private static final float DELTA_ALPHA = 0.13F; |
|
|
|
|
private Image image; |
|
|
|
|
private float alpha = 1.0F; |
|
|
|
|
|
|
|
|
|
public EmbedPane(OnlineEmbedFilterShowPane showPane) { |
|
|
|
|
this.addMouseListener(new MouseAdapter() { |
|
|
|
@ -54,8 +60,7 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
private JPanel initCenterPane(OnlineEmbedFilterShowPane showPane) { |
|
|
|
|
JPanel jPanel = new JPanel(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
jPanel.setBackground(Color.WHITE); |
|
|
|
|
jPanel.setPreferredSize(new Dimension(200, 200)); |
|
|
|
|
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); |
|
|
|
|
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); |
|
|
|
|
|
|
|
|
|
FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) { |
|
|
|
|
@Override |
|
|
|
@ -65,9 +70,9 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
}; |
|
|
|
|
UIButton searchBtn = initSearchBtn(filterConfigPane, showPane); |
|
|
|
|
filterConfigPane.setBorder(null); |
|
|
|
|
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Tip")); |
|
|
|
|
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
|
|
|
|
jPanel.add(tipLabel, BorderLayout.NORTH); |
|
|
|
|
JPanel tipPane = getFilterTipPane(); |
|
|
|
|
tipPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
|
|
|
|
jPanel.add(tipPane, BorderLayout.NORTH); |
|
|
|
|
jPanel.add(filterConfigPane, BorderLayout.CENTER); |
|
|
|
|
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
southPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8)); |
|
|
|
@ -79,6 +84,43 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
return jPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel getFilterTipPane() { |
|
|
|
|
String remark = Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Tip"); |
|
|
|
|
UILabel label = new UILabel(); |
|
|
|
|
label.setSize(new Dimension(212, 30)); |
|
|
|
|
|
|
|
|
|
//用THML标签进行拼接,以实现自动换行
|
|
|
|
|
StringBuilder builder = new StringBuilder("<html>"); |
|
|
|
|
char[] chars = remark.toCharArray(); |
|
|
|
|
//获取字体计算大小
|
|
|
|
|
FontMetrics fontMetrics = label.getFontMetrics(label.getFont()); |
|
|
|
|
int start = 0; |
|
|
|
|
int len = 0; |
|
|
|
|
while (start + len < remark.length()) { |
|
|
|
|
while (true) { |
|
|
|
|
len++; |
|
|
|
|
if (start + len > remark.length()) |
|
|
|
|
break; |
|
|
|
|
if (fontMetrics.charsWidth(chars, start, len) |
|
|
|
|
> label.getWidth()) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
builder.append(chars, start, len - 1).append("<br/>"); |
|
|
|
|
start = start + len - 1; |
|
|
|
|
len = 0; |
|
|
|
|
} |
|
|
|
|
//拼接剩余部分
|
|
|
|
|
builder.append(chars, start, remark.length() - start); |
|
|
|
|
builder.append("</html>"); |
|
|
|
|
|
|
|
|
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
label.setText(builder.toString()); |
|
|
|
|
jPanel.add(label); |
|
|
|
|
|
|
|
|
|
return jPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private UIButton initSearchBtn(FilterConfigPane filterConfigPane, OnlineEmbedFilterShowPane showPane) { |
|
|
|
|
UIButton searchBtn = new UIButton(Toolkit.i18nText("Fine-Design_Share_Online_Query_Recommend_Component")); |
|
|
|
|
searchBtn.setUI(new UIButtonUI() { |
|
|
|
@ -86,7 +128,7 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
protected void paintBorder(Graphics g, UIButton b) { |
|
|
|
|
Color oldColor = g.getColor(); |
|
|
|
|
g.setColor(SEARCH_BUTTON_COLOR); |
|
|
|
|
g.drawRoundRect(0, 0, b.getWidth() - 4, b.getHeight() - 4, 2, 2); |
|
|
|
|
g.drawRoundRect(2, 2, b.getWidth() - 4, b.getHeight() - 4, 2, 2); |
|
|
|
|
g.setColor(oldColor); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -96,7 +138,7 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
String filterStr = filterConfigPane.assembleFilter(); |
|
|
|
|
if (StringUtils.isEmpty(filterStr)) { |
|
|
|
|
FineJOptionPane.showMessageDialog(EmbedPane.this, |
|
|
|
|
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Warning_Tip"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Message"), WARNING_MESSAGE, |
|
|
|
|
UIManager.getIcon("OptionPane.warningIcon")); |
|
|
|
@ -134,6 +176,7 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
Dimension newDimension = new Dimension(dimension.width - 25, dimension.height - 30); |
|
|
|
|
EmbedPane.this.setSize(newDimension); |
|
|
|
|
EmbedPane.this.setLocation(point.x + 25, 0); |
|
|
|
|
alpha -= DELTA_ALPHA; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, 0, 60, TimeUnit.MILLISECONDS); |
|
|
|
@ -141,6 +184,8 @@ public class EmbedPane extends JPanel {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paint(Graphics g) { |
|
|
|
|
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Math.max(0, alpha)); |
|
|
|
|
((Graphics2D) g).setComposite(composite); |
|
|
|
|
super.paint(g); |
|
|
|
|
if (image != null) { |
|
|
|
|
g.drawImage(image, 0, 0, EmbedPane.this.getWidth(), EmbedPane.this.getHeight(), null); |
|
|
|
|