From faa69e6c42789dd6325e18efd83e645bf4882177 Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 18 Sep 2021 11:24:45 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-59719=20=E3=80=9010.0=E3=80=91=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=95=B0=E6=8D=AE=E6=BA=90=E7=9A=84=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BC=9A=E5=8F=98=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/ConnectionComboBoxPanel.java | 5 +++-- .../data/datapane/connect/ItemEditableComboBoxPanel.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java index 1ce37b4c51..5ed53cef40 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java @@ -87,12 +87,13 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { * 刷新ComboBox.items */ protected Iterator items() { - nameList = new ArrayList(); - ConnectionConfig mgr = ConnectionConfig.getInstance(); Iterator nameIt = mgr.getConnections().keySet().iterator(); Collection noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); + + nameList = new ArrayList<>(); + if (noAuthConnections == null) { return nameList.iterator(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java index 248d3318c9..748e70d6e9 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java @@ -91,6 +91,9 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { refreshWorker.cancel(true); } + // 记录原来选中的Item,重新加载后需要再次选中 + Object lastSelectedItem = itemComboBox.getSelectedItem(); + DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); model.removeAllElements(); @@ -98,6 +101,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { model.addElement(EMPTY); model.addElement(PENDING); + // 存在两种场景之前只考虑了填充场景 有populate会填充下 把这边的填充逻辑删了 所以没有问题 + // 如果是纯通过刷新按钮 没有populate 需要手动设置下上次选中的内容 + if (lastSelectedItem != null) { + model.setSelectedItem(lastSelectedItem); + } + refreshWorker = new SwingWorker, Void>() { @Override protected Iterator doInBackground() throws Exception {