diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java index a335aba921..1e712238df 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java @@ -1,11 +1,16 @@ package com.fine.theme.light.ui; +import com.fine.theme.utils.FineClientProperties; +import com.fine.theme.utils.FineUIScale; import com.formdev.flatlaf.ui.FlatComboBoxUI; +import com.formdev.flatlaf.ui.FlatUIUtils; +import org.jetbrains.annotations.Nullable; -import javax.swing.JComponent; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.SwingConstants; import javax.swing.plaf.ComponentUI; +import java.awt.Dimension; import java.awt.Graphics2D; /** @@ -38,4 +43,25 @@ public class FineComboBoxUI extends FlatComboBoxUI { super.paintArrow(g); } } + + @Override + public Dimension getMinimumSize(JComponent c) { + // ComboBox基于子组件计算适配尺寸性能一般,仅考虑部分ComboBox进行适配计算,其他采用默认值 + if (FineClientProperties.ADAPTIVE_COMBO_BOX.equals(getComboBoxTypeStr(c))) { + return super.getMinimumSize(c); + } + return FineUIScale.scale(new Dimension( + FlatUIUtils.getUIInt("ComboBox.minimumWidth", 72), + FlatUIUtils.getUIInt("ComboBox.comboHeight", 24) + )); + } + + @Nullable + static String getComboBoxTypeStr(JComponent c) { + Object value = c.getClientProperty(FineClientProperties.COMBO_BOX_TYPE); + if (value instanceof String) { + return (String) value; + } + return null; + } } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 82042e978c..6ea6b1775c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -114,6 +114,8 @@ import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.column; import static com.fine.swing.ui.layout.Layouts.fix; import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE; +import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX; import static com.fine.theme.utils.FineUIConstants.SCALE_FONT_SIZE_12; import static com.fr.design.i18n.Toolkit.i18nText; @@ -615,6 +617,7 @@ public class PreferencePane extends BasicPane { String[] undoTimes = {i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + i18nText("Fine-Design_Basic_Time(s)") , MAX_UNDO_LIMIT_15 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + i18nText("Fine-Design_Basic_Time(s)")}; maxUndoLimit = new UIComboBox(undoTimes); + maxUndoLimit.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); //不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数 supportUndoCheckBox.addActionListener(new ActionListener() { @@ -811,6 +814,7 @@ public class PreferencePane extends BasicPane { i++; } UIDictionaryComboBox languageComboBox = new UIDictionaryComboBox<>(keys, values); + languageComboBox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); languageComboBox.setFont(FRFont.getInstance("Dialog", Font.PLAIN, SCALE_FONT_SIZE_12));//为了在中文系统中显示韩文 return languageComboBox; } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index cf0b739337..d587c2cafe 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -90,6 +90,9 @@ import java.awt.event.KeyListener; import java.util.ArrayList; import java.util.List; +import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE; +import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX; + /** * @author rinoux * @version 10.0 @@ -337,6 +340,7 @@ public class DBTableDataPane extends AbstractTableDataPane implemen private void createToolbarEsdComponents(final UIToolbar editToolBar) { this.esdSettingsLabel = new UILabel(Toolkit.i18nText("Fine-Design_ESD_Cache_Settings")); this.esdConfigOption = new UIComboBox(StrategyConfigFrom.values()); + this.esdConfigOption.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); this.esdEnabled = new UICheckBox(Toolkit.i18nText("Fine-Design_ESD_Enable_Cache")); this.barErrorTips = new UILabel(); this.barErrorTips.setForeground(Color.RED); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java index 1468e9255a..ddb402db2d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -237,7 +237,6 @@ public class UIButtonGroup extends Column implements GlobalNameObserver, UIOb } protected void initButton(UIToggleButton labelButton, int index) { - labelButton.setBorder(new FineRoundBorder()); labelButton.setBorderPainted(false); labelButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_GROUP); labelButton.putClientProperty(BUTTON_GROUP_POSITION, getGroupButtonPosition(index)); diff --git a/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java b/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java index 901f1b6010..128972b755 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java @@ -19,6 +19,8 @@ import java.util.stream.Collectors; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE; +import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX; import static com.fr.design.i18n.Toolkit.i18nText; public abstract class BaseFitAttrPane extends BasicBeanPane { @@ -96,6 +98,7 @@ public abstract class BaseFitAttrPane extends BasicBeanPane { private void initItemChoose() { belowSetLabel = new UILabel(i18nText("Fine-Design_Report_Blow_Set")); itemChoose = new UIComboBox(getItemNames()); + itemChoose.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); ItemListener itemListener = getItemListener(); itemChoose.addItemListener(itemListener); //以下设置横向布局 diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 605d84b40e..f7f20e311c 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -3,6 +3,7 @@ package com.fr.design.write.submit; import com.fine.swing.ui.layout.Layouts; import com.fine.theme.icon.LazyIcon; import com.fine.swing.ui.layout.Spacer; +import com.fine.theme.utils.FineClientProperties; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIUtils; import com.fr.base.BaseFormula; @@ -98,6 +99,7 @@ import java.util.stream.Collectors; import static com.fine.swing.ui.layout.Layouts.row; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.row; //august:这个东西应该分成两类,一类是有单元格的情况,一类是没有单元格的情况 public class DBManipulationPane extends BasicBeanPane { @@ -153,6 +155,7 @@ public class DBManipulationPane extends BasicBeanPane { JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); + dmlConfigComboBox.putClientProperty(FineClientProperties.COMBO_BOX_TYPE, FineClientProperties.ADAPTIVE_COMBO_BOX); JPanel typePane = new JPanel(new BorderLayout()); typePane.add(row(10, @@ -162,7 +165,7 @@ public class DBManipulationPane extends BasicBeanPane { chooseTable.setTableNameComboBoxPopSize(FineUIScale.scale(160), FineUIScale.scale(320)); // peter:编辑的TablePane - JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel editTablePane = new JPanel(new BorderLayout(FineUIScale.scale(10), 0)); editTablePane.setBounds(0, 0, FineUIScale.scale(280), FineUIScale.scale(180)); keyColumnValuesTable = new KeyColumnNameValueTable(); editTablePane.add(new UIScrollPane(keyColumnValuesTable), BorderLayout.CENTER); @@ -707,6 +710,7 @@ public class DBManipulationPane extends BasicBeanPane { // 设置column1的editor columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); + columnsComboBox.setRenderer(new UIComboBoxRenderer() { @Override diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java index 2b423e0ab0..c6f0f6416d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java @@ -3,6 +3,7 @@ */ package com.fr.design.actions.cell.style; +import com.fine.theme.utils.FineUIScale; import com.fr.design.utils.DesignUtils; import com.fr.stable.os.OperatingSystem; import java.awt.Dimension; @@ -11,7 +12,6 @@ import javax.swing.ComboBoxModel; import javax.swing.JComponent; import com.fr.base.Style; -import com.fr.base.Utils; import com.fr.base.core.StyleUtils; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.general.ComparatorUtils; @@ -84,9 +84,7 @@ public class ReportFontNameAction extends AbstractStyleAction { UIComboBox itemComponent = new UIComboBox(DesignUtils.getAvailableFontFamilyNames4Report()); this.putValue(UIComboBox.class.getName(), itemComponent); //设置最佳宽度. - itemComponent.setPreferredSize(new Dimension( - Math.min(140, itemComponent.getPreferredSize().width), - itemComponent.getPreferredSize().height)); + itemComponent.setPreferredSize(FineUIScale.scale(new Dimension(140, 24))); itemComponent.setEnabled(this.isEnabled()); itemComponent.addActionListener(this); diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index ae5268a711..5bae0b22d0 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -35,6 +35,8 @@ import java.awt.event.ActionListener; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.column; import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE; +import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX; import static com.fine.theme.utils.FineUIUtils.wrapComponentWithTitle; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.SPECIFY; @@ -236,6 +238,7 @@ public class DSColumnAdvancedPane extends BasicPane { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Odd"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Even"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Specify"),}); + selectCountComboBox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); selectCountComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java index 9723d494af..aea44cbe50 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java @@ -105,14 +105,7 @@ public class ReportColumnsPane extends BasicPane{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_TurnOn"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_TurnOff") }; - onOffButtonGroup = new UIButtonGroup(textArray) { - @Override - protected void initButton(UIToggleButton labelButton, int index) { - labelButton.setSize(new Dimension(60,20)); - labelButton.setPreferredSize(FineUIScale.scale(new Dimension(60, 20))); - super.initButton(labelButton, index); - } - }; + onOffButtonGroup = new UIButtonGroup(textArray); onOffButtonGroup.addActionListener(onOffListener); UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportColumns_Columns"));