From 644d39ca07515910a66dd430736498684bca8e52 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 13 May 2020 19:44:58 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-31412=20=E3=80=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=88=B6=E4=BD=9C=E4=BC=98=E5=8C=96=E3=80=91@kerry=EF=BC=8C?= =?UTF-8?q?=E5=86=B3=E7=AD=96=E6=8A=A5=E8=A1=A8=E5=88=B6=E4=BD=9C=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E5=B8=83=E5=B1=80=E4=B8=8B=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=B2=A1=E6=9C=89=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/beans/models/SelectionModel.java | 2 +- .../template/info/ComponentOperate.java | 7 ++++++- .../info/ComponentCreateOperateTest.java | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 33312483e..a8adfeb27 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -258,11 +258,11 @@ public class SelectionModel { designer.removeParaComponent(); } removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); + FormDesignerUtils.removeWidgetProcessInfo(creator.toData()); creator.deleteRelatedComponent(creator, designer); creator.removeAll(); // 清除被选中的组件 selection.reset(); - FormDesignerUtils.removeWidgetProcessInfo(creator.toData()); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java index d82bc1688..b6fd79d27 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java @@ -7,6 +7,7 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WTitleLayout; import com.fr.general.ComparatorUtils; import com.fr.json.JSONObject; @@ -23,7 +24,11 @@ public abstract class ComponentOperate implements TemplateOperate { private Widget widget; public ComponentOperate(Widget widget) { - this.widget = widget; + if (widget.acceptType(WTitleLayout.class)) { + this.widget = ((WTitleLayout) widget).getBodyBoundsWidget().getWidget(); + }else { + this.widget = widget; + } } @Override diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java index 2a6ec4ba6..e11c33c55 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java @@ -9,14 +9,31 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.general.ComparatorUtils; import com.fr.json.JSONObject; import org.junit.Assert; import org.junit.Test; +import java.awt.Rectangle; + /** * Created by kerry on 2020-05-08 */ public class ComponentCreateOperateTest { + + @Test + public void testConstructor(){ + ElementCaseEditor caseEditor = new ElementCaseEditor(); + caseEditor.setWidgetName("report0"); + caseEditor.setWidgetID("xxxx0"); + WTitleLayout wTitleLayout = new WTitleLayout(); + wTitleLayout.addBody(caseEditor, new Rectangle()); + ComponentOperate componentOperate0 = new ComponentCreateOperate(caseEditor); + ComponentOperate componentOperate1 = new ComponentCreateOperate(wTitleLayout); + ComparatorUtils.equals(componentOperate0.toJSONObject(), componentOperate1.toJSONObject()); + } + @Test public void testToJSONObject() { Widget button = new FreeButton();