Browse Source

REPORT-52525 设计器数据集查询界面增加复制传参后sql的功能

feature/10.0
Bruce.Deng 4 years ago
parent
commit
188c446450
  1. 31
      designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

31
designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java

@ -16,6 +16,9 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.parameter.ParameterInputPane; import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -43,10 +46,10 @@ import java.awt.Frame;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -71,11 +74,17 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
if (isShowSpecialCharSqlPane(selectedSpecialCharIndex)) { if (isShowSpecialCharSqlPane(selectedSpecialCharIndex)) {
imageLabel = new UILabel(UIManager.getIcon("OptionPane.warningIcon")); imageLabel = new UILabel(UIManager.getIcon("OptionPane.warningIcon"));
MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), "https://help.fanruan.com/finereport/doc-view-2219.html", Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message"));
messagePanel = new JPanel(); messagePanel = new JPanel();
messagePanel.setLayout(FRGUIPaneFactory.createBorderLayout()); messagePanel.setLayout(FRGUIPaneFactory.createBorderLayout());
messagePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); messagePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
messagePanel.add(message); // 日韩取消超链,直接显示文字
if (isNotShowLink()) {
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message") + Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention") + Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message"));
messagePanel.add(label);
} else {
MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), CloudCenter.getInstance().acquireConf(Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention_Help"), "https://help.fanruan.com/finereport/doc-view-2219.html"), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message"));
messagePanel.add(message);
}
// 提示图标 // 提示图标
JPanel tipPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel tipPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
UILabel tipLabel = new UILabel(UIManager.getIcon("OptionPane.tipIcon")); UILabel tipLabel = new UILabel(UIManager.getIcon("OptionPane.tipIcon"));
@ -114,7 +123,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
try { try {
highLighter.addHighlight(specialCharIndex[0], specialCharIndex[1], p); highLighter.addHighlight(specialCharIndex[0], specialCharIndex[1], p);
} catch (BadLocationException e) { } catch (BadLocationException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
} }
@ -139,12 +148,16 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }
private boolean isNotShowLink() {
return GeneralContext.getLocale().equals(Locale.JAPAN) || GeneralContext.getLocale().equals(Locale.KOREA);
}
public static void previewPerformedSql(DBTableData tableData) { public static void previewPerformedSql(DBTableData tableData) {
Calculator calculator = Calculator.createCalculator(); Calculator calculator = Calculator.createCalculator();
//参数 //参数
ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tableData); ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tableData);
if (ArrayUtils.isEmpty(parameters)) { if (ArrayUtils.isEmpty(parameters)) {
parameters = tableData.getParameters(Calculator.createCalculator()); parameters = tableData.getParameters(calculator);
} }
Map<String, Object> parameterMap = new HashMap<>(); Map<String, Object> parameterMap = new HashMap<>();
if (needInputParams(parameters)) { if (needInputParams(parameters)) {
@ -187,7 +200,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
} }
String oldSql = ParameterHelper.analyzeCurrentContextTableData4Templatee(tableData.getQuery(), paras); String oldSql = ParameterHelper.analyzeCurrentContextTableData4Templatee(tableData.getQuery(), paras);
sql = processExtraSQL(paras, oldSql, calculator, tableDataProviders); sql = processExtraSQL(paras, oldSql, calculator, tableDataProviders);
if (oldSql.length() != sql.length()) { if (!StringUtils.equals(oldSql, sql)) {
highlight = false; highlight = false;
} }
} }
@ -209,12 +222,12 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
} }
private static Parameter[] processParameters(DBTableData tableData, Calculator calculator) { private static Parameter[] processParameters(DBTableData tableData, Calculator calculator) {
Collection<ParameterProvider> parameters = tableData.getParameters(); ParameterProvider[] parameters = tableData.getParameters();
if (parameters.size() == 0) { if (parameters == null || parameters.length == 0) {
tableData.setParameters(ParameterHelper.analyze4Parameters(tableData.getQuery(), false)); tableData.setParameters(ParameterHelper.analyze4Parameters(tableData.getQuery(), false));
return new Parameter[0]; return new Parameter[0];
} }
return Parameter.providers2Parameter(Calculator.processParameters(calculator, parameters.toArray(new ParameterProvider[parameters.size()]))); return Parameter.providers2Parameter(Calculator.processParameters(calculator, parameters));
} }
private static String processExtraSQL(Parameter[] ps, String sql, Calculator ca, Set<TableDataProvider> tableDataProviders) { private static String processExtraSQL(Parameter[] ps, String sql, Calculator ca, Set<TableDataProvider> tableDataProviders) {

5
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -41,10 +41,7 @@ public class MessageWithLink extends JEditorPane {
} }
public MessageWithLink(String message, String linkName, String link, Color color, Font font) { public MessageWithLink(String message, String linkName, String link, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>"); this(message, linkName, link, StringUtils.EMPTY, color, font);
initListener(link);
setEditable(false);
setBorder(null);
} }
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color color, Font font) { public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color color, Font font) {

Loading…
Cancel
Save