Browse Source

REPORT-81336 FR11决策报表报表块-编辑退出,编辑内容丢失

【问题原因】
1. 将主题应用到模板上时,需要遍历模板对象查找颜色对象,以更新
其颜色。优化后的更新方案,使用了基于clone的值修改,即利用clone
方法遍历执行特征,在FineColor等类的clone方法内,修改返回值的颜
色值,使得Form.clone可以返回一个应用了主题色的新表单对象。
于是就需要使用新的表单对象更新模板,以及设计器界面。

2. 撤销回退时,因为撤销前后模板的主题可能会发生变化,所以需要应用
新主题到模板。所以撤销回退时,需要调用setTemplateTheme

3. BUG发生的直接原因是当主题应用到模板上时,仅仅更新了target,
没有更新报表块编辑界面内ElementCase对象,导致后续在报表块上的更新
保存在了一个无效的,与Target失去联系的ElementCase上了

4. 还有一个BUG: 报表块的撤销回退,没有更新Target,仅仅更新了
ElementCase,导致后续主题更新以及主题色更新时,新Target基于
旧Target产生,所以新Target中的ElementCase还是旧的ElementCase,
从而报表块内的撤销回退无效.

【改动思路】
1. 当编辑报表块时更新主题,需要更新报表块编辑界面内的ElementCase
2. 报表块撤销回退时,更新Target
newui
Starryi 2 years ago
parent
commit
5d8d998af3
  1. 47
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java

47
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -704,8 +704,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
} }
} else { } else {
// 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块.
// 修改了JForm的Target需要同步修改formDesign的Target. // 修改了JForm的Target需要同步修改formDesign的Target.
this.setTarget(undoForm);
String widgetName = this.formDesign.getElementCaseContainerName(); String widgetName = this.formDesign.getElementCaseContainerName();
//这儿太坑了,u.getForm() 与 getTarget内容不一样 //这儿太坑了,u.getForm() 与 getTarget内容不一样
FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName); FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName);
@ -1249,8 +1249,26 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
@Override @Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
FormTheme oldTheme = getTarget().getTemplateTheme(); FormTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
Form target = getTarget();
target.setTemplateTheme(newTheme, compatible);
target = (Form) FineColorSynchronizer.flush(target, target.getTemplateTheme());
refreshTarget(target);
super.setTemplateTheme(newTheme, compatible);
fireTargetModified(shouldCreateUndoState);
}
private void refreshTarget(Form form) {
setTarget(form);
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() == this) {
if (this.index == FORM_TAB) {
// save state
FormArea formArea = formDesign.getArea(); FormArea formArea = formDesign.getArea();
int horizontalValue = formArea.getHorizontalValue(); int horizontalValue = formArea.getHorizontalValue();
int verticalValue = formArea.getVerticalValue(); int verticalValue = formArea.getVerticalValue();
@ -1258,20 +1276,20 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
double widthValue = formArea.getWidthPaneValue(); double widthValue = formArea.getWidthPaneValue();
double heightValue = formArea.getHeightPaneValue(); double heightValue = formArea.getHeightPaneValue();
double slideValue = formArea.getSlideValue(); double slideValue = formArea.getSlideValue();
Widget[] selectedWidgets = formArea.getFormEditor().getSelectionModel().getSelection().getSelectedWidgets();
getTarget().setTemplateTheme(newTheme, compatible); // refresh ui
setTarget((Form) FineColorSynchronizer.flush(getTarget(), newTheme, compatible)); JForm.this.refreshRoot();
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() == this) { // restore state
fireTargetModified(shouldCreateUndoState);
formDesign.refreshRoot();
// 刷新界面后恢复原来的尺寸
formDesign.getArea().setAreaSize(areaSize, horizontalValue, verticalValue, widthValue, heightValue, slideValue); formDesign.getArea().setAreaSize(areaSize, horizontalValue, verticalValue, widthValue, heightValue, slideValue);
formDesign.getArea().undoFixLayoutState(formArea.isFixLayout()); formDesign.getArea().undoFixLayoutState(formArea.isFixLayout());
if (this.index != FORM_TAB) { this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(),
formDesign.getRootComponent() == selectedBodyLayout() ? selectedWidgets : new Widget[]{selectedBodyLayout().toData()}));
refreshToolArea(); refreshToolArea();
} else {
// CHART-20568: 当图表块处于编辑状态时,任何界面内容的修改都会导致其进行截图操作,进而引起设计器界面再次重绘,导致死循环,因而需要停止编辑 恢复浮层展示 // 停止编辑 恢复浮层展示
TreePath[] treePaths = FormHierarchyTreePane.getInstance(formDesign).getComponentTree().getSelectedTreePath(); TreePath[] treePaths = FormHierarchyTreePane.getInstance(formDesign).getComponentTree().getSelectedTreePath();
if (treePaths != null) { if (treePaths != null) {
for (TreePath path : treePaths) { for (TreePath path : treePaths) {
@ -1280,11 +1298,14 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
} }
} }
} else {
String widgetName = this.formDesign.getElementCaseContainerName();
FormElementCaseProvider dataTable = form.getElementCaseByName(widgetName);
this.reportComposite.setSelectedWidget(dataTable);
formDesign.setElementCase(dataTable);
} }
FormHierarchyTreePane.getInstance().refreshRoot(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
} }
super.setTemplateTheme(newTheme, compatible);
} }
@Override @Override

Loading…
Cancel
Save