Browse Source

REPORT-35387 参数面板已有控件的时候,点击右侧全部添加,控件重叠

feature/big-screen
Henry.Wang 4 years ago
parent
commit
89f5de1f09
  1. 30
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

30
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -83,6 +83,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
private static final int SUBMIT_BUTTON_H_LOCATION = 270; private static final int SUBMIT_BUTTON_H_LOCATION = 270;
private static final int PARA_IMAGE_SHIFT_X = -4; private static final int PARA_IMAGE_SHIFT_X = -4;
private static final int FORM_AREA_PADDING_LEFT = 13; private static final int FORM_AREA_PADDING_LEFT = 13;
private int addableRegionY;
private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png"); private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png");
@ -412,10 +413,31 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
if (layoutContainer == null) { if (layoutContainer == null) {
layoutContainer = new XWParameterLayout(); layoutContainer = new XWParameterLayout();
} }
refreshAddableRegion(layoutContainer);
layoutContainer.setSize(LARGE_PREFERRED_SIZE); layoutContainer.setSize(LARGE_PREFERRED_SIZE);
setRootComponent(layoutContainer); setRootComponent(layoutContainer);
} }
/**
* @Description: 为了不覆盖以前的组件所以要计算可以添加组件的区域
* @param layoutContainer
* @return:
* @Author: Henry.Wang
* @date: 2020/7/15 15:12
*/
public void refreshAddableRegion(XLayoutContainer layoutContainer) {
addableRegionY = 0;
for (int i = 0; i < layoutContainer.getComponentCount(); i++) {
Rectangle rectangle = layoutContainer.getComponent(i).getBounds();
System.out.println("rectangle:" + rectangle);
if (addableRegionY < rectangle.y + rectangle.height) {
addableRegionY = rectangle.y + rectangle.height;
}
}
int vGap = V_COMPONENT_GAP - (int) XCreator.SMALL_PREFERRED_SIZE.getHeight();
addableRegionY = Math.max(0, addableRegionY - FIRST_V_LOCATION + (int) (XCreator.SMALL_PREFERRED_SIZE.getHeight() / 2) + vGap);
}
/** /**
* 是否是报表的参数面板 * 是否是报表的参数面板
* *
@ -584,13 +606,13 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
label.setWidgetValue(new WidgetValue(name + ":")); label.setWidgetValue(new WidgetValue(name + ":"));
XCreator xCreator = XCreatorUtils.createXCreator(label); XCreator xCreator = XCreatorUtils.createXCreator(label);
if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE)
+ FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) {
return false; return false;
} }
EditorHolder editor = new EditorHolder(parameter); EditorHolder editor = new EditorHolder(parameter);
xCreator = XCreatorUtils.createXCreator(editor); xCreator = XCreatorUtils.createXCreator(editor);
if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE)
+ SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) {
return false; return false;
} }
return true; return true;
@ -647,7 +669,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
XCreator xCreator = XCreatorUtils.createXCreator(label); XCreator xCreator = XCreatorUtils.createXCreator(label);
if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE)
+ FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + FIRST_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) {
break; break;
} }
// 每行显示5组 // 每行显示5组
@ -655,7 +677,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
editor.setWidgetName(parameterArray[i].getName()); editor.setWidgetName(parameterArray[i].getName());
xCreator = XCreatorUtils.createXCreator(editor); xCreator = XCreatorUtils.createXCreator(editor);
if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE)
+ SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { + SECOND_H_LOCATION, addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) {
break; break;
} }
currentIndex++; currentIndex++;

Loading…
Cancel
Save