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..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 @@ -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<>();