From ad297d2c0038f6e750f557487282aff9b4a478ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Thu, 29 Aug 2024 16:31:46 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-132283=20feat:=20NewUI=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=9C=E5=8C=BA=E9=9D=A2=E6=9D=BF=E6=8B=96=E6=8B=BD=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fine/theme/utils/FineUIUtils.java | 13 ++ .../icontainer/UIEastResizableContainer.java | 124 ++++++++++-------- .../mainframe/EastRegionContainerPane.java | 11 +- .../fr/design/i18n/dimension_en.properties | 3 + .../fr/design/i18n/dimension_ja_JP.properties | 3 + .../fr/design/i18n/dimension_ko_KR.properties | 3 + .../fr/design/i18n/dimension_zh.properties | 3 + .../fr/design/i18n/dimension_zh_TW.properties | 3 + 8 files changed, 105 insertions(+), 58 deletions(-) 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 bf48c66c6d..92ee62ff5e 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 @@ -6,6 +6,7 @@ import com.fr.design.border.FineBorderFactory; import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.stable.os.OperatingSystem; import com.fr.value.AtomicClearableLazyValue; @@ -16,6 +17,7 @@ import javax.swing.UIManager; import java.awt.Color; import java.awt.Component; import java.awt.Composite; +import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; @@ -435,4 +437,15 @@ public class FineUIUtils { Font newSizeFont = font.deriveFont(font.getStyle(), scale(size)); c.setFont(newSizeFont); } + + /** + * 获取缩放后的国际化尺寸 + * + * @param i18nDimensionKey 国际化key值 + * @return 缩放后的国际化尺寸 + */ + public static Dimension getScaledI18nDimension(String i18nDimensionKey) { + return FineUIScale.scale(DesignSizeI18nManager.getInstance().i18nDimension(i18nDimensionKey)); + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index d85793d5c4..876ebc0ca9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -3,27 +3,26 @@ package com.fr.design.gui.icontainer; import com.fine.theme.icon.LazyIcon; import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIUtils; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.BorderFactory; -import javax.swing.UIManager; +import javax.swing.Icon; import javax.swing.JComponent; -import javax.swing.JFrame; import javax.swing.JPanel; -import javax.swing.Icon; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.border.Border; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.LayoutManager; +import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; @@ -34,32 +33,84 @@ import java.awt.event.MouseMotionListener; public class UIEastResizableContainer extends JPanel { private static final long serialVersionUID = 1854340560790476907L; - public static final int MAX_CONTAINER_WIDTH = FineUIScale.scale(340); - public static final int MIN_CONTAINER_WIDTH = FineUIScale.scale(286); + public static final int MAX_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension( + "com.fr.design.mainframe.EastRegionContainerPane.maximum").width; + public static final int MIN_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension( + "com.fr.design.mainframe.EastRegionContainerPane.minimum").width; + public static final int STD_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension( + "com.fr.design.mainframe.EastRegionContainerPane.standard").width; + + private int containerWidth = STD_CONTAINER_WIDTH; + private int preferredWidth = STD_CONTAINER_WIDTH; + protected final int leftPaneWidth = FineUIScale.scale(42); + protected final int topToolPaneHeight = FineUIScale.scale(40); - private int containerWidth = FineUIScale.scale(240); - private int preferredWidth = FineUIScale.scale(240); - private int topToolPaneHeight = FineUIScale.scale(40); - private int leftPaneWidth = FineUIScale.scale(42); + private static final int ARROW_RANGE = FineUIScale.scale(35); private JComponent leftPane; private JComponent rightPane; private TopToolPane topToolPane; - - private static final int ARROW_MARGIN = FineUIScale.scale(15); - private static final int ARROW_RANGE = FineUIScale.scale(35); - + private static final int DRAG_GAP_SIZE = 10; + private Point dragPoint; public UIEastResizableContainer() { this(new JPanel(), new JPanel()); + initMouseListener(); + } + + private void initMouseListener() { + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + updateCursor(e); + } + + @Override + public void mousePressed(MouseEvent e) { + if (isEnableDrag(e)) { + dragPoint = e.getPoint(); + } + } + + @Override + public void mouseDragged(MouseEvent e) { + resizePanel(e); + } + }; + + addMouseListener(mouseAdapter); + addMouseMotionListener(mouseAdapter); + } + + private void updateCursor(MouseEvent e) { + if (isEnableDrag(e)) { + setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); + } else { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } + + protected boolean isEnableDrag(MouseEvent e) { + return e.getX() <= DRAG_GAP_SIZE && isRightPaneVisible(); + } + + protected void resizePanel(MouseEvent e) { + int dx = e.getX() - dragPoint.x; + Dimension size = getSize(); + + int newWidth = size.width - dx; + // 限制container大小为指定范围 + containerWidth = Math.max(MIN_CONTAINER_WIDTH, Math.min(newWidth, MAX_CONTAINER_WIDTH)); + + SwingUtilities.invokeLater(this::revalidate); } /** * 设置面板宽度 * - * @param width + * @param width 宽度 */ public void setContainerWidth(int width) { this.containerWidth = width; @@ -70,8 +121,6 @@ public class UIEastResizableContainer extends JPanel { return containerWidth > leftPaneWidth; } - - private void setPreferredWidth(int width) { this.preferredWidth = width; } @@ -81,7 +130,7 @@ public class UIEastResizableContainer extends JPanel { this.rightPane = rightPane; this.topToolPane = new TopToolPane(); topToolPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 0)); - topToolPane.setBorder(BorderFactory.createMatteBorder(0 ,1, 0, 1, UIManager.getColor("East.border"))); + topToolPane.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 1, UIManager.getColor("East.border"))); setLayout(containerLayout); add(topToolPane); @@ -89,38 +138,6 @@ public class UIEastResizableContainer extends JPanel { add(rightPane); } - public static void main(String... args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - - JPanel leftPane = new JPanel(); -// leftPane.setBackground(Color.yellow); - JPanel rightPane = new JPanel(); -// rightPane.setBackground(Color.green); - - UIButton b1, b2; - b1 = new UIButton("b1"); - b2 = new UIButton("b2"); - b1.setPreferredSize(new Dimension(40, 40)); - b2.setPreferredSize(new Dimension(40, 40)); - leftPane.add(b1); - leftPane.add(b2); - - - UIEastResizableContainer bb = new UIEastResizableContainer(leftPane, rightPane); - - JPanel cc = new JPanel(); -// cc.setBackground(Color.WHITE); - - content.add(bb, BorderLayout.EAST); - content.add(cc, BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(500, 500); - jf.setVisible(true); - } - /** * 将面板设置成最佳的宽度 */ @@ -156,7 +173,6 @@ public class UIEastResizableContainer extends JPanel { @Override public void removeLayoutComponent(Component comp) { - // TODO Auto-generated method stub } @@ -182,7 +198,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void addLayoutComponent(String name, Component comp) { - // do nothing + } }; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 0ee74940d6..6fae3748ff 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -142,10 +142,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private static int containerWidth() { - if (FRContext.isChineseEnv()) { - return UIEastResizableContainer.MIN_CONTAINER_WIDTH; - } - return UIEastResizableContainer.MAX_CONTAINER_WIDTH; + return UIEastResizableContainer.STD_CONTAINER_WIDTH; + } + + @Override + protected boolean isEnableDrag(MouseEvent e) { + return super.isEnableDrag(e) + && e.getY() > topToolPaneHeight + leftPane.getPreferredSize().height; } /** diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index 24cc2ad5aa..864dfef4dc 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -30,3 +30,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=1200*600 com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=130*20 com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=140*20 com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=100*24 +com.fr.design.mainframe.EastRegionContainerPane.maximum=600*400 +com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400 +com.fr.design.mainframe.EastRegionContainerPane.standard=480*400 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index d052ead680..a0fcc4c55b 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=100*20 com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=130*20 com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=160*24 +com.fr.design.mainframe.EastRegionContainerPane.maximum=600*400 +com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400 +com.fr.design.mainframe.EastRegionContainerPane.standard=480*400 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index 525bfe56ad..7dacc1d209 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20 com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20 com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24 +com.fr.design.mainframe.EastRegionContainerPane.maximum=500*400 +com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400 +com.fr.design.mainframe.EastRegionContainerPane.standard=340*400 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index 3e54c98a84..8826ed856b 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20 com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20 com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24 +com.fr.design.mainframe.EastRegionContainerPane.maximum=400*400 +com.fr.design.mainframe.EastRegionContainerPane.minimum=286*400 +com.fr.design.mainframe.EastRegionContainerPane.standard=286*400 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index e1bcdba473..53a453dccd 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -28,3 +28,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20 com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20 com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24 +com.fr.design.mainframe.EastRegionContainerPane.maximum=400*400 +com.fr.design.mainframe.EastRegionContainerPane.minimum=286*400 +com.fr.design.mainframe.EastRegionContainerPane.standard=286*400