diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java index ff8a74e57..2a903f1c2 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java @@ -20,8 +20,11 @@ import com.fr.grid.selection.CellSelection; import com.fr.quickeditor.CellQuickEditor; import com.fr.report.ReportHelper; import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; import com.fr.stable.StringUtils; +import com.fr.web.core.A.S; import javax.swing.BorderFactory; import javax.swing.JComponent; @@ -56,6 +59,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor { //默认值 private static final String DEFAULT_FORMULA = "="; + //正在编辑的单元格 + private TemplateCellElement editingCellElement; + private DocumentListener documentListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -102,9 +108,11 @@ public class CellFormulaQuickEditor extends CellQuickEditor { formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); formulaButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { - String text = formulaTextField.getText(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - formulaPane.populate(BaseFormula.createFormulaBuilder().build(text)); + CellSelection cellSelection = (CellSelection)tc.getSelection(); + editingCellElement = tc.getEditingElementCase().getTemplateCellElement(cellSelection.getColumn(),cellSelection.getRow()); + BaseFormula baseFormula = (BaseFormula) editingCellElement.getValue(); + formulaPane.populate(baseFormula); formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { @@ -113,8 +121,8 @@ public class CellFormulaQuickEditor extends CellQuickEditor { formulaTextField.setText(DEFAULT_FORMULA); } else { formulaTextField.setText(fm.getContent()); + editingCellElement.setValue(fm); } - } }).setVisible(true); }