Browse Source

Merge pull request #806 in BA/design from ~YAOH.WU/design_0407:release to release

* commit '228d8bb8e8865d78257a6aa825529ce26bdb4fc3':
  组件复用层叠顺序新添加的组件在上方
  无任务代码调整
  report-1945frm本地组件复用:1、自适应或者tab布局时,不选中粘贴默认为上下平分左上角的组件;2、tab布局(有无参数面板)粘贴位置问题
master
superman 8 years ago
parent
commit
455c766b18
  1. 6
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 42
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  3. 19
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  4. 14
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

6
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -235,7 +235,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.hasTitleStyle()) { if (creator.hasTitleStyle()) {
addParentCreator(creator); addParentCreator(creator);
} else { } else {
container.add(creator, creator.toData().getWidgetName()); container.add(creator, creator.toData().getWidgetName(),0);
} }
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator); layout.updateBoundsWidget(creator);
@ -246,7 +246,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator); addParentCreator(creator);
} else { } else {
container.add(creator, creator.toData().getWidgetName()); container.add(creator, creator.toData().getWidgetName(),0);
} }
XWFitLayout layout = (XWFitLayout) container; XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget // 更新对应的BoundsWidget
@ -265,7 +265,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
private void addParentCreator(XCreator child) { private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
container.add(parentPanel, child.toData().getWidgetName()); container.add(parentPanel, child.toData().getWidgetName(),0);
} }
/** /**

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

@ -136,19 +136,20 @@ public class SelectionModel {
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)) { if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) {
Rectangle rec = selection.getRelativeBounds(); XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator();
//Tab布局 //tab布局编辑器内部左上角第一个坐标点
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), int leftUpX = container.toData().getMargin().getLeft() + 1;
clipboard, int leftUpY = container.toData().getMargin().getTop() + 1;
rec.x + rec.width / 2, //选中第一个坐标点坐在的组件
rec.y + DELTA_X_Y); selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY));
pasteFromClipBoard();
} else { } else {
Rectangle rec = selection.getRelativeBounds(); //自适应布局编辑器内部左上角第一个坐标点
//自适应布局 int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
clipboard, //选中第一个坐标点坐在的组件
rec.x + rec.width / 2, selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY));
rec.y + DELTA_X_Y); pasteFromClipBoard();
} }
} else { } else {
//绝对布局 //绝对布局
@ -178,12 +179,23 @@ public class SelectionModel {
container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
//自适应布局 //自适应布局
Rectangle selectionRec = selection.getRelativeBounds(); Rectangle selectionRec = selection.getRelativeBounds();
//获取父容器位置,补充因参数面板高度导致的位置坐标计算偏移
Rectangle containerRec = ComponentUtils.getRelativeBounds(container); Rectangle containerRec = ComponentUtils.getRelativeBounds(container);
int positionX, positionY;
if (container.getClass().equals(XWTabFitLayout.class)) {
//tab内部粘贴不补充高度偏移
//且不计算参数面板造成的影响,因为在
//@see com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter#addBean中做了
positionX = selectionRec.x + selectionRec.width / 2;
positionY = (int) (selectionRec.y + selectionRec.height * OFFSET_RELATIVE);
} else {
//计算自适应布局位置 //计算自适应布局位置
int positionX = selectionRec.x - containerRec.x + selectionRec.width / 2; positionX = selectionRec.x - containerRec.x + selectionRec.width / 2;
int positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE);
}
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY);
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { } else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
//绝对布局 //绝对布局

19
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -86,6 +86,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回容器大小的百分比 * 返回容器大小的百分比
*
* @return the containerPercent * @return the containerPercent
*/ */
public double getContainerPercent() { public double getContainerPercent() {
@ -94,6 +95,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 设置容器大小的百分比 * 设置容器大小的百分比
*
* @param containerPercent the containerPercent to set * @param containerPercent the containerPercent to set
*/ */
public void setContainerPercent(double containerPercent) { public void setContainerPercent(double containerPercent) {
@ -104,6 +106,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回界面处根据百分比调整后的最小宽度 * 返回界面处根据百分比调整后的最小宽度
*
* @return 最小宽度 * @return 最小宽度
*/ */
public int getActualMinWidth() { public int getActualMinWidth() {
@ -112,6 +115,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回界面处根据百分比调整后的最小高度 * 返回界面处根据百分比调整后的最小高度
*
* @return 最小高度 * @return 最小高度
*/ */
public int getActualMinHeight() { public int getActualMinHeight() {
@ -120,6 +124,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回界面处根据百分比调整后的间隔大小且为偶数 * 返回界面处根据百分比调整后的间隔大小且为偶数
*
* @return 间隔 * @return 间隔
*/ */
public int getAcualInterval() { public int getAcualInterval() {
@ -198,6 +203,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
* 更新子组件的Bound * 更新子组件的Bound
* 这边主要用于绝对布局子组件在适应区域选项时 * 这边主要用于绝对布局子组件在适应区域选项时
* 涉及到的不同分辨率下缩放 * 涉及到的不同分辨率下缩放
*
* @param minHeight 最小高度 * @param minHeight 最小高度
*/ */
@Override @Override
@ -222,6 +228,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 增加对齐线 * 增加对齐线
*
* @param connector 对齐线 * @param connector 对齐线
*/ */
public void addConnector(Connector connector) { public void addConnector(Connector connector) {
@ -235,6 +242,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 去除对齐线 * 去除对齐线
*
* @param connector 对齐线 * @param connector 对齐线
*/ */
public void removeConnector(Connector connector) { public void removeConnector(Connector connector) {
@ -244,6 +252,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回对应的widget容器 * 返回对应的widget容器
*
* @return 返回WAbsoluteLayout * @return 返回WAbsoluteLayout
*/ */
@Override @Override
@ -258,6 +267,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 返回默认的容器name * 返回默认的容器name
*
* @return 返回绝对布局容器名 * @return 返回绝对布局容器名
*/ */
@Override @Override
@ -315,6 +325,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 当前组件zorder位置替换新的控件 * 当前组件zorder位置替换新的控件
*
* @param widget 控件 * @param widget 控件
* @param oldcreator 旧组件 * @param oldcreator 旧组件
* @return 组件 * @return 组件
@ -333,6 +344,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 组件增加 * 组件增加
*
* @param e 容器事件 * @param e 容器事件
*/ */
@Override @Override
@ -350,6 +362,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* 在设计界面中有组件移除的时候需要通知WLayout容器重新paint * 在设计界面中有组件移除的时候需要通知WLayout容器重新paint
*
* @param e 容器事件 * @param e 容器事件
*/ */
@Override @Override
@ -379,14 +392,14 @@ public class XWAbsoluteLayout extends XLayoutContainer {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout(); XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()) { if (xTopLayout != null && !xTopLayout.isEditable()) {
return xTopLayout; return xTopLayout;
} } else {
else{
return this; return this;
} }
} }
/** /**
* 得到属性名 * 得到属性名
*
* @return 属性名 * @return 属性名
* @throws java.beans.IntrospectionException * @throws java.beans.IntrospectionException
*/ */
@ -459,6 +472,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* body大小手动调整的时候 * body大小手动调整的时候
* 按照比例调整组件的宽度 * 按照比例调整组件的宽度
*
* @param percent 比例 * @param percent 比例
*/ */
@Override @Override
@ -475,6 +489,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
/** /**
* body大小手动调整的时候 * body大小手动调整的时候
* 按照比例调整组件的高度 * 按照比例调整组件的高度
*
* @param percent 比例 * @param percent 比例
*/ */
@Override @Override

14
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -3,8 +3,10 @@ package com.fr.design.mainframe;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.utils.ComponentUtils;
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;
@ -83,15 +85,27 @@ public class FormSelectionUtils {
* 相对布局粘贴 * 相对布局粘贴
*/ */
private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) {
//@see FRTabFitLayoutAdapter
Rectangle tabContainerRect = ComponentUtils.getRelativeBounds(designer.getSelectionModel().getSelection()
.getSelectedCreator().getParent());
designer.getSelectionModel().getSelection().reset(); designer.getSelectionModel().getSelection().reset();
for (XCreator creator : clipboard.getSelectedCreators()) { for (XCreator creator : clipboard.getSelectedCreators()) {
try { try {
Widget copied = copyWidget(designer, creator); Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
} else {
if (!adapter.accept(copiedCreator, x, y)) { if (!adapter.accept(copiedCreator, x, y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste")); designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return; return;
} }
}
boolean addSuccess = adapter.addBean(copiedCreator, x, y); boolean addSuccess = adapter.addBean(copiedCreator, x, y);
if (addSuccess) { if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);

Loading…
Cancel
Save