|
|
@ -91,6 +91,9 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { |
|
|
|
refreshWorker.cancel(true); |
|
|
|
refreshWorker.cancel(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录原来选中的Item,重新加载后需要再次选中
|
|
|
|
|
|
|
|
Object lastSelectedItem = itemComboBox.getSelectedItem(); |
|
|
|
|
|
|
|
|
|
|
|
DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); |
|
|
|
DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); |
|
|
|
model.removeAllElements(); |
|
|
|
model.removeAllElements(); |
|
|
|
|
|
|
|
|
|
|
@ -98,6 +101,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { |
|
|
|
model.addElement(EMPTY); |
|
|
|
model.addElement(EMPTY); |
|
|
|
model.addElement(PENDING); |
|
|
|
model.addElement(PENDING); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 存在两种场景之前只考虑了填充场景 有populate会填充下 把这边的填充逻辑删了 所以没有问题
|
|
|
|
|
|
|
|
// 如果是纯通过刷新按钮 没有populate 需要手动设置下上次选中的内容
|
|
|
|
|
|
|
|
if (lastSelectedItem != null) { |
|
|
|
|
|
|
|
model.setSelectedItem(lastSelectedItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
refreshWorker = new SwingWorker<Iterator<String>, Void>() { |
|
|
|
refreshWorker = new SwingWorker<Iterator<String>, Void>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Iterator<String> doInBackground() throws Exception { |
|
|
|
protected Iterator<String> doInBackground() throws Exception { |
|
|
@ -112,7 +121,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { |
|
|
|
while(itemIt.hasNext()) { |
|
|
|
while(itemIt.hasNext()) { |
|
|
|
model.addElement(itemIt.next()); |
|
|
|
model.addElement(itemIt.next()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果加载成功 但是下拉框是可见的 下拉框高度是会固定为原始高度 不会因为填充了更多下拉项而变化
|
|
|
|
|
|
|
|
// 需要重新设置下拉框高度 但值一样时相关事件不会生效 所以先加再减下
|
|
|
|
|
|
|
|
if (itemComboBox.isPopupVisible()) { |
|
|
|
itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); |
|
|
|
itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); |
|
|
|
|
|
|
|
itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() - 1); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
if (!(e instanceof CancellationException)) { |
|
|
|
if (!(e instanceof CancellationException)) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|