From 2ffd076c072e6da130cea745b0f9ac3861cb5c41 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 9 Sep 2024 18:33:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-133908=20=E3=80=90fr-fbp=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91DB2=20=E6=96=B0=E5=BB=BA=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 4 ++-- .../connect/LocalConnectionSource.java | 13 +++++++++++-- .../preview/ConnectionInfoBeanHelper.java | 18 +++++++++++++++++- .../tabledatapane/ProcedureDataPane.java | 4 ++-- .../com/fr/design/gui/ilist/TableViewList.java | 4 ++-- .../design/present/dict/DatabaseDictPane.java | 3 ++- .../fanruan/data/ConnectionConfigWrapper.java | 3 ++- 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 4229b54036..49af47f2ca 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -332,7 +332,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha List authConnections = getHasAuthConnections(); for (String name : authConnections) { if (ComparatorUtils.equals(selectedDSName, name)) { - return ConnectionRepository.getInstance().getByName(name).getConnection(); + return ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(name)); } } return null; @@ -442,7 +442,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha boolean connect = false; com.fr.data.impl.Connection database = null; try { - database = ConnectionRepository.getInstance().getByName(paras.getDatabaseName()).getConnection(); + database = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(paras.getDatabaseName())); } catch (Exception e) { FineLoggerFactory.getLogger().info(e.getMessage(), e); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java index bfad0a1850..1aaa2fb46a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java @@ -41,11 +41,20 @@ public class LocalConnectionSource extends BaseConnectionSource { } @Override - public void testConnection(ConnectionInfoBean database) throws Exception { + public ConnectionInfoBean getByName(String name) { + try { + return ConnectionInfoBeanHelper.createConnectionInfoBean(name, ConnectionConfigProviderFactory.getConfigProvider().getConnection(name)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public String[] testConnection(ConnectionInfoBean database) throws Exception { try { // 暂时这么处理,后续最好拉到外层包装一下 TransmissionEncryptionManager.setTransEncryptionLevel(1); - ConnectionProcessorFactory.testConnectionWithSchemaReturn(database); + return ConnectionProcessorFactory.testConnectionWithSchemaReturn(database); } catch (DriverNotFoundException e) { throw new DriverUnExistException(); } finally { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java index 6ad25c57c6..26ae869fcd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java @@ -78,13 +78,29 @@ public class ConnectionInfoBeanHelper { return ans; } + /** + * 根据bean创建连接 + */ + public static Connection createConnection(ConnectionInfoBean infoBean) { + try { + if (JDBCConnectionProcessor.KEY.acceptConnectionTypes().contains(infoBean.getConnectionType())) { + return createJDBCConnection(infoBean); + } else { + return ConnectionProcessorFactory.createConnection(infoBean, true); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return null; + } + } + /** * 创建数据连接Bean,可自定义是否携带密码 */ public static ConnectionInfoBean createConnectionInfoBean(String name, Connection connection, boolean withPassword) throws Exception { if (connection instanceof NameDatabaseConnection) { name = ((NameDatabaseConnection) connection).getName(); - connection = ConnectionRepository.getInstance().getByName(name).getConnection(); + connection = createConnection(ConnectionRepository.getInstance().getByName(name)); } if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) { ConnectionInfoBean bean = new ConnectionInfoBean(); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java index a5ced9dfe0..e1d9263c90 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java @@ -20,6 +20,7 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.StoreProcedureWorkerListener; @@ -187,8 +188,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp } private boolean isAutoParameterDatabase() { - ConnectionBean bean = ConnectionRepository.getInstance().getByName(connectionTableProcedurePane.getSelectedDatabaseConnnectonName()); - Connection connection = bean == null ? null : bean.getConnection(); + Connection connection = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(connectionTableProcedurePane.getSelectedDatabaseConnnectonName())); return connection != null && ArrayUtils.contains(DRIVERS, connection.getDriver()); } diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java index b0483dfdd3..682e68be7d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java @@ -104,7 +104,7 @@ public class TableViewList extends UIList { @Override protected DefaultListModel doInBackground() throws Exception { - Connection datasource = ConnectionRepository.getInstance().getByName(databaseName).getConnection(); + Connection datasource = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(databaseName)); boolean status = false; int count = 3; //总共给3次连接的机会 @@ -168,7 +168,7 @@ public class TableViewList extends UIList { */ private DefaultListModel processDataInAnotherThread(String databaseName, String searchFilter, String... typesFilter) throws Exception { DefaultListModel defaultListModel = new DefaultListModel(); - Connection datasource = ConnectionRepository.getInstance().getByName(databaseName).getConnection(); + Connection datasource = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(databaseName)); if (datasource == null) { return defaultListModel; } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java index 2c1f46a4a1..aa126574ea 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java @@ -15,6 +15,7 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.ChoosePane; import com.fr.design.data.datapane.DataBaseItems; import com.fr.design.data.datapane.VerticalChoosePane; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.editor.DoubleDeckValueEditorPane; import com.fr.design.editor.editor.ColumnIndexEditor; @@ -178,7 +179,7 @@ public class DatabaseDictPane extends FurtherBasicBeanPane i if (StringUtils.isBlank(para.getDatabaseName())) { dbDict.setDatabaseConnection(null); } else { - Connection connection = ConnectionRepository.getInstance().getByName(para.getDatabaseName()).getConnection(); + Connection connection = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(para.getDatabaseName())); if (connection != null) { database = new NameDatabaseConnection(para.getDatabaseName()); dbDict.setDatabaseConnection(database); diff --git a/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java b/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java index 8dd3ea86e5..68516dd7b8 100644 --- a/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java +++ b/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java @@ -3,6 +3,7 @@ package com.fanruan.data; import com.fanruan.config.impl.data.ConnectionConfigProvider; import com.fanruan.config.impl.data.ConnectionConfigWriter; import com.fr.data.impl.Connection; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.file.ConnectionConfig; import com.fr.log.FineLoggerFactory; import com.fr.transaction.Configurations; @@ -108,7 +109,7 @@ public class ConnectionConfigWrapper implements ConnectionConfigProvider, Connec @Override public @Nullable Connection getConnection(@NotNull String connectionName) { - Connection connection = WorkContext.getCurrent().isLocal() ? ConnectionConfig.getInstance().getConnection(connectionName) : ConnectionRepository.getInstance().getByName(connectionName).getConnection(); + Connection connection = WorkContext.getCurrent().isLocal() ? ConnectionConfig.getInstance().getConnection(connectionName) : ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(connectionName));; if (connection != null) { connection.setConnectionName(connectionName); } From a01affc9e57d26a7f297938def0f6a54ed65cb2b Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 10 Sep 2024 09:42:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-133888=20=E3=80=90fr-fbp=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91=E6=96=87=E4=BB=B6=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?excel=E5=8F=AA=E8=83=BD=E8=A2=AB=E9=80=89=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/file/FILEChooserPane.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 2cf1016c48..8b6d645fb3 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -1092,7 +1092,29 @@ public class FILEChooserPane extends BasicPane { String lastDirectoryPath = DesignerEnvManager.getEnvManager().getDialogCurrentDirectory(); String prefix = DesignerEnvManager.getEnvManager().getCurrentDirectoryPrefix(); FILE lastDirectory = FILEFactory.createFolder(prefix + lastDirectoryPath); + dealCurrentDirectory(model, lastDirectory) ; + } + + + + private void setPlaceListModel4DataFile(AbstractPlaceListModel model) { + if (placesList == null) { + return; + } + placesList.setModel(model); + String lastDirectoryPath = FILEFactory.ENV_PREFIX; + String prefix = ProjectConstants.REPORTLETS_NAME; + FILE lastDirectory; + if (model instanceof FileDataPlaceListModel) { + FileDataFILE file = new FileDataFILE(new FileNode(), false, StringUtils.EMPTY, ((FileDataPlaceListModel) model).getType()); + lastDirectory = FILEFactory.createFolder(file, prefix + lastDirectoryPath); + } else { + lastDirectory = FILEFactory.createFolder(prefix + lastDirectoryPath); + } + dealCurrentDirectory(model, lastDirectory); + } + private void dealCurrentDirectory(AbstractPlaceListModel model, FILE lastDirectory) { model.setCD(lastDirectory); if (currentDirectory != null) { @@ -1109,6 +1131,7 @@ public class FILEChooserPane extends BasicPane { } } + private void setPlaceListModel() { if (placesList == null) { return; @@ -1140,7 +1163,7 @@ public class FILEChooserPane extends BasicPane { if (placesList == null) { return; } - setPlaceListModel(new FileDataPlaceListModel(type)); + setPlaceListModel4DataFile(new FileDataPlaceListModel(type)); } protected void setFileCAPlaceListModel() {