diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index ba491e3519..0a4aa98944 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -468,18 +468,21 @@ public class JForm extends JTemplate implements BaseJForm { @Override protected void applyUndoState(FormUndoState u) { try { - //JForm的target重置 - this.setTarget((Form) u.getForm().clone()); if (this.index == FORM_TAB) { + //JForm的target重置 + this.setTarget((Form) u.getForm().clone()); JForm.this.refreshRoot(); this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue()); //撤销的时候要重新选择的body布局 this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(), formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()})); } else { + // 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块. + // 修改了JForm的Target需要同步修改formDesign的Target. + Form undoForm = (Form) u.getForm().clone(); String widgetName = this.formDesign.getElementCaseContainerName(); //这儿太坑了,u.getForm() 与 getTarget内容不一样 - FormElementCaseProvider dataTable = getTarget().getElementCaseByName(widgetName); + FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName); this.reportComposite.setSelectedWidget(dataTable); //下面这句话是防止撤销之后直接退出编辑再编辑撤销的东西会回来,因为撤销不会保存EC formDesign.setElementCase(dataTable);