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 bfc32f4e9e..b2d46a0445 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 @@ -16,4 +16,9 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider */ boolean isContainer(); + /** + * 如果是布局容器要实现粘贴到容器中的操作 + */ + void paste2Container(); + } \ 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 43cab95143..9a8139e0d8 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 @@ -25,4 +25,9 @@ public abstract class AbstractFormWidgetOptionProvider extends AbstractProvider public boolean isContainer() { return false; } + + @Override + public void paste2Container() { + // 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 dd964e4ab5..99865ea1ca 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 @@ -1,6 +1,7 @@ package com.fr.design.designer.beans.models; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.base.clipboard.ClipboardFilter; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; @@ -19,11 +20,13 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import java.awt.LayoutManager; @@ -31,6 +34,7 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.Set; /** * 该model保存当前选择的组件和剪切版信息 @@ -43,6 +47,7 @@ public class SelectionModel { private FormDesigner designer; private FormSelection selection; private Rectangle hotspotBounds; + private FormWidgetOptionProvider provider; public SelectionModel(FormDesigner designer) { this.designer = designer; @@ -256,9 +261,30 @@ public class SelectionModel { //绝对布局 Rectangle rec = selection.getSelctionBounds(); FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); + } else if (isExtraContainer(container)) { + provider.paste2Container(); } } + + /** + * 扩展的容器布局 + * @param container + * @return + */ + private boolean isExtraContainer(XLayoutContainer container) { + if (container != null) { + Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); + for (FormWidgetOptionProvider provider : set) { + if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), selection.getSelectedCreator().getParent().getClass())) { + this.provider = provider; + return true; + } + } + } + return false; + } + /** * 删除当前所有选择的组件 */