Browse Source

tab 文件间复用

master
yaoh.wu 8 years ago
parent
commit
31e9e165bb
  1. 1
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  2. 2
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  3. 55
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

1
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -52,6 +52,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public void setEdit(boolean edit) {
isEdit = edit;
}
/**
* 构造函数
*

2
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java

@ -69,7 +69,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
if (!accept(creator, posX, posY)) {
return false;
}
// posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到
// posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到l
// 父层自适应布局中,这时候的添加位置就是tab布局所在的位置
if (this.intersectsEdge(posX, posY, backUpContainer)) {
if (!ComparatorUtils.equals(backUpContainer.getOuterLayout(), backUpContainer.getBackupParent())) {

55
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

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

Loading…
Cancel
Save