From f13287a467b2e1e2498f30b84b88687843f8c3b0 Mon Sep 17 00:00:00 2001 From: kerry Date: Sat, 18 Sep 2021 18:19:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-57810=20=E5=9B=BA=E5=AE=9A=E5=B8=83?= =?UTF-8?q?=E5=B1=80-=E5=8E=9F=E5=B8=83=E5=B1=80=E6=8E=A8=E8=8D=904.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapters/layout/FRFixLayoutAdapter.java | 14 +++++++----- .../layout/FROccupiedLayoutAdapter.java | 9 ++------ .../designer/creator/XLayoutContainer.java | 4 ++++ .../design/designer/creator/XWFitLayout.java | 22 +++++++++++++++---- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java index 798b277f6..d649c5e30 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java @@ -21,7 +21,7 @@ import java.awt.Graphics; public class FRFixLayoutAdapter extends AbstractLayoutAdapter { private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png"); - public FRFixLayoutAdapter(XLayoutContainer container) { + public FRFixLayoutAdapter( XLayoutContainer container) { super(container); } @@ -32,12 +32,11 @@ public class FRFixLayoutAdapter extends AbstractLayoutAdapter { } child.setLocation(component.getX(), component.getY()); child.setSize(component.getWidth(), component.getHeight()); - container.remove(component); if (child.shouldScaleCreator() || child.hasTitleStyle()) { XLayoutContainer parentPanel = child.initCreatorWrapper(21); - container.add(parentPanel, child.toData().getWidgetName()); + container.replaceXcreator(parentPanel, (XCreator) component); } else { - container.add(child, child.toData().getWidgetName()); + container.replaceXcreator(child, (XCreator) component); } if (child.getBackupRectangle() != null && child.getParent() == container) { Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); @@ -52,15 +51,20 @@ public class FRFixLayoutAdapter extends AbstractLayoutAdapter { @Override public void delete(XCreator creator, int creatorWidth, int creatorHeight) { + //固定布局下不支持移除占位块组件 + if (creator.acceptType(XOccupiedLayout.class)){ + return; + } OccupiedLayout occupiedLayout = new OccupiedLayout(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension()); ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout); xoccupiedLayout.setLocation(creator.getX(), creator.getY()); xoccupiedLayout.setSize(creatorWidth, creatorHeight); - container.add(xoccupiedLayout); + container.replaceXcreator(xoccupiedLayout,creator); } + @Override public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { return new DefaultXCreatorTreeCellRender(creator) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java index 6c6aa2647..00dc41aed 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java @@ -9,18 +9,15 @@ import com.fr.design.designer.treeview.XCreatorTreeCellRender; import com.fr.design.utils.gui.LayoutUtils; import java.awt.Color; import java.awt.Component; -import java.awt.Container; import java.awt.Graphics; public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter { - public FROccupiedLayoutAdapter(XLayoutContainer container) { super(container); painter = new FROccupiedLayoutPainter(container); } - private HoverPainter painter; @@ -29,14 +26,12 @@ public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter { if (container.getComponentCount() == 0) { creator.setLocation(container.getLocation().x, container.getLocation().y); creator.setSize(container.getWidth(), container.getHeight()); - //将 xcreator 添加到其父容器中,并删除此 XLayoutContainer parent = (XLayoutContainer) container.getParent(); - parent.getLayoutAdapter().removeBean(container, container.getWidth(), container.getHeight()); if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { XLayoutContainer parentPanel = creator.initCreatorWrapper(21); - parent.add(parentPanel, creator.toData().getWidgetName()); + parent.replaceXcreator(parentPanel, container); } else { - parent.add(creator, creator.toData().getWidgetName()); + parent.replaceXcreator(creator, container); } LayoutUtils.layoutContainer(parent); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java index 12812880d..801f18969 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java @@ -608,4 +608,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme public boolean supportFixLayout(){ return false; } + + public void replaceXcreator(XCreator newCreator, XCreator oldCreator){ + + } } 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 9aacc7c5d..bacb7a5b7 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 @@ -3,6 +3,7 @@ package com.fr.design.designer.creator; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRNoFixLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; @@ -82,6 +83,7 @@ public class XWFitLayout extends XLayoutContainer { @Override public LayoutAdapter getLayoutAdapter() { FRFitLayoutAdapter layoutAdapter = new FRFitLayoutAdapter(this); + if (isFixLayout) { layoutAdapter.setFrLayoutState(new FRFixLayoutAdapter(this)); } @@ -871,10 +873,22 @@ public class XWFitLayout extends XLayoutContainer { Widget wgt = xwc.toData(); BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt); wlayout.removeWidget(bw); - if(!isFixLayout){ - updateBoundsWidget(); - ((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); - } + updateBoundsWidget(); + ((FRFitLayoutAdapter) getLayoutAdapter()).updateCreatorBackBound(); + } + + public void replaceXcreator(XCreator newCreator, XCreator oldCreator) { + WFitLayout wlayout = this.toData(); + Widget wgt = oldCreator.toData(); + BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt); + wlayout.removeWidget(bw); + wlayout.addWidget(new BoundsWidget(newCreator.toData(), bw.getBounds())); + newCreator.setBackupParent(this); + isRefreshing = true; + this.remove(oldCreator); + this.add(newCreator); + isRefreshing = false; + LayoutUtils.layoutContainer(this); } /** From 1abc3ecb3ddae47de528922c112d8a3149212028 Mon Sep 17 00:00:00 2001 From: kerry Date: Sat, 18 Sep 2021 18:55:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index d6d508a0a..78c49d6f2 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -8,6 +8,7 @@ import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.Item; @@ -169,6 +170,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); boundPane.populate(); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); + WidgetPropertyPane.getInstance().getEditingFormDesigner().switchBodyLayout((XLayoutContainer) creator); } public WAbsoluteBodyLayout updateSubPane() {