From edb11bc89785f98c4f2cbbe083aa4c1d52d189d1 Mon Sep 17 00:00:00 2001 From: "Richard.Fang" Date: Thu, 17 Oct 2024 14:59:59 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-137558=20&&=20REPORT-137547=20&&=20REPOR?= =?UTF-8?q?T-137533=20fix:=E5=9B=BE=E6=A0=87=E5=8F=8A=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E8=83=8C=E6=99=AF=E7=BC=96=E8=BE=91=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/widget/IconDefinePane.java | 17 +++------- .../com/fr/design/webattr/EditToolBar.java | 2 +- .../com/fr/design/webattr/ToolBarButton.java | 31 ++++++++++++++++--- .../com/fr/design/webattr/ToolBarPane.java | 2 +- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/widget/IconDefinePane.java b/designer-base/src/main/java/com/fr/design/widget/IconDefinePane.java index f22f1eb0a6..879b417b9e 100644 --- a/designer-base/src/main/java/com/fr/design/widget/IconDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/IconDefinePane.java @@ -23,6 +23,8 @@ import java.awt.event.ActionListener; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.flex; public class IconDefinePane extends BasicPane { @@ -66,8 +68,9 @@ public class IconDefinePane extends BasicPane { showIconImageLable.setIcon(null); } }); - - JPanel iconButtonPane = row(LayoutConstants.HORIZONTAL_GAP, cell(this.showIconImageLable), cell(this.editIconButton), cell(this.removeIconButton)).getComponent(); + JPanel iconButtonPane = row(LayoutConstants.HORIZONTAL_GAP, cell(this.showIconImageLable), + column(flex(), row(LayoutConstants.HORIZONTAL_GAP, cell(this.editIconButton), cell(this.removeIconButton)), flex()) + ).getComponent(); iconButtonPane.setBorder(new ScaledEmptyBorder(0,0,0,0)); this.setLayout(new BorderLayout()); this.add(iconButtonPane, BorderLayout.CENTER); @@ -92,16 +95,6 @@ public class IconDefinePane extends BasicPane { setShowIconImage(); } - /** - * 直接更新icon - * @param iconName - * @param icon - */ - public void populateIcon(String iconName, Icon icon) { - this.curIconName = iconName; - showIconImageLable.setIcon(icon); - } - public String update() { return this.curIconName; } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java index 2fc42d01a5..f722725a6d 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java @@ -667,7 +667,7 @@ public class EditToolBar extends BasicPane { this.icon.setSelected(button.isShowIcon()); this.text.setSelected(button.isShowText()); this.nameField.setText(button.getText()); - this.iconPane.populateIcon(((Button) widget).getIconName(), icon); + this.iconPane.populate(((Button) widget).getIconName()); } /** diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarButton.java b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarButton.java index e375289d63..c1efe6397f 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarButton.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarButton.java @@ -1,6 +1,6 @@ package com.fr.design.webattr; -import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIScale; import com.fr.base.vcs.DesignerMode; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; @@ -8,16 +8,22 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.Widget; +import com.fr.stable.StringUtils; +import com.fr.form.ui.WidgetInfoConfig; import java.awt.Insets; import java.awt.Graphics; +import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.Icon; +import javax.swing.ImageIcon; public class ToolBarButton extends UIButton implements MouseListener { private Widget widget; private WidgetOption no; + private final int ICON_WIDTH = FineUIScale.scale(16); + private final int ICON_HEIGHT = FineUIScale.scale(16); public ToolBarButton(Icon icon, Widget widget) { this(null, icon, widget); @@ -30,15 +36,30 @@ public class ToolBarButton extends UIButton implements MouseListener { public ToolBarButton(String text, Icon icon, Widget widget) { super(text, icon); this.widget = widget; - //直接设置Icon图标 - setIcon(icon); - if (icon instanceof LazyIcon) { - setDisabledIcon(((LazyIcon) icon).disabled()); + if (widget instanceof com.fr.form.ui.Button) { + com.fr.form.ui.Button button = (com.fr.form.ui.Button) widget; + String iconName = button.getIconName(); + if (StringUtils.isNotEmpty(iconName)) { + Image iimage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); + if (iimage != null) { + setIcon(new ImageIcon(iimage)); + } + } } this.addMouseListener(this); setMargin(new Insets(0, 0, 0, 0)); } + @Override + public void setIcon(Icon icon) { + if (icon instanceof ImageIcon) { + //自定义上传的图标在设计器工具栏显示需要按照16*16进行缩放 + Image originalImage = ((ImageIcon) icon).getImage(); + Image scaledImage = originalImage.getScaledInstance(ICON_WIDTH, ICON_HEIGHT, Image.SCALE_SMOOTH); + icon = new ImageIcon(scaledImage); + } + super.setIcon(icon); + } /** * 改变按钮的权限细粒度状态 diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarPane.java index ef228699f6..bb05139af8 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarPane.java @@ -154,7 +154,7 @@ public class ToolBarPane extends BasicBeanPane { this.validate(); this.repaint(); } -// this.getFToolBar().setBackground(toolbar.getBackground()); + this.getFToolBar().setBackground(toolbar.getBackground()); this.getFToolBar().setDefault(toolbar.isDefault()); this.getFToolBar().setButtonBgColorMode(toolbar.getButtonBgColorMode()); setPopulateFinished(true);