diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java index 2428c9a00..947cb6e75 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java @@ -2,11 +2,15 @@ package com.fr.design.data.datapane.connect; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.editlock.EditLockUtils; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.file.ConnectionConfig; import com.fr.report.LockItem; +import javax.swing.JOptionPane; + /** * @author hades * @version 11.0 @@ -32,7 +36,13 @@ public class ConnectionListDialogActionAdapter extends DialogActionAdapter { connectionListDialog.setDoOKSucceed(false); return; } - connectionManagerPane.update(connectionConfig); + try { + connectionManagerPane.update(connectionConfig); + } catch (Exception e) { + connectionListDialog.setDoOKSucceed(false); + FineJOptionPane.showMessageDialog(connectionManagerPane, e.getMessage(), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); + return; + } DesignerContext.getDesignerBean("databasename").refreshBeanElement(); // 关闭定义数据连接页面,为其解锁 EditLockUtils.unlock(LockItem.CONNECTION); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 12c62b435..e4deae04b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -1,6 +1,7 @@ package com.fr.design.data.datapane.connect; import com.fr.config.RemoteConfigEvent; +import com.fr.data.core.db.JDBCSecurityChecker; import com.fr.data.impl.Connection; import com.fr.data.impl.ConnectionBean; import com.fr.data.impl.JDBCDatabaseConnection; @@ -28,6 +29,7 @@ import com.fr.transaction.WorkerFacade; import com.fr.workspace.WorkContext; import java.awt.Window; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -166,7 +168,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh /** * Update. */ - public void update(ConnectionConfig connectionConfig) { + public void update(ConnectionConfig connectionConfig) throws Exception { // Nameable[]居然不能强转成NameObject[],一定要这么写... Nameable[] res = this.update(); Map updatedMap = new LinkedHashMap<>(); @@ -188,10 +190,27 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } }); - + this.checkSecurity(addedOrUpdatedConnections); this.alterConnections(removedConnNames, addedOrUpdatedConnections); } + + private void checkSecurity(List addedOrUpdatedConnections) throws Exception { + + for (ConnectionBean connectionBean : addedOrUpdatedConnections) { + Connection connection = connectionBean.getConnection(); + if (connection instanceof JDBCDatabaseConnection) { + try { + JDBCSecurityChecker.checkURL(((JDBCDatabaseConnection) connection).getURL()); + JDBCSecurityChecker.checkValidationQuery(((JDBCDatabaseConnection) connection).getDbcpAttr().getValidationQuery()); + } catch (SQLException e) { + throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause()); + } + } + } + + } + private void alterConnections(List removedConnNames, List addedOrUpdatedConnections) { try { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java index 6c768145f..eadf456e0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java @@ -4,9 +4,8 @@ import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.file.ConnectionConfig; - -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; import java.util.HashMap; public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane { @@ -39,7 +38,7 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio this.connectionListPane.populate(datasourceManager); } - public void update(ConnectionConfig datasourceManager) { + public void update(ConnectionConfig datasourceManager) throws Exception { this.connectionListPane.update(datasourceManager); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java index b5ae09be8..2b74ddcf9 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionShowPane.java @@ -7,7 +7,7 @@ import com.fr.file.ConnectionConfig; * 数据链接显示面板 */ public interface ConnectionShowPane { - void update(ConnectionConfig connectionConfig); + void update(ConnectionConfig connectionConfig) throws Exception; void populate(ConnectionConfig connectionConfig); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java index bfa8b43e9..ba66c0392 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java @@ -173,12 +173,8 @@ public abstract class VanChartUIListControlPane extends UIListControlPane implem JPanel buttonsPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0)); controlPane.add(buttonsPane, BorderLayout.EAST); - //确定 addOkButton(buttonsPane); - //取消 - addCancelButton(buttonsPane); - controlPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); return controlPane;