Browse Source

Pull request #2085: REPORT-37487 && REPORT-37484

Merge in DESIGN/design from ~HARRISON/design:release/10.0 to release/10.0

* commit '7150ffee7a5ee992ee1b095e16fabafb7ca6be4f':
  REPORT-37487 && REPORT-37484 1、回复 result 默认为 $$$ 。 2、和产品沟通,将两个面板分别默认展示 = 和不展示 = 3、恢复数据的联动
feature/big-screen
Harrison 4 years ago
parent
commit
a16c7cbc79
  1. 33
      designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java
  2. 2
      designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java
  3. 28
      designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java
  4. 11
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  5. 8
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

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

@ -16,7 +16,9 @@ import javax.swing.text.Document;
**/
public class FormulaTextField extends DictionaryTextField<BaseFormula> {
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build("=");
private static final String EMPTY_STRING = "=";
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build(EMPTY_STRING);
public FormulaTextField() {
}
@ -43,7 +45,15 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
if (this.value == null) {
this.value = createDefault();
}
return this.value;
//保持联动
linkValueByText();
return value;
}
private void linkValueByText() {
String content = getText();
this.value.setContent(content);
}
/**
@ -58,7 +68,24 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
if (this.value == null) {
this.value = createDefault();
}
setText(this.value.getPureContent());
}
/**
* 是需要设置不带 = 还是带 =
*
* @param value
* @param isPure 带不带 = , = 不带 =
*/
public void setValueAndText(BaseFormula value, boolean isPure) {
setValue(value);
String content = null;
if (isPure) {
content = this.value.getPureContent();
} else {
content = this.value.getContent();
}
setText(content);
}
private BaseFormula createDefault() {

2
designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java

@ -64,7 +64,7 @@ public abstract class SortFormulaPane extends JPanel {
public void doOk() {
BaseFormula fm = formulaPane.update();
if (fm != null) {
sortFormulaTextField.setValue(fm);
sortFormulaTextField.setValueAndText(fm, true);
}
}
}).setVisible(true);

28
designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java

@ -0,0 +1,28 @@
package com.fr.design.formula;
import com.fr.base.BaseFormula;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class FormulaTextFieldTest {
@Test
public void testSet() {
FormulaTextField field = new FormulaTextField();
BaseFormula aaaa = BaseFormula.createFormulaBuilder().build("aaaa");
field.setValueAndText(aaaa, true);
Assert.assertEquals("aaaa", field.getText());
field.setValueAndText(aaaa, false);
Assert.assertEquals("=aaaa", field.getText());
field.setText("bbbb");
BaseFormula formula = field.getValue();
Assert.assertEquals("bbbb", formula.getPureContent());
}
}

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

@ -257,7 +257,7 @@ public class DSColumnAdvancedPane extends BasicPane {
this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
BaseFormula sortFormulaObject = dSColumn.getSortFormulaObject();
sortFormulaTextField.setValue(sortFormulaObject);
sortFormulaTextField.setValueAndText(sortFormulaObject, true);
}
public void update(CellElement cellElement) {
@ -421,7 +421,7 @@ public class DSColumnAdvancedPane extends BasicPane {
this.add(bottomLabel);
formulaTextField = new FormulaTextField(24);
this.add(formulaTextField);
formulaTextField.setValue(defaultFormula);
formulaTextField.setValueAndText(defaultFormula, true);
UIButton bottomFrmulaButton = new UIButton("...");
this.add(bottomFrmulaButton);
@ -444,8 +444,7 @@ public class DSColumnAdvancedPane extends BasicPane {
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValue(baseFormula);
this.formulaTextField.setText(baseFormula.getPureContent());
this.formulaTextField.setValueAndText(baseFormula, true);
}
public BaseFormula getFormula() {
@ -481,9 +480,9 @@ public class DSColumnAdvancedPane extends BasicPane {
public void doOk() {
BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) {
formulaTextField.setValue(defaultFormula);
formulaTextField.setValueAndText(defaultFormula, true);
} else {
formulaTextField.setValue(valueFormula);
formulaTextField.setValueAndText(valueFormula, true);
}
}
}).setVisible(true);

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

@ -1070,7 +1070,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue);
formulaTextField = new FormulaTextField();
formulaTextField.setValue(defaultFormula);
formulaTextField.setValueAndText(defaultFormula, false);
JPanel textFieldPane = new JPanel(new BorderLayout());
textFieldPane.add(formulaTextField, BorderLayout.CENTER);
@ -1101,7 +1101,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValue(baseFormula);
this.formulaTextField.setValueAndText(baseFormula, false);
}
public BaseFormula getFormula() {
@ -1145,9 +1145,9 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void doOk() {
BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) {
formulaTextField.setValue(defaultFormula);
formulaTextField.setValueAndText(defaultFormula, false);
} else {
formulaTextField.setValue(valueFormula);
formulaTextField.setValueAndText(valueFormula, false);
}
}
}).setVisible(true);

Loading…
Cancel
Save