forked from fanruan/design
Browse Source
Merge in DESIGN/design from ~HARRISON/design:release/10.0 to release/10.0 * commit '2886d3b5d9d73eb90601f593510d25b68daebfde': 1、更新注释 2、优化一下代码结构 REPORT-24268 增强公式编辑器插件问题 [reason] 由于数据集相关没有保存公式的具体类,导致重新打开时, 都是默认的公式形态。 [solution] 直接保存公式形态,而不是字符串feature/big-screen
Harrison
4 years ago
5 changed files with 220 additions and 81 deletions
@ -0,0 +1,73 @@
|
||||
package com.fr.design.formula; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.design.gui.itextfield.DictionaryTextField; |
||||
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> { |
||||
|
||||
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build("="); |
||||
|
||||
public FormulaTextField() { |
||||
} |
||||
|
||||
public FormulaTextField(int columns) { |
||||
super(columns); |
||||
} |
||||
|
||||
public FormulaTextField(String text, int columns, BaseFormula value) { |
||||
super(text, columns, value); |
||||
} |
||||
|
||||
public FormulaTextField(String text, BaseFormula value) { |
||||
super(text, value); |
||||
} |
||||
|
||||
public FormulaTextField(Document doc, String text, int columns, BaseFormula value) { |
||||
super(doc, text, columns, value); |
||||
} |
||||
|
||||
@Override |
||||
public BaseFormula getValue() { |
||||
|
||||
if (this.value == null) { |
||||
this.value = createDefault(); |
||||
} |
||||
return this.value; |
||||
} |
||||
|
||||
/** |
||||
* 设置值时,会将展示的公式值一同设置进去 |
||||
* |
||||
* @param value 公式值 |
||||
*/ |
||||
@Override |
||||
public void setValue(BaseFormula value) { |
||||
|
||||
this.value = value; |
||||
if (this.value == null) { |
||||
this.value = createDefault(); |
||||
} |
||||
setText(this.value.getPureContent()); |
||||
} |
||||
|
||||
private BaseFormula createDefault() { |
||||
|
||||
String text = getText(); |
||||
if (StringUtils.isNotEmpty(text)) { |
||||
return BaseFormula.createFormulaBuilder().build(text); |
||||
} else { |
||||
return EMPTY_FORMULA; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
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 { |
||||
|
||||
protected T value; |
||||
|
||||
public DictionaryTextField() { |
||||
} |
||||
|
||||
public DictionaryTextField(int columns) { |
||||
super(columns); |
||||
} |
||||
|
||||
public DictionaryTextField(String text, int columns, T value) { |
||||
super(text, columns); |
||||
this.value = value; |
||||
} |
||||
|
||||
public DictionaryTextField(String text, T value) { |
||||
super(text); |
||||
this.value = value; |
||||
} |
||||
|
||||
public DictionaryTextField(Document doc, String text, int columns, T value) { |
||||
super(doc, text, columns); |
||||
this.value = value; |
||||
} |
||||
|
||||
public T getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(T value) { |
||||
this.value = value; |
||||
} |
||||
} |
Loading…
Reference in new issue