From ef5fe653ca0e8c3940d15dffcc966f27adf516b8 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 5 Jan 2021 14:07:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-44577=20=E5=AF=B9=E4=BA=8E=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=9E=8B=E6=8F=92=E4=BB=B6=E5=88=9B=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8C=E5=9C=A8=E7=B2=98=E8=B4=B4=E5=88=B0?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E5=AE=B9=E5=99=A8=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89=E6=88=90=E5=8A=9F=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E5=88=B0=E5=AE=B9=E5=99=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/FormWidgetOptionProvider.java | 8 +++++++ .../AbstractFormWidgetOptionProvider.java | 5 +++++ .../designer/beans/models/SelectionModel.java | 14 +++++++++++- .../design/mainframe/FormSelectionUtils.java | 22 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java index 9f033d6dc6..304b7d94a5 100644 --- a/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java @@ -23,4 +23,12 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider */ void paste2Container(T t); + /** + * 往扩展容器本身中添加粘贴内容 + * @param r + * @param + * @param + */ + void formWidgetPaste(T t, R r, int x, int y); + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java index 537a49d018..2e0633e870 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java @@ -30,4 +30,9 @@ public abstract class AbstractFormWidgetOptionProvider extends AbstractProvider public void paste2Container(T t) { // do nothing } + + @Override + public void formWidgetPaste(T t, R r, int x, int y) { + // do nothing + } } \ No newline at end of file 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 f6c74986e0..dc74087c40 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 @@ -399,8 +399,10 @@ public class SelectionModel { boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class); //选中的参数面板编辑器本身 boolean parameterEditor = selectionXCreator.getClass().equals(XWParameterLayout.class); + // 选中的是扩展容器布局本身 + boolean extraEditor = isSelectedExtraEditor(selectionXCreator); - return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor || parameterEditor); + return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor || parameterEditor || extraEditor); } else { return false; } @@ -410,6 +412,16 @@ public class SelectionModel { } } + private boolean isSelectedExtraEditor(XCreator selectionXCreator) { + Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); + for (FormWidgetOptionProvider provider : set) { + if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), selectionXCreator.getClass())) { + return true; + } + } + return false; + } + /** * 是否有组件被选择。如果所选组件是最底层容器,也视为无选择 * diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java index c310ee5780..2900650aa0 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; @@ -12,6 +13,7 @@ import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.utils.ComponentUtils; import com.fr.form.main.Form; import com.fr.form.ui.Widget; @@ -26,6 +28,7 @@ import java.awt.Toolkit; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Set; /** * 表单选中工具类 @@ -46,6 +49,8 @@ public class FormSelectionUtils { */ private static final String POSTFIX = "_c"; + private static FormWidgetOptionProvider optionProvider; + private FormSelectionUtils() { } @@ -64,10 +69,27 @@ public class FormSelectionUtils { //相对布局 relativePaste(designer, clipboard, adapter, x, y); return; + } else if (isExtraContainer(parent)) { + // 扩展布局 + optionProvider.formWidgetPaste(clipboard, adapter, x, y); + return; } Toolkit.getDefaultToolkit().beep(); } + private static boolean isExtraContainer(XLayoutContainer parent) { + if (parent != null) { + Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); + for (FormWidgetOptionProvider provider : set) { + if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), parent.getClass())) { + optionProvider = provider; + return true; + } + } + } + return false; + } + public static void rebuildSelection(FormDesigner designer) { ArrayList newSelection = new ArrayList<>(); From 099c818a7e05e2ac03ee98052137698c1b907035 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 5 Jan 2021 14:10:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-44577=20=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/fun/FormWidgetOptionProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java index 304b7d94a5..d1b64e2bd9 100644 --- a/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java @@ -26,8 +26,8 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider /** * 往扩展容器本身中添加粘贴内容 * @param r - * @param - * @param + * @param 粘贴板选中的组件 + * @param 容器布局适配器 */ void formWidgetPaste(T t, R r, int x, int y);