From b24ab29cd62d587fe00af701b358340424a71dff Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Wed, 18 Aug 2021 17:28:40 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-54887=20=E5=85=AC=E5=BC=8F=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E4=BC=98=E5=8C=96=E4=B8=80=E6=9C=9F=201.?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=EF=BC=9B=202.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=8F=90=E7=A4=BA=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 495a91de2..47c84ecbf 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -665,7 +665,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { .getFunctionChecker(node) .checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA; } catch (ConditionCheckWrongException cce) { - List rules = cce.getRules(); String functionName = cce.getFunctionName(); StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":"); return errorMsg.toString(); @@ -716,31 +715,39 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { @Override public void actionPerformed(ActionEvent e) { String formulaText = formulaTextArea.getText().trim(); - String messageTips = getFormulaValidMessage(formulaText).equals(VALID_FORMULA) ? " " : getFormulaValidMessage(formulaText) + "\n"; - Map paramsMap = setParamsIfExist(formulaText); - Calculator calculator = Calculator.createCalculator(); - ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); - calculator.pushNameSpace(parameterMapNameSpace); - - WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); - calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance()); - TableDataSource tableDataSource = workBook.getReport(0).getTableDataSource(); - calculator.setAttribute(TableDataSource.KEY, tableDataSource); - calculator.pushNameSpace(TableDataNameSpace.getInstance()); - BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); - try { - Object value = calculator.evalValue(baseFormula); - messageTips = messageTips + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + value; - FineLoggerFactory.getLogger().info("value:{}", value); - } catch (UtilEvalError utilEvalError) { - FineLoggerFactory.getLogger().error("", utilEvalError); + String formulaValidMessage = getFormulaValidMessage(formulaText); + if (formulaValidMessage.equals(INVALID_FORMULA)) { + FineJOptionPane.showMessageDialog( + FormulaPane.this, + formulaValidMessage, + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE); + } else { + String messageTips = formulaValidMessage.equals(VALID_FORMULA) ? "" : formulaValidMessage + "\n"; + Map paramsMap = setParamsIfExist(formulaText); + Calculator calculator = Calculator.createCalculator(); + ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); + calculator.pushNameSpace(parameterMapNameSpace); + + WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); + calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance()); + TableDataSource tableDataSource = workBook.getReport(0).getTableDataSource(); + calculator.setAttribute(TableDataSource.KEY, tableDataSource); + calculator.pushNameSpace(TableDataNameSpace.getInstance()); + BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); + try { + Object value = calculator.evalValue(baseFormula); + messageTips = messageTips + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + value; + FineLoggerFactory.getLogger().info("value:{}", value); + } catch (UtilEvalError utilEvalError) { + FineLoggerFactory.getLogger().error("", utilEvalError); + } + FineJOptionPane.showMessageDialog( + FormulaPane.this, + messageTips, + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE); } - FineJOptionPane.showMessageDialog( - FormulaPane.this, - messageTips, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.INFORMATION_MESSAGE); - } };