From 405197fcb487107a1c879824ebd1ee11735e9a20 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 4 Aug 2020 20:50:26 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-35569=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8E=A7=E4=BB=B6=EF=BC=8C=E6=92=A4=E9=94=80=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=86=8D=E6=AC=A1=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E4=BC=9A=E7=A9=BA=E4=B8=80=E4=B8=AA=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parameter/ParameterDesignerProvider.java | 2 +- .../form/parameter/FormParaDesigner.java | 9 ++++--- .../parameter/ParameterDefinitePane.java | 26 ++++++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java index abd27f89bf..e0b69fea05 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java @@ -48,7 +48,7 @@ public interface ParameterDesignerProvider { boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index); - void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); + int addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); JPanel[] toolbarPanes4Form(); 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 c72aa45128..b918850616 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 @@ -74,7 +74,7 @@ import java.util.List; public class FormParaDesigner extends FormDesigner implements ParameterDesignerProvider { private static final int NUM_IN_A_LINE = 4; private static final int H_COMPONENT_GAP = 165; - private static final int V_COMPONENT_GAP = 25; + public static final int V_COMPONENT_GAP = 25; private static final int FIRST_V_LOCATION = 35; private static final int FIRST_H_LOCATION = 90; private static final int SECOND_H_LOCATION = 170; @@ -637,9 +637,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP * * @param parameterArray 参数 c * @param currentIndex 位置 w - * @return 是否加入 s + * @return currentIndex的最新值 */ - public void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex) { + public int addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex) { for (int i = 0; i < parameterArray.length; i++) { com.fr.form.ui.Label label = new com.fr.form.ui.Label(); label.setWidgetName("Label" + parameterArray[i].getName()); @@ -667,9 +667,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP XCreator xCreator = XCreatorUtils.createXCreator(formSubmitButton); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * 3 + H_GAP, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { - return; + currentIndex = ((int) Math.ceil((currentIndex + 1) / (double) NUM_IN_A_LINE)) * NUM_IN_A_LINE; } } + return currentIndex; } /** diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index 13d53b5b25..74f1435a4d 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -17,6 +17,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.FRGUIPaneFactory; @@ -30,6 +31,10 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.module.DesignModuleFactory; import com.fr.design.style.background.BackgroundPane; +import com.fr.form.main.parameter.FormParameterUI; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WLayout; import com.fr.log.FineLoggerFactory; import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.TemplateParameterAttr; @@ -46,6 +51,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -249,6 +255,22 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + currentIndex = reportParameterAttr.getCurrentIndex(); + //因为以前的版本没有保存currentIndex,所以要计算currentIndex的值 + if (parameterUI != null && parameterUI instanceof FormParameterUI && currentIndex == 0) { + WLayout wLayout = ((FormParameterUI) parameterUI).getContainer(); + int widgetCount = wLayout.getWidgetCount(); + Rectangle endRec = null; + for (int i = 0; i < widgetCount; i++) { + Widget widget = wLayout.getWidget(i); + Rectangle tempRec = ((WAbsoluteLayout.BoundsWidget) widget).getBounds(); + if (endRec == null || tempRec.y > endRec.y) { + endRec = tempRec; + } + } + if (endRec != null) + currentIndex = (int) (Math.ceil(endRec.y / FormParaDesigner.V_COMPONENT_GAP)) * NUM_IN_A_LINE; + } paraDesignEditor.populate(parameterUI); @@ -268,8 +290,6 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus bridge.setBackground(reportParameterAttr.getBackground()); bridge.setUseParamsTemplate(reportParameterAttr.isUseParamsTemplate()); } - - currentIndex = reportParameterAttr.getCurrentIndex(); } @@ -438,7 +458,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus return; } - paraDesignEditor.addingAllParameter2Editor(parameterArray, currentIndex); + currentIndex = paraDesignEditor.addingAllParameter2Editor(parameterArray, currentIndex); parameterArray = null; refreshParameter();