From eeb3ad9ce3593882f1d1a67a7b91e34e4f8fbb84 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Tue, 8 Jun 2021 10:22:16 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53351=20=E5=A4=8D=E5=88=B6=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E5=90=8Esql-=E5=8F=82=E6=95=B0=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=98=BE=E7=A4=BA=E7=BB=93=E6=9E=9C=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preview/sql/PreviewPerformedSqlPane.java | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java index 2800e6f75..938c49f9a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java @@ -107,11 +107,11 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { topPanel.add(imagePanel, BorderLayout.WEST); topPanel.add(messagePanel, BorderLayout.CENTER); - topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10)); + topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); //中间的SQL面板 centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); - centerPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); + centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); JScrollPane scrollPane = new JScrollPane(); JTextArea checkArea = new JTextArea(sql); checkArea.setEditable(false); @@ -135,7 +135,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); okButton.addActionListener(this); bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); - bottomPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); bottomPanel.add(okButton, BorderLayout.EAST); this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql")); @@ -167,42 +167,28 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { parameterMap.put(parameter.getName(), parameter.getValue()); } } - boolean showOriginSql = true; - for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tableData)) { - if (parameterMap.containsKey(parameter.getName())) { - Object value = parameterMap.get(parameter.getName()); - if (value != null && !StringUtils.EMPTY.equals(value)) { - showOriginSql = false; - } - parameter.setValue(value); - } - } String sql; // 计算高亮文本位置 List specialCharParamIndex = null; boolean highlight = true; - if (showOriginSql) { - sql = tableData.getQuery(); - } else { - NameSpace ns = ParameterMapNameSpace.create(parameterMap); - calculator.pushNameSpace(ns); - Parameter[] paras = processParameters(tableData, calculator); - // 所有被转义参数的集合 - Set specialCharParam = EscapeSqlHelper.getInstance().getSpecialCharParam(paras); - // 将参数转义等 - Set tableDataProviders = getTableDataProviders(); - for (TableDataProvider provider : tableDataProviders) { - provider.processParametersBeforeAnalyzeSQL(paras, calculator); - } + NameSpace ns = ParameterMapNameSpace.create(parameterMap); + calculator.pushNameSpace(ns); + Parameter[] paras = processParameters(tableData, calculator); + // 所有被转义参数的集合 + Set specialCharParam = EscapeSqlHelper.getInstance().getSpecialCharParam(paras); + // 将参数转义等 + Set tableDataProviders = getTableDataProviders(); + for (TableDataProvider provider : tableDataProviders) { + provider.processParametersBeforeAnalyzeSQL(paras, calculator); + } - if (!specialCharParam.isEmpty()) { - specialCharParamIndex = ParameterHelper.analyzeCurrentContextTableData4Template(tableData.getQuery(), paras, specialCharParam); - } - String oldSql = ParameterHelper.analyzeCurrentContextTableData4Templatee(tableData.getQuery(), paras); - sql = processExtraSQL(paras, oldSql, calculator, tableDataProviders); - if (!StringUtils.equals(oldSql, sql)) { - highlight = false; - } + if (!specialCharParam.isEmpty()) { + specialCharParamIndex = ParameterHelper.analyzeCurrentContextTableData4Template(tableData.getQuery(), paras, specialCharParam); + } + String oldSql = ParameterHelper.analyzeCurrentContextTableData4Templatee(tableData.getQuery(), paras); + sql = processExtraSQL(paras, oldSql, calculator, tableDataProviders); + if (!StringUtils.equals(oldSql, sql)) { + highlight = false; } // sql内容复制到剪切板 StringSelection selection = new StringSelection(sql);