Browse Source

Pull request #6214: REPORT-59545 设计器很多报错提示弹窗的交互有问题

Merge in DESIGN/design from ~FANGLEI/design10.0:release/11.0 to release/11.0

* commit '10a55919ae344a8f8ee7dada36d0f0d892785160':
  REPORT-60900 视觉切图提供的有点问题,找视觉更新了切图
  REPORT-59545 设计器很多报错提示弹窗的交互有问题
bugfix/11.0
fanglei 3 years ago
parent
commit
f46959d561
  1. 17
      designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java
  2. 11
      designer-base/src/main/java/com/fr/design/formula/FormulaCheckerException.java
  3. 60
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  4. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/simple_style_18.png

17
designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java

@ -25,7 +25,7 @@ public class FormulaChecker {
private static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula");
public static final String COLON = ":";
public static String check(String formulaText) {
public static String check(String formulaText) throws FormulaCheckerException {
StringReader in = new StringReader(formulaText);
FRLexer lexer = new FRLexer(in);
@ -34,12 +34,15 @@ public class FormulaChecker {
try {
Expression expression = parser.parse();
Node node = expression.getConditionalExpression();
return FunctionCheckerDispatcher.getInstance()
.getFunctionChecker(node)
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA;
boolean valid = FunctionCheckerDispatcher.getInstance().getFunctionChecker(node).checkFunction(node);
if (valid) {
return VALID_FORMULA;
} else {
throw new FormulaCheckerException(INVALID_FORMULA);
}
} catch (ConditionCheckWrongException cce) {
String functionName = cce.getFunctionName();
return functionName + Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + COLON;
throw new FormulaCheckerException(functionName + Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + COLON);
} catch (FunctionCheckWrongException ce) {
List<FunctionRule> rules = ce.getRules();
String functionName = ce.getFunctionName();
@ -60,10 +63,10 @@ public class FormulaChecker {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or"));
}
}
return errorMsg.toString();
throw new FormulaCheckerException(errorMsg.toString());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return INVALID_FORMULA;
throw new FormulaCheckerException(INVALID_FORMULA);
// alex:继续往下面走,expression为null时告知不合法公式
}
}

11
designer-base/src/main/java/com/fr/design/formula/FormulaCheckerException.java

@ -0,0 +1,11 @@
package com.fr.design.formula;
public class FormulaCheckerException extends Exception {
public FormulaCheckerException() {
}
public FormulaCheckerException(String message) {
super(message);
}
}

60
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -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 {

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/simple_style_18.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Loading…
Cancel
Save