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