diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index fc666f15fd..f6bfdd29a7 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -3,6 +3,7 @@ */ package com.fr.design.data.datapane.connect; +import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.operator.DataOperator; @@ -10,6 +11,7 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.scrollruler.ModLineBorder; import com.fr.design.utils.gui.GUICoreUtils; @@ -19,12 +21,24 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; +import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; /** * Database Connection pane. @@ -48,9 +62,9 @@ public abstract class DatabaseConnectionPane connectionThread = new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + Connection database = DatabaseConnectionPane.this.updateBean(); + // 返回连接结果 + return DataOperator.getInstance().testConnection(database); + } + + @Override + protected void done() { try { - com.fr.data.impl.Connection database = DatabaseConnectionPane.this.updateBean(); - boolean connect = DataOperator.getInstance().testConnection(database); + boolean connect = get(); okButton.setEnabled(true); - message.setText(database.connectMessage(connect)); if (connect) { uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); - message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); + message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); }else{ uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); - message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")); + message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")); } - } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - return null; } }; @@ -158,18 +177,18 @@ public abstract class DatabaseConnectionPane