Browse Source

Merge branch 'release/11.0' of https://code.fineres.com/scm/~henry.wang/design into release/11.0

fix-lag
Henry.Wang 3 years ago
parent
commit
01a7889402
  1. 13
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  2. 43
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  3. 49
      designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java
  4. 8
      designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java
  5. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  6. 11
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

13
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -710,7 +710,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName); strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName);
if (useGlobal(getTableData(), strategyConfig, tplPath)) { if (useGlobal(getTableData(), strategyConfig)) {
//使用全局配置 //使用全局配置
strategyConfig = StrategyConfigHelper.createStrategyConfig(true); strategyConfig = StrategyConfigHelper.createStrategyConfig(true);
} else if (getTableData().isShare()) { } else if (getTableData().isShare()) {
@ -722,14 +722,13 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
return strategyConfig; return strategyConfig;
} }
private boolean useGlobal(DBTableData dbTableData, StrategyConfig strategyConfig, String tplPath) { private boolean useGlobal(DBTableData dbTableData, StrategyConfig strategyConfig) {
//非共享且配置为空或者指定使用全局配置时,检查是否全局开启 //非共享且配置为空或者指定使用全局配置时,检查是否全局开启
if (!dbTableData.isShare() && (strategyConfig == null || strategyConfig.isUseGlobal())) { if (strategyConfig == null) {
//模版里面没有配置,检查模版是否被开启 return !dbTableData.isShare();
return StrategyConfigService.isTemplateEnabled(tplPath); } else {
return strategyConfig.isUseGlobal();
} }
return false;
} }
@Override @Override

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

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

49
designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java

@ -0,0 +1,49 @@
package com.fr.design.formula;
import com.fr.parser.BinaryExpression;
import com.fr.parser.FunctionCall;
import com.fr.stable.script.Node;
import java.util.Arrays;
/**
* @author Hoky
* @date 2021/8/30
*/
public class UnsupportedFormulaScanner {
public final static String[] UNSUPPORTED_FORMULAS = new String[]{"PROPORTION", "TOIMAGE",
"WEBIMAGE", "SORT", "CROSSLAYERTOTAL", "CIRCULAR", "LAYERTOTAL", "MOM", "HIERARCHY",
"FILENAME", "FILESIZE", "FILETYPE", "TREELAYER", "GETUSERDEPARTMENTS", "GETUSERJOBTITLES"};
private String unSupportFormula = "";
public boolean travelFormula(Node node) {
if (node instanceof FunctionCall) {
if (isUnsupportedFomula(((FunctionCall) node).getName())) {
unSupportFormula = ((FunctionCall) node).getName();
return false;
} else {
for (Node argument : ((FunctionCall) node).getArguments()) {
if (!travelFormula(argument)) {
return false;
}
}
}
} else if (node instanceof BinaryExpression) {
for (Node array : ((BinaryExpression) node).getNodes()) {
if (!travelFormula(array)) {
return false;
}
}
}
return true;
}
public String getUnSupportFormula() {
return unSupportFormula;
}
private static boolean isUnsupportedFomula(String formula) {
return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula.toUpperCase());
}
}

8
designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java

@ -13,6 +13,9 @@ import javax.swing.text.PlainDocument;
* Number Field. * Number Field.
*/ */
public class EditTextField extends UIGridTextField { public class EditTextField extends UIGridTextField {
private static final String I18NProperty = "i18n";
private int maxLength = 24; private int maxLength = 24;
public EditTextField() { public EditTextField() {
@ -39,7 +42,11 @@ public class EditTextField extends UIGridTextField {
} }
class TextDocument extends PlainDocument { class TextDocument extends PlainDocument {
private Object defaultI18NProperty;
public TextDocument() { public TextDocument() {
defaultI18NProperty = getProperty(I18NProperty);
} }
@Override @Override
@ -49,6 +56,7 @@ public class EditTextField extends UIGridTextField {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
return; return;
} }
putProperty(I18NProperty, defaultI18NProperty);
super.insertString(offset, s, a); super.insertString(offset, s, a);
} }
} }

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -173,8 +173,7 @@ public class ChartTypePane extends AbstractChartAttrPane {
Map<Integer, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane, Map<Integer, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) { ActionListener autoButtonListener) {
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDsIncludeDisabled();
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
for (String id : chartIDs) { for (String id : chartIDs) {
@ -222,6 +221,7 @@ public class ChartTypePane extends AbstractChartAttrPane {
String lastPlotID = chart.getID(); String lastPlotID = chart.getID();
boolean chartTypeChange = false;
try { try {
AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane();
ChartProvider newDefaultChart = (ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); ChartProvider newDefaultChart = (ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone();
@ -231,13 +231,16 @@ public class ChartTypePane extends AbstractChartAttrPane {
editingCollection.removeNameObject(editingCollection.getSelectedIndex()); editingCollection.removeNameObject(editingCollection.getSelectedIndex());
editingCollection.addChart(newDefaultChart); editingCollection.addChart(newDefaultChart);
chart = newDefaultChart; chart = newDefaultChart;
chartTypeChange = true;
} }
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
//这一步会替换plot //这一步会替换plot
String id = chart.getID();
((AbstractChartTypePane) getSelectedPane()).updateBean(chart); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart);
if (inForm) { chartTypeChange = chartTypeChange || !ComparatorUtils.equals(id, chart.getID());
if (inForm && chartTypeChange) {
chart.resetAttrInForm(); chart.resetAttrInForm();
} }
reLayoutEditPane(chart, lastPlotID); reLayoutEditPane(chart, lastPlotID);
@ -465,5 +468,6 @@ public class ChartTypePane extends AbstractChartAttrPane {
public void registerChartEditPane(ChartEditPane currentEditPane) { public void registerChartEditPane(ChartEditPane currentEditPane) {
this.editPane = currentEditPane; this.editPane = currentEditPane;
this.inForm = editPane.isInForm(); this.inForm = editPane.isInForm();
buttonPane.refreshChartInForm(inForm);
} }
} }

11
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -799,10 +799,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); try {
popup.updatePane(designer); popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); popup.updatePane(designer);
popup.setRelativeBounds(bounds); popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog());
popup.setRelativeBounds(bounds);
} catch (Exception ignored) {
}
} }
}); });
} }

Loading…
Cancel
Save