|
|
@ -9,7 +9,6 @@ import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.formula.FormulaFactory; |
|
|
|
import com.fr.design.formula.FormulaFactory; |
|
|
|
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.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
@ -20,6 +19,7 @@ import com.fr.grid.selection.CellSelection; |
|
|
|
import com.fr.quickeditor.CellQuickEditor; |
|
|
|
import com.fr.quickeditor.CellQuickEditor; |
|
|
|
import com.fr.report.ReportHelper; |
|
|
|
import com.fr.report.ReportHelper; |
|
|
|
import com.fr.report.cell.DefaultTemplateCellElement; |
|
|
|
import com.fr.report.cell.DefaultTemplateCellElement; |
|
|
|
|
|
|
|
import com.fr.report.cell.TemplateCellElement; |
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
@ -56,6 +56,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor { |
|
|
|
//默认值
|
|
|
|
//默认值
|
|
|
|
private static final String DEFAULT_FORMULA = "="; |
|
|
|
private static final String DEFAULT_FORMULA = "="; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//正在编辑的单元格
|
|
|
|
|
|
|
|
private TemplateCellElement editingCellElement; |
|
|
|
|
|
|
|
|
|
|
|
private DocumentListener documentListener = new DocumentListener() { |
|
|
|
private DocumentListener documentListener = new DocumentListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
@ -102,19 +105,27 @@ public class CellFormulaQuickEditor extends CellQuickEditor { |
|
|
|
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); |
|
|
|
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); |
|
|
|
formulaButton.addActionListener(new ActionListener() { |
|
|
|
formulaButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
String text = formulaTextField.getText(); |
|
|
|
|
|
|
|
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); |
|
|
|
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); |
|
|
|
|
|
|
|
CellSelection cellSelection = (CellSelection) tc.getSelection(); |
|
|
|
|
|
|
|
editingCellElement = tc.getEditingElementCase().getTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); |
|
|
|
|
|
|
|
Object object = editingCellElement.getValue(); |
|
|
|
|
|
|
|
if (object instanceof BaseFormula) { |
|
|
|
|
|
|
|
formulaPane.populate((BaseFormula) object); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
String text = formulaTextField.getText(); |
|
|
|
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text)); |
|
|
|
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text)); |
|
|
|
|
|
|
|
} |
|
|
|
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
|
|
|
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
BaseFormula fm = formulaPane.update(); |
|
|
|
BaseFormula fm = formulaPane.update(); |
|
|
|
if (fm.getContent().length() <= 1) { |
|
|
|
if (fm.getContent().length() <= 1) { |
|
|
|
|
|
|
|
fm.setContent(DEFAULT_FORMULA); |
|
|
|
formulaTextField.setText(DEFAULT_FORMULA); |
|
|
|
formulaTextField.setText(DEFAULT_FORMULA); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
formulaTextField.setText(fm.getContent()); |
|
|
|
formulaTextField.setText(fm.getContent()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
editingCellElement.setValue(fm); |
|
|
|
} |
|
|
|
} |
|
|
|
}).setVisible(true); |
|
|
|
}).setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|