Browse Source

REPORT-35569 参数面板,添加一个参数控件,撤销之后,再次添加的控件会空一个位置添加

feature/big-screen
Henry.Wang 4 years ago
parent
commit
957d89eed5
  1. 39
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  2. 10
      designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java

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

@ -83,7 +83,6 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
private static final int SUBMIT_BUTTON_H_LOCATION = 270;
private static final int PARA_IMAGE_SHIFT_X = -4;
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");
@ -413,30 +412,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
if (layoutContainer == null) {
layoutContainer = new XWParameterLayout();
}
refreshAddableRegion(layoutContainer);
layoutContainer.setSize(LARGE_PREFERRED_SIZE);
setRootComponent(layoutContainer);
}
/**
* @param layoutContainer
* @Description: 为了不覆盖以前的组件所以要计算可以添加组件的区域
* @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();
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);
}
/**
* 是否是报表的参数面板
*
@ -604,15 +583,14 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
label.setWidgetName("Label" + name);
label.setWidgetValue(new WidgetValue(name + ":"));
XCreator xCreator = XCreatorUtils.createXCreator(label);
int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION;
int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE);
if (!(this.autoAddComponent(xCreator, x, y))) {
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)))) {
return false;
}
EditorHolder editor = new EditorHolder(parameter);
xCreator = XCreatorUtils.createXCreator(editor);
x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION;
if (!(this.autoAddComponent(xCreator, x, y))) {
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)))) {
return false;
}
return true;
@ -668,17 +646,16 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
label.setWidgetValue(new WidgetValue(parameterArray[i].getName() + ":"));
XCreator xCreator = XCreatorUtils.createXCreator(label);
int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION;
int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE);
if (!(this.autoAddComponent(xCreator, x, y))) {
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)))) {
break;
}
// 每行显示5组
EditorHolder editor = new EditorHolder(parameterArray[i]);
editor.setWidgetName(parameterArray[i].getName());
xCreator = XCreatorUtils.createXCreator(editor);
x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION;
if (!(this.autoAddComponent(xCreator, x, y))) {
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)))) {
break;
}
currentIndex++;

10
designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java

@ -212,12 +212,13 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
return parameterArray;
}
public int getToolBarHeight(){
public int getToolBarHeight() {
return TOOLBARPANEDIMHEIGHT;
}
/**
* 导出菜单项用于图表设计器
*
* @return 菜单项
*/
public ShortCut[] shortcut4ExportMenu() {
@ -267,6 +268,8 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
bridge.setBackground(reportParameterAttr.getBackground());
bridge.setUseParamsTemplate(reportParameterAttr.isUseParamsTemplate());
}
currentIndex = reportParameterAttr.getCurrentIndex();
}
@ -376,8 +379,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
}
//这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性
paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(),
(int)paraDesignEditor.getParaTarget().getDesignSize().getHeight()));
(int) paraDesignEditor.getParaTarget().getDesignSize().getHeight()));
reportParameterAttr.setParameterUI(parameterUI);
reportParameterAttr.setCurrentIndex(currentIndex);
return reportParameterAttr;
}
@ -489,7 +493,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
* @return 模板菜单
*/
public MenuDef[] menus4Target() {
MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(),KeySetUtils.TEMPLATE.getMnemonic());
MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(), KeySetUtils.TEMPLATE.getMnemonic());
if (!DesignerMode.isAuthorityEditing()) {
tplMenu.addShortCut(new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_WorkBook")));
tplMenu.addShortCut(new ReportParameterAction(workBook));

Loading…
Cancel
Save