Browse Source

Merge pull request #2117 in DESIGN/design from release/10.0 to bugfix/10.0

* commit '2bbc66984ff58151ff98131d9f1f44480d3f390d':
  回滚代码, 现有逻辑不支持功能
  REPORT-36306 linux设计器改成跳转到平台的插件管理
bugfix/10.0
superman 4 years ago
parent
commit
dfc926ef20
  1. 99
      designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java
  2. 25
      designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java
  3. 45
      designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java
  4. 4
      designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java
  5. 28
      designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java
  6. 84
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  7. 74
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

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

@ -1,99 +0,0 @@
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 String EMPTY_STRING = "=";
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();
}
//保持联动
linkValueByText();
return value;
}
private void linkValueByText() {
String content = getText();
this.value.setContent(content);
}
/**
* 设置值时会将展示的公式值一同设置进去
*
* @param value 公式值
*/
@Override
public void setValue(BaseFormula value) {
if (value == null) {
value = createDefault();
}
this.value = value;
}
/**
* 是需要设置不带 = 还是带 =
*
* @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() {
String text = getText();
if (StringUtils.isNotEmpty(text)) {
return BaseFormula.createFormulaBuilder().build(text);
} else {
//防止默认值被修改, 每一次创建都是不一样的。
return BaseFormula.createFormulaBuilder().build(EMPTY_STRING);
}
}
}

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

@ -7,13 +7,12 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.SortOrderComboBox; import com.fr.design.gui.icombobox.SortOrderComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.SwingUtilities; import java.awt.*;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -21,7 +20,7 @@ public abstract class SortFormulaPane extends JPanel {
protected static final String InsetText = " "; protected static final String InsetText = " ";
protected SortOrderComboBox sortOrderComboBox; protected SortOrderComboBox sortOrderComboBox;
protected FormulaTextField sortFormulaTextField; protected UITextField sortFormulaTextField;
// 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮 // 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮
protected UIButton sortFormulaTextFieldButton; protected UIButton sortFormulaTextFieldButton;
@ -36,7 +35,7 @@ public abstract class SortFormulaPane extends JPanel {
} }
}); });
sortFormulaTextField = new FormulaTextField(16); sortFormulaTextField = new UITextField(16);
//Lance:添加一公式编辑器按钮 //Lance:添加一公式编辑器按钮
sortFormulaTextFieldButton = new UIButton("..."); sortFormulaTextFieldButton = new UIButton("...");
sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "..."); sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "...");
@ -56,15 +55,17 @@ public abstract class SortFormulaPane extends JPanel {
public abstract void formulaAction(); public abstract void formulaAction();
public void showFormulaDialog(String[] displayNames) { public void showFormulaDialog(String[] displayNames) {
BaseFormula value = sortFormulaTextField.getValue(); String text = sortFormulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(value, new CustomVariableResolver(displayNames, true)); formulaPane.populate(BaseFormula.createFormulaBuilder().build(text), new CustomVariableResolver(displayNames, true));
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this), formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this),
new DialogActionAdapter() { new DialogActionAdapter() {
public void doOk() { public void doOk() {
BaseFormula fm = formulaPane.update(); BaseFormula fm = formulaPane.update();
if (fm != null) { if (fm.getContent().length() <= 1) {
sortFormulaTextField.setValueAndText(fm, true); sortFormulaTextField.setText("");
} else {
sortFormulaTextField.setText(fm.getContent().substring(1));
} }
} }
}).setVisible(true); }).setVisible(true);

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

@ -1,45 +0,0 @@
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;
}
}

4
designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java

@ -17,11 +17,11 @@ public class PMDialogAction implements OSBasedAction {
private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; private static String PLUGIN_MANAGER_ROUTE = "#management/plugin";
@Override @Override
public void execute(Object... objects) { public void execute(Object... objects) {
if(Arch.getArch() == Arch.ARM){ if(Arch.getArch() == Arch.ARM || OperatingSystem.isLinux()){
DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null);
return; return;
} }
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && !OperatingSystem.isLinux()) { if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) {
UpmFinder.showUPMDialog(); UpmFinder.showUPMDialog();
} else { } else {
WebViewDlgHelper.createPluginDialog(); WebViewDlgHelper.createPluginDialog();

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

@ -1,28 +0,0 @@
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());
}
}

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

@ -7,7 +7,6 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.FormulaTextField;
import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.SortFormulaPane;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -26,17 +25,8 @@ import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.report.cell.cellattr.core.group.SelectCount;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.Box; import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -231,7 +221,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
@ -248,7 +238,7 @@ public class DSColumnAdvancedPane extends BasicPane {
this.cellElement = cellElement; this.cellElement = cellElement;
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
@ -256,8 +246,8 @@ public class DSColumnAdvancedPane extends BasicPane {
int sort = dSColumn.getOrder(); int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
BaseFormula sortFormulaObject = dSColumn.getSortFormulaObject(); String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setValueAndText(sortFormulaObject, true); sortFormulaTextField.setText(sortFormula);
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
@ -273,7 +263,15 @@ public class DSColumnAdvancedPane extends BasicPane {
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula //lance:sort formula
dSColumn.setSortFormulaObject(sortFormulaTextField.getValue()); String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
} }
} }
@ -369,9 +367,9 @@ public class DSColumnAdvancedPane extends BasicPane {
int selectCountType = selectCount.getType(); int selectCountType = selectCount.getType();
this.selectCountComboBox.setSelectedIndex(selectCountType); this.selectCountComboBox.setSelectedIndex(selectCountType);
if (selectCountType == TOP.getValue()) { if (selectCountType == TOP.getValue()) {
this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); this.topFormulaPane.populate(selectCount.getFormulaCount());
} else if (selectCountType == BOTTOM.getValue()) { } else if (selectCountType == BOTTOM.getValue()) {
this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); this.bottomFormulaPane.populate(selectCount.getFormulaCount());
} else if (selectCountType == SPECIFY.getValue()) { } else if (selectCountType == SPECIFY.getValue()) {
this.serialTextField.setText(selectCount.getSerial()); this.serialTextField.setText(selectCount.getSerial());
} }
@ -397,9 +395,9 @@ public class DSColumnAdvancedPane extends BasicPane {
dSColumn.setSelectCount(selectCount); dSColumn.setSelectCount(selectCount);
selectCount.setType(selectCountSelectIndex); selectCount.setType(selectCountSelectIndex);
if (selectCountSelectIndex == TOP.getValue()) { if (selectCountSelectIndex == TOP.getValue()) {
selectCount.setFormulaObject(this.topFormulaPane.getFormula()); selectCount.setFormulaCount(this.topFormulaPane.getFormulaText());
} else if (selectCountSelectIndex == BOTTOM.getValue()) { } else if (selectCountSelectIndex == BOTTOM.getValue()) {
selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText());
} else if (selectCountSelectIndex == SPECIFY.getValue()) { } else if (selectCountSelectIndex == SPECIFY.getValue()) {
selectCount.setSerial(this.serialTextField.getText()); selectCount.setSerial(this.serialTextField.getText());
} }
@ -409,7 +407,7 @@ 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 UITextField formulaTextField;
private String defaultValue; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
@ -419,10 +417,9 @@ public class DSColumnAdvancedPane extends BasicPane {
UILabel bottomLabel = new UILabel("="); UILabel bottomLabel = new UILabel("=");
bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12));
this.add(bottomLabel); this.add(bottomLabel);
formulaTextField = new FormulaTextField(24); formulaTextField = new UITextField(24);
this.add(formulaTextField); this.add(formulaTextField);
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue); formulaTextField.setText(defaultValue);
formulaTextField.setValueAndText(defaultFormula, true);
UIButton bottomFrmulaButton = new UIButton("..."); UIButton bottomFrmulaButton = new UIButton("...");
this.add(bottomFrmulaButton); this.add(bottomFrmulaButton);
@ -442,24 +439,16 @@ public class DSColumnAdvancedPane extends BasicPane {
public String getFormulaText() { public String getFormulaText() {
return this.formulaTextField.getText(); return this.formulaTextField.getText();
} }
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValueAndText(baseFormula, true);
}
public BaseFormula getFormula() {
return this.formulaTextField.getValue();
}
private ActionListener formulaButtonActionListener = new ActionListener() { private ActionListener formulaButtonActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
BaseFormula valueFormula = formulaTextField.getValue(); String text = formulaTextField.getText();
if (valueFormula == null) { if (text == null || text.length() <= 0) {
valueFormula = BaseFormula.createFormulaBuilder().build(); valueFormula.setContent(defaultValue);
} else {
valueFormula.setContent(text);
} }
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
@ -468,7 +457,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dsColumn = (DSColumn) value; DSColumn dsColumn = (DSColumn) value;
@ -481,10 +470,9 @@ 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.setText(defaultValue);
formulaTextField.setValueAndText(defaultFormula, true);
} else { } else {
formulaTextField.setValueAndText(valueFormula, true); formulaTextField.setText(valueFormula.getContent().substring(1));
} }
} }
}).setVisible(true); }).setVisible(true);
@ -515,12 +503,12 @@ public class DSColumnAdvancedPane extends BasicPane {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
//formula //formula
BaseFormula valueFormula = dSColumn.getResultObject(); String valueFormula = dSColumn.getResult();
if (valueFormula == null) { if (valueFormula == null) {
valueFormula = BaseFormula.createFormulaBuilder().build("$$$"); valueFormula = "$$$";
} }
formulaField.populateElement(cellElement); formulaField.populateElement(cellElement);
formulaField.populateFormula(valueFormula); formulaField.populate(valueFormula);
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
@ -528,13 +516,13 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dSColumn = (DSColumn) (cellElement.getValue()); DSColumn dSColumn = (DSColumn) (cellElement.getValue());
//formula //formula
dSColumn.setResultObject(this.formulaField.getFormula()); dSColumn.setResult(this.formulaField.getFormulaText());
} }
} }

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

@ -12,7 +12,6 @@ import com.fr.design.dscolumn.SelectedDataColumnPane;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.FormulaTextField;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
@ -720,12 +719,11 @@ public class CellDSColumnEditor extends CellQuickEditor {
centerPane.setPreferredSize(new Dimension(156, 20)); centerPane.setPreferredSize(new Dimension(156, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
} }
BaseFormula baseFormula = dSColumn.getSortFormulaObject(); String sortFormula = dSColumn.getSortFormula();
if (baseFormula == null) { if (sortFormula != null && sortFormula.length() >= 1) {
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(); this.formulaField.populate(sortFormula);
this.formulaField.populateFormula(defaultFormula);
} else { } else {
this.formulaField.populateFormula(baseFormula); this.formulaField.populate(DEFAULT_VALUE);
} }
} }
} }
@ -742,7 +740,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); dSColumn.setOrder(this.sortTypePane.getSelectedIndex());
dSColumn.setSortFormulaObject(this.formulaField.getFormula()); dSColumn.setSortFormula(this.formulaField.getFormulaText());
} }
} }
} }
@ -776,7 +774,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class ResultSetFilterConfigPane extends JPanel { public class ResultSetFilterConfigPane 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 JPanel contentPane; private JPanel contentPane;
private UIComboBox rsComboBox; private UIComboBox rsComboBox;
@ -921,8 +918,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout();
CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout();
// 重置默认值 // 重置默认值
this.topFormulaPane.populateFormula(DEFAULT_FORMULA); this.topFormulaPane.populate(DEFAULT_VALUE);
this.bottomFormulaPane.populateFormula(DEFAULT_FORMULA); this.bottomFormulaPane.populate(DEFAULT_VALUE);
this.serialTextField.setText(StringUtils.EMPTY); this.serialTextField.setText(StringUtils.EMPTY);
if (selectCount != null) { if (selectCount != null) {
@ -930,7 +927,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
this.rsComboBox.setSelectedIndex(selectCountType); this.rsComboBox.setSelectedIndex(selectCountType);
switch (FilterTypeEnum.getFilterByValue(selectCountType)) { switch (FilterTypeEnum.getFilterByValue(selectCountType)) {
case TOP: case TOP:
this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); this.topFormulaPane.populate(selectCount.getFormulaCount());
//前N个 //前N个
setCardPaneLayout.show(setCardPane, TOP.name()); setCardPaneLayout.show(setCardPane, TOP.name());
tipCardPaneLayout.show(tipCardPane, TOP.name()); tipCardPaneLayout.show(tipCardPane, TOP.name());
@ -941,7 +938,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0);
break; break;
case BOTTOM: case BOTTOM:
this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); this.bottomFormulaPane.populate(selectCount.getFormulaCount());
//后N个 //后N个
setCardPaneLayout.show(setCardPane, BOTTOM.name()); setCardPaneLayout.show(setCardPane, BOTTOM.name());
tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, BOTTOM.name());
@ -1022,9 +1019,9 @@ public class CellDSColumnEditor extends CellQuickEditor {
dSColumn.setSelectCount(selectCount); dSColumn.setSelectCount(selectCount);
//noinspection Duplicates //noinspection Duplicates
if (selectedFilterIndex == TOP.getValue()) { if (selectedFilterIndex == TOP.getValue()) {
selectCount.setFormulaObject(this.topFormulaPane.getFormula()); selectCount.setFormulaCount(this.topFormulaPane.getFormulaText());
} else if (selectedFilterIndex == BOTTOM.getValue()) { } else if (selectedFilterIndex == BOTTOM.getValue()) {
selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText());
} else if (selectedFilterIndex == SPECIFY.getValue()) { } else if (selectedFilterIndex == SPECIFY.getValue()) {
selectCount.setSerial(this.serialTextField.getText()); selectCount.setSerial(this.serialTextField.getText());
} }
@ -1063,16 +1060,14 @@ 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 UITextField formulaTextField;
private String defaultValue; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue); formulaTextField = new UITextField();
formulaTextField = new FormulaTextField(); formulaTextField.setText(defaultValue);
formulaTextField.setValueAndText(defaultFormula, false);
JPanel textFieldPane = new JPanel(new BorderLayout()); JPanel textFieldPane = new JPanel(new BorderLayout());
textFieldPane.add(formulaTextField, BorderLayout.CENTER); textFieldPane.add(formulaTextField, BorderLayout.CENTER);
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
@ -1099,16 +1094,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public String getFormulaText() { public String getFormulaText() {
return this.formulaTextField.getText().trim(); return this.formulaTextField.getText().trim();
} }
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValueAndText(baseFormula, false);
}
public BaseFormula getFormula() {
return this.formulaTextField.getValue();
}
/** /**
* 添加事件监听器 * 添加事件监听器
@ -1129,14 +1114,16 @@ public class CellDSColumnEditor extends CellQuickEditor {
private ActionListener formulaButtonActionListener = new ActionListener() { private ActionListener formulaButtonActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
BaseFormula valueFormula = formulaTextField.getValue(); String text = formulaTextField.getText();
if (valueFormula == null) { if (text == null || text.length() <= 0) {
valueFormula = BaseFormula.createFormulaBuilder().build(); valueFormula.setContent(defaultValue);
} else {
valueFormula.setContent(text);
} }
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
if (cellElement != null) { if (cellElement != null) {
final Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dsColumn = (DSColumn) value; DSColumn dsColumn = (DSColumn) value;
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName());
@ -1146,10 +1133,9 @@ 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.setText(defaultValue);
formulaTextField.setValueAndText(defaultFormula, false);
} else { } else {
formulaTextField.setValueAndText(valueFormula, false); formulaTextField.setText(valueFormula.getContent());
} }
} }
}).setVisible(true); }).setVisible(true);
@ -1166,7 +1152,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 JFormulaField formulaField; private JFormulaField formulaField;
public CustomValuePane() { public CustomValuePane() {
@ -1185,12 +1171,11 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
//formula //formula
BaseFormula valueFormula = dSColumn.getResultObject(); String valueFormula = dSColumn.getResult();
if (valueFormula != null) { if (valueFormula != null) {
formulaField.populateFormula(valueFormula); formulaField.populate(valueFormula);
} else { } else {
BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); formulaField.populate(DEFAULT_VALUE);
formulaField.populateFormula(defaultFormula);
} }
formulaField.populateElement(cellElement); formulaField.populateElement(cellElement);
@ -1203,7 +1188,8 @@ 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(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? null : this.formulaField.getFormula()); dSColumn.setResult(StringUtils.isEmpty(this.formulaField.getFormulaText()) ?
null : this.formulaField.getFormulaText());
} }
} }
} }

Loading…
Cancel
Save