|
|
|
@ -6,11 +6,11 @@ import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter
|
|
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
|
import com.fr.design.designer.creator.XWParameterLayout; |
|
|
|
|
import com.fr.design.designer.creator.XWTitleLayout; |
|
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
@ -23,8 +23,6 @@ import java.util.Set;
|
|
|
|
|
*/ |
|
|
|
|
public class AddingModel { |
|
|
|
|
|
|
|
|
|
private static final String POSTFIX = "_a"; |
|
|
|
|
|
|
|
|
|
// 当前要添加的组件
|
|
|
|
|
private XCreator creator; |
|
|
|
|
// 记录当前鼠标的位置信息
|
|
|
|
@ -77,41 +75,46 @@ public class AddingModel {
|
|
|
|
|
* @param xCreator 创建器 |
|
|
|
|
*/ |
|
|
|
|
private static void renameWidgetName(Form form, XCreator xCreator) { |
|
|
|
|
|
|
|
|
|
Set<String> nameSpace = new HashSet<>(8); |
|
|
|
|
recursiveRenameWidgetName(form, nameSpace, xCreator); |
|
|
|
|
|
|
|
|
|
Set<String> nameSpace = new HashSet<>(); |
|
|
|
|
recursiveRenameWidgetName(form, xCreator, nameSpace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void recursiveRenameWidgetName(Form form, Set<String> nameSpace, XCreator xCreator) { |
|
|
|
|
private static void recursiveRenameWidgetName(Form form, XCreator xCreator, Set<String> nameSpace) { |
|
|
|
|
|
|
|
|
|
String copyName = getAddWidgetName(form, xCreator.toData(), nameSpace); |
|
|
|
|
String creatorName = uniqueName(form, xCreator, nameSpace); |
|
|
|
|
if (xCreator.toData() instanceof WTitleLayout) { |
|
|
|
|
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize()); |
|
|
|
|
xwTitleLayout.resetCreatorName(copyName); |
|
|
|
|
xwTitleLayout.resetCreatorName(creatorName); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
xCreator.resetCreatorName(copyName); |
|
|
|
|
xCreator.resetCreatorName(creatorName); |
|
|
|
|
int count = xCreator.getComponentCount(); |
|
|
|
|
for (int a = 0; a < count; a++) { |
|
|
|
|
if (xCreator.getComponent(a) instanceof XCreator) { |
|
|
|
|
XCreator child = (XCreator) xCreator.getComponent(a); |
|
|
|
|
recursiveRenameWidgetName(form, nameSpace, child); |
|
|
|
|
recursiveRenameWidgetName(form, child, nameSpace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 组件拷贝命名规则 |
|
|
|
|
* 组件命名规则 |
|
|
|
|
*/ |
|
|
|
|
private static String getAddWidgetName(Form form, Widget added, Set<String> nameSpace) { |
|
|
|
|
public static String uniqueName(Form form, XCreator x, Set<String> nameSpace) { |
|
|
|
|
|
|
|
|
|
StringBuilder name = new StringBuilder(added.getWidgetName()); |
|
|
|
|
do { |
|
|
|
|
name.append(POSTFIX); |
|
|
|
|
} while (form.isNameExist(name.toString()) || nameSpace.contains(name.toString())); |
|
|
|
|
nameSpace.add(name.toString()); |
|
|
|
|
return name.toString(); |
|
|
|
|
String def = x.createDefaultName(); |
|
|
|
|
if (x.acceptType(XWParameterLayout.class)) { |
|
|
|
|
return def; |
|
|
|
|
} |
|
|
|
|
int i = 0; |
|
|
|
|
String name = def + i; |
|
|
|
|
while (form.isNameExist(name) || nameSpace.contains(name)) { |
|
|
|
|
i++; |
|
|
|
|
name = def + i; |
|
|
|
|
} |
|
|
|
|
return name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getCurrentX() { |
|
|
|
|