|
|
|
@ -650,12 +650,14 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
|
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
// Execute Formula default cell element.
|
|
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
|
String formulaValidMessage = FormulaChecker.check(formulaText); |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
FormulaPane.this, |
|
|
|
|
formulaValidMessage + ".", |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
JOptionPane.WARNING_MESSAGE); |
|
|
|
|
String formulaValidMessage; |
|
|
|
|
try { |
|
|
|
|
formulaValidMessage = FormulaChecker.check(formulaText); |
|
|
|
|
showMessageDialog(formulaValidMessage + "."); |
|
|
|
|
} catch (FormulaCheckerException e) { |
|
|
|
|
formulaValidMessage = e.getMessage(); |
|
|
|
|
showMessageDialog(formulaValidMessage + ".", false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -663,22 +665,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
|
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
|
String formulaValidMessage = FormulaChecker.check(formulaText); |
|
|
|
|
; |
|
|
|
|
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText); |
|
|
|
|
if (unSupportFormula != null) { |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
FormulaPane.this, |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
showMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String formulaValidMessage; |
|
|
|
|
boolean formulaValid; |
|
|
|
|
try { |
|
|
|
|
formulaValidMessage = FormulaChecker.check(formulaText); |
|
|
|
|
formulaValid = true; |
|
|
|
|
} catch (FormulaCheckerException formulaCheckerException) { |
|
|
|
|
formulaValidMessage = formulaCheckerException.getMessage(); |
|
|
|
|
formulaValid = false; |
|
|
|
|
} |
|
|
|
|
String messageTips; |
|
|
|
|
if (formulaValidMessage.equals(INVALID_FORMULA)) { |
|
|
|
|
if (ComparatorUtils.equals(formulaValidMessage, INVALID_FORMULA)) { |
|
|
|
|
messageTips = INVALID_FORMULA; |
|
|
|
|
} else { |
|
|
|
|
messageTips = formulaValidMessage.equals(VALID_FORMULA) ? "" : formulaValidMessage + "\n"; |
|
|
|
|
messageTips = ComparatorUtils.equals(formulaValidMessage, VALID_FORMULA) ? "" : formulaValidMessage + "\n"; |
|
|
|
|
Map<String, Object> paramsMap = setParamsIfExist(formulaText); |
|
|
|
|
Calculator calculator = Calculator.createCalculator(); |
|
|
|
|
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); |
|
|
|
@ -699,19 +705,33 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
|
|
|
|
|
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? |
|
|
|
|
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; |
|
|
|
|
messageTips = messageTips + |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; |
|
|
|
|
FineLoggerFactory.getLogger().info("value:{}", value); |
|
|
|
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
|
FineLoggerFactory.getLogger().error("", utilEvalError); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
showMessageDialog(messageTips, formulaValid); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
private void showMessageDialog(String message) { |
|
|
|
|
showMessageDialog(message, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void showMessageDialog(String message, boolean formulaValid) { |
|
|
|
|
if (formulaValid) { |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
FormulaPane.this, |
|
|
|
|
message); |
|
|
|
|
} else { |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
FormulaPane.this, |
|
|
|
|
messageTips, |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
message, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
JOptionPane.WARNING_MESSAGE); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String containsUnsupportedSimulationFormulas(String formulaText) { |
|
|
|
|
try { |
|
|
|
|