|
|
@ -12,6 +12,7 @@ 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; |
|
|
@ -645,6 +646,7 @@ 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; |
|
|
@ -719,11 +721,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); |
|
|
|
} |
|
|
|
} |
|
|
|
String sortFormula = dSColumn.getSortFormula(); |
|
|
|
BaseFormula baseFormula = dSColumn.getSortFormulaObject(); |
|
|
|
if (sortFormula != null && sortFormula.length() >= 1) { |
|
|
|
if (baseFormula == null) { |
|
|
|
this.formulaField.populate(sortFormula); |
|
|
|
this.formulaField.populateFormula(DEFAULT_FORMULA); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.formulaField.populate(DEFAULT_VALUE); |
|
|
|
this.formulaField.populateFormula(baseFormula); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -740,7 +742,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.setSortFormula(this.formulaField.getFormulaText()); |
|
|
|
dSColumn.setSortFormulaObject(this.formulaField.getFormula()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -774,6 +776,7 @@ 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; |
|
|
@ -918,8 +921,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.populate(DEFAULT_VALUE); |
|
|
|
this.topFormulaPane.populateFormula(DEFAULT_FORMULA); |
|
|
|
this.bottomFormulaPane.populate(DEFAULT_VALUE); |
|
|
|
this.bottomFormulaPane.populateFormula(DEFAULT_FORMULA); |
|
|
|
this.serialTextField.setText(StringUtils.EMPTY); |
|
|
|
this.serialTextField.setText(StringUtils.EMPTY); |
|
|
|
|
|
|
|
|
|
|
|
if (selectCount != null) { |
|
|
|
if (selectCount != null) { |
|
|
@ -927,7 +930,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.populate(selectCount.getFormulaCount()); |
|
|
|
this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); |
|
|
|
//前N个
|
|
|
|
//前N个
|
|
|
|
setCardPaneLayout.show(setCardPane, TOP.name()); |
|
|
|
setCardPaneLayout.show(setCardPane, TOP.name()); |
|
|
|
tipCardPaneLayout.show(tipCardPane, TOP.name()); |
|
|
|
tipCardPaneLayout.show(tipCardPane, TOP.name()); |
|
|
@ -938,7 +941,7 @@ public class CellDSColumnEditor extends CellQuickEditor { |
|
|
|
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); |
|
|
|
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case BOTTOM: |
|
|
|
case BOTTOM: |
|
|
|
this.bottomFormulaPane.populate(selectCount.getFormulaCount()); |
|
|
|
this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); |
|
|
|
//后N个
|
|
|
|
//后N个
|
|
|
|
setCardPaneLayout.show(setCardPane, BOTTOM.name()); |
|
|
|
setCardPaneLayout.show(setCardPane, BOTTOM.name()); |
|
|
|
tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); |
|
|
|
tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); |
|
|
@ -1019,9 +1022,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.setFormulaCount(this.topFormulaPane.getFormulaText()); |
|
|
|
selectCount.setFormulaObject(this.topFormulaPane.getFormula()); |
|
|
|
} else if (selectedFilterIndex == BOTTOM.getValue()) { |
|
|
|
} else if (selectedFilterIndex == BOTTOM.getValue()) { |
|
|
|
selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); |
|
|
|
selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); |
|
|
|
} else if (selectedFilterIndex == SPECIFY.getValue()) { |
|
|
|
} else if (selectedFilterIndex == SPECIFY.getValue()) { |
|
|
|
selectCount.setSerial(this.serialTextField.getText()); |
|
|
|
selectCount.setSerial(this.serialTextField.getText()); |
|
|
|
} |
|
|
|
} |
|
|
@ -1060,14 +1063,15 @@ public class CellDSColumnEditor extends CellQuickEditor { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class JFormulaField extends JPanel { |
|
|
|
public class JFormulaField extends JPanel { |
|
|
|
private CellElement cellElement; |
|
|
|
private CellElement cellElement; |
|
|
|
private UITextField formulaTextField; |
|
|
|
private FormulaTextField formulaTextField; |
|
|
|
private String defaultValue; |
|
|
|
private BaseFormula defaultFormula; |
|
|
|
|
|
|
|
|
|
|
|
public JFormulaField(String defaultValue) { |
|
|
|
public JFormulaField(String defaultValue) { |
|
|
|
|
|
|
|
|
|
|
|
this.defaultValue = defaultValue; |
|
|
|
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); |
|
|
|
formulaTextField = new UITextField(); |
|
|
|
formulaTextField = new FormulaTextField(); |
|
|
|
formulaTextField.setText(defaultValue); |
|
|
|
formulaTextField.setValue(defaultFormula); |
|
|
|
|
|
|
|
|
|
|
|
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)); |
|
|
@ -1094,6 +1098,16 @@ 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.setValue(baseFormula); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseFormula getFormula() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.formulaTextField.getValue(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 添加事件监听器 |
|
|
|
* 添加事件监听器 |
|
|
@ -1114,16 +1128,14 @@ 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(); |
|
|
|
|
|
|
|
String text = formulaTextField.getText(); |
|
|
|
BaseFormula valueFormula = formulaTextField.getValue(); |
|
|
|
if (text == null || text.length() <= 0) { |
|
|
|
if (valueFormula == null) { |
|
|
|
valueFormula.setContent(defaultValue); |
|
|
|
valueFormula = BaseFormula.createFormulaBuilder().build(); |
|
|
|
} else { |
|
|
|
|
|
|
|
valueFormula.setContent(text); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); |
|
|
|
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); |
|
|
|
if (cellElement != null) { |
|
|
|
if (cellElement != null) { |
|
|
|
Object value = cellElement.getValue(); |
|
|
|
final 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()); |
|
|
@ -1133,9 +1145,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) { |
|
|
|
formulaTextField.setText(defaultValue); |
|
|
|
formulaTextField.setValue(defaultFormula); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
formulaTextField.setText(valueFormula.getContent()); |
|
|
|
formulaTextField.setValue(valueFormula); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}).setVisible(true); |
|
|
|
}).setVisible(true); |
|
|
@ -1152,6 +1164,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; |
|
|
|
|
|
|
|
|
|
|
@ -1171,11 +1184,11 @@ public class CellDSColumnEditor extends CellQuickEditor { |
|
|
|
if (value instanceof DSColumn) { |
|
|
|
if (value instanceof DSColumn) { |
|
|
|
DSColumn dSColumn = (DSColumn) value; |
|
|
|
DSColumn dSColumn = (DSColumn) value; |
|
|
|
//formula
|
|
|
|
//formula
|
|
|
|
String valueFormula = dSColumn.getResult(); |
|
|
|
BaseFormula valueFormula = dSColumn.getResultObject(); |
|
|
|
if (valueFormula != null) { |
|
|
|
if (valueFormula != null) { |
|
|
|
formulaField.populate(valueFormula); |
|
|
|
formulaField.populateFormula(valueFormula); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
formulaField.populate(DEFAULT_VALUE); |
|
|
|
formulaField.populateFormula(DEFAULT_FORMULA); |
|
|
|
} |
|
|
|
} |
|
|
|
formulaField.populateElement(cellElement); |
|
|
|
formulaField.populateElement(cellElement); |
|
|
|
|
|
|
|
|
|
|
@ -1188,8 +1201,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.setResult(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? |
|
|
|
dSColumn.setResultObject(this.formulaField.getFormula()); |
|
|
|
null : this.formulaField.getFormulaText()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|