From fbc5dc08da163f289e3e6abe8b47eafeb2d8ae77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Wed, 10 Jan 2024 11:47:58 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-111995=20=E3=80=90UI=E7=BF=BB=E6=96=B0?= =?UTF-8?q?=E3=80=91=E7=BF=BB=E6=96=B0=E6=95=B0=E6=8D=AE=E9=9B=86=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF;=E8=A1=A5=E5=85=85=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/FineLightIconSet.java | 3 + .../com/fine/theme/utils/FineUIStyle.java | 1 + .../com/fine/theme/utils/FineUIUtils.java | 12 + .../fr/design/border/FineBorderFactory.java | 37 +++ .../data/datapane/connect/AdvancePane.java | 70 +++-- .../connect/ConnectionManagerPane.java | 2 - .../data/datapane/connect/DBCPAttrPane.java | 104 ++++--- .../connect/DatabaseConnectionPane.java | 125 ++++---- .../data/datapane/connect/JDBCDefPane.java | 288 +++++++++--------- .../design/data/datapane/connect/SshPane.java | 207 +++++++------ .../design/data/datapane/connect/SslPane.java | 122 ++++---- .../com/fr/design/formula/FormulaPane.java | 5 +- .../design/gui/controlpane/JControlPane.java | 9 +- .../gui/controlpane/JListControlPane.java | 29 +- .../com/fr/design/gui/ilable/ActionLabel.java | 6 +- .../gui/itree/filetree/FileTreeIcon.java | 2 +- .../mainframe/WestRegionContainerPane.java | 5 +- .../com/fine/theme/icon/expand/forbid.svg | 3 + .../fine/theme/icon/expand/forbid_disable.svg | 3 + .../com/fine/theme/icon/expand/horizontal.svg | 6 + .../theme/icon/expand/horizontal_disable.svg | 6 + .../com/fine/theme/icon/expand/vertical.svg | 6 + .../theme/icon/expand/vertical_disable.svg | 6 + .../light/ui/laf/FineLightLaf.properties | 18 +- .../cell/settingpane/CellExpandAttrPane.java | 7 +- 25 files changed, 612 insertions(+), 470 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/border/FineBorderFactory.java create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/forbid.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/forbid_disable.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal_disable.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/vertical.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/expand/vertical_disable.svg diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java index 0a2094636..415b416e0 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java @@ -194,6 +194,9 @@ public class FineLightIconSet extends AbstractIconSet { //东区面板 new SvgIconSource("cellelement_small", "com/fine/theme/icon/cellelement.svg"), + new SvgIconSource("forbid", "com/fine/theme/icon/expand/forbid.svg"), + new SvgIconSource("horizontal_expand", "com/fine/theme/icon/expand/horizontal.svg"), + new SvgIconSource("vertical_expand", "com/fine/theme/icon/expand/vertical.svg"), // 三角 new SvgIconSource("triangle_down", "com/fine/theme/icon/triangle/triangle_down.svg"), diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java index 68fa7a94c..0af3013ff 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java @@ -27,6 +27,7 @@ public interface FineUIStyle { String TOP_TOOLS = "topTools"; String BRAND_COLOR_LABEL = "brandColorLabel"; String BUTTON_TAB_ACTION = "tabAction"; + String LABEL_BOLD = "boldLabel"; String MENU_TOOL_BAR = "menuToolBar"; String MENU_ITEM_TOOL_BAR = "menuItemToolBar"; diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java index 01b92af01..225fce4be 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java @@ -1,10 +1,12 @@ package com.fine.theme.utils; import com.formdev.flatlaf.ui.FlatUIUtils; +import com.fr.design.border.FineBorderFactory; import com.fr.stable.os.OperatingSystem; import com.fr.value.AtomicClearableLazyValue; import javax.swing.UIManager; +import javax.swing.JLabel; import java.awt.Color; import java.awt.Component; import java.awt.Composite; @@ -364,4 +366,14 @@ public class FineUIUtils { return createPartRoundRectangle(x, y, width, height, 0, 0, arc, 0); } + /** + * 标签加粗显示,并设置下划线;适用于小标题 + * + * @param label 标签 + */ + public static void wrapBoldLabelWithUnderline(JLabel label) { + label.setBorder(FineBorderFactory.createDefaultUnderlineBorder()); + FineUIStyle.setStyle(label, FineUIStyle.LABEL_BOLD); + } + } diff --git a/designer-base/src/main/java/com/fr/design/border/FineBorderFactory.java b/designer-base/src/main/java/com/fr/design/border/FineBorderFactory.java new file mode 100644 index 000000000..02cf2541a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/border/FineBorderFactory.java @@ -0,0 +1,37 @@ +package com.fr.design.border; + +import com.fine.theme.utils.FineUIUtils; + +import javax.swing.BorderFactory; +import javax.swing.border.Border; +import java.awt.Color; + +/** + * 创建Border的工厂 + * + * @author Levy.Xie + * @since 11.0 + * Created on 2024/01/08 + */ +public class FineBorderFactory { + + /** + * 创建一个下划线边框 + * + * @param color 下划线颜色 + * @return 边框 + */ + public static Border createUnderlineBorder(Color color) { + return BorderFactory.createMatteBorder(0, 0, 1, 0, color); + } + + /** + * 创建默认的下划线边框 + * + * @return 边框 + */ + public static Border createDefaultUnderlineBorder() { + return createUnderlineBorder(FineUIUtils.getUIColor("Label.borderColor", "defaultBorderColor")); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java index 7784aa571..a2aadbb03 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java @@ -1,55 +1,69 @@ package com.fr.design.data.datapane.connect; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.utils.FineUIUtils; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.pool.DBCPConnectionPoolAttr; +import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.stable.StringUtils; -import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +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.flex; + /** * @author xiqiu * @date 2021/11/22 * @description */ public class AdvancePane extends BasicPane { - private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor(); - private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")}); - private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor(); - private SpecialUITextField DBCP_VALIDATION_QUERY = new SpecialUITextField(); + private final IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor(); + private final UIComboBox DBCP_TEST_ON_BORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), + Toolkit.i18nText("Fine-Design_Basic_Yes")}); + private final IntegerEditor DBCP_MAX_WAIT = new IntegerEditor(); + private final SpecialUITextField DBCP_VALIDATION_QUERY = new SpecialUITextField(); public AdvancePane() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); DBCP_VALIDATION_QUERY.addFocusListener(new JTextFieldHintListener(DBCP_VALIDATION_QUERY)); - double p = TableLayout.PREFERRED; DBCP_VALIDATION_QUERY.setColumns(20); - double[] rowSizeDbcp = {p, p, p, p}; - double[] columnDbcp = {190, p}; - Component[][] comps = { - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT} - }; - - JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSizeDbcp, columnDbcp, 11, 11); - jPanel.add(contextPane, BorderLayout.CENTER); - this.add(jPanel); + this.setLayout(new BorderLayout()); + this.add(Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Advanced"))).with(FineUIUtils::wrapBoldLabelWithUnderline), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active"), SwingConstants.LEFT)).weight(1), + cell(DBCP_MAX_ACTIVE).weight(1.5), + flex(2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query"), SwingConstants.LEFT)).weight(1), + cell(DBCP_VALIDATION_QUERY).weight(1.5), + flex(2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow"), SwingConstants.LEFT)).weight(1), + cell(DBCP_TEST_ON_BORROW).weight(1.5), + flex(2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time"), SwingConstants.LEFT)).weight(1), + cell(DBCP_MAX_WAIT).weight(1.5), + flex(2) + ) + + ).getComponent(), BorderLayout.CENTER); } @@ -62,7 +76,7 @@ public class AdvancePane extends BasicPane { this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive()); this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait()); this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery()); - this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0); + this.DBCP_TEST_ON_BORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0); } @@ -75,7 +89,7 @@ public class AdvancePane extends BasicPane { dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue()); dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue()); dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText()); - dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true); + dbcpAttr.setTestOnBorrow(this.DBCP_TEST_ON_BORROW.getSelectedIndex() != 0); } @Override @@ -84,8 +98,8 @@ public class AdvancePane extends BasicPane { } - private class JTextFieldHintListener implements FocusListener { - private SpecialUITextField textField; + private static class JTextFieldHintListener implements FocusListener { + private final SpecialUITextField textField; public JTextFieldHintListener(SpecialUITextField jTextField) { this.textField = jTextField; @@ -108,7 +122,7 @@ public class AdvancePane extends BasicPane { } } - private class SpecialUITextField extends UITextField { + private static class SpecialUITextField extends UITextField { @Override public String getText() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java index eadf456e0..e23e4bb6e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java @@ -33,8 +33,6 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio } public void populate(ConnectionConfig datasourceManager) { -// this.connectionTextField.setText(WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.RESOURCES_NAME -// + File.separator + datasourceManager.fileName()); this.connectionListPane.populate(datasourceManager); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java index ebfd195d8..67142a34a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java @@ -1,9 +1,13 @@ package com.fr.design.data.datapane.connect; -import com.fr.base.GraphHelper; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.ui.FlatUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.pool.DBCPConnectionPoolAttr; +import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.editor.editor.IntegerEditor; @@ -11,19 +15,13 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; import javax.swing.JTextField; -import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; import java.awt.Window; import java.awt.event.InputMethodEvent; import java.awt.event.InputMethodListener; @@ -36,6 +34,10 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; +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.flex; + public class DBCPAttrPane extends BasicPane { public static final int TIME_MULTIPLE = 1000; private static final Pattern FETCHSIZE_PATTERN = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");; @@ -70,37 +72,44 @@ public class DBCPAttrPane extends BasicPane { } public DBCPAttrPane() { - defaultPane = this; - + this.setLayout(new BorderLayout()); + defaultPane = Layouts.column(20) + .with(it -> it.setBorder(new ScaledEmptyBorder(10, 10, 10, 10))).getComponent(); // JPanel northFlowPane - northFlowPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr")); - northFlowPane.setPreferredSize(new Dimension(630, 330)); - defaultPane.add(northFlowPane, BorderLayout.NORTH); - - // ContextPane - - double f = TableLayout.FILL; - // double p = TableLayout.PREFERRED; - double[] rowSize = {f, f, f, f, f, f, f}; - double[] columnSize = {f, f}; - Component[][] comps = { - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT), - DBCP_TIMEBETWEENEVICTIONRUNSMILLS}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN}, - {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT), - DBCP_MINEVICTABLEIDLETIMEMILLIS}}; - - JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 10); - northFlowPane.add(contextPane); - JPanel boxFlowInnerContainer = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 5); - UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Dbcp_Warning")); - uiLabel.setForeground(Color.RED); - boxFlowInnerContainer.add(uiLabel); - northFlowPane.add(boxFlowInnerContainer); + northFlowPane = Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"))).with(FineUIUtils::wrapBoldLabelWithUnderline), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size"))).weight(1), + cell(DBCP_INITIAL_SIZE).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle"))).weight(1), + cell(DBCP_MIN_IDLE).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return"))).weight(1), + cell(DBCP_TESTONRETURN).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle"))).weight(1), + cell(DBCP_TESTWHILEIDLE).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis"))).weight(1), + cell(DBCP_TIMEBETWEENEVICTIONRUNSMILLS).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run"))).weight(1), + cell(DBCP_NUMTESTSPEREVICTIONRUN).weight(1), flex(1.2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis"))).weight(1), + cell(DBCP_MINEVICTABLEIDLETIMEMILLIS).weight(1), flex(1.2) + ), + cell(new UILabel(Toolkit.i18nText("Fine-Design_Dbcp_Warning"))).with(it -> it.setForeground(FlatUIUtils.getUIColor("Label.strongHintColor", Color.RED))) + ).getComponent(); + defaultPane.add(northFlowPane); + this.add(defaultPane); } public void populate(JDBCDatabaseConnection jdbcDatabase) { @@ -188,24 +197,19 @@ public class DBCPAttrPane extends BasicPane { public BasicDialog showWindow(Window window) { String databaseName = JDBCConnectionDef.getInstance().getDatabaseName(); if (showOtherConfig(databaseName)) { - southFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Other")); - southFlowPane.setPreferredSize(new Dimension(630, 200)); - double f = TableLayout.FILL; - double[] rowSize = {f}; - double otherColumnSize = GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis")) + 6; - double[] columnSize = {otherColumnSize, otherColumnSize}; FETCHSIZE.addKeyListener(fetchSizeKeyListener); FETCHSIZE.addInputMethodListener(fetchSizeInputMethodListener); FETCHSIZE.setHorizontalAlignment(JTextField.RIGHT); - Component[][] comps = { - {new UILabel("Fetchsize:", SwingConstants.RIGHT), FETCHSIZE} - }; - JPanel otherConfigPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4); - southFlowPane.add(otherConfigPane); + southFlowPane = Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_Other"))).with(FineUIUtils::wrapBoldLabelWithUnderline), + row( + cell(new UILabel("Fetchsize")).weight(1), cell(FETCHSIZE).weight(1), flex(1.2) + ) + ).getComponent(); defaultPane.removeAll(); - defaultPane.add(northFlowPane, BorderLayout.NORTH); - defaultPane.add(southFlowPane, BorderLayout.SOUTH); + defaultPane.add(northFlowPane); + defaultPane.add(southFlowPane); } else { if (southFlowPane != null) { defaultPane.remove(southFlowPane); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 11c3f64d6..821c3fd48 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -3,6 +3,10 @@ */ package com.fr.design.data.datapane.connect; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIStyle; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.data.driver.util.JarFileParseUtil; import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; @@ -14,6 +18,7 @@ import com.fr.data.solution.entity.DriverPage; import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor; import com.fr.data.solution.processor.SolutionProcessor; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -29,6 +34,7 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import org.jetbrains.annotations.NotNull; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -62,6 +68,10 @@ import java.io.File; import java.net.URI; import java.util.concurrent.ExecutionException; +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.flex; + /** * Database Connection pane. */ @@ -124,11 +134,11 @@ public abstract class DatabaseConnectionPane it.setBorder(new ScaledEmptyBorder(0, 10, 0, 10))) + .getComponent(); + JPanel columnContainer = new JPanel(new BorderLayout()); + columnContainer.add(corePane); + UIScrollPane uiScrollPane = new UIScrollPane(columnContainer, + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); this.add(uiScrollPane, BorderLayout.CENTER); - // 按钮. - JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - northPane.add(testPane, BorderLayout.NORTH); - UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection")); - testPane.add(testButton); - testButton.addActionListener(testConnectionActionListener); - testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4)); + // 按钮 + JPanel testButtonPane = initTestButtonPane(); + corePane.add(testButtonPane); // Center mainPanel = mainPanel(); - JPanel advancedPanel = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Advanced")); + JPanel advancedPanel = Layouts.column(LayoutConstants.VERTICAL_GAP).getComponent(); if (mainPanel instanceof JDBCDefPane) { - northPane.add(mainPanel, BorderLayout.CENTER); - ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Advanced_More_Settings")); - actionLabel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - JDialog wDialog = createJDialog(); - if (wDialog != null) { - wDialog.setVisible(true); - } - } - }); - JPanel actionLabelPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - actionLabelPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 20)); - actionLabelPanel.add(actionLabel, BorderLayout.WEST); - JPanel advancePane = getAdvancePane(); - if (advancePane != null) { - advancedPanel.add(advancePane); - } - advancedPanel.add(actionLabelPanel); - northPane.add(getSshPane()); - northPane.add(getSslPane()); + initJDBCLayout(corePane, advancedPanel); } else { - //非jdbc配置布局保持不变 - advancedPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 60)); - if (mainPanel.getPreferredSize().height > MAX_MAIN_PANEL_HEIGHT || mainPanel.getPreferredSize().width > MAX_MAIN_PANEL_WIDTH) { - UIScrollPane jp = new - UIScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jp.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT)); - northPane.add(jp, BorderLayout.CENTER); - } else { - mainPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT)); - northPane.add(mainPanel, BorderLayout.CENTER); + initJNDILayout(corePane, advancedPanel); + } + corePane.add(advancedPanel); + } + + @NotNull + private JPanel initTestButtonPane() { + JPanel testPane = new JPanel(new BorderLayout()); + UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection")); + testButton.addActionListener(testConnectionActionListener); + testPane.add(testButton, BorderLayout.WEST); + return testPane; + } + + private void initJNDILayout(JPanel corePane, JPanel advancedPanel) { + corePane.add(mainPanel); + // ChartSet + String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")}; + charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY)); + JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2); + chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":")); + advancedPanel.add(chartSetPane); + } + + private void initJDBCLayout(JPanel corePane, JPanel advancedPanel) { + corePane.add(mainPanel); + ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Advanced_More_Settings")); + actionLabel.addActionListener(evt -> { + JDialog wDialog = createJDialog(); + if (wDialog != null) { + wDialog.setVisible(true); } - // ChartSet - String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")}; - charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY)); - JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2); - chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":")); - advancedPanel.add(chartSetPane); + }); + JPanel advancePane = getAdvancePane(); + if (advancePane != null) { + advancedPanel.add(advancePane); } - northPane.add(advancedPanel); + advancedPanel.add( + row(cell(actionLabel),flex()).getComponent()); + corePane.add(getSshPane()); + corePane.add(getSslPane()); } private JDialog createJDialog() { - return JDBC.getAdvancedAttrPane() != null ? JDBC.getAdvancedAttrPane().showWindow(SwingUtilities.getWindowAncestor(mainPanel)) : null; + return JDBC.getAdvancedAttrPane() != null ? + JDBC.getAdvancedAttrPane().showWindow(SwingUtilities.getWindowAncestor(mainPanel)) : null; } private void initDialogPane() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index e8c7c17b8..4646d4da8 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -1,12 +1,14 @@ package com.fr.design.data.datapane.connect; -import com.fr.base.GraphHelper; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIUtils; import com.fr.data.driver.DriverLoader; import com.fr.data.driver.config.DriverLoaderConfig; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.solution.entity.DriverClasses; -import com.fr.design.border.UITitledBorder; -import com.fr.design.constants.UIConstants; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.core.ReactiveCardPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxUI; @@ -15,9 +17,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.BrowseUtils; import com.fr.file.filter.ChooseFileFilter; @@ -29,8 +28,6 @@ import com.fr.stable.StringUtils; import com.fr.third.guava.collect.HashBiMap; import com.fr.workspace.WorkContext; -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JPasswordField; @@ -39,10 +36,6 @@ import javax.swing.event.DocumentListener; import javax.swing.plaf.ComboBoxUI; import javax.swing.plaf.basic.ComboPopup; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputMethodEvent; @@ -59,6 +52,10 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +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.flex; + public class JDBCDefPane extends JPanel { public static final String DRIVER_TYPE = "driver_type"; public static final String USER_NAME = "user_name"; @@ -104,9 +101,8 @@ public class JDBCDefPane extends JPanel { private JPasswordField passwordTextField; private UIComboBox charSetComboBox; private ActionLabel odbcTipsLink; - private JPanel centerPanel; - private Component[][] allComponents; - private Component[][] partComponents; + private ReactiveCardPane centerPanel; + private ReactiveCardPane driverSelectRow; // 请不要改动dbtype,只应该最后添加 private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB}; @@ -116,16 +112,18 @@ public class JDBCDefPane extends JPanel { private UIComboBox driverManageBox; private ActionLabel driverManageLabel; private UIComboBox driverLoaderBox; - ActionListener driverManageListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean selectSelfDefine = isSelfDefine(); - driverManageLabel.setVisible(selectSelfDefine); - driverLoaderBox.setVisible(selectSelfDefine); - driverComboBox.setVisible(!selectSelfDefine); - odbcTipsLink.setVisible(driverComboBox.isVisible() && ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); + ActionListener driverManageListener = e -> changeDriverRow(); + + private void changeDriverRow() { + if (isSelfDefine()) { + driverSelectRow.select("define").populate(); + } else if (ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())) { + driverSelectRow.select("odbc").populate(); + } else { + driverSelectRow.select("normal").populate(); } - }; + } + ActionListener dbtypeActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { @@ -162,27 +160,24 @@ public class JDBCDefPane extends JPanel { public JDBCDefPane() { initMap(); - this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); - this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); - JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - innerthis.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - this.add(innerthis); + this.setLayout(new BorderLayout()); dbtypeComboBox = new UIComboBox(); dbtypeComboBox.setName(DRIVER_TYPE); - for (int i = 0; i < dbtype.length; i++) { - dbtypeComboBox.addItem(dbtype[i]); + for (String s : dbtype) { + dbtypeComboBox.addItem(s); } dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.setMaximumRowCount(10); + driverLoaderBox = new SpecialUIComboBox(); refreshDriverLoader(); - driverLoaderBox.setPreferredSize(new Dimension(200, driverLoaderBox.getPreferredSize().height)); driverLoaderBox.setEditable(false); + driverManageBox = new UIComboBox(); refreshDriverManage(true); driverManageBox.setEditable(false); driverManageBox.addActionListener(driverManageListener); - driverLoaderBox.setVisible(isSelfDefine()); + driverComboBox = new UIComboBox(); driverComboBox.setEditable(true); driverComboBox.addActionListener(driverListener); @@ -198,124 +193,117 @@ public class JDBCDefPane extends JPanel { userNameTextField.setName(USER_NAME); passwordTextField = new UIPasswordFieldWithFixedLength(15); dbtypeButton = new UIButton(); - dbtypeButton.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); - dbtypeButton.setPreferredSize(new Dimension(20, 20)); + dbtypeButton.setIcon(new LazyIcon("dot")); dbtypeButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL")); dbtypeButton.addActionListener(dbtypeButtonActionListener); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - dbtypePane.add(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Database") + ":"))); - Component[][] dbtypeComComponents = {{dbtypeComboBox}}; - double[] dbtypeRowSize = {p}; - double[] dbtypeColumnSize = {p}; - JPanel dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize); - - JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - driverPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Driver") + ":")); + JPanel dbTypeRow = row( + cell(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Database")))).weight(1.2), + cell(dbtypeComboBox).weight(2), + flex(5.8) + ).getComponent(); + // 选择ODBC数据源的时候的提示链接 - JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - odbcTipsLink = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) { - @Override - public void paintComponent(Graphics _gfx) { - super.paintComponent(_gfx); - _gfx.setColor(Color.blue); - _gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1); - } - }; - odbcTipsPane.add(odbcTipsLink); - odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height)); - odbcTipsLink.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); - BrowseUtils.browser(url); - } + odbcTipsLink = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")); + odbcTipsLink.addActionListener(evt -> { + String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); + BrowseUtils.browser(url); }); - driverManageLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")) { - @Override - public void paintComponent(Graphics _gfx) { - super.paintComponent(_gfx); - _gfx.setColor(Color.blue); - _gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1); - } - }; - driverManageLabel.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")), driverManageLabel.getPreferredSize().height)); - driverManageLabel.setVisible(isSelfDefine()); - driverManageLabel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent evt) { - String url = CloudCenter.getInstance().acquireUrlByKind("driver.add.help"); - BrowseUtils.browser(url); - } + driverManageLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")); + driverManageLabel.addActionListener(evt -> { + String url = CloudCenter.getInstance().acquireUrlByKind("driver.add.help"); + BrowseUtils.browser(url); }); - odbcTipsPane.add(driverManageLabel); - odbcTipsPane.add(odbcTipsLink); - - JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); - JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 0); - normalFlowInnerContainer_s_pane.add(driverManageBox); - normalFlowInnerContainer_s_pane.add(driverComboBox); - normalFlowInnerContainer_s_pane.add(driverLoaderBox); - driverComboBoxAndTips.add(normalFlowInnerContainer_s_pane, BorderLayout.WEST); - driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER); - - JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - hostPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host") + ":")); - Component[][] hostComComponents = {{hostTextField}}; - double[] hostRowSize = {p}; - double[] hostColumnSize = {p}; - JPanel hostComPane = TableLayoutHelper.createTableLayoutPane(hostComComponents, hostRowSize, hostColumnSize); - - JPanel portPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - portPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port") + ":")); - Component[][] portComComponents = {{portTextField}}; - double[] portRowSize = {p}; - double[] portColumnSize = {p}; - JPanel portComPane = TableLayoutHelper.createTableLayoutPane(portComComponents, portRowSize, portColumnSize); - - JPanel dbNamePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - dbNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_DatabaseName") + ":")); - Component[][] dbNameComComponents = {{dbNameTextField}}; - double[] dbNameRowSize = {p}; - double[] dbNameColumnSize = {p}; - JPanel dbNameComPane = TableLayoutHelper.createTableLayoutPane(dbNameComComponents, dbNameRowSize, dbNameColumnSize); - - JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - urlPane.add(new UILabel("URL:")); - Component[][] urlComComponents = {{urlTextField, dbtypeButton}}; - double[] urlRowSize = {p}; - double[] urlColumnSize = {f, 21}; - JPanel urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4); - - JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - userPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":")); - Component[][] userComComponents = {{userNameTextField, new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}}; - double[] userRowSize = {p}; - double[] userColumnSize = {f, p, f}; - JPanel userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4); + driverSelectRow = ReactiveCardPane.create() + .addSupplier("normal", () -> row( + cell(driverComboBox).weight(3), flex(2) + ).getComponent()) + .addSupplier("odbc", () -> row( + cell(driverComboBox).weight(3), flex(0.2), cell(odbcTipsLink).weight(1.8) + ).getComponent()) + .addSupplier("define", () -> row( + cell(driverLoaderBox).weight(3), cell(driverManageLabel).weight(2) + ).getComponent()); + changeDriverRow(); + + JPanel driverRow = row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Driver"))).weight(1.2), + cell(driverManageBox).weight(1.2), + flex(0.2), + cell(driverSelectRow).weight(4.6), + flex(1.8) + ).getComponent(); + + // 以下布局比例为对齐计算而出 + JPanel hostRow = row( + cell(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Host")))).weight(1.2), + cell(hostTextField).weight(4.16), + flex(3.64) + ).getComponent(); + + JPanel portRow = row( + cell(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Port")))).weight(1.2), + cell(portTextField).weight(4.16), + flex(3.64) + ).getComponent(); + + JPanel dbNameRow = row( + cell(new UILabel((Toolkit.i18nText("Fine-Design_Basic_DatabaseName")))).weight(1.2), + cell(dbNameTextField).weight(4.16), + flex(3.64) + ).getComponent(); + + JPanel urlRow = row( + cell(new UILabel("URL")).weight(1.2), + cell(urlTextField).weight(5.6), + flex(0.1), + cell(dbtypeButton).weight(0.3), + flex(1.8) + ).getComponent(); + + JPanel userRow = row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName"))).weight(1.2), + cell(userNameTextField).weight(2.3), + flex(0.2), + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password"))).weight(1.2), + cell(passwordTextField).weight(2.3), + flex(1.8) + ).getComponent(); String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")}; charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY)); - JPanel chartSetPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - chartSetPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":")); - Component[][] charSetComComponents = {{charSetComboBox}}; - double[] charSetRowSize = {p}; - double[] charSetColumnSize = {f}; - JPanel charSetComPane = TableLayoutHelper.createTableLayoutPane(charSetComComponents, charSetRowSize, charSetColumnSize); + JPanel charSetRow = row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset"))).weight(1.2), + cell(charSetComboBox).weight(6), + flex(1.8) + ).getComponent(); //这边调整的话注意下面的changePane - allComponents = new Component[][]{{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {hostPane, hostComPane}, - {portPane, portComPane}, {dbNamePane, dbNameComPane}, {userPane, userComPane}, - {chartSetPane, charSetComPane}, {urlPane, urlComPane}}; - partComponents = new Component[][]{{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, - {userPane, userComPane}, {chartSetPane, charSetComPane}}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - double[] columnSize = {p, f, 22}; - // REPORT-41450 Windows环境的jdk11下dpi为125%时会因为缩放导致显示问题,因此加个水平gap值 - centerPanel = TableLayoutHelper.createGapTableLayoutPane(allComponents, rowSize, columnSize, 6, 6); - innerthis.add(centerPanel); + centerPanel = ReactiveCardPane.create() + .addSupplier("all", () -> Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(dbTypeRow), + cell(driverRow), + cell(hostRow), + cell(portRow), + cell(dbNameRow), + cell(userRow), + cell(charSetRow), + cell(urlRow) + ).getComponent()) + .addSupplier("part", () -> Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(dbTypeRow), + cell(driverRow), + cell(urlRow), + cell(userRow), + cell(charSetRow) + ).getComponent()); + centerPanel.select("all").populate(); + + this.add(Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel("JDBC")).with(FineUIUtils::wrapBoldLabelWithUnderline), + cell(centerPanel) + ).getComponent()); } private void refreshDriverLoader() { @@ -365,17 +353,10 @@ public class JDBCDefPane extends JPanel { } private void changePane(Object dbType) { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f, 22}; if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) { - if (this.centerPanel.getComponentCount() != partComponents.length * 2) { - centerPanel.removeAll(); - TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel); - } - } else if (this.centerPanel.getComponentCount() != allComponents.length * 2) { - centerPanel.removeAll(); - TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel); + centerPanel.select("part").populate(); + } else { + centerPanel.select("all").populate(); } } @@ -488,8 +469,13 @@ public class JDBCDefPane extends JPanel { linkPanel.setVisible(DriverClasses.MYSQL.toString().equalsIgnoreCase((String) dbtypeComboBox.getSelectedItem()) && driverComboBox.getSelectedItem() != null && ComparatorUtils.equals(DriverClasses.MYSQL.getDriverClass(), driverComboBox.getSelectedItem().toString().trim())); - odbcTipsLink.setVisible(driverComboBox.getSelectedItem() != null - && ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem().toString().trim())); // 选择的如果是ODBC就显示提示 + if (driverComboBox.getSelectedItem() != null + && ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem().toString().trim())) { + driverSelectRow.select("odbc").populate(); + } else { + driverSelectRow.select("normal").populate(); + + } if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) { return; } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java index 48f710dfb..c40407826 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java @@ -1,5 +1,8 @@ package com.fr.design.data.datapane.connect; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIUtils; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.security.ssh.BaseSsh; import com.fr.data.security.ssh.Ssh; @@ -8,10 +11,10 @@ import com.fr.data.security.ssh.SshType; import com.fr.data.security.ssh.impl.KeyVerifySsh; import com.fr.data.security.ssh.impl.NormalSsh; import com.fr.data.security.ssl.SslUtils; -import com.fr.design.border.UITitledBorder; -import com.fr.design.constants.UIConstants; +import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.editor.editor.NotNegativeIntegerEditor; +import com.fr.design.gui.core.ReactiveCardPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; @@ -19,29 +22,22 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.HashBiMap; -import javax.swing.ImageIcon; -import javax.swing.JPanel; import javax.swing.JPasswordField; -import javax.swing.SwingConstants; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.cell; import static com.fr.design.i18n.Toolkit.i18nText; /** @@ -58,114 +54,135 @@ public class SshPane extends BasicPane { typeMap.put(Toolkit.i18nText("Fine-Design_Basic_Ssh_Public_Key"), SshType.KEY); } - private UICheckBox usingSsh = new UICheckBox(i18nText("Fine-Design_Basic_Ssh_Using")); - private NotNegativeIntegerEditor port = new NotNegativeIntegerEditor(20); - private UITextField ip = new UITextField(20); - private UIComboBox type = new UIComboBox(); - private UITextField user = new UITextField(20); - private JPasswordField password = new UIPasswordFieldWithFixedLength(20); - private JPasswordField secret = new UIPasswordFieldWithFixedLength(20); - private KeyFileUITextField keyPath = new KeyFileUITextField(18); - private JPanel contextPane; - private Component[][] passwordComps; - private Component[][] keyComps; - private double p = TableLayout.PREFERRED; - private double f = TableLayout.FILL; - private JPanel jPanel; - private UIButton fileChooserButton = new UIButton(); - private double[] columnSize = new double[]{195, p}; + private final UICheckBox usingSsh = new UICheckBox(i18nText("Fine-Design_Basic_Ssh_Using")); + private final NotNegativeIntegerEditor port = new NotNegativeIntegerEditor(20); + private final UITextField ip = new UITextField(20); + private final UIComboBox type = new UIComboBox(); + private final UITextField user = new UITextField(20); + private final JPasswordField password = new UIPasswordFieldWithFixedLength(20); + private final JPasswordField secret = new UIPasswordFieldWithFixedLength(20); + private final KeyFileUITextField keyPath = new KeyFileUITextField(18); + private ReactiveCardPane coreCardPane; + private ReactiveCardPane verifyCardPane; + private final UIButton fileChooserButton = new UIButton(); + + private static final String USE_SSH = "useSSH"; + private static final String NOT_USE_SSH = "notUseSSH"; + private static final String USE_PASSWORD = "usePassword"; + private static final String USE_KEY = "useKey"; + public SshPane() { - fileChooserButton.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); - this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings"))); - this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); + this.setLayout(new BorderLayout()); + + fileChooserButton.setIcon(new LazyIcon("dot")); typeMap.keySet().forEach(key -> type.addItem(key)); type.setSelectedItem(typeMap.inverse().get(SshType.KEY)); - jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - fileChooserButton.setPreferredSize(new Dimension(20, 20)); type.setEditable(false); type.setSelectedItem(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key")); - JPanel filePanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPath, fileChooserButton}}, new double[]{p}, new double[]{f, 20}, 0); - Component[] compIp = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host") + ":", SwingConstants.RIGHT), ip}; - Component[] compPort = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port") + ":", SwingConstants.RIGHT), port}; - Component[] compUserName = {new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":", SwingConstants.RIGHT), user}; - Component[] compMethod = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Verify_Method") + ":", SwingConstants.RIGHT), type}; - Component[] compPassword = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":", SwingConstants.RIGHT), password}; - Component[] compKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key") + ":", SwingConstants.RIGHT), filePanel}; - Component[] comSecret = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Secret") + ":", SwingConstants.RIGHT), secret}; - - passwordComps = new Component[][]{ - compIp, - compPort, - compUserName, - compMethod, - compPassword - }; - keyComps = new Component[][]{ - compIp, - compPort, - compUserName, - compMethod, - compKey, - comSecret - }; - usingSsh.setSelected(true); - contextPane = TableLayoutHelper.createGapTableLayoutPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, 11, 11); - jPanel.add(usingSsh, BorderLayout.NORTH); - jPanel.add(contextPane, BorderLayout.CENTER); - this.add(jPanel); - - usingSsh.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - changePane(); - } - }); - type.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - changePaneForType(); - } - }); - fileChooserButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(SslUtils.PREFIX, new ChooseFileFilter(true), SslUtils.CERTIFICATES); - int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY); - if (type == FILEChooserPane.OK_OPTION) { - final FILE file = fileChooser.getSelectedFILE(); - if (file == null) { - keyPath.setText(StringUtils.EMPTY); - } else { - keyPath.setText(file.getPath()); - } + initVerifyCardPane(); + initCoreCardPane(); + + initListeners(); + + this.add(Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings"))).with(FineUIUtils::wrapBoldLabelWithUnderline), + cell(coreCardPane) + ).getComponent()); + } + + private void initListeners() { + usingSsh.addActionListener(e -> changePane()); + + type.addActionListener(e -> changePaneForType()); + fileChooserButton.addActionListener(e -> { + FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(SslUtils.PREFIX, new ChooseFileFilter(true), SslUtils.CERTIFICATES); + int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY); + if (type == FILEChooserPane.OK_OPTION) { + final FILE file = fileChooser.getSelectedFILE(); + if (file == null) { + keyPath.setText(StringUtils.EMPTY); + } else { + keyPath.setText(file.getPath()); } - fileChooser.removeAllFilter(); - fileChooser.removeTopPath(); } + fileChooser.removeAllFilter(); + fileChooser.removeTopPath(); }); } + private void initCoreCardPane() { + coreCardPane = ReactiveCardPane.create() + .addSupplier(NOT_USE_SSH, () -> cell(usingSsh).getComponent()) + .addSupplier(USE_SSH, () -> Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(usingSsh), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host"))).weight(1), + cell(ip).weight(5), + flex(6) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port"))).weight(1), + cell(port).weight(5), + flex(6) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName"))).weight(1), + cell(user).weight(5), + flex(6) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Verify_Method"))).weight(1), + cell(type).weight(5), + flex(6) + ), + cell(verifyCardPane) + ).getComponent()); + coreCardPane.select(USE_SSH).populate(); + } + + private void initVerifyCardPane() { + verifyCardPane = ReactiveCardPane.create() + .addSupplier(USE_PASSWORD, () -> Layouts.row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password"))).weight(1), + cell(password).weight(5), + flex(6) + ).getComponent()) + .addSupplier(USE_KEY, () -> Layouts.column(LayoutConstants.VERTICAL_GAP, + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key"))).weight(1), + cell(keyPath).weight(4.5), + flex(0.1), + cell(fileChooserButton).weight(0.4), + flex(6) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Secret"))).weight(1), + cell(secret).weight(5), + flex(6) + ) + ).getComponent()); + + verifyCardPane.select(USE_KEY).populate(); + } + private void changePane() { - contextPane.setVisible(usingSsh.isSelected()); + coreCardPane.select(usingSsh.isSelected() ? USE_SSH: NOT_USE_SSH).populate(); } private void changePaneForType() { - contextPane.removeAll(); switch (typeMap.get(type.getSelectedItem())) { case NORMAL: - TableLayoutHelper.addComponent2ResultPane(passwordComps, new double[]{p, p, p, p, p}, columnSize, contextPane); + verifyCardPane.select(USE_PASSWORD).populate(); break; case KEY: - TableLayoutHelper.addComponent2ResultPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, contextPane); + verifyCardPane.select(USE_KEY).populate(); break; default: throw new SshException("un support ssh type"); } - jPanel.revalidate(); - jPanel.repaint(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java index 8789a39a1..10cd4e5e2 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java @@ -1,37 +1,36 @@ package com.fr.design.data.datapane.connect; +import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIUtils; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.security.ssl.Ssl; import com.fr.data.security.ssl.SslException; import com.fr.data.security.ssl.SslType; import com.fr.data.security.ssl.SslUtils; import com.fr.data.security.ssl.impl.NormalSsl; -import com.fr.design.border.UITitledBorder; -import com.fr.design.constants.UIConstants; +import com.fr.design.constants.LayoutConstants; import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.core.ReactiveCardPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.StringUtils; -import javax.swing.ImageIcon; -import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.cell; import static com.fr.design.i18n.Toolkit.i18nText; /** @@ -41,65 +40,66 @@ import static com.fr.design.i18n.Toolkit.i18nText; */ public class SslPane extends BasicPane { UICheckBox usingSsl = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Using")); - private KeyFileUITextField keyPathCa = new KeyFileUITextField(18); - private UIButton fileChooserButtonCa = new UIButton(); - private KeyFileUITextField keyPathClientCert = new KeyFileUITextField(18); - private UIButton fileChooserButtonClientCert = new UIButton(); - private KeyFileUITextField keyPathClientKey = new KeyFileUITextField(18); - private UIButton fileChooserButtonClientKey = new UIButton(); - private UICheckBox verifyCa = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Verify_Ca")); -// private UITextField cipher = new UITextField(20); - private JPanel jPanel; - private Component[][] usingComps; - private double p = TableLayout.PREFERRED; - private double f = TableLayout.FILL; - private JPanel contextPane; - private double[] columnSize = new double[]{195, p}; + private final KeyFileUITextField keyPathCa = new KeyFileUITextField(18); + private final UIButton fileChooserButtonCa = new UIButton(); + private final KeyFileUITextField keyPathClientCert = new KeyFileUITextField(18); + private final UIButton fileChooserButtonClientCert = new UIButton(); + private final KeyFileUITextField keyPathClientKey = new KeyFileUITextField(18); + private final UIButton fileChooserButtonClientKey = new UIButton(); + private final UICheckBox verifyCa = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Verify_Ca")); + private final ReactiveCardPane cardPane; public SslPane() { - fileChooserButtonCa.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); - fileChooserButtonClientCert.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); - fileChooserButtonClientKey.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); - this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings"))); - this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); - jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - Dimension dimension = new Dimension(20, 20); - fileChooserButtonCa.setPreferredSize(dimension); - fileChooserButtonClientCert.setPreferredSize(dimension); - fileChooserButtonClientKey.setPreferredSize(dimension); - JPanel filePanelCa = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathCa, fileChooserButtonCa}}, new double[]{p}, new double[]{f, 20}, 0); - Component[] compCa = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Ca") + ":", SwingConstants.RIGHT), filePanelCa}; - Component[] compVerifyCa = {null, verifyCa}; - JPanel filePanelClientKey = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientKey, fileChooserButtonClientKey}}, new double[]{p}, new double[]{f, 20}, 0); - Component[] compClientKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Key") + ":", SwingConstants.RIGHT), filePanelClientKey}; - JPanel filePanelClientCert = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientCert, fileChooserButtonClientCert}}, new double[]{p}, new double[]{f, 20}, 0); - Component[] compClientCert = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Cert") + ":", SwingConstants.RIGHT), filePanelClientCert}; -// Component[] comCipher = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Cipher") + ":", SwingConstants.RIGHT), cipher}; - usingComps = new Component[][]{ - compCa, - compVerifyCa, - compClientKey, - compClientCert -// comCipher - }; + initDotButtons(); + this.setLayout(new BorderLayout()); usingSsl.setSelected(true); - contextPane = TableLayoutHelper.createGapTableLayoutPane(usingComps, new double[]{p, p, p, p}, columnSize, 11, 11); - jPanel.add(usingSsl, BorderLayout.NORTH); - jPanel.add(contextPane, BorderLayout.CENTER); - this.add(jPanel); - usingSsl.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - changePane(); - } - }); + cardPane = ReactiveCardPane.create() + .addSupplier("notUseSSL", () -> cell(usingSsl).getComponent()) + .addSupplier("useSSL", () -> Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(usingSsl), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Ca"), SwingConstants.LEFT)).weight(1), + cell(keyPathCa).weight(1.3), + flex(0.05), + cell(fileChooserButtonCa).weight(0.15), + flex(2) + ), + cell(verifyCa), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Key"), SwingConstants.LEFT)).weight(1), + cell(keyPathClientKey).weight(1.3), + flex(0.05), + cell(fileChooserButtonClientKey).weight(0.15), + flex(2) + ), + row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Cert"), SwingConstants.LEFT)).weight(1), + cell(keyPathClientCert).weight(1.3), + flex(0.05), + cell(fileChooserButtonClientCert).weight(0.15), + flex(2) + ) + ).getComponent() + ); + cardPane.select("useSSL").populate(); + this.add(Layouts.column(LayoutConstants.VERTICAL_GAP, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings"))).with(FineUIUtils::wrapBoldLabelWithUnderline), + cell(cardPane) + ).getComponent()); + usingSsl.addActionListener(e -> changePane()); + } + + private void initDotButtons() { + fileChooserButtonCa.setIcon(new LazyIcon("dot")); + fileChooserButtonClientCert.setIcon(new LazyIcon("dot")); + fileChooserButtonClientKey.setIcon(new LazyIcon("dot")); fileChooserButtonCa.addActionListener(new TextFieldActionListener(keyPathCa)); fileChooserButtonClientCert.addActionListener(new TextFieldActionListener(keyPathClientCert)); fileChooserButtonClientKey.addActionListener(new TextFieldActionListener(keyPathClientKey)); } private void changePane() { - contextPane.setVisible(usingSsl.isSelected()); + cardPane.select(usingSsl.isSelected() ? "useSSL" : "notUseSSL").populate(); } @@ -120,7 +120,6 @@ public class SslPane extends BasicPane { keyPathClientCert.setText(normalSsl.getClientCertificate()); keyPathClientKey.setText(normalSsl.getClientPrivateKey()); verifyCa.setSelected(normalSsl.isVerifyCa()); -// cipher.setText(normalSsl.getCipher()); } else { throw new SslException("un support ssl type"); } @@ -130,7 +129,6 @@ public class SslPane extends BasicPane { public void update(JDBCDatabaseConnection jdbcDatabase) { NormalSsl normalSsl = new NormalSsl(); -// normalSsl.setCipher(cipher.getText().trim()); normalSsl.setVerifyCa(verifyCa.isSelected()); normalSsl.setCaCertificate(keyPathCa.getText().trim()); normalSsl.setClientCertificate(keyPathClientCert.getText().trim()); @@ -140,7 +138,7 @@ public class SslPane extends BasicPane { } private class TextFieldActionListener implements ActionListener { - private UITextField textField; + private final UITextField textField; public TextFieldActionListener(UITextField textField) { this.textField = textField; diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index dcfecd81c..35c5a2c68 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -4,6 +4,7 @@ import com.fine.swing.ui.layout.Layouts; import com.fine.theme.icon.LazyIcon; import com.fine.theme.light.ui.FineRoundBorder; import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIStyle; import com.formdev.flatlaf.ui.FlatUIUtils; import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; @@ -1361,7 +1362,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private JPanel createNamePane(String name, JComponent comp) { JPanel namePane = new JPanel(new BorderLayout(0, 4)); - namePane.add(new UILabel(name), BorderLayout.NORTH); + UILabel label = new UILabel(name); + FineUIStyle.setStyle(label, FineUIStyle.LABEL_BOLD); + namePane.add(label, BorderLayout.NORTH); namePane.add(comp, BorderLayout.CENTER); return namePane; } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java index 37fef509d..2f73936c7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java @@ -1,5 +1,7 @@ package com.fr.design.gui.controlpane; +import com.formdev.flatlaf.ui.FlatUIUtils; +import com.fr.design.border.FineBorderFactory; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.controlpane.shortcutfactory.AbstractShortCutFactory; import com.fr.design.gui.controlpane.shortcutfactory.OldShortCutFactory; @@ -7,16 +9,15 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ToolBarDef; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.Filter; import com.fr.stable.Nameable; -import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JSplitPane; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Color; import java.util.Arrays; import java.util.stream.Stream; @@ -107,7 +108,6 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S initCardPane(); // SplitPane JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); - mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); mainSplitPane.setOneTouchExpandable(true); this.add(mainSplitPane, BorderLayout.CENTER); @@ -163,7 +163,8 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S } initToolBar(); - + toolBar.setBorder(FineBorderFactory.createUnderlineBorder(FlatUIUtils.getUIColor("defaultBorderColor", Color.GRAY))); + toolBar.setBorderPainted(true); leftPane.add(toolBar, BorderLayout.NORTH); return leftPane; } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index dfece2e13..3dec4e1c3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -1,6 +1,10 @@ package com.fr.design.gui.controlpane; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.light.ui.FineRoundBorder; +import com.formdev.flatlaf.ui.FlatUIUtils; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.border.FineBorderFactory; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.JNameEdList; @@ -10,14 +14,12 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.JLabel; @@ -87,8 +89,9 @@ public abstract class JListControlPane extends JControlPane implements ListContr protected void initLeftPane(JPanel leftPane) { nameableList = createJNameList(); nameableList.setName(LIST_NAME); + nameableList.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); - + leftPane.setBorder(new FineRoundBorder()); nameableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); nameableList.addMouseListener(listMouseListener); nameableList.addListSelectionListener(new ListSelectionListener() { @@ -107,6 +110,12 @@ public abstract class JListControlPane extends JControlPane implements ListContr }); } + @Override + protected void initToolBar() { + super.initToolBar(); + toolBar.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); + } + protected JNameEdList createJNameList() { JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { @Override @@ -355,19 +364,17 @@ public abstract class JListControlPane extends JControlPane implements ListContr /** * JList默认单元格渲染器的选中背景色 */ - private final Color selectedBgColor = new Color(65, 155, 249); protected NameableListCellRenderer() { setLayout(new BorderLayout()); this.textLabel = new JLabel(); this.iconLabel = new JLabel(); - this.textLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1)); - this.iconLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 0)); add(this.textLabel, BorderLayout.CENTER); add(this.iconLabel, BorderLayout.WEST); - this.iconLabel.setBackground(Color.WHITE); + this.iconLabel.setBackground(FlatUIUtils.getUIColor("List.cellRender.background", Color.WHITE)); //iconLabel和textLabel的背景颜色不会被JList背景颜色覆盖,开发者自定义 this.textLabel.setOpaque(true); this.iconLabel.setOpaque(true); + this.setBorder(FineBorderFactory.createUnderlineBorder(FlatUIUtils.getUIColor("defaultBorderColor", Color.GRAY))); } @Override @@ -380,11 +387,9 @@ public abstract class JListControlPane extends JControlPane implements ListContr this.textLabel.setText(nameable.getName()); boolean iconSet = false; if(isSelected) { - this.textLabel.setBackground(selectedBgColor); - this.textLabel.setForeground(Color.WHITE); + this.textLabel.setBackground(FlatUIUtils.getUIColor("List.selectionInactiveBackground", Color.GRAY)); } else { - this.textLabel.setBackground(Color.WHITE); - this.textLabel.setForeground(Color.BLACK); + this.textLabel.setBackground(FlatUIUtils.getUIColor("List.cellRender.background", Color.WHITE)); } for (NameableCreator creator : JListControlPane.this.creators()) { if (creator.menuIcon() != null && creator.acceptObject2Populate(nameable) != null) { @@ -395,7 +400,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr } } if (!iconSet) { - this.setIcon(IOUtils.readIcon("/com/fr/base/images/oem/cpt.png")); + this.setIcon(new LazyIcon("cpt_icon")); } } return this; diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java index c98455a58..b4dc77e92 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java @@ -1,5 +1,7 @@ package com.fr.design.gui.ilable; +import com.formdev.flatlaf.ui.FlatUIUtils; + import javax.swing.event.MouseInputAdapter; import java.awt.Color; import java.awt.Cursor; @@ -13,12 +15,12 @@ import java.awt.event.MouseEvent; */ public class ActionLabel extends UILabel { private ActionListener actionListener; - private Color color; + private final Color color; // 文字是否有下划线 private boolean drawUnderLine = true; public ActionLabel(String text) { - this(text, Color.blue); + this(text, FlatUIUtils.getUIColor("Label.hyperLinkColor", Color.BLUE)); } public ActionLabel(String text, boolean drawUnderLine) { diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index e5e89bf72..4a2525d7c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -42,11 +42,11 @@ public class FileTreeIcon { public static final Icon JPG_FILE_IMAGE_ICON = new LazyIcon("jpgFile"); public static final Icon BMP_FILE_IMAGE_ICON = new LazyIcon("bmpFile"); public static final Icon MODERN_CHT_FILE_IMAGE_ICON = new LazyIcon("chtFile"); + public static final Icon CPTX_ICON = new LazyIcon("cpt_icon"); // TODO: 以下Icon视觉暂未提供,需提供后替换 public static final Icon BLANK_IMAGE_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/blank.gif"); public static final Icon FOLDER_HALF_IMAGE_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/folder_half_authority.svg"); - public static final Icon CPTX_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/cptx_icon.svg"); public static final Icon CPTX_LOCKED_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/cptx_icon_locked.svg"); public static final LockIcon FOLDER_LOCK_ICON = diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index e1f5ff3ad..8d037e330 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fine.theme.utils.FineUIScale; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.data.datapane.TableDataTreePane; @@ -16,6 +17,7 @@ import com.fr.stable.Constants; public class WestRegionContainerPane extends UIResizableContainer { private static WestRegionContainerPane THIS; + private static final int WEST_CONTAINER_WIDTH = 165; /** * 得到实例 @@ -56,7 +58,6 @@ public class WestRegionContainerPane extends UIResizableContainer { } }); - setContainerWidth(165); -// setBackground(UIConstants.TREE_BACKGROUND); + setContainerWidth(FineUIScale.scale(WEST_CONTAINER_WIDTH)); } } diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid.svg new file mode 100755 index 000000000..7196cbd02 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid_disable.svg new file mode 100755 index 000000000..9a161d213 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/forbid_disable.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal.svg new file mode 100755 index 000000000..bce0ec62e --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal_disable.svg new file mode 100755 index 000000000..a5fa25983 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/horizontal_disable.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical.svg new file mode 100755 index 000000000..52375c61c --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical_disable.svg new file mode 100755 index 000000000..bbacb6db0 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/expand/vertical_disable.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index 266c1fd71..d9deea101 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -399,6 +399,9 @@ FormattedTextField.iconTextGap = 4 # ---- Label ---- Label.tipColor = @BrandTipColor +Label.borderColor = $defaultBorderColor +Label.hyperLinkColor = #2576EF +Label.strongHintColor = #FF0000 #---- HelpButton ---- @@ -421,8 +424,8 @@ HelpButton.innerFocusWidth = $?Button.innerFocusWidth #---- List ---- -List.border = 2,2,2,2 -List.cellMargins = 1,6,1,6 +List.border = 0,0,0,0 +List.cellMargins = 1,12,1,12 List.selectionInsets = 0,0,0,0 List.selectionArc = 0 List.cellFocusColor = @cellFocusColor @@ -540,7 +543,7 @@ PasswordField.capsLockIconColor = #00000064 PasswordField.revealIconColor = tint(@foreground,40%) PasswordField.border = com.formdev.flatlaf.ui.FlatTextBorder PasswordField.margin = @componentMargin -PasswordField.background = @componentBackground +PasswordField.background = $fill.normal PasswordField.placeholderForeground = @disabledForeground PasswordField.iconTextGap = 4 PasswordField.echoChar = \u2022 @@ -669,7 +672,7 @@ ScrollBar.largeBar.buttonBackground = $ScrollBar.track #---- ScrollPane ---- -ScrollPane.border = com.formdev.flatlaf.ui.FlatBorder +ScrollPane.border = null ScrollPane.background = $ScrollBar.track ScrollPane.fillUpperCorner = true ScrollPane.smoothScrolling = true @@ -765,6 +768,8 @@ FormulaPane.buttonHeight=$Component.defaultHeight SplitPane.dividerSize = 5 SplitPane.continuousLayout = true SplitPane.border = null +# \u5F71\u54CD\u89C6\u89C9\u6548\u679C\uFF0C\u4E34\u65F6\u5148\u5173\u6389 +SplitPane.supportsOneTouchButtons = false SplitPane.centerOneTouchButtons = true SplitPane.oneTouchButtonSize = {scaledInteger}6 SplitPane.oneTouchButtonOffset = {scaledInteger}2 @@ -1293,4 +1298,7 @@ CellOtherSetPane.height=$Component.defaultHeight toolbar.margin: 1,1,1,1; \ toolbar.spacingInsets: 1,1,1,1; \ toolbar.hoverBackground: null; \ - toolbar.pressedBackground: null \ No newline at end of file + toolbar.pressedBackground: null + +[style]Label.boldLabel = \ + font: bold $defaultFont \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 7cff6e11a..0d04bb77a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fine.swing.ui.layout.Layouts; +import com.fine.theme.icon.LazyIcon; import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.constants.LayoutConstants; import com.fr.design.expand.ExpandLeftFatherPane; @@ -53,9 +54,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { public JPanel createContentPane() { String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_ExpandD_Not_Expand"), Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom"), Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right")}; Icon[][] iconArray = { - {IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), IOUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, - {IOUtils.readIcon("/com/fr/design/images/expand/vertical.png"), IOUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")}, - {IOUtils.readIcon("/com/fr/design/images/expand/landspace.png"), IOUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")} + {new LazyIcon("forbid"), new LazyIcon("forbid").white()}, + {new LazyIcon("vertical_expand"), new LazyIcon("vertical_expand").white()}, + {new LazyIcon("horizontal_expand"), new LazyIcon("horizontal_expand").white()} }; Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT}; expandDirectionButton = new UIButtonGroup(iconArray, valueArray);