|
|
@ -39,7 +39,6 @@ import com.fr.parser.BlockIntervalLiteral; |
|
|
|
import com.fr.parser.ColumnRowRangeInPage; |
|
|
|
import com.fr.parser.ColumnRowRangeInPage; |
|
|
|
import com.fr.parser.FRLexer; |
|
|
|
import com.fr.parser.FRLexer; |
|
|
|
import com.fr.parser.FRParser; |
|
|
|
import com.fr.parser.FRParser; |
|
|
|
import com.fr.parser.FunctionCall; |
|
|
|
|
|
|
|
import com.fr.parser.SheetIntervalLiteral; |
|
|
|
import com.fr.parser.SheetIntervalLiteral; |
|
|
|
import com.fr.report.core.namespace.SimpleCellValueNameSpace; |
|
|
|
import com.fr.report.core.namespace.SimpleCellValueNameSpace; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.script.Calculator; |
|
|
@ -100,7 +99,6 @@ import java.io.InputStreamReader; |
|
|
|
import java.io.Reader; |
|
|
|
import java.io.Reader; |
|
|
|
import java.io.StringReader; |
|
|
|
import java.io.StringReader; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -729,15 +727,16 @@ 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(); |
|
|
|
if (containsUnsupportedSimulationFormulas(formulaText)) { |
|
|
|
String formulaValidMessage = getFormulaValidMessage(formulaText); |
|
|
|
|
|
|
|
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText); |
|
|
|
|
|
|
|
if (unSupportFormula != null) { |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
FormulaPane.this, |
|
|
|
FormulaPane.this, |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
String formulaValidMessage = getFormulaValidMessage(formulaText); |
|
|
|
|
|
|
|
String messageTips; |
|
|
|
String messageTips; |
|
|
|
if (formulaValidMessage.equals(INVALID_FORMULA)) { |
|
|
|
if (formulaValidMessage.equals(INVALID_FORMULA)) { |
|
|
|
messageTips = INVALID_FORMULA; |
|
|
|
messageTips = INVALID_FORMULA; |
|
|
@ -777,20 +776,21 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private boolean containsUnsupportedSimulationFormulas(String formulaText) { |
|
|
|
private String containsUnsupportedSimulationFormulas(String formulaText) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Expression expression = Calculator.createCalculator().parse(formulaText); |
|
|
|
Expression expression = Calculator.createCalculator().parse(formulaText); |
|
|
|
String name = ((FunctionCall) expression.getConditionalExpression()).getName(); |
|
|
|
UnsupportedFormulaScanner scanner = new UnsupportedFormulaScanner(); |
|
|
|
if (UnsupportedSimulationFormulaHunter.isUnsupportedFomula(name)) { |
|
|
|
if (!scanner.travelFormula(expression.getConditionalExpression())) { |
|
|
|
return true; |
|
|
|
return scanner.getUnSupportFormula(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UnsupportedSimulationFormulaHunter unsupportedSimulationFormulaHunter = new UnsupportedSimulationFormulaHunter(); |
|
|
|
UnsupportedSimulationFormulaHunter unsupportedSimulationFormulaHunter = new UnsupportedSimulationFormulaHunter(); |
|
|
|
expression.traversal4Tiny(unsupportedSimulationFormulaHunter); |
|
|
|
expression.traversal4Tiny(unsupportedSimulationFormulaHunter); |
|
|
|
return !unsupportedSimulationFormulaHunter.isSupported(); |
|
|
|
return unsupportedSimulationFormulaHunter.isSupported() ? null : unsupportedSimulationFormulaHunter.getUnSupportFormula(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error("", e); |
|
|
|
FineLoggerFactory.getLogger().error("", e); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> setParamsIfExist(String formulaText) { |
|
|
|
private Map<String, Object> setParamsIfExist(String formulaText) { |
|
|
@ -814,7 +814,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
}).setVisible(true); |
|
|
|
}).setVisible(true); |
|
|
|
//过滤出数组参数,如:[1,2]
|
|
|
|
//过滤出数组参数,如:[1,2]
|
|
|
|
for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { |
|
|
|
for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { |
|
|
|
if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().startsWith("]")) { |
|
|
|
if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().endsWith("]")) { |
|
|
|
Expression parse = calculator.parse(entry.getValue()); |
|
|
|
Expression parse = calculator.parse(entry.getValue()); |
|
|
|
ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression(); |
|
|
|
ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression(); |
|
|
|
FArray<Node> fArray = new FArray<>(arrayExpression.getArrays()); |
|
|
|
FArray<Node> fArray = new FArray<>(arrayExpression.getArrays()); |
|
|
@ -839,7 +839,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
String statement = tiny.getStatement(); |
|
|
|
String statement = tiny.getStatement(); |
|
|
|
if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) { |
|
|
|
if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) { |
|
|
|
parameterList.add(new Parameter(statement.substring(1))); |
|
|
|
parameterList.add(new Parameter(statement.substring(1))); |
|
|
|
} else if (tiny.getClass() == ColumnRowRange.class || tiny.getClass() == ColumnRowRangeInPage.class || |
|
|
|
} else if (tiny.getClass() == ColumnRowRange.class || |
|
|
|
tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) { |
|
|
|
tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) { |
|
|
|
parameterList.add(new Parameter(tiny.toString())); |
|
|
|
parameterList.add(new Parameter(tiny.toString())); |
|
|
|
} |
|
|
|
} |
|
|
@ -847,25 +847,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class UnsupportedSimulationFormulaHunter extends TinyHunter { |
|
|
|
private static class UnsupportedSimulationFormulaHunter extends TinyHunter { |
|
|
|
public final static String[] UNSUPPORTED_FORMULAS = new String[]{"PROPORTION", "TOIMAGE", |
|
|
|
|
|
|
|
"WEBIMAGE", "SORT", "CROSSLAYERTOTAL", "CIRCULAR", "LAYERTOTAL", "MOM", "HIERARCHY"}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean supported = true; |
|
|
|
private boolean supported = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String unSupportFormula; |
|
|
|
|
|
|
|
|
|
|
|
public boolean isSupported() { |
|
|
|
public boolean isSupported() { |
|
|
|
return supported; |
|
|
|
return supported; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getUnSupportFormula() { |
|
|
|
|
|
|
|
return unSupportFormula; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void hunter4Tiny(Tiny tiny) { |
|
|
|
public void hunter4Tiny(Tiny tiny) { |
|
|
|
String statement = tiny.getStatement().toUpperCase(); |
|
|
|
if (tiny.getClass() == ColumnRowRangeInPage.class) { |
|
|
|
if (Arrays.asList(UNSUPPORTED_FORMULAS).contains(statement)) { |
|
|
|
|
|
|
|
supported = false; |
|
|
|
supported = false; |
|
|
|
|
|
|
|
unSupportFormula = tiny.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isUnsupportedFomula(String formula) { |
|
|
|
|
|
|
|
return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class VariableTreeAndDescriptionArea extends JPanel { |
|
|
|
public class VariableTreeAndDescriptionArea extends JPanel { |
|
|
|