Browse Source

REPORT-6096 TAB页中组件在复制粘贴后会位移

master
yaoh.wu 6 years ago
parent
commit
7b12c56f99
  1. 34
      designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java

34
designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -12,6 +12,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
@ -107,6 +108,7 @@ public class FormSelectionUtils {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste"));
return;
}
resetTabSub2RealSize(copiedCreator);
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y);
if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);
@ -121,6 +123,34 @@ public class FormSelectionUtils {
}
/**
* REPORT-6096 复制得到的是显示的大小如果因屏幕分辨率问题存在缩放的话显示大小和实际大小会有区别粘贴后tab内部调整大小时会再次缩放导致问题
* 因此在粘贴之前将tab内部的组件调整成实际的大小
*
* @param copiedCreator 复制的组件
*/
private static void resetTabSub2RealSize(XCreator copiedCreator) {
ArrayList<?> childrenList = copiedCreator.getTargetChildrenList();
if (!childrenList.isEmpty()) {
for (Object aChildrenList : childrenList) {
XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList;
double percent = tabLayout.getContainerPercent();
Component[] components = tabLayout.getComponents();
for (Component component : components) {
Rectangle show = component.getBounds();
component.setBounds(new Rectangle((int) (show.x * percent), (int) (show.y * percent), (int) (show.width * percent), (int) (show.height * percent)));
}
}
}
Component[] components = copiedCreator.getComponents();
for (Component component : components) {
try {
resetTabSub2RealSize((XCreator) component);
} catch (ClassCastException ignored) {
}
}
}
/**
* 相对布局粘贴
*/
@ -178,9 +208,9 @@ public class FormSelectionUtils {
*/
private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) {
//当宽度为奇数时 设置偏移
int xoffset = (copiedCreator.getWidth() & 1) == 1 ? 1 : 0;
int xoffset = copiedCreator.getWidth() & 1;
//当高度为奇数时 设置偏移
int yoffset = (copiedCreator.getHeight() & 1) == 1 ? 1 : 0;
int yoffset = copiedCreator.getHeight() & 1;
if (!layoutAdapter.accept(copiedCreator, x, y)) {
XLayoutContainer container = layoutAdapter.getContainer();

Loading…
Cancel
Save