From 89f5de1f09853c9adfe6bb30a57e166f25757a05 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 15 Jul 2020 15:35:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-35387=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=B7=B2=E6=9C=89=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E7=82=B9=E5=87=BB=E5=8F=B3=E4=BE=A7=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=B7=BB=E5=8A=A0=EF=BC=8C=E6=8E=A7=E4=BB=B6=E9=87=8D?= =?UTF-8?q?=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/parameter/FormParaDesigner.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index c72aa4512..ea222f98c 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -83,6 +83,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP private static final int SUBMIT_BUTTON_H_LOCATION = 270; private static final int PARA_IMAGE_SHIFT_X = -4; private static final int FORM_AREA_PADDING_LEFT = 13; + private int addableRegionY; private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png"); @@ -412,10 +413,31 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP if (layoutContainer == null) { layoutContainer = new XWParameterLayout(); } + refreshAddableRegion(layoutContainer); layoutContainer.setSize(LARGE_PREFERRED_SIZE); setRootComponent(layoutContainer); } + /** + * @Description: 为了不覆盖以前的组件,所以要计算可以添加组件的区域 + * @param layoutContainer + * @return: + * @Author: Henry.Wang + * @date: 2020/7/15 15:12 + */ + public void refreshAddableRegion(XLayoutContainer layoutContainer) { + addableRegionY = 0; + for (int i = 0; i < layoutContainer.getComponentCount(); i++) { + Rectangle rectangle = layoutContainer.getComponent(i).getBounds(); + System.out.println("rectangle:" + rectangle); + if (addableRegionY < rectangle.y + rectangle.height) { + addableRegionY = rectangle.y + rectangle.height; + } + } + int vGap = V_COMPONENT_GAP - (int) XCreator.SMALL_PREFERRED_SIZE.getHeight(); + addableRegionY = Math.max(0, addableRegionY - FIRST_V_LOCATION + (int) (XCreator.SMALL_PREFERRED_SIZE.getHeight() / 2) + vGap); + } + /** * 是否是报表的参数面板 * @@ -584,13 +606,13 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetValue(new WidgetValue(name + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } EditorHolder editor = new EditorHolder(parameter); xCreator = XCreatorUtils.createXCreator(editor); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } return true; @@ -647,7 +669,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP XCreator xCreator = XCreatorUtils.createXCreator(label); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } // 每行显示5组 @@ -655,7 +677,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP editor.setWidgetName(parameterArray[i].getName()); xCreator = XCreatorUtils.createXCreator(editor); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } currentIndex++; From 2a26171429a66a8804f24f7cb17a2b721a810726 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 15 Jul 2020 15:38:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-35387=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=B7=B2=E6=9C=89=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E7=82=B9=E5=87=BB=E5=8F=B3=E4=BE=A7=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=B7=BB=E5=8A=A0=EF=BC=8C=E6=8E=A7=E4=BB=B6=E9=87=8D?= =?UTF-8?q?=E5=8F=A0=20=E5=88=A0=E9=99=A4=E6=89=93=E5=8D=B0=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/form/parameter/FormParaDesigner.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index ea222f98c..a15a1cd4e 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -429,7 +429,6 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP addableRegionY = 0; for (int i = 0; i < layoutContainer.getComponentCount(); i++) { Rectangle rectangle = layoutContainer.getComponent(i).getBounds(); - System.out.println("rectangle:" + rectangle); if (addableRegionY < rectangle.y + rectangle.height) { addableRegionY = rectangle.y + rectangle.height; } From e842f26de29af1658c636126c7fd371eda5e5c0b Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 15 Jul 2020 16:20:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-35387=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=B7=B2=E6=9C=89=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E7=82=B9=E5=87=BB=E5=8F=B3=E4=BE=A7=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=B7=BB=E5=8A=A0=EF=BC=8C=E6=8E=A7=E4=BB=B6=E9=87=8D?= =?UTF-8?q?=E5=8F=A0=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/parameter/FormParaDesigner.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index a15a1cd4e..a91342d4a 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -419,8 +419,8 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP } /** - * @Description: 为了不覆盖以前的组件,所以要计算可以添加组件的区域 * @param layoutContainer + * @Description: 为了不覆盖以前的组件,所以要计算可以添加组件的区域 * @return: * @Author: Henry.Wang * @date: 2020/7/15 15:12 @@ -604,14 +604,15 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetName("Label" + name); label.setWidgetValue(new WidgetValue(name + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; + int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); + if (!(this.autoAddComponent(xCreator, x, y))) { return false; } EditorHolder editor = new EditorHolder(parameter); xCreator = XCreatorUtils.createXCreator(editor); - if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; + if (!(this.autoAddComponent(xCreator, x, y))) { return false; } return true; @@ -667,16 +668,17 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetValue(new WidgetValue(parameterArray[i].getName() + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; + int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); + if (!(this.autoAddComponent(xCreator, x, y))) { break; } // 每行显示5组 EditorHolder editor = new EditorHolder(parameterArray[i]); editor.setWidgetName(parameterArray[i].getName()); xCreator = XCreatorUtils.createXCreator(editor); - if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) - + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; + if (!(this.autoAddComponent(xCreator, x, y))) { break; } currentIndex++;