|
|
@ -12,11 +12,15 @@ import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
import com.fr.design.designer.beans.location.Direction; |
|
|
|
import com.fr.design.designer.beans.location.Direction; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.creator.*; |
|
|
|
import com.fr.design.designer.creator.*; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
|
|
|
import com.fr.design.form.util.XCreatorConstants; |
|
|
|
import com.fr.design.form.util.XCreatorConstants; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.mainframe.FormSelection; |
|
|
|
import com.fr.design.mainframe.FormSelection; |
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -25,6 +29,7 @@ import com.fr.stable.ArrayUtils; |
|
|
|
public class SelectionModel { |
|
|
|
public class SelectionModel { |
|
|
|
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
|
|
|
|
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
|
|
|
|
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
|
|
|
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
|
|
|
|
|
|
|
private static final int BORDER_PROPORTION = 10; |
|
|
|
private static FormSelection CLIP_BOARD = new FormSelection(); |
|
|
|
private static FormSelection CLIP_BOARD = new FormSelection(); |
|
|
|
private FormDesigner designer; |
|
|
|
private FormDesigner designer; |
|
|
|
private FormSelection selection; |
|
|
|
private FormSelection selection; |
|
|
@ -111,15 +116,26 @@ public class SelectionModel { |
|
|
|
public boolean pasteFromClipBoard() { |
|
|
|
public boolean pasteFromClipBoard() { |
|
|
|
if (!CLIP_BOARD.isEmpty()) { |
|
|
|
if (!CLIP_BOARD.isEmpty()) { |
|
|
|
XLayoutContainer parent = null; |
|
|
|
XLayoutContainer parent = null; |
|
|
|
|
|
|
|
//未选
|
|
|
|
if (!hasSelectionComponent()) { |
|
|
|
if (!hasSelectionComponent()) { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
|
|
|
|
|
|
|
|
if (selection.getSelectedCreator() instanceof XWFitLayout) { |
|
|
|
if (selection.getSelectedCreator() instanceof XWFitLayout) { |
|
|
|
//相对布局
|
|
|
|
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { |
|
|
|
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), |
|
|
|
Rectangle rec = selection.getRelativeBounds(); |
|
|
|
CLIP_BOARD, |
|
|
|
//Tab布局
|
|
|
|
DELTA_X_Y, |
|
|
|
System.out.println("ADD: " + (rec.x + rec.width / 2) + "\t" + (rec.y + BORDER_PROPORTION)); |
|
|
|
DELTA_X_Y); |
|
|
|
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), |
|
|
|
|
|
|
|
CLIP_BOARD, |
|
|
|
|
|
|
|
rec.x + rec.width / 2, |
|
|
|
|
|
|
|
rec.y + BORDER_PROPORTION); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Rectangle rec = selection.getRelativeBounds(); |
|
|
|
|
|
|
|
//自适应布局
|
|
|
|
|
|
|
|
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), |
|
|
|
|
|
|
|
CLIP_BOARD, |
|
|
|
|
|
|
|
rec.x + rec.width / 2, |
|
|
|
|
|
|
|
rec.y + BORDER_PROPORTION); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//绝对布局
|
|
|
|
//绝对布局
|
|
|
|
//编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
|
|
|
|
//编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
|
|
|
@ -137,15 +153,17 @@ public class SelectionModel { |
|
|
|
DELTA_X_Y, |
|
|
|
DELTA_X_Y, |
|
|
|
DELTA_X_Y); |
|
|
|
DELTA_X_Y); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
//已选
|
|
|
|
|
|
|
|
else { |
|
|
|
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
|
|
|
|
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
|
|
|
|
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
|
|
|
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
|
|
|
if (selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
|
|
|
if (selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
|
|
|
//相对布局
|
|
|
|
//自适应布局
|
|
|
|
if (parent != null) { |
|
|
|
if (parent != null) { |
|
|
|
Rectangle rec = selection.getSelctionBounds(); |
|
|
|
Rectangle rec = selection.getSelctionBounds(); |
|
|
|
FormSelectionUtils.paste2Container(designer, parent, CLIP_BOARD, rec.x + rec.width / 2, rec.y + |
|
|
|
FormSelectionUtils.paste2Container(designer, parent, CLIP_BOARD, rec.x + rec.width / 2, rec.y + |
|
|
|
rec.height - 2); |
|
|
|
rec.height - BORDER_PROPORTION); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { |
|
|
|
} else if (selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { |
|
|
|
//绝对布局
|
|
|
|
//绝对布局
|
|
|
@ -256,18 +274,17 @@ public class SelectionModel { |
|
|
|
public boolean hasSelectionComponent() { |
|
|
|
public boolean hasSelectionComponent() { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
//frm本地组件复用
|
|
|
|
//frm本地组件复用
|
|
|
|
if (selection.getSelectedCreator() == null) { |
|
|
|
return selection.getSelectedCreator() != null |
|
|
|
return false; |
|
|
|
&& !( |
|
|
|
} else if (selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
|
|
|
//frm绝对布局编辑器
|
|
|
|
// 相对布局
|
|
|
|
selection.getSelectedCreator().getClass().equals(XWAbsoluteBodyLayout.class) |
|
|
|
// 已选:selection.getSelectedCreator().getParent() instanceof @XWFitLayout
|
|
|
|
//Tab布局编辑器
|
|
|
|
// 未选:selection.getSelectedCreator() instanceof @XWFitLayout
|
|
|
|
|| selection.getSelectedCreator().getClass().equals(XWCardMainBorderLayout.class) |
|
|
|
return !(selection.getSelectedCreator() instanceof XWAbsoluteLayout); |
|
|
|
|| selection.getSelectedCreator().getClass().equals(XWCardLayout.class) |
|
|
|
} else { |
|
|
|
|| selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class) |
|
|
|
//绝对布局
|
|
|
|
//自适应布局编辑器
|
|
|
|
//已选:selection.getSelectedCreator().getParent() instanceof @XWAbsoluteLayout
|
|
|
|
|| selection.getSelectedCreator().getClass().equals(XWFitLayout.class) |
|
|
|
return selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout; |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout
|
|
|
|
//cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout
|
|
|
|
return selection.getSelectedCreator() != null && selection.getSelectedCreator().getParent() != null; |
|
|
|
return selection.getSelectedCreator() != null && selection.getSelectedCreator().getParent() != null; |
|
|
|