Browse Source

REPORT-62926 && REPORT-62920 && REPORT-62967 && REPORT-62964

feature/x
kerry 3 years ago
parent
commit
eb4fbebd72
  1. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  2. 34
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java
  3. 41
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/PreviewImagePane.java
  4. 50
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java
  5. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java
  6. 15
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -237,7 +237,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
lastStallTime = System.currentTimeMillis(); lastStallTime = System.currentTimeMillis();
Dimension dimension = getCoverDimension(); Dimension dimension = getCoverDimension();
Rectangle containerRec = new Rectangle(0, 0, dimension.width, dimension.height); Rectangle containerRec = new Rectangle(0, 0, dimension.width, dimension.height);
if (!isRightClickPopupMenuVisible()) { if (!isRightClickPopupMenuVisible() && !FirstDragAnimateStateManager.getInstance().animating()) {
if (containerRec.contains(e.getX(), e.getY())) { if (containerRec.contains(e.getX(), e.getY())) {
this.showPreviewPane(); this.showPreviewPane();
} else { } else {

34
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java

@ -23,11 +23,8 @@ import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Toolkit;
/** /**
* @author Starryi * @author Starryi
@ -35,7 +32,7 @@ import java.awt.Toolkit;
* Created by Starryi on 2021/9/14 * Created by Starryi on 2021/9/14
*/ */
public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane<OnlineShareWidget> { public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane<OnlineShareWidget> {
private static final int POPUP_WIDTH = 412; public static final int POPUP_WIDTH = 412;
private static final int POPUP_TOP_HEIGHT = 28; private static final int POPUP_TOP_HEIGHT = 28;
private static final int POPUP_BOTTOM_HEIGHT = 54; private static final int POPUP_BOTTOM_HEIGHT = 54;
@ -221,33 +218,4 @@ public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane
compatibleEnVersionLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Compatible_Designer_Version") + ": " + compatibleEnVersion); compatibleEnVersionLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Compatible_Designer_Version") + ": " + compatibleEnVersion);
} }
private static class PreviewImagePane extends JPanel {
private static final Image DEFAULT_IMAGE = IOUtils.readImage("com/fr/base/images/share/component_error.png");
private static final int PREVIEW_IMAGE_WIDTH = POPUP_WIDTH - 20;
private static final int STANDARD_DPI = 128;
private Image previewImage;
public void setPreviewImage(Image previewImage) {
this.previewImage = previewImage;
if (this.previewImage == null) {
this.previewImage = DEFAULT_IMAGE;
}
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
int imageWidth = this.previewImage.getWidth(null);
int imageHeight = this.previewImage.getHeight(null);
double imageAspectRatio = (double) imageWidth / imageHeight;
int width = (PREVIEW_IMAGE_WIDTH * dpi) / STANDARD_DPI;
int height = (int) (width / imageAspectRatio);
setPreferredSize(new Dimension(width, height));
}
@Override
public void paint(Graphics g) {
g.drawImage(this.previewImage, 0, 0, getWidth(), getHeight(), null);
}
}
} }

41
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/PreviewImagePane.java

@ -0,0 +1,41 @@
package com.fr.design.mainframe.share.ui.online;
import com.fr.general.IOUtils;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
/**
* Created by kerry on 2021/11/19
*/
public class PreviewImagePane extends JPanel {
private static final Image DEFAULT_IMAGE = IOUtils.readImage("com/fr/base/images/share/component_error.png");
private static final int PREVIEW_IMAGE_WIDTH = OnlineWidgetPopupPreviewPane.POPUP_WIDTH - 20;
private static final int STANDARD_DPI = 128;
private Image previewImage;
public void setPreviewImage(Image previewImage) {
this.previewImage = previewImage;
if (this.previewImage == null) {
this.previewImage = DEFAULT_IMAGE;
}
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
int imageWidth = this.previewImage.getWidth(null);
int imageHeight = this.previewImage.getHeight(null);
double imageAspectRatio = (double) imageWidth / imageHeight;
int width = (PREVIEW_IMAGE_WIDTH * dpi) / STANDARD_DPI;
int height = (int) (width / imageAspectRatio);
setPreferredSize(new Dimension(width, height));
}
@Override
public void paint(Graphics g) {
g.drawImage(this.previewImage, 0, 0, getWidth(), getHeight(), null);
}
}

50
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java

@ -7,6 +7,7 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; 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.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterConfigPane; import com.fr.design.mainframe.share.ui.widgetfilter.FilterConfigPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils; import com.fr.design.mainframe.share.util.OnlineShopUtils;
@ -21,6 +22,7 @@ import javax.swing.UIManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Point; import java.awt.Point;
@ -54,7 +56,6 @@ public class EmbedPane extends JPanel {
private JPanel initCenterPane(OnlineEmbedFilterShowPane showPane) { private JPanel initCenterPane(OnlineEmbedFilterShowPane showPane) {
JPanel jPanel = new JPanel(FRGUIPaneFactory.createBorderLayout()); JPanel jPanel = new JPanel(FRGUIPaneFactory.createBorderLayout());
jPanel.setBackground(Color.WHITE); jPanel.setBackground(Color.WHITE);
jPanel.setPreferredSize(new Dimension(200, 200));
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) { FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) {
@ -65,9 +66,9 @@ public class EmbedPane extends JPanel {
}; };
UIButton searchBtn = initSearchBtn(filterConfigPane, showPane); UIButton searchBtn = initSearchBtn(filterConfigPane, showPane);
filterConfigPane.setBorder(null); filterConfigPane.setBorder(null);
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Tip")); JPanel tipPane = getFilterTipPane();
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tipPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
jPanel.add(tipLabel, BorderLayout.NORTH); jPanel.add(tipPane, BorderLayout.NORTH);
jPanel.add(filterConfigPane, BorderLayout.CENTER); jPanel.add(filterConfigPane, BorderLayout.CENTER);
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
southPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8)); southPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
@ -79,6 +80,43 @@ public class EmbedPane extends JPanel {
return 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) { private UIButton initSearchBtn(FilterConfigPane filterConfigPane, OnlineEmbedFilterShowPane showPane) {
UIButton searchBtn = new UIButton(Toolkit.i18nText("Fine-Design_Share_Online_Query_Recommend_Component")); UIButton searchBtn = new UIButton(Toolkit.i18nText("Fine-Design_Share_Online_Query_Recommend_Component"));
searchBtn.setUI(new UIButtonUI() { searchBtn.setUI(new UIButtonUI() {
@ -86,7 +124,7 @@ public class EmbedPane extends JPanel {
protected void paintBorder(Graphics g, UIButton b) { protected void paintBorder(Graphics g, UIButton b) {
Color oldColor = g.getColor(); Color oldColor = g.getColor();
g.setColor(SEARCH_BUTTON_COLOR); 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); g.setColor(oldColor);
} }
}); });
@ -96,7 +134,7 @@ public class EmbedPane extends JPanel {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String filterStr = filterConfigPane.assembleFilter(); String filterStr = filterConfigPane.assembleFilter();
if (StringUtils.isEmpty(filterStr)) { 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_Share_Online_Embed_Filter_Warning_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Message"), WARNING_MESSAGE,
UIManager.getIcon("OptionPane.warningIcon")); UIManager.getIcon("OptionPane.warningIcon"));

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java

@ -21,7 +21,7 @@ public class OnlineEmbedFilterShowPane extends JPanel {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
embedPane = new EmbedPane(this); embedPane = new EmbedPane(this);
embedPane.setLocation(10, 0); embedPane.setLocation(10, 0);
embedPane.setSize(228, 273); embedPane.setSize(228, embedPane.getPreferredSize().height);
this.add(embedPane); this.add(embedPane);
this.onlineWidgetShowPane = onlineWidgetShowPane; this.onlineWidgetShowPane = onlineWidgetShowPane;
this.add(onlineWidgetShowPane, BorderLayout.CENTER); this.add(onlineWidgetShowPane, BorderLayout.CENTER);

15
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java

@ -1,10 +1,8 @@
package com.fr.design.mainframe.share.ui.online.embed; package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.share.ui.online.PreviewImagePane;
import javax.swing.ImageIcon;
import javax.swing.JDialog; import javax.swing.JDialog;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Image; import java.awt.Image;
@ -25,12 +23,13 @@ public class PreviewDialog extends JDialog {
public void setImage(Image image, Point point) { public void setImage(Image image, Point point) {
this.getContentPane().removeAll(); this.getContentPane().removeAll();
this.getContentPane().add(new UILabel(new ImageIcon(image))); PreviewImagePane previewImagePane = new PreviewImagePane();
int width = image.getWidth(null); previewImagePane.setPreviewImage(image);
this.setSize(width, image.getHeight(null)); Dimension dimension = previewImagePane.getPreferredSize();
this.setLocation(point.x - width, point.y + OFFSET_Y); this.getContentPane().add(previewImagePane);
setSize(new Dimension(dimension.width, dimension.height));
this.setLocation(point.x - dimension.width, point.y + OFFSET_Y);
this.doLayout(); this.doLayout();
this.validate(); this.validate();
this.repaint(); this.repaint();
} }

Loading…
Cancel
Save