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 798b277f63..d649c5e30b 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 6c6aa26471..00dc41aedb 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 12812880d2..801f18969f 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 9aacc7c5d0..bacb7a5b75 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); } /** 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 d6d508a0ab..78c49d6f24 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() {