From c4beeb8e8ac223bcfd5206606df32b61ea24ee88 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 25 Aug 2021 21:30:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58000=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E4=B8=BB=E9=A2=98=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E8=B6=85=E9=95=BF=E7=9A=84=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20REPORT-58001=20=E3=80=90=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E3=80=91=E4=B8=BB=E9=A2=98=E8=B6=85=E9=95=BF=E6=97=B6=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E4=B8=BB=E9=A2=98=E5=B7=A5=E5=85=B7=E6=A0=8F=E5=B0=B1?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=B8=BB=E9=A2=98=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=8F=8A=E5=9B=BE=E6=A0=87=EF=BC=88=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=B9=9F=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=BA=86?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 限制主题切换按钮的尺寸 【改动思路】 同上 --- .../com/fr/design/mainframe/JTemplate.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index b88deffda..7074c8f1f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -94,6 +94,8 @@ import javax.swing.JOptionPane; import javax.swing.SwingConstants; import javax.swing.undo.UndoManager; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FontMetrics; import java.util.Set; import java.util.concurrent.Callable; @@ -103,6 +105,7 @@ import java.util.concurrent.Callable; public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null + private static final int PREDEFINED_ICON_WIDTH = 27; private static final int PREFIX_NUM = 3000; protected FILE editingFILE = null; // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 @@ -1420,8 +1423,15 @@ public abstract class JTemplate> } protected UIButton createTemplateThemeButton() { - UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); - button.setToolTipText(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Title")); + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")) { + @Override + public Dimension getPreferredSize() { + FontMetrics metrics = getFontMetrics(getFont()); + int width = Math.min(metrics.stringWidth(getText()) + PREDEFINED_ICON_WIDTH, 100); + return new Dimension(width, 20); + } + }; + button.setToolTipText(getTemplateTheme().getName()); button.setText(getTemplateTheme().getName()); button.setAlignmentX(SwingConstants.LEFT); button.set4ToolbarButton(); @@ -1730,6 +1740,8 @@ public abstract class JTemplate> @Override public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { ThemedTemplate.super.setTemplateTheme(newTheme, compatible); - templateThemeButton.setText(newTheme.getName()); + String name = newTheme.getName(); + templateThemeButton.setText(name); + templateThemeButton.setToolTipText(name); } }