From c58b21eb637339e06106d75b731f2bf2a3a790b4 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 10 Dec 2019 10:22:41 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-24957=20frm=E6=89=93=E4=B8=8D=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRWCardTagLayoutAdapter.java | 39 +++++++++++++++++++ .../creator/cardlayout/XWCardTagLayout.java | 12 ++---- .../layout/FRWCardTagLayoutAdapterTest.java | 23 +++++++++++ .../cardlayout/XWCardTagLayoutTest.java | 18 +++++++++ 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java create mode 100644 designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java create mode 100644 designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java new file mode 100644 index 0000000000..e5331edd05 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java @@ -0,0 +1,39 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; + +/** + * 针对tabpane的布局适配器 + * Created by kerry on 2019-12-10 + */ +public class FRWCardTagLayoutAdapter extends AbstractLayoutAdapter { + public FRWCardTagLayoutAdapter(XLayoutContainer container) { + super(container); + } + + /** + * 对于这种布局方式,不允许其他组件添加 + * + * @param creator + * @param x + * @param y + */ + @Override + protected void addComp(XCreator creator, int x, int y) { + + } + + /** + * 对于这种布局方式,不允许其他组件添加 + * + * @param creator 组件 + * @param x 添加的位置x,该位置是相对于container的 + * @param y 添加的位置y,该位置是相对于container的 + * @return + */ + @Override + public boolean accept(XCreator creator, int x, int y) { + return false; + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 77282f63f9..dc8bb90801 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -8,8 +8,7 @@ import com.fr.base.ScreenResolution; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.LayoutAdapter; -import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter; -import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; @@ -311,12 +310,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { @Override public LayoutAdapter getLayoutAdapter() { - if (isHori()) { - return new FRHorizontalLayoutAdapter(this); - }else{ - return new FRVerticalLayoutAdapter(this); - } - + return new FRWCardTagLayoutAdapter(this); } private boolean isHori(){ @@ -452,4 +446,4 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } } -} \ No newline at end of file +} diff --git a/designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java b/designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java new file mode 100644 index 0000000000..0ff3ec0cc9 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java @@ -0,0 +1,23 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import org.junit.Assert; +import org.junit.Test; + +import java.awt.Dimension; + +/** + * Created by kerry on 2019-12-10 + */ +public class FRWCardTagLayoutAdapterTest { + @Test + public void testAccept() { + FRWCardTagLayoutAdapter adapter = new FRWCardTagLayoutAdapter( + new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100))); + Assert.assertFalse(adapter.accept(new XElementCase( + new ElementCaseEditor(), new Dimension(100, 100)), 1, 1)); + } +} diff --git a/designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java b/designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java new file mode 100644 index 0000000000..2b5ec78f21 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java @@ -0,0 +1,18 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import org.junit.Assert; +import org.junit.Test; + +import java.awt.Dimension; + +/** + * Created by kerry on 2019-12-10 + */ +public class XWCardTagLayoutTest { + @Test + public void testGetLayoutAdapter() { + XWCardTagLayout tagLayout = new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100)); + Assert.assertEquals("com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter", tagLayout.getLayoutAdapter().getClass().getName()); + } +}