From ab7298f13f021bfce60ab00fe2a7348224d458a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 27 Sep 2021 18:20:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-59952&REPORT-60057&REPORT-60139=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=89=93=E5=BC=80=E7=A9=BA=E7=99=BD=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=92=8C=E5=B8=83=E5=B1=80=E6=A8=A1=E6=9D=BF=E6=9C=89?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E7=9A=84=E4=B8=80=E7=B1=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/widget/ui/designer/NewFormPane.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java index 2f0b446e35..4d9359e4d5 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java @@ -15,6 +15,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.main.Form; +import com.fr.form.ui.container.WBorderLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; @@ -264,13 +265,12 @@ public class NewFormPane extends BasicPane { private void newForm(String path) { BaseJForm jForm; try { + Form form = new Form(new WBorderLayout("form")); if (StringUtils.isNotEmpty(path)) { - Form form = new Form(); form.readStream(NewFormPane.class.getResourceAsStream(path)); - jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class); - } else { - jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class); + form = (Form) form.cloneAsLayoutTemplate(); } + jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class); DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate) jForm); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); From 1f797aaf24272b34c6d68a8f6a4cb7f35fa7be8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 28 Sep 2021 14:56:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-59952&REPORT-60057&REPORT-60139=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3pr=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/JForm.java | 11 +--- .../widget/ui/designer/NewFormPane.java | 61 ++++++++++++++++--- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index ecb57eeb2c..7379b0a60b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -6,7 +6,6 @@ import com.fr.base.Parameter; import com.fr.base.Releasable; import com.fr.base.extension.FileExtension; import com.fr.base.iofile.attr.ExtendSharableAttrMark; -import com.fr.base.iofile.attr.TemplateLayoutIdAttrMark; import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormThemeConfig; import com.fr.base.theme.TemplateTheme; @@ -117,7 +116,6 @@ import java.util.List; public class JForm extends JTemplate implements BaseJForm
, Releasable { private static final String FORM_CARD = "FORM"; private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; - private static final String EMPTY_FORM_LAYOUTID = "9ebf6aff-ad53-45a9-a175-9633f4162a3a"; private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD}; private static final int TOOLBARPANEDIMHEIGHT_FORM = 60; @@ -138,8 +136,7 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm) jForm); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + /** + * 通过布局文件的位置初始化Form对象的布局信息 + * + * @param form 新建的form对象 + * @param path 布局文件位置 + * @throws Exception + */ + private void initLayoutInfo(Form form, String path) throws Exception { + if (isNewEmptyForm(path)) { + initEmptyFormLayoutId(form); + } else { + Form layoutTemplate = new Form(); + layoutTemplate.readStream(NewFormPane.class.getResourceAsStream(path)); + + if (layoutTemplate.getBody() != null && layoutTemplate.getBody() instanceof WFitLayout) { + WFitLayout layoutTemplateBody = (WFitLayout) layoutTemplate.getBody(); + WFitLayout body = (WFitLayout) form.getBody(); + + body.setMargin(layoutTemplateBody.getMargin()); + body.setCompInterval(layoutTemplateBody.getCompInterval()); + for (int i = 0; i < layoutTemplateBody.getWidgetCount(); i++) { + Widget boundsWidget = layoutTemplateBody.getWidget(i); + if (boundsWidget != null && boundsWidget instanceof BoundsWidget) { + Widget widget = ((BoundsWidget) boundsWidget).getWidget(); + if (widget != null && widget instanceof OccupiedLayout) { + body.addWidget((Widget) boundsWidget.clone()); + } + } + } + + form.setLayoutId(layoutTemplate.getLayoutId()); + } + } + } + + private void initEmptyFormLayoutId(Form form) { + form.addAttrMark(new TemplateLayoutIdAttrMark(EMPTY_FORM_LAYOUTID)); + form.setLayoutId(EMPTY_FORM_LAYOUTID); + } + + private boolean isNewEmptyForm(String layoutTemplatePath) { + return StringUtils.isEmpty(layoutTemplatePath); + } + private void setSelectedLayoutPane(PredefinedLayoutPane layoutPane) { if (selectedLayoutPane != layoutPane) { if (selectedLayoutPane != null) { From b4abd422c9aee5195b9819c94fb8b71019a3521a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 28 Sep 2021 15:42:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-59952&REPORT-60057&REPORT-60139=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3pr=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/ui/designer/NewFormPane.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java index c4ac581b5f..0771329cd2 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java @@ -19,6 +19,7 @@ import com.fr.form.main.Form; import com.fr.form.ui.Widget; import com.fr.form.ui.container.OccupiedLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; +import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -271,15 +272,22 @@ public class NewFormPane extends BasicPane { private void newForm(String path) { BaseJForm jForm; try { - jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class); - Form form = (Form) jForm.getTarget(); + Form form = initEmptyBodyForm(); initLayoutInfo(form, path); + jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class); DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate) jForm); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + private Form initEmptyBodyForm() { + WFitLayout body = new WFitLayout(); + WBorderLayout borderLayout = new WBorderLayout("form"); + borderLayout.addCenter(body); + return new Form(borderLayout); + } + /** * 通过布局文件的位置初始化Form对象的布局信息 *