Browse Source

1、更新注释

2、优化一下代码结构
feature/big-screen
Harrison 4 years ago
parent
commit
2886d3b5d9
  1. 10
      designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java
  2. 4
      designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java
  3. 8
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  4. 14
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

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

@ -7,6 +7,11 @@ import com.fr.stable.StringUtils;
import javax.swing.text.Document;
/**
* 公式展示时使用
* 展示 String.
* 但实际保存的是 BaseFormula
* 从而保留公式的形态
*
* created by Harrison on 2020/08/03
**/
public class FormulaTextField extends DictionaryTextField<BaseFormula> {
@ -41,6 +46,11 @@ public class FormulaTextField extends DictionaryTextField<BaseFormula> {
return this.value;
}
/**
* 设置值时会将展示的公式值一同设置进去
*
* @param value 公式值
*/
@Override
public void setValue(BaseFormula value) {

4
designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java

@ -3,6 +3,10 @@ package com.fr.design.gui.itextfield;
import javax.swing.text.Document;
/**
* 文字 ui.
* 保存实际值展示值
* 允许实际值和展示值不同
*
* created by Harrison on 2020/08/03
**/
public class DictionaryTextField<T> extends UITextField {

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

@ -410,17 +410,16 @@ public class DSColumnAdvancedPane extends BasicPane {
private static class JFormulaField extends JPanel {
private CellElement cellElement;
private FormulaTextField formulaTextField;
private String defaultValue;
private BaseFormula defaultFormula;
public JFormulaField(String defaultValue) {
this.defaultValue = defaultValue;
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue);
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
UILabel bottomLabel = new UILabel("=");
bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12));
this.add(bottomLabel);
formulaTextField = new FormulaTextField(24);
this.add(formulaTextField);
formulaTextField.setText(defaultValue);
UIButton bottomFrmulaButton = new UIButton("...");
@ -481,9 +480,8 @@ public class DSColumnAdvancedPane extends BasicPane {
public void doOk() {
BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) {
formulaTextField.setText(defaultValue);
formulaTextField.setValue(defaultFormula);
} else {
formulaTextField.setText(valueFormula.getPureContent());
formulaTextField.setValue(valueFormula);
}
}

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

@ -1064,13 +1064,14 @@ public class CellDSColumnEditor extends CellQuickEditor {
public class JFormulaField extends JPanel {
private CellElement cellElement;
private FormulaTextField formulaTextField;
private String defaultValue;
private BaseFormula defaultFormula;
public JFormulaField(String defaultValue) {
this.defaultValue = defaultValue;
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue);
formulaTextField = new FormulaTextField();
formulaTextField.setText(defaultValue);
formulaTextField.setValue(defaultFormula);
JPanel textFieldPane = new JPanel(new BorderLayout());
textFieldPane.add(formulaTextField, BorderLayout.CENTER);
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
@ -1101,7 +1102,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValue(baseFormula);
this.formulaTextField.setText(baseFormula.getContent());
}
public BaseFormula getFormula() {
@ -1145,9 +1145,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void doOk() {
BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) {
formulaTextField.setText(defaultValue);
formulaTextField.setValue(defaultFormula);
} else {
formulaTextField.setText(valueFormula.getPureContent());
formulaTextField.setValue(valueFormula);
}
}
@ -1165,6 +1164,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/
public class CustomValuePane extends JPanel {
private static final String DEFAULT_VALUE = "=$$$";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE);
private JFormulaField formulaField;
@ -1187,6 +1187,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
BaseFormula valueFormula = dSColumn.getResultObject();
if (valueFormula != null) {
formulaField.populateFormula(valueFormula);
} else {
formulaField.populateFormula(DEFAULT_FORMULA);
}
formulaField.populateElement(cellElement);

Loading…
Cancel
Save