|
|
|
@ -6,12 +6,15 @@ import com.fr.design.gui.icontainer.UIScrollPane;
|
|
|
|
|
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.parser.FRLexer; |
|
|
|
|
import com.fr.parser.FRParser; |
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
import com.fr.solution.plugin.design.formula.ui.evt.OperateListener; |
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.script.Expression; |
|
|
|
|
import com.fr.third.antlr.ANTLRException; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
@ -304,20 +307,14 @@ public abstract class BaseFormulaPane<T extends BaseFormula> extends FurtherBasi
|
|
|
|
|
public void checkContentValid() { |
|
|
|
|
// Execute Formula default cell element.
|
|
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
|
|
|
|
|
|
if (formulaText != null && formulaText.length() > 0) { |
|
|
|
|
StringReader in = new StringReader(formulaText); |
|
|
|
|
|
|
|
|
|
FRLexer lexer = new FRLexer(in); |
|
|
|
|
FRParser parser = new FRParser(lexer); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(formulaText)) { |
|
|
|
|
Calculator calculator = Calculator.createCalculator(); |
|
|
|
|
Expression expression = null; |
|
|
|
|
try { |
|
|
|
|
expression = parser.parse(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
expression = calculator.parse(formulaText); |
|
|
|
|
} catch (ANTLRException e) { |
|
|
|
|
FRLogger.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JOptionPane.showMessageDialog( |
|
|
|
|
BaseFormulaPane.this, |
|
|
|
|
(expression != null ? Inter.getLocText("Plugin-Design_Basic_FormulaD_Valid_Formula") : Inter.getLocText("Plugin-Design_Basic_FormulaD_Invalid_Formula")) + ".", ProductConstants.PRODUCT_NAME, |
|
|
|
|