Browse Source

Pull request #6760: REPORT-62926 && REPORT-62920 && REPORT-62967 && REPORT-62964

Merge in DESIGN/design from ~KERRY/design_10.0:feature/x to feature/x

* commit '427fb1aa96942d417238b8cb65ee794cab6e4f1e':
  REPORT-62398 【接触点优化】筛选面板存在时,上下滑动鼠标显示异常
  REPORT-62970【接触点优化】筛选动效问题,交互看下
  REPORT-62926 && REPORT-62920 && REPORT-62967 && REPORT-62964
feature/x
kerry 3 years ago
parent
commit
00ff65fb26
  1. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  2. 14
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetShowPane.java
  3. 34
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java
  4. 41
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/PreviewImagePane.java
  5. 59
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java
  6. 13
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java
  7. 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 {

14
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetShowPane.java

@ -43,6 +43,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
protected FilterPane filterPane; protected FilterPane filterPane;
private JPanel centerPane; private JPanel centerPane;
private SortTabPane sortTabPane; private SortTabPane sortTabPane;
private JPanel toolBarPane;
private final JPanel loadingPane = new LoadingPane(); private final JPanel loadingPane = new LoadingPane();
@ -77,10 +78,10 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
FlexSearchFieldPane flexSearchPane = new FlexSearchFieldPane(filterPane); FlexSearchFieldPane flexSearchPane = new FlexSearchFieldPane(filterPane);
initSearchTextFieldPaneListener(flexSearchPane); initSearchTextFieldPaneListener(flexSearchPane);
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolBarPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.add(flexSearchPane, BorderLayout.CENTER); toolBarPane.add(flexSearchPane, BorderLayout.CENTER);
northPane.add(sortTabPane, BorderLayout.SOUTH); toolBarPane.add(sortTabPane, BorderLayout.SOUTH);
initNorthPane(jPanel, northPane); initNorthPane(jPanel, toolBarPane);
this.searchResultShowPane = initSearchResultShowPane(sharableWidgetProviders); this.searchResultShowPane = initSearchResultShowPane(sharableWidgetProviders);
mainCardLayout = new CardLayout(); mainCardLayout = new CardLayout();
@ -93,10 +94,15 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
return jPanel; return jPanel;
} }
protected void initNorthPane(JPanel jPanel, JPanel northPane) { protected void initNorthPane(JPanel jPanel, JPanel northPane) {
jPanel.add(northPane, BorderLayout.NORTH); jPanel.add(northPane, BorderLayout.NORTH);
} }
public void setToolBarPaneVisible(boolean flag){
this.toolBarPane.setVisible(flag);
}
protected AbstractOnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) { protected AbstractOnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
return new OnlineWidgetSelectPane(sharableWidgetProviders, filterPane, 50); return new OnlineWidgetSelectPane(sharableWidgetProviders, filterPane, 50);

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);
}
}

59
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;
@ -18,10 +19,13 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.awt.AlphaComposite;
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.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Point; import java.awt.Point;
import java.awt.event.ActionEvent; 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 String EMBED_PANE_TIMER = "EMBED_PANE_TIMER";
private static final Color BORDER_COLOR = Color.decode("#D9DADD"); private static final Color BORDER_COLOR = Color.decode("#D9DADD");
private static final Color SEARCH_BUTTON_COLOR = Color.decode("#419BF9"); private static final Color SEARCH_BUTTON_COLOR = Color.decode("#419BF9");
private static final float DELTA_ALPHA = 0.13F;
private Image image; private Image image;
private float alpha = 1.0F;
public EmbedPane(OnlineEmbedFilterShowPane showPane) { public EmbedPane(OnlineEmbedFilterShowPane showPane) {
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
@ -54,8 +60,7 @@ 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, 5, 5, 0));
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) { FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) {
@Override @Override
@ -65,9 +70,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 +84,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 +128,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 +138,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"));
@ -134,6 +176,7 @@ public class EmbedPane extends JPanel {
Dimension newDimension = new Dimension(dimension.width - 25, dimension.height - 30); Dimension newDimension = new Dimension(dimension.width - 25, dimension.height - 30);
EmbedPane.this.setSize(newDimension); EmbedPane.this.setSize(newDimension);
EmbedPane.this.setLocation(point.x + 25, 0); EmbedPane.this.setLocation(point.x + 25, 0);
alpha -= DELTA_ALPHA;
}); });
}, 0, 60, TimeUnit.MILLISECONDS); }, 0, 60, TimeUnit.MILLISECONDS);
@ -141,6 +184,8 @@ public class EmbedPane extends JPanel {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Math.max(0, alpha));
((Graphics2D) g).setComposite(composite);
super.paint(g); super.paint(g);
if (image != null) { if (image != null) {
g.drawImage(image, 0, 0, EmbedPane.this.getWidth(), EmbedPane.this.getHeight(), null); g.drawImage(image, 0, 0, EmbedPane.this.getWidth(), EmbedPane.this.getHeight(), null);

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

@ -21,14 +21,23 @@ 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, BorderLayout.NORTH);
this.onlineWidgetShowPane = onlineWidgetShowPane; this.onlineWidgetShowPane = onlineWidgetShowPane;
this.onlineWidgetShowPane.setToolBarPaneVisible(false);
this.add(onlineWidgetShowPane, BorderLayout.CENTER); this.add(onlineWidgetShowPane, BorderLayout.CENTER);
} }
public void filterStateChanged(String filterStr) { public void filterStateChanged(String filterStr) {
this.removeAll();
this.add(embedPane);
this.add(onlineWidgetShowPane, BorderLayout.CENTER);
this.validate();
this.doLayout();
this.repaint();
onlineWidgetShowPane.setToolBarPaneVisible(true);
selectPane = onlineWidgetShowPane.animate(filterStr); selectPane = onlineWidgetShowPane.animate(filterStr);
} }
public void animate(List<WidgetFilterInfo> selectedFilters) throws InterruptedException { public void animate(List<WidgetFilterInfo> selectedFilters) throws InterruptedException {

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