From faa69e6c42789dd6325e18efd83e645bf4882177 Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 18 Sep 2021 11:24:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-59719=20=E3=80=9010.0=E3=80=91?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=95=B0=E6=8D=AE=E6=BA=90=E7=9A=84=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=8C=89=E9=92=AE=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=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 { From 0f7eea4bc69f3a1c0afd680c4a0384736e11c2da Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 18 Sep 2021 13:54:44 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-59719=20=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E8=BF=98=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/ItemEditableComboBoxPanel.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 748e70d6e9..45fadd26c6 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 @@ -104,7 +104,14 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { // 存在两种场景之前只考虑了填充场景 有populate会填充下 把这边的填充逻辑删了 所以没有问题 // 如果是纯通过刷新按钮 没有populate 需要手动设置下上次选中的内容 if (lastSelectedItem != null) { + ActionListener[] actionListeners = itemComboBox.getActionListeners(); + for (ActionListener actionListener : actionListeners) { + itemComboBox.removeActionListener(actionListener); + } model.setSelectedItem(lastSelectedItem); + for (ActionListener actionListener : actionListeners) { + itemComboBox.addActionListener(actionListener); + } } refreshWorker = new SwingWorker, Void>() { @@ -121,7 +128,9 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { while(itemIt.hasNext()) { model.addElement(itemIt.next()); } + // 重置下拉框高度 值一样时不会生效 所以先加再减下 itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() - 1); } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); From 2609ac2aad49b91c79cc62dac47de9f1288d7429 Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 18 Sep 2021 15:41:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-59719=20=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E8=BF=98=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/ItemEditableComboBoxPanel.java | 7 ------- 1 file changed, 7 deletions(-) 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 45fadd26c6..2205a4f569 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 @@ -104,14 +104,7 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { // 存在两种场景之前只考虑了填充场景 有populate会填充下 把这边的填充逻辑删了 所以没有问题 // 如果是纯通过刷新按钮 没有populate 需要手动设置下上次选中的内容 if (lastSelectedItem != null) { - ActionListener[] actionListeners = itemComboBox.getActionListeners(); - for (ActionListener actionListener : actionListeners) { - itemComboBox.removeActionListener(actionListener); - } model.setSelectedItem(lastSelectedItem); - for (ActionListener actionListener : actionListeners) { - itemComboBox.addActionListener(actionListener); - } } refreshWorker = new SwingWorker, Void>() { From 54a51dcfd729221d59c6d23f288f2a77b297055e Mon Sep 17 00:00:00 2001 From: hades Date: Sat, 18 Sep 2021 16:14:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-59719=20fix=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/ItemEditableComboBoxPanel.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 2205a4f569..d0738e57b8 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 @@ -121,9 +121,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { while(itemIt.hasNext()) { model.addElement(itemIt.next()); } - // 重置下拉框高度 值一样时不会生效 所以先加再减下 - itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); - itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() - 1); + // 如果加载成功 但是下拉框是可见的 下拉框高度是会固定为原始高度 不会因为填充了更多下拉项而变化 + // 需要重新设置下拉框高度 但值一样时相关事件不会生效 所以先加再减下 + if (itemComboBox.isPopupVisible()) { + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() - 1); + } } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e);