Browse Source

Merge pull request #3267 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit '3d270bd98e7825c312f6a887bd6205e7a841e20e':
  REPORT-44577 添加注释
  REPORT-44577 对于容器型插件创建的组件,在粘贴到空的容器的时候,没有成功粘贴到容器中
research/11.0
superman 4 years ago
parent
commit
89ac9e8ff5
  1. 8
      designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java
  2. 5
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java
  3. 14
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  4. 22
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

8
designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java

@ -23,4 +23,12 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider
*/
<T> void paste2Container(T t);
/**
* 往扩展容器本身中添加粘贴内容
* @param r
* @param <T> 粘贴板选中的组件
* @param <R> 容器布局适配器
*/
<T, R> void formWidgetPaste(T t, R r, int x, int y);
}

5
designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java

@ -30,4 +30,9 @@ public abstract class AbstractFormWidgetOptionProvider extends AbstractProvider
public <T> void paste2Container(T t) {
// do nothing
}
@Override
public <T, R> void formWidgetPaste(T t, R r, int x, int y) {
// do nothing
}
}

14
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<FormWidgetOptionProvider> set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG);
for (FormWidgetOptionProvider provider : set) {
if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), selectionXCreator.getClass())) {
return true;
}
}
return false;
}
/**
* 是否有组件被选择如果所选组件是最底层容器也视为无选择
*

22
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<FormWidgetOptionProvider> 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<XCreator> newSelection = new ArrayList<>();

Loading…
Cancel
Save