From 20978231b8863568c476b7fc49461ee7932d6e86 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 27 Sep 2021 17:03:01 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-59906=E3=80=90=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=B8=83=E5=B1=80-=E5=8E=9F=E5=B8=83=E5=B1=80=E6=8E=A8?= =?UTF-8?q?=E8=8D=904.1=E3=80=91=E5=86=B3=E7=AD=96=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E5=B8=83=E5=B1=80-=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E7=94=BB=E5=B8=83=E5=9D=97=E5=8C=85=E5=90=AB=E5=AD=90?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E5=A4=8D=E7=94=A8=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=8B=96=E5=85=A5=E5=88=B0=E5=8D=A0=E4=BD=8D=E5=9D=97?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=95=B4=E4=BD=93=E7=BC=A9=E5=B0=8F=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E9=87=8C=E9=9D=A2=E7=9A=84=E5=AD=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=B2=A1=E6=9C=89=E7=AD=89=E6=AF=94=E4=BE=8B=E7=BC=A9?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapters/layout/FRFitLayoutAdapter.java | 6 ++++-- .../designer/beans/models/AddingModel.java | 8 ++++---- .../design/designer/creator/XCreatorUtils.java | 18 ++++++++++++++++++ .../design/designer/creator/XWFitLayout.java | 1 + .../mainframe/FormCreatorDropTarget.java | 16 +++++----------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index 3e255d2a4..84013aadf 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -160,8 +160,10 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { //布局控件要先判断是不是可编辑 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); - boolean access = topLayout != null && !isMatchEdge && !topLayout.isEditable() && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp) && !topLayout.isDragInAble(); - if (access) { + boolean access = topLayout != null && !isMatchEdge && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp) && !topLayout.isDragInAble(); + //topLayout.getParent() != container说明当前增加的组件所在容器是嵌套在外部的自适应容器内部的,此时需要判断增加组件所在容器是否可编辑,不可编辑的话就直接返回 false + //否则说明就是往当前自适应容器内部添加组件,不需要判断其是否可编辑 + if (access && (topLayout.getParent() != container && !topLayout.isEditable())) { return false; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index e55aa86d3..1926b57b1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -4,8 +4,8 @@ import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter; 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.XWAbsoluteLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.mainframe.FormDesigner; import com.fr.design.utils.ComponentUtils; @@ -124,11 +124,10 @@ public class AddingModel { */ public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) { //考虑不同布局嵌套的情况,获取顶层容器 - XLayoutContainer xLayoutContainer = container.getTopLayout(); - if (xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { + XLayoutContainer xLayoutContainer = XCreatorUtils.getTopEditableContainer(container); + if (xLayoutContainer != null) { container = xLayoutContainer; } - Rectangle rect = ComponentUtils.getRelativeBounds(container); if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) { added = container.getLayoutAdapter().addBean(creator, @@ -141,4 +140,5 @@ public class AddingModel { y + designer.getVerticalScaleValue() - rect.y); return added; } + } 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 38fb9d73e..02ac912c3 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 @@ -402,4 +402,22 @@ public class XCreatorUtils { FineColorFlushUtils.replaceCacheObject(container.toData(), colorGather); FineColorManager.traverse(container.toData(), colorGather); } + + + /** + * 获取容器组件的顶层正编辑的组件 + */ + @Nullable + public static XLayoutContainer getTopEditableContainer(XLayoutContainer container) { + if (container == null) { + return null; + } + XLayoutContainer xLayoutContainer = container.getTopLayout(); + if (xLayoutContainer != null && xLayoutContainer.getParent() != null) { + if (!xLayoutContainer.isEditable()) { + return (XLayoutContainer) xLayoutContainer.getParent(); + } + } + return null; + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index b9814a0f3..5b9a13334 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -796,6 +796,7 @@ public class XWFitLayout extends XLayoutContainer { layout.setContainerHeight(containerHeight); layout.setContainerWidth(containerWidth); addCompInterval(getAcualInterval()); + LayoutUtils.layoutContainer(this); // REPORT-54410: 决策报表,模板中其他组件的宽高修改会影响绝对画布块中组件的宽高和位置 // 绝对布局内的组件尺寸调整需要在绝对布局的bound排除GAP后进行,否则计算出的 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 926b6be5e..45a6d9647 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -193,7 +193,6 @@ public class FormCreatorDropTarget extends DropTarget { private void dealWithContainer(int x, int y, XLayoutContainer container) { HoverPainter painter = null; - if (container != current || designer.getPainter() == null) { // 如果焦点容器不是当前容器 if (current != null) { @@ -204,15 +203,9 @@ public class FormCreatorDropTarget extends DropTarget { throw new IllegalArgumentException("container can not be null!"); } //获取painter的时候要考虑布局之间嵌套的问题 - XLayoutContainer xLayoutContainer = container.getTopLayout(); - if (xLayoutContainer != null && xLayoutContainer.getParent() != null - && ((XLayoutContainer) xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)) { - if (!xLayoutContainer.isEditable()) { - xLayoutContainer = (XLayoutContainer) xLayoutContainer.getParent(); - } - } + XLayoutContainer xLayoutContainer = XCreatorUtils.getTopEditableContainer(container); painter = AdapterBus.getContainerPainter(designer, - xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container); + xLayoutContainer != null ? xLayoutContainer : container); // 为界面设计器设置提示渲染提示器 designer.setPainter(painter); @@ -227,8 +220,9 @@ public class FormCreatorDropTarget extends DropTarget { } } if (painter != null) { + XLayoutContainer xLayoutContainer = XCreatorUtils.getTopEditableContainer(container); // 为提示渲染器设置焦点位置、区域等渲染参数 - Rectangle rect = ComponentUtils.getRelativeBounds(container); + Rectangle rect = ComponentUtils.getRelativeBounds(xLayoutContainer != null ? xLayoutContainer : container); rect.x -= designer.getArea().getHorizontalValue(); rect.y -= designer.getArea().getVerticalValue(); painter.setRenderingBounds(rect); @@ -236,7 +230,7 @@ public class FormCreatorDropTarget extends DropTarget { painter.setCreator(addingModel.getXCreator()); } } - + private void promptUser(int x, int y, XLayoutContainer container) { if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)) { promptButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Forbid_Drag_Into_Para_Pane"));