From a1fdbf1e0d875645e174198902403aad82de77c0 Mon Sep 17 00:00:00 2001 From: kerry Date: Sat, 7 May 2022 17:12:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-67316=20=E5=86=B3=E7=AD=96=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8-=E5=AE=A2=E6=88=B7=E6=A8=A1=E6=9D=BF=E6=98=AF?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=9B=BA=E5=AE=9A=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E7=9A=84=EF=BC=8C=E5=A4=8D=E5=88=B6=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=87=8C=E7=9A=84tab=E5=88=B0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=96=B0=E5=BB=BA=E7=9A=84=E7=BB=9D=E5=AF=B9=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E5=9B=BA=E5=AE=9A=E5=A4=A7=E5=B0=8Ffrm=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=85=B3=E9=97=AD=E5=86=8D=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=A8=A1=E6=9D=BF=EF=BC=8Ctab=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E8=A1=A8=E5=9D=97=E5=B0=BA=E5=AF=B8=E5=8F=98?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/FormSelectionUtils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java index 5e5740f03a..68461206a2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java @@ -16,6 +16,7 @@ import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.utils.ComponentUtils; +import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.main.Form; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; @@ -290,11 +291,25 @@ public class FormSelectionUtils { public static XCreator copyXcreator(Form form, XCreator xCreator) throws CloneNotSupportedException{ Widget copied = (Widget) xCreator.toData().clone(); XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize()); + //主要用来处理组件间隔和padding,保证界面上展示的组件尺寸是计算过padding和组件间隔的 + LayoutUtils.layoutContainer(copiedCreator); + traverAndAdjust(copiedCreator); ArrayList nameSpace = new ArrayList<>(); copyWidgetName(form, nameSpace, copiedCreator); return copiedCreator; } + private static void traverAndAdjust(XCreator creator) { + for (int i = 0; i < creator.getComponentCount(); i++) { + Object object = creator.getComponent(i); + if (object instanceof XCreator) { + XCreator temp = (XCreator) object; + temp.adjustCompSize(0.0); + traverAndAdjust(temp); + } + } + } + /** * 拷贝组件 * @param form 当前表单 From f2931631f0f7b431d9b2fccde552890cda885c99 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 9 May 2022 10:20:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-67316=20=E4=BC=98=E5=8C=96=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/XCreatorUtils.java | 17 +++++++++++++++++ .../java/com/fr/design/mainframe/FormArea.java | 16 ++-------------- .../fr/design/mainframe/FormSelectionUtils.java | 12 +----------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 1be6f0d335..d5b6a95814 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -472,4 +472,21 @@ public class XCreatorUtils { } return container; } + + + /** + * 循环遍历组件,调整组件间隙 + * @param creator + */ + public static void traverAndAdjust(XCreator creator) { + for (int i = 0; i < creator.getComponentCount(); i++) { + Object object = creator.getComponent(i); + if (object instanceof XCreator) { + XCreator temp = (XCreator) object; + temp.adjustCompSize(0.0); + traverAndAdjust(temp); + } + } + + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index d989aae21f..54e412383b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -4,6 +4,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWFitLayout; @@ -447,7 +448,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { XLayoutContainer root = FormArea.this.designer.getRootComponent(); if (root.acceptType(XWFitLayout.class)) { XWFitLayout layout = (XWFitLayout) root; - traverAndAdjust(layout, 0.0); + XCreatorUtils.traverAndAdjust(layout); layout.adjustCreatorsWhileSlide(0.0); // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); @@ -469,19 +470,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } } - //循环遍历布局,按百分比调整子组件大小 - private void traverAndAdjust(XCreator creator, double percent) { - for (int i = 0; i < creator.getComponentCount(); i++) { - Object object = creator.getComponent(i); - if (object instanceof XCreator) { - XCreator temp = (XCreator) object; - temp.adjustCompSize(percent); - traverAndAdjust(temp, percent); - } - } - - } - /** * 增加刻度条 */ diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java index 68461206a2..331a1f3fe3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java @@ -293,22 +293,12 @@ public class FormSelectionUtils { XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize()); //主要用来处理组件间隔和padding,保证界面上展示的组件尺寸是计算过padding和组件间隔的 LayoutUtils.layoutContainer(copiedCreator); - traverAndAdjust(copiedCreator); + XCreatorUtils.traverAndAdjust(copiedCreator); ArrayList nameSpace = new ArrayList<>(); copyWidgetName(form, nameSpace, copiedCreator); return copiedCreator; } - private static void traverAndAdjust(XCreator creator) { - for (int i = 0; i < creator.getComponentCount(); i++) { - Object object = creator.getComponent(i); - if (object instanceof XCreator) { - XCreator temp = (XCreator) object; - temp.adjustCompSize(0.0); - traverAndAdjust(temp); - } - } - } /** * 拷贝组件