From 151a8bb5ca78c66a0894f76223ba64458b5a38ce Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 24 Jun 2020 15:34:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-34222=20=E6=8A=A5=E8=A1=A8=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E7=BB=99=E5=AE=B9=E5=99=A8=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=BC=80=E4=B8=AA=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20=E5=90=8C=E6=AD=A5=E5=88=B0final?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/FormWidgetOptionProvider.java | 7 +++++ .../AbstractFormWidgetOptionProvider.java | 5 ++++ .../designer/beans/models/SelectionModel.java | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+) 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 bfc32f4e9..9f033d6dc 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,11 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider */ boolean isContainer(); + /** + * 如果是布局容器要实现粘贴到容器中的操作 + * @param t + * @param 泛型参数 表示选中的组件 一般为FormSelection + */ + void paste2Container(T t); + } \ 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 43cab9514..537a49d01 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(T t) { + // 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 dd964e4ab..9f5f36f66 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(selection); } } + + /** + * 扩展的容器布局 + * @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; + } + /** * 删除当前所有选择的组件 */