Browse Source

REPORT-13548【10.0.2回归】tab块复制粘贴后点击会产生联动

bugfix/10.0
kerry 6 years ago
parent
commit
9d2d79d44c
  1. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  2. 58
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

10
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -106,6 +106,16 @@ public class XWCardLayout extends XLayoutContainer {
return new Dimension(500, 300);
}
/**
* 重置组件的名称
* @param name 名称
*/
public void resetCreatorName(String name) {
super.resetCreatorName(name);
changeRelateSwitchCardName(name);
}
@Override
protected void initLayoutManager() {
cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap());

58
designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

@ -14,12 +14,11 @@ 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.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
@ -97,8 +96,7 @@ public class FormSelectionUtils {
Rectangle rec = clipboard.getSelctionBounds();
for (XCreator creator : clipboard.getSelectedCreators()) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
XCreator copiedCreator = copyXcreator(designer.getTarget(), creator);
// 获取位置
Point point = getPasteLocation((AbstractLayoutAdapter) adapter,
copiedCreator,
@ -181,8 +179,7 @@ public class FormSelectionUtils {
private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedXCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
XCreator copiedXCreator = copyXcreator(designer.getTarget(), creator);
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Too_Small_To_Paste"));
@ -235,33 +232,52 @@ public class FormSelectionUtils {
return new Point(x, y);
}
/**
* 拷贝组件
* @param form 当前表单
* @param xCreator 待拷贝的组件
* @return XCreator 拷贝的组件
*/
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws
CloneNotSupportedException {
ArrayList<String> nameSpace = new ArrayList<>();
public static XCreator copyXcreator(Form form, XCreator xCreator) throws CloneNotSupportedException{
Widget copied = (Widget) xCreator.toData().clone();
//重命名拷贝的组件
String name = getCopiedName(formDesigner, copied, nameSpace);
if (copied instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) copied, xCreator.getSize());
xwTitleLayout.resetCreatorName(name);
} else {
copied.setWidgetName(name);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize());
ArrayList<String> nameSpace = new ArrayList<>();
copyWidgetName(form, nameSpace, copiedCreator);
return copiedCreator;
}
/**
* 拷贝组件
* @param form 当前表单
* @param nameSpace 命名空间
* @param xCreator 拷贝的组件
*/
private static void copyWidgetName(Form form, ArrayList<String> nameSpace, XCreator xCreator){
String copyName = FormSelectionUtils.getCopiedName(form, xCreator.toData(), nameSpace);
if (xCreator.toData() instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize());
xwTitleLayout.resetCreatorName(copyName);
return;
}
xCreator.resetCreatorName(copyName);
int count = xCreator.getComponentCount();
for(int a = 0; a <count; a++){
if(xCreator.getComponent(a) instanceof XCreator){
XCreator child = (XCreator)xCreator.getComponent(a);
copyWidgetName(form, nameSpace, child);
}
}
return copied;
}
/**
* 组件拷贝命名规则
*/
private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) {
private static String getCopiedName(Form form, Widget copied, ArrayList<String> nameSpace) {
StringBuilder name = new StringBuilder(copied.getWidgetName());
do {
name.append(POSTFIX);
} while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString()));
} while (form.isNameExist(name.toString()) || nameSpace.contains(name.toString()));
nameSpace.add(name.toString());
return name.toString();
}
@ -308,4 +324,4 @@ public class FormSelectionUtils {
}
}
}
}
}
Loading…
Cancel
Save