diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineComponentsFactory.java b/designer-base/src/main/java/com/fine/theme/utils/FineComponentsFactory.java index 80cc69c932..2e8e71d393 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineComponentsFactory.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineComponentsFactory.java @@ -1,12 +1,22 @@ package com.fine.theme.utils; import com.fine.theme.icon.LazyIcon; +import com.formdev.flatlaf.util.ScaledEmptyBorder; +import com.fr.data.core.FormatField; +import com.fr.design.border.UIRoundedBorder; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.stable.Constants; +import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JPanel; +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; + +import java.awt.Color; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.flex; @@ -62,4 +72,24 @@ public class FineComponentsFactory { flex(), cell(confirmButton), cell(cancelButton)).getComponent(); } + /** + * 创建示例文本,圆角边框&浅灰背景 + * + * @return 示例文本Label + */ + public static UILabel createSampleLabel() { + Color labelColor = FineUIUtils.getUIColor("Label.tipColor", "inactiveCaption"); + Border interBorder = new UIRoundedBorder(labelColor, 0, 4); + + Border border = BorderFactory.createTitledBorder(interBorder, Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), + TitledBorder.ABOVE_TOP, 0, null, labelColor); + + UILabel sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()); + sampleLabel.setHorizontalAlignment(UILabel.CENTER); + sampleLabel.setBorder(BorderFactory.createCompoundBorder(border, new ScaledEmptyBorder(2, 0, 8, 0))); + FineUIStyle.setStyle(sampleLabel, FineUIStyle.LABEL_TIP); + + return sampleLabel; + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java index 8ab812e9dc..7d3f7d5a9b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java @@ -1,9 +1,9 @@ package com.fr.design.gui.style; +import com.fine.theme.utils.FineComponentsFactory; import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIStyle; -import com.fine.theme.utils.FineUIUtils; import com.fr.base.CoreDecimalFormat; import com.fr.base.Style; import com.fr.base.TextFormat; @@ -12,8 +12,6 @@ import com.fr.data.core.FormatField.FormatContents; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.gui.icombobox.TextFontComboBox; @@ -28,13 +26,10 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.math.RoundingMode; -import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.SwingConstants; -import javax.swing.border.Border; -import javax.swing.border.TitledBorder; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.text.Format; @@ -161,14 +156,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse } private void initSampleLabel() { - Color labelColor = FineUIUtils.getUIColor("Label.tipColor", "inactiveCaption"); - Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); - String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); - Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, labelColor); - sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()); - sampleLabel.setHorizontalAlignment(UILabel.CENTER); - sampleLabel.setBorder(border); - FineUIStyle.setStyle(sampleLabel, FineUIStyle.LABEL_TIP); + sampleLabel = FineComponentsFactory.createSampleLabel(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java index a86bc70e05..e2d65aa91c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java @@ -1,15 +1,13 @@ package com.fr.design.gui.style; +import com.fine.theme.utils.FineComponentsFactory; import com.fine.theme.utils.FineUIStyle; -import com.fine.theme.utils.FineUIUtils; import com.fr.base.CoreDecimalFormat; import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; -import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.LayoutConstants; -import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserverListener; @@ -22,17 +20,11 @@ import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; -import javax.swing.UIManager; -import javax.swing.border.Border; -import javax.swing.border.TitledBorder; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.FontMetrics; -import java.awt.Graphics; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.math.RoundingMode; @@ -112,14 +104,7 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName } private void initPreviewLabel4GeneralFormat() { - Color labelColor = FineUIUtils.getUIColor("Label.tipColor", "inactiveCaption"); - Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 0, 4); - String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); - Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.ABOVE_TOP, 0, null, labelColor); - previewLabel = new UILabel(FormatField.getInstance().getFormatValue()); - previewLabel.setHorizontalAlignment(UILabel.CENTER); - previewLabel.setBorder(border); - FineUIStyle.setStyle(previewLabel, FineUIStyle.LABEL_TIP); + previewLabel = FineComponentsFactory.createSampleLabel(); } protected void initLayout() {