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