|
|
@ -665,7 +665,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
.getFunctionChecker(node) |
|
|
|
.getFunctionChecker(node) |
|
|
|
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA; |
|
|
|
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA; |
|
|
|
} catch (ConditionCheckWrongException cce) { |
|
|
|
} catch (ConditionCheckWrongException cce) { |
|
|
|
List<FunctionRule> rules = cce.getRules(); |
|
|
|
|
|
|
|
String functionName = cce.getFunctionName(); |
|
|
|
String functionName = cce.getFunctionName(); |
|
|
|
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":"); |
|
|
|
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":"); |
|
|
|
return errorMsg.toString(); |
|
|
|
return errorMsg.toString(); |
|
|
@ -716,31 +715,39 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
String messageTips = getFormulaValidMessage(formulaText).equals(VALID_FORMULA) ? " " : getFormulaValidMessage(formulaText) + "\n"; |
|
|
|
String formulaValidMessage = getFormulaValidMessage(formulaText); |
|
|
|
Map<String, Object> paramsMap = setParamsIfExist(formulaText); |
|
|
|
if (formulaValidMessage.equals(INVALID_FORMULA)) { |
|
|
|
Calculator calculator = Calculator.createCalculator(); |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); |
|
|
|
FormulaPane.this, |
|
|
|
calculator.pushNameSpace(parameterMapNameSpace); |
|
|
|
formulaValidMessage, |
|
|
|
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); |
|
|
|
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance()); |
|
|
|
} else { |
|
|
|
TableDataSource tableDataSource = workBook.getReport(0).getTableDataSource(); |
|
|
|
String messageTips = formulaValidMessage.equals(VALID_FORMULA) ? "" : formulaValidMessage + "\n"; |
|
|
|
calculator.setAttribute(TableDataSource.KEY, tableDataSource); |
|
|
|
Map<String, Object> paramsMap = setParamsIfExist(formulaText); |
|
|
|
calculator.pushNameSpace(TableDataNameSpace.getInstance()); |
|
|
|
Calculator calculator = Calculator.createCalculator(); |
|
|
|
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); |
|
|
|
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); |
|
|
|
try { |
|
|
|
calculator.pushNameSpace(parameterMapNameSpace); |
|
|
|
Object value = calculator.evalValue(baseFormula); |
|
|
|
|
|
|
|
messageTips = messageTips + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + value; |
|
|
|
WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); |
|
|
|
FineLoggerFactory.getLogger().info("value:{}", value); |
|
|
|
calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance()); |
|
|
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
TableDataSource tableDataSource = workBook.getReport(0).getTableDataSource(); |
|
|
|
FineLoggerFactory.getLogger().error("", utilEvalError); |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|