From e972e7ef1cc5323bf4127d966262c5733d20dac6 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 10 Dec 2021 16:11:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=96=B0=E8=80=81=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=97=B6=EF=BC=8C=E8=B0=83=E6=95=B4=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=B0=BA=E5=AF=B8=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/fit/NewJForm.java | 63 ++----------------- .../design/fit/common/AdaptiveSwitchUtil.java | 5 +- .../com/fr/design/fit/common/LayoutTool.java | 15 ----- .../fr/design/fit/common/TemplateTool.java | 62 +----------------- .../com/fr/design/mainframe/FormArea.java | 17 ----- 5 files changed, 7 insertions(+), 155 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java index 6859c1231..2445b45e5 100644 --- a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java +++ b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java @@ -8,12 +8,12 @@ import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.*; -import com.fr.design.fit.common.AdaptiveSwitchUtil; -import com.fr.design.fit.common.LayoutTool; -import com.fr.form.fit.NewFormMarkAttr; -import com.fr.design.fit.common.TemplateTool; import com.fr.design.actions.NewFormMobileAttrAction; +import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.preview.DeveloperPreview; import com.fr.design.preview.FormAdaptivePreview; @@ -29,7 +29,6 @@ import com.fr.design.utils.ComponentUtils; import com.fr.file.FILE; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; -import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.ui.ElementCaseEditor; import com.fr.stable.ArrayUtils; @@ -49,13 +48,11 @@ public class NewJForm extends JForm { public NewJForm() { super(); init(); - changePaneSize(); } public NewJForm(Form form) { super(form); init(); - changePaneSize(); } public NewJForm(Form form, FILE file, Parameter[] parameters) { @@ -67,48 +64,6 @@ public class NewJForm extends JForm { if (DesignerUIModeConfig.getInstance().newUIMode()) { init(); } - changePaneSize(); - } - - /** - * @Description:改变body的大小,主要针对新模式下打开老模板出现截断的情况 - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/9/13 23:23 - */ - private void changePaneSize() { - NewFormMarkAttr newFormMarkAttr = this.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr.isNotSetOriginSize()) { - newFormMarkAttr.setBodyHeight(LayoutTool.getBodyHeight(this)); - newFormMarkAttr.setBodyWidth(LayoutTool.getBodyWidth(this)); - return; - } - //这种是针对body为绝对布局时,可能出现截断的情况 - if (LayoutTool.absoluteLayoutForm(this)) { - int bodyHeight = newFormMarkAttr.getBodyHeight(); - int bodyWidth = newFormMarkAttr.getBodyWidth(); - Rectangle rectangle = LayoutTool.getAbsoluteBodySize(this); - if (!isNewJFrom() && (rectangle.width != bodyWidth || rectangle.height != bodyHeight)) { - TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, bodyWidth, this); - } else if (isNewJFrom()) { - if (rectangle.width > bodyWidth && rectangle.height > bodyHeight) { - TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, rectangle.width, this); - } else if (rectangle.width > bodyWidth) { - TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, rectangle.width, this); - } else if (rectangle.height > bodyHeight) { - TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, bodyWidth, this); - } - } - } else if (AdaptiveSwitchUtil.isSwitchJFromIng()) { - //这种是针对body中有绝对画布块,导致截断的情况 - double scale = LayoutTool.getContainerPercent(); - if (isNewJFrom()) { - LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), 1 / scale); - } else { - LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), scale); - } - } } public JFormType getJFormType() { @@ -270,14 +225,6 @@ public class NewJForm extends JForm { return new PreviewProvider[]{new FormPreview(), new MobilePreview()}; } - public boolean mobileForm() { - FormMobileAttr mobileAttr = this.getTarget().getFormMobileAttr(); - if (mobileAttr.isMobileOnly() && mobileAttr.isAdaptivePropertyAutoMatch()) { - return true; - } - return false; - } - private SwitchAction switchAction; public UIButton[] createExtraButtons() { diff --git a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java index a5df5fabd..3d090d8f1 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java @@ -61,7 +61,7 @@ public class AdaptiveSwitchUtil { return; } JTemplate old = TemplateTool.getCurrentEditingTemplate(); - if (old == null || !(old instanceof JForm)) { + if (!(old instanceof JForm)) { return; } JTemplate template = createNewJTemplate(old); @@ -152,9 +152,6 @@ public class AdaptiveSwitchUtil { private static JTemplate createNewJTemplateInternal(JTemplate old) { FILE file = old.getEditingFILE(); if ((file instanceof MemFILE) || !old.isSaved()) { - if (old instanceof NewJForm) { - TemplateTool.resetAbsoluteBodySize((NewJForm) old); - } TemplateTool.saveForm(old); } if (old.getTarget() instanceof Form) { diff --git a/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java b/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java index 6bebbbbe8..1d3c85f2c 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java @@ -7,20 +7,16 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.fit.NewJForm; -import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.JForm; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WLayout; import com.fr.form.ui.widget.CRBoundsWidget; -import com.fr.general.FRScreen; import com.fr.log.FineLoggerFactory; import java.awt.Component; -import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.Toolkit; /** * @description:布局工具类 @@ -163,15 +159,4 @@ public class LayoutTool { } } - /** - * @Description: 获取老预览时的缩放比例 - * @return: - * @Author: Henry.Wang - * @date: 2020/10/26 20:39 - */ - public static double getContainerPercent(){ - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - double screenValue = FRScreen.getFRScreenByDimension(screen).getValue(); - return screenValue / FormArea.DEFAULT_SLIDER; - } } diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index cb415df59..f763fbf3a 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -1,17 +1,12 @@ package com.fr.design.fit.common; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; + import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.JFormType; import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.FormArea; -import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.event.Event; @@ -19,12 +14,7 @@ import com.fr.event.Listener; import com.fr.file.MemFILE; import com.fr.file.StashedFILE; import com.fr.form.fit.common.LightTool; -import com.fr.form.fit.NewFormMarkAttr; -import com.fr.form.ui.Widget; -import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.ComparatorUtils; - -import java.awt.Rectangle; import java.util.List; /** @@ -168,55 +158,5 @@ public class TemplateTool { jTemplate.requestFocus(); } - /** - * @param height - * @param width - * @param newJForm - * @Description: 只改变绝对布局body的尺寸 - * @return: - * @Author: Henry.Wang - * @date: 2020/9/11 15:14 - */ - public static void onlyChangeAbsoluteBodySize(int height, int width, NewJForm newJForm) { - FormDesigner formDesigner = newJForm.getFormDesign(); - FormArea formArea = formDesigner.getArea(); - XLayoutContainer root = formDesigner.getRootComponent(); - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = LayoutTool.getXWAbsoluteBodyLayout(newJForm); - if (root.acceptType(XWFitLayout.class) && xwAbsoluteBodyLayout != null) { - XWFitLayout layout = (XWFitLayout) root; - if (height == layout.toData().getContainerHeight() && width == layout.toData().getContainerWidth()) - return; - formArea.setWidthPaneValue(width); - formArea.setHeightPaneValue(height); - layout.setSize(width, height); - xwAbsoluteBodyLayout.setSize(width, height); - Widget widget = layout.toData().getWidget(0); - if (widget instanceof CRBoundsWidget) { - ((CRBoundsWidget) widget).setBounds(new Rectangle(0, 0, width, height)); - } - layout.toData().setContainerWidth(width); - layout.toData().setContainerHeight(height); - formArea.doReCalculateRoot(width, height, layout); - } - formDesigner.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); - } - - /** - * @param newJForm - * @Description: 因为新老模板切换有截断的问题,所以body的尺寸会在调用onlyChangeAbsoluteBodySize之后发生改变。为了使模板文件中的尺寸不发生,要在模板保存时调用此函数 - * @return: - * @Author: Henry.Wang - * @date: 2020/9/11 15:20 - */ - public static void resetAbsoluteBodySize(NewJForm newJForm) { - if (LayoutTool.absoluteLayoutForm(newJForm)) { - NewFormMarkAttr newFormMarkAttr = newJForm.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - XLayoutContainer root = newJForm.getFormDesign().getRootComponent(); - if (newFormMarkAttr != null && root instanceof XWFitLayout) { - ((XWFitLayout) root).toData().setContainerWidth(newFormMarkAttr.getBodyWidth()); - ((XWFitLayout) root).toData().setContainerHeight(newFormMarkAttr.getBodyHeight()); - } - } - } } 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 635920c79..d989aae21 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 @@ -24,7 +24,6 @@ import com.fr.design.scrollruler.VerticalRuler; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.LayoutUtils; -import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBorderLayout; @@ -335,18 +334,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent { // 失去焦点时,可以认为输入结束 int width = (int) ((UINumberField) e.getSource()).getValue(); changeWidthPaneValue(width); - changeFormMarkAttrWidth(width); } }); } - private void changeFormMarkAttrWidth(int width) { - NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr != null) { - newFormMarkAttr.setBodyWidth(width); - } - } - private void changeWidthPaneValue(int width) { XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); @@ -362,7 +353,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { public void actionPerformed(ActionEvent evt) { int height = (int) ((UINumberField) evt.getSource()).getValue(); changeHeightPaneValue(height); - changeFormMarkAttrHeight(height); } }); heightPane.addFocusListener( @@ -375,13 +365,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { }); } - private void changeFormMarkAttrHeight(int height){ - NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr != null) { - newFormMarkAttr.setBodyHeight(height); - } - } - private void changeHeightPaneValue(int height) { XWFitLayout layout = (XWFitLayout) designer.getRootComponent();