Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit b74ca80

Browse files
committed
fix: 修复api选择的List监听无法选择的bug
1 parent 34ec7a0 commit b74ca80

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Plugin/src/com/ciy/plugin/ui/SelectApiDialog.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,22 @@ private void refreshListData() {
231231
});
232232
lsApiList.setListData(listData.toArray());
233233
lsApiList.setCellRenderer(new SelectApiCellRenderer());
234-
lsApiList.addListSelectionListener(new ListSelectionListener() {
235-
@Override
236-
public void valueChanged(ListSelectionEvent e) {
237-
// 每选择一次,就会触发2次这个回调,这个getValueIsAdjusting能控制只触发后一次
238-
if (e.getValueIsAdjusting()) {
239-
// 选择位置
240-
int selectIndex = lsApiList.getSelectedIndex();
241-
Object data = listData.get(selectIndex);
242-
if (data instanceof ApiBean) {
243-
((ApiBean) data).setSelect(!((ApiBean) data).getSelect());
234+
if (lsApiList.getListSelectionListeners().length == 0) {
235+
lsApiList.addListSelectionListener(new ListSelectionListener() {
236+
@Override
237+
public void valueChanged(ListSelectionEvent e) {
238+
// 每选择一次,就会触发2次这个回调,这个getValueIsAdjusting能控制只触发后一次
239+
if (e.getValueIsAdjusting()) {
240+
// 选择位置
241+
int selectIndex = lsApiList.getSelectedIndex();
242+
Object data = listData.get(selectIndex);
243+
if (data instanceof ApiBean) {
244+
((ApiBean) data).setSelect(!((ApiBean) data).getSelect());
245+
}
244246
}
245247
}
246-
}
247-
});
248+
});
249+
}
248250
}
249251

250252
/**

0 commit comments

Comments
 (0)