diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 453e4bc946..c57dfe00dd 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -710,7 +710,7 @@ public class DBTableDataPane extends AbstractTableDataPane { strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName); - if (useGlobal(getTableData(), strategyConfig, tplPath)) { + if (useGlobal(getTableData(), strategyConfig)) { //使用全局配置 strategyConfig = StrategyConfigHelper.createStrategyConfig(true); } else if (getTableData().isShare()) { @@ -722,14 +722,13 @@ public class DBTableDataPane extends AbstractTableDataPane { 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())) { - //模版里面没有配置,检查模版是否被开启 - return StrategyConfigService.isTemplateEnabled(tplPath); + if (strategyConfig == null) { + return !dbTableData.isShare(); + } else { + return strategyConfig.isUseGlobal(); } - - return false; } @Override diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 582fcb8d13..f836cd571f 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/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.FRLexer; import com.fr.parser.FRParser; -import com.fr.parser.FunctionCall; import com.fr.parser.SheetIntervalLiteral; import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.script.Calculator; @@ -100,7 +99,6 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -729,15 +727,16 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { @Override public void actionPerformed(ActionEvent e) { String formulaText = formulaTextArea.getText().trim(); - if (containsUnsupportedSimulationFormulas(formulaText)) { + String formulaValidMessage = getFormulaValidMessage(formulaText); + String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText); + if (unSupportFormula != null) { FineJOptionPane.showMessageDialog( 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"), JOptionPane.INFORMATION_MESSAGE); return; } - String formulaValidMessage = getFormulaValidMessage(formulaText); String messageTips; if (formulaValidMessage.equals(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 { Expression expression = Calculator.createCalculator().parse(formulaText); - String name = ((FunctionCall) expression.getConditionalExpression()).getName(); - if (UnsupportedSimulationFormulaHunter.isUnsupportedFomula(name)) { - return true; + UnsupportedFormulaScanner scanner = new UnsupportedFormulaScanner(); + if (!scanner.travelFormula(expression.getConditionalExpression())) { + return scanner.getUnSupportFormula(); } + UnsupportedSimulationFormulaHunter unsupportedSimulationFormulaHunter = new UnsupportedSimulationFormulaHunter(); expression.traversal4Tiny(unsupportedSimulationFormulaHunter); - return !unsupportedSimulationFormulaHunter.isSupported(); + return unsupportedSimulationFormulaHunter.isSupported() ? null : unsupportedSimulationFormulaHunter.getUnSupportFormula(); } catch (Exception e) { FineLoggerFactory.getLogger().error("", e); } - return true; + return null; } private Map setParamsIfExist(String formulaText) { @@ -814,7 +814,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { }).setVisible(true); //过滤出数组参数,如:[1,2] for (Map.Entry 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()); ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression(); FArray fArray = new FArray<>(arrayExpression.getArrays()); @@ -839,7 +839,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { String statement = tiny.getStatement(); if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) { 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) { parameterList.add(new Parameter(tiny.toString())); } @@ -847,25 +847,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } 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 String unSupportFormula; + public boolean isSupported() { return supported; } + public String getUnSupportFormula() { + return unSupportFormula; + } + public void hunter4Tiny(Tiny tiny) { - String statement = tiny.getStatement().toUpperCase(); - if (Arrays.asList(UNSUPPORTED_FORMULAS).contains(statement)) { + if (tiny.getClass() == ColumnRowRangeInPage.class) { supported = false; + unSupportFormula = tiny.toString(); } } - - public static boolean isUnsupportedFomula(String formula) { - return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula); - } } public class VariableTreeAndDescriptionArea extends JPanel { diff --git a/designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java b/designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java new file mode 100644 index 0000000000..343086af55 --- /dev/null +++ b/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()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java index 694c3e507e..9ed9068273 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java @@ -13,6 +13,9 @@ import javax.swing.text.PlainDocument; * Number Field. */ public class EditTextField extends UIGridTextField { + + private static final String I18NProperty = "i18n"; + private int maxLength = 24; public EditTextField() { @@ -39,7 +42,11 @@ public class EditTextField extends UIGridTextField { } class TextDocument extends PlainDocument { + + private Object defaultI18NProperty; + public TextDocument() { + defaultI18NProperty = getProperty(I18NProperty); } @Override @@ -49,6 +56,7 @@ public class EditTextField extends UIGridTextField { Toolkit.getDefaultToolkit().beep(); return; } + putProperty(I18NProperty, defaultI18NProperty); super.insertString(offset, s, a); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index e93f0023bc..985ee28afa 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -173,8 +173,7 @@ public class ChartTypePane extends AbstractChartAttrPane { Map>> allChartTypePane, ActionListener autoButtonListener) { - - String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); + String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDsIncludeDisabled(); for (String id : chartIDs) { @@ -222,6 +221,7 @@ public class ChartTypePane extends AbstractChartAttrPane { String lastPlotID = chart.getID(); + boolean chartTypeChange = false; try { AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); ChartProvider newDefaultChart = (ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); @@ -231,13 +231,16 @@ public class ChartTypePane extends AbstractChartAttrPane { editingCollection.removeNameObject(editingCollection.getSelectedIndex()); editingCollection.addChart(newDefaultChart); chart = newDefaultChart; + chartTypeChange = true; } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } //这一步会替换plot + String id = chart.getID(); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart); - if (inForm) { + chartTypeChange = chartTypeChange || !ComparatorUtils.equals(id, chart.getID()); + if (inForm && chartTypeChange) { chart.resetAttrInForm(); } reLayoutEditPane(chart, lastPlotID); @@ -465,5 +468,6 @@ public class ChartTypePane extends AbstractChartAttrPane { public void registerChartEditPane(ChartEditPane currentEditPane) { this.editPane = currentEditPane; this.inForm = editPane.isInForm(); + buttonPane.refreshChartInForm(inForm); } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index c3e29e1237..55b9c191f3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/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() { @Override public void run() { - popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); - popup.updatePane(designer); - popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); - popup.setRelativeBounds(bounds); + try { + popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); + popup.updatePane(designer); + popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); + popup.setRelativeBounds(bounds); + } catch (Exception ignored) { + } } }); }