From 6740020f6576e88b62547a58a4e663c2fbcca0d6 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 18 May 2020 16:26:37 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-31291=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 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 eda6414671..52ed6861b1 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 @@ -1,12 +1,10 @@ package com.fr.design.data.datapane; -import com.fr.base.BaseUtils; import com.fr.base.TableData; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; -import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; @@ -37,6 +35,7 @@ import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.connection.DBConnectAuth; import javax.swing.JList; import javax.swing.JOptionPane; @@ -61,9 +60,10 @@ import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.List; -import java.util.Map; +import java.util.Set; /** * @author zhou @@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha @SuppressWarnings("unchecked") protected void initDsNameComboBox() { dsNameComboBox.setRefreshingModel(true); - ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); - List dsList = new ArrayList<>(); - dsList.addAll(connectionConfig.getConnections().keySet()); - FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList); + FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections()); dsNameComboBox.setModel(dsNameComboBoxModel); dsNameComboBox.setRefreshingModel(false); } @@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane implements Refresha return null; // peter:选中了当前的零长度的节点,直接返回. } ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); - for (Map.Entry entry : connectionConfig.getConnections().entrySet()) { - if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { - return entry.getValue(); + List authConnections = getHasAuthConnections(); + for (String name : authConnections) { + if (ComparatorUtils.equals(selectedDSName, name)) { + return connectionConfig.getConnection(name); } } return null; } + private List getHasAuthConnections() { + List authConnections = new ArrayList<>(); + Set allConnections = ConnectionConfig.getInstance().getConnections().keySet(); + Collection noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); + if (noAuthConnections == null) { + return authConnections; + } + + for (String name : allConnections) { + if (!noAuthConnections.contains(name)) { + authConnections.add(name); + } + } + return authConnections; + } + /** * 刷新没多大用。而且要刷新也不是这儿刷新。 */