Browse Source

REPORT-60163 公式编辑器优化2.0

1.修改一些测试问题
feature/x
Hoky 3 years ago
parent
commit
d8140ae8c2
  1. 4
      designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java
  2. 13
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/formula/exception/FormulaExceptionTipsProcessor.java
  4. 8
      designer-base/src/main/java/com/fr/design/formula/exception/function/FormulaCheckWrongFunction.java
  5. 4
      designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedCharFunction.java
  6. 4
      designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedTokenFunction.java
  7. 4
      designer-base/src/main/java/com/fr/design/formula/exception/function/NoViableAltForCharFunction.java
  8. 4
      designer-base/src/main/java/com/fr/design/formula/exception/function/NoViableAltFunction.java
  9. 2
      designer-base/src/main/java/com/fr/design/gui/autocomplete/FormulaAutoCompletePopupWindow.java

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

@ -25,7 +25,7 @@ public class FormulaChecker {
public static FormulaCheckResult check(String formulaText) { public static FormulaCheckResult check(String formulaText) {
if (StringUtils.isEmpty(formulaText) || formulaText.equals(Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Tips"))) { if (StringUtils.isEmpty(formulaText) || formulaText.equals(Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Tips"))) {
return new FormulaCheckResult(true, VALID_FORMULA, FormulaCoordinates.INVALID); return new FormulaCheckResult(true, VALID_FORMULA, FormulaCoordinates.INVALID, true);
} }
//过滤一些空格等符号 //过滤一些空格等符号
StringReader in = new StringReader(formulaText); StringReader in = new StringReader(formulaText);
@ -37,7 +37,7 @@ public class FormulaChecker {
Node node = expression.getConditionalExpression(); Node node = expression.getConditionalExpression();
boolean valid = FunctionCheckerDispatcher.getInstance().getFunctionChecker(node).checkFunction(formulaText, node); boolean valid = FunctionCheckerDispatcher.getInstance().getFunctionChecker(node).checkFunction(formulaText, node);
return new FormulaCheckResult(valid, valid ? Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : return new FormulaCheckResult(valid, valid ? Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") :
Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"), FormulaCoordinates.INVALID); Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"), FormulaCoordinates.INVALID, true);
} catch (Exception e) { } catch (Exception e) {
if (e instanceof TokenStreamRecognitionException) { if (e instanceof TokenStreamRecognitionException) {
return processor.getExceptionTips(((TokenStreamRecognitionException) e).recog); return processor.getExceptionTips(((TokenStreamRecognitionException) e).recog);

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

@ -387,7 +387,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
completionProvider.addCompletion(new FormulaCompletion(completionProvider, paramWithoutPre, BaseUtils.readIcon(PARAM_ICON))); completionProvider.addCompletion(new FormulaCompletion(completionProvider, paramWithoutPre, BaseUtils.readIcon(PARAM_ICON)));
} }
completionProvider.addCompletion(new FormulaCompletion(completionProvider, "$$$", BaseUtils.readIcon(PARAM_ICON)));
return completionProvider; return completionProvider;
} }
@ -787,7 +786,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
// Execute Formula default cell element. // Execute Formula default cell element.
String formulaText = formulaTextArea.getText().trim(); String formulaText = formulaTextArea.getText().trim();
FormulaCheckResult checkResult = FormulaChecker.check(formulaText); FormulaCheckResult checkResult = FormulaChecker.check(formulaText);
confirmCheckResult(checkResult); confirmCheckResult(checkResult, checkResult.getTips());
} }
}; };
@ -804,7 +803,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
String messageTips; String messageTips;
FormulaCheckResult checkResult = FormulaChecker.check(formulaText); FormulaCheckResult checkResult = FormulaChecker.check(formulaText);
if (checkResult.isValid()) { if (checkResult.grammarValid()) {
messageTips = checkResult.getTips() + NEWLINE; messageTips = checkResult.getTips() + NEWLINE;
Map<String, Object> paramsMap = setParamsIfExist(formulaText); Map<String, Object> paramsMap = setParamsIfExist(formulaText);
Calculator calculator = Calculator.createCalculator(); Calculator calculator = Calculator.createCalculator();
@ -836,12 +835,12 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (checkResult.isValid()) { if (checkResult.isValid()) {
showMessageDialog(messageTips, checkResult.isValid()); showMessageDialog(messageTips, checkResult.isValid());
} else { } else {
confirmCheckResult(checkResult); confirmCheckResult(checkResult, messageTips);
} }
} }
}; };
private boolean confirmCheckResult(FormulaCheckResult checkResult) { private boolean confirmCheckResult(FormulaCheckResult checkResult, String messageTips) {
if (checkResult.isValid()) { if (checkResult.isValid()) {
showMessageDialog(checkResult.getTips(), checkResult.isValid()); showMessageDialog(checkResult.getTips(), checkResult.isValid());
} else { } else {
@ -849,7 +848,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
+ Toolkit.i18nText("Fine-Design_Basic_Formula_Error_Position") + " "; + Toolkit.i18nText("Fine-Design_Basic_Formula_Error_Position") + " ";
int confirmDialog = FineJOptionPane.showConfirmDialog( int confirmDialog = FineJOptionPane.showConfirmDialog(
FormulaPane.this, FormulaPane.this,
position + checkResult.getTips(), position + messageTips,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, JOptionPane.WARNING_MESSAGE,
@ -902,7 +901,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
String formula = formulaTextArea.getText().trim(); String formula = formulaTextArea.getText().trim();
FormulaCheckResult checkResult = FormulaChecker.check(formula); FormulaCheckResult checkResult = FormulaChecker.check(formula);
if (!checkResult.isValid()) { if (!checkResult.isValid()) {
return confirmCheckResult(checkResult); return confirmCheckResult(checkResult, checkResult.getTips());
} }
} }
return true; return true;

2
designer-base/src/main/java/com/fr/design/formula/exception/FormulaExceptionTipsProcessor.java

@ -38,7 +38,7 @@ public class FormulaExceptionTipsProcessor {
public FormulaCheckResult getExceptionTips(Exception e) { public FormulaCheckResult getExceptionTips(Exception e) {
return EXCEPTION_TIPS.getOrDefault(e.getClass(), return EXCEPTION_TIPS.getOrDefault(e.getClass(),
e1 -> new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID)) e1 -> new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false))
.apply(e); .apply(e);
} }

8
designer-base/src/main/java/com/fr/design/formula/exception/function/FormulaCheckWrongFunction.java

@ -41,9 +41,9 @@ public class FormulaCheckWrongFunction implements Function<Exception, FormulaChe
errorMsg.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or")); errorMsg.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or"));
} }
} }
return new FormulaCheckResult(false, errorMsg.toString(), new FormulaCoordinates(1, indexPosition(ce.getFormulaText(), ce.getNode().toString()))); return new FormulaCheckResult(false, errorMsg.toString(), new FormulaCoordinates(1, indexPosition(ce.getFormulaText(), ce.getNode().toString())), true);
} }
return new FormulaCheckResult(false, StringUtils.EMPTY, new FormulaCoordinates(-1, -1)); return new FormulaCheckResult(false, StringUtils.EMPTY, new FormulaCoordinates(-1, -1), true);
} }
private static String getTypeString(FunctionParameterType type) { private static String getTypeString(FunctionParameterType type) {
@ -69,6 +69,10 @@ public class FormulaCheckWrongFunction implements Function<Exception, FormulaChe
} }
private int indexPosition(String formulaText, String invalidFormula) { private int indexPosition(String formulaText, String invalidFormula) {
//处理一下自己FunctionCall自己拼的逗号逻辑
if (invalidFormula.contains(",")) {
invalidFormula = invalidFormula.substring(0, invalidFormula.indexOf(","));
}
return formulaText.indexOf(invalidFormula); return formulaText.indexOf(invalidFormula);
} }
} }

4
designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedCharFunction.java

@ -20,9 +20,9 @@ public class MismatchedCharFunction implements Function<Exception, FormulaCheckR
if (e instanceof MismatchedCharException) { if (e instanceof MismatchedCharException) {
MismatchedCharException charException = (MismatchedCharException) e; MismatchedCharException charException = (MismatchedCharException) e;
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1);
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates); return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false);
} }
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID); return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false);
} }
public static Function<Exception, FormulaCheckResult> getFunction() { public static Function<Exception, FormulaCheckResult> getFunction() {

4
designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedTokenFunction.java

@ -24,9 +24,9 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
if (e instanceof MismatchedTokenException) { if (e instanceof MismatchedTokenException) {
MismatchedTokenException charException = (MismatchedTokenException) e; MismatchedTokenException charException = (MismatchedTokenException) e;
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1);
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates); return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false);
} }
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID); return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false);
} }
public static Function<Exception, FormulaCheckResult> getFunction() { public static Function<Exception, FormulaCheckResult> getFunction() {

4
designer-base/src/main/java/com/fr/design/formula/exception/function/NoViableAltForCharFunction.java

@ -20,9 +20,9 @@ public class NoViableAltForCharFunction implements Function<Exception, FormulaCh
if (e instanceof NoViableAltForCharException) { if (e instanceof NoViableAltForCharException) {
NoViableAltForCharException charException = (NoViableAltForCharException) e; NoViableAltForCharException charException = (NoViableAltForCharException) e;
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1);
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates); return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false);
} }
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID); return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false);
} }
public static Function<Exception, FormulaCheckResult> getFunction() { public static Function<Exception, FormulaCheckResult> getFunction() {

4
designer-base/src/main/java/com/fr/design/formula/exception/function/NoViableAltFunction.java

@ -21,9 +21,9 @@ public class NoViableAltFunction implements Function<Exception, FormulaCheckResu
if (e instanceof NoViableAltException) { if (e instanceof NoViableAltException) {
NoViableAltException altException = (NoViableAltException) e; NoViableAltException altException = (NoViableAltException) e;
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(altException.line, altException.column - 1); FormulaCoordinates formulaCoordinates = new FormulaCoordinates(altException.line, altException.column - 1);
return new FormulaCheckResult(false, getMessage(altException), formulaCoordinates); return new FormulaCheckResult(false, getMessage(altException), formulaCoordinates, false);
} }
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID); return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false);
} }
public static Function<Exception, FormulaCheckResult> getFunction() { public static Function<Exception, FormulaCheckResult> getFunction() {

2
designer-base/src/main/java/com/fr/design/gui/autocomplete/FormulaAutoCompletePopupWindow.java

@ -371,7 +371,7 @@ class FormulaAutoCompletePopupWindow extends JWindow implements CaretListener,
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) { if (e.getClickCount() == 2 && e.getButton() == 1) {
insertSelectedCompletion(); insertSelectedCompletion();
refreshInstallComp(); refreshInstallComp();
} else if (e.getClickCount() == 1) { } else if (e.getClickCount() == 1) {

Loading…
Cancel
Save