diff --git a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java index 82536e887..4e2a7cbb0 100644 --- a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java @@ -6,24 +6,39 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; import com.fr.base.Formula; +import com.fr.design.actions.ElementCaseAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.UIFormula; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; +import com.fr.design.report.SelectImagePane; import com.fr.general.Inter; import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; +import com.fr.report.cell.cellattr.CellImage; import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.CoreGraphHelper; +import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; +import java.io.File; /** * Insert formula. */ -public class FormulaFloatAction extends AbstractShapeAction { +public class FormulaFloatAction extends ElementCaseAction { + + private boolean returnValue = false; + public FormulaFloatAction(ElementCasePane t) { super(t); this.setMenuKeySet(FLOAT_INSERT_FORMULA); @@ -49,23 +64,6 @@ public class FormulaFloatAction extends AbstractShapeAction { } }; - /** - * 动作 - * - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - ElementCasePane jws = getEditingComponent(); - if (jws == null) { - return; - } - // - FloatElement floatElement = new FloatElement(new Formula("")); - this.startDraw(floatElement); - doWithDrawingFloatElement(); - jws.getGrid().startEditing(); - } - private void doWithDrawingFloatElement() { ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); Grid grid = jws.getGrid(); @@ -95,4 +93,43 @@ public class FormulaFloatAction extends AbstractShapeAction { reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); } + /** + * 执行动作 + * + * @return 成功返回true + */ + @Override + public boolean executeActionReturnUndoRecordNeeded() { + final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (reportPane == null) { + return false; + } + + reportPane.stopEditing(); + final FloatElement floatElement = new FloatElement(); + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(new Formula(StringUtils.EMPTY)); + + BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + floatElement.setValue(formulaPane.update()); + if (reportPane == null) { + return; + } + reportPane.getGrid().setDrawingFloatElement(floatElement); + doWithDrawingFloatElement(); + returnValue = true; + } + + @Override + public void doCancel() { + returnValue = false; + } + }); + dialog.setVisible(true); + return returnValue; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java index 9548db51c..6001e2e72 100644 --- a/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java @@ -54,6 +54,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { * * @param e 动作 */ + @Override public void actionPerformed(ActionEvent e) { ElementCasePane jws = getEditingComponent(); if (jws == null) { @@ -67,7 +68,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { private void doWithDrawingFloatElement() { ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - ; + Grid grid = jws.getGrid(); ElementCasePane reportPane = grid.getElementCasePane(); @@ -93,5 +94,6 @@ public class TextBoxFloatAction extends AbstractShapeAction { report.addFloatElement(grid.getDrawingFloatElement()); reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); + reportPane.fireTargetModified(); } } \ No newline at end of file