Browse Source

REPORT-37487 数据列右侧属性面板高级部分功能出现问题

右侧面板,显示值为空时,重置为 =$$$
双击数据源高级中,不会重置。
feature/big-screen
Harrison 4 years ago
parent
commit
3b5adce5d3
  1. 11
      designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java
  2. 6
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  3. 20
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

11
designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java

@ -18,8 +18,6 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
private static final String EMPTY_STRING = "="; private static final String EMPTY_STRING = "=";
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build(EMPTY_STRING);
public FormulaTextField() { public FormulaTextField() {
} }
@ -64,10 +62,10 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
@Override @Override
public void setValue(BaseFormula value) { public void setValue(BaseFormula value) {
this.value = value; if (value == null) {
if (this.value == null) { value = createDefault();
this.value = createDefault();
} }
this.value = value;
} }
/** /**
@ -94,7 +92,8 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
if (StringUtils.isNotEmpty(text)) { if (StringUtils.isNotEmpty(text)) {
return BaseFormula.createFormulaBuilder().build(text); return BaseFormula.createFormulaBuilder().build(text);
} else { } else {
return EMPTY_FORMULA; //防止默认值被修改, 每一次创建都是不一样的。
return BaseFormula.createFormulaBuilder().build(EMPTY_STRING);
} }
} }
} }

6
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -410,10 +410,10 @@ public class DSColumnAdvancedPane extends BasicPane {
private static class JFormulaField extends JPanel { private static class JFormulaField extends JPanel {
private CellElement cellElement; private CellElement cellElement;
private FormulaTextField formulaTextField; private FormulaTextField formulaTextField;
private BaseFormula defaultFormula; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); this.defaultValue = defaultValue;
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
UILabel bottomLabel = new UILabel("="); UILabel bottomLabel = new UILabel("=");
@ -421,6 +421,7 @@ public class DSColumnAdvancedPane extends BasicPane {
this.add(bottomLabel); this.add(bottomLabel);
formulaTextField = new FormulaTextField(24); formulaTextField = new FormulaTextField(24);
this.add(formulaTextField); this.add(formulaTextField);
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue);
formulaTextField.setValueAndText(defaultFormula, true); formulaTextField.setValueAndText(defaultFormula, true);
UIButton bottomFrmulaButton = new UIButton("..."); UIButton bottomFrmulaButton = new UIButton("...");
@ -480,6 +481,7 @@ public class DSColumnAdvancedPane extends BasicPane {
public void doOk() { public void doOk() {
BaseFormula valueFormula = formulaPane.update(); BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) { if (valueFormula.getContent().length() <= 1) {
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue);
formulaTextField.setValueAndText(defaultFormula, true); formulaTextField.setValueAndText(defaultFormula, true);
} else { } else {
formulaTextField.setValueAndText(valueFormula, true); formulaTextField.setValueAndText(valueFormula, true);

20
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -646,7 +646,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class ResultSetSortConfigPane extends JPanel { public class ResultSetSortConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "="; private static final String DEFAULT_VALUE = "=";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build();
private JPanel contentPane; private JPanel contentPane;
private UIButtonGroup sortTypePane; private UIButtonGroup sortTypePane;
private JFormulaField formulaField; private JFormulaField formulaField;
@ -723,7 +722,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
} }
BaseFormula baseFormula = dSColumn.getSortFormulaObject(); BaseFormula baseFormula = dSColumn.getSortFormulaObject();
if (baseFormula == null) { if (baseFormula == null) {
this.formulaField.populateFormula(DEFAULT_FORMULA); BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build();
this.formulaField.populateFormula(defaultFormula);
} else { } else {
this.formulaField.populateFormula(baseFormula); this.formulaField.populateFormula(baseFormula);
} }
@ -1064,11 +1064,12 @@ public class CellDSColumnEditor extends CellQuickEditor {
public class JFormulaField extends JPanel { public class JFormulaField extends JPanel {
private CellElement cellElement; private CellElement cellElement;
private FormulaTextField formulaTextField; private FormulaTextField formulaTextField;
private BaseFormula defaultFormula; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); this.defaultValue = defaultValue;
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue);
formulaTextField = new FormulaTextField(); formulaTextField = new FormulaTextField();
formulaTextField.setValueAndText(defaultFormula, false); formulaTextField.setValueAndText(defaultFormula, false);
@ -1145,6 +1146,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void doOk() { public void doOk() {
BaseFormula valueFormula = formulaPane.update(); BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) { if (valueFormula.getContent().length() <= 1) {
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue);
formulaTextField.setValueAndText(defaultFormula, false); formulaTextField.setValueAndText(defaultFormula, false);
} else { } else {
formulaTextField.setValueAndText(valueFormula, false); formulaTextField.setValueAndText(valueFormula, false);
@ -1164,8 +1166,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class CustomValuePane extends JPanel { public class CustomValuePane extends JPanel {
private static final String DEFAULT_VALUE = "=$$$"; private static final String DEFAULT_VALUE = "=$$$";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE);
private JFormulaField formulaField; private JFormulaField formulaField;
public CustomValuePane() { public CustomValuePane() {
@ -1188,7 +1189,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (valueFormula != null) { if (valueFormula != null) {
formulaField.populateFormula(valueFormula); formulaField.populateFormula(valueFormula);
} else { } else {
formulaField.populateFormula(DEFAULT_FORMULA); BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE);
formulaField.populateFormula(defaultFormula);
} }
formulaField.populateElement(cellElement); formulaField.populateElement(cellElement);
@ -1201,7 +1203,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) (cellElement.getValue()); DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setResultObject(this.formulaField.getFormula()); dSColumn.setResultObject(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? null : this.formulaField.getFormula());
} }
} }
} }

Loading…
Cancel
Save