void () { myReloadableComboBoxPanel = new ReloadableComboBoxPanel<>() { @Override protected void doUpdateValues(@NotNull Set<GithubTagInfo> tags) { if (!shouldUpdate(tags)) { return; } List<GithubTagInfo> sortedTags = createSortedTagList(tags); GithubTagInfo selectedItem = getSelectedValue(); if (selectedItem == null && sortedTags.size() > 0) { selectedItem = sortedTags.get(0); } myComboBox.removeAllItems(); if (myDefaultBranchTag != null) { myComboBox.addItem(myDefaultBranchTag); } for (GithubTagInfo tag : sortedTags) { myComboBox.addItem(tag); } if (selectedItem != null) { // restore previously selected item for (int i = 0; i < myComboBox.getItemCount(); i++) { GithubTagInfo item = GithubTagInfo.tryCast(myComboBox.getItemAt(i)); if (item != null && item.getName().equals(selectedItem.getName())) { myComboBox.setSelectedIndex(i); break; } } } myComboBox.updateUI(); fireStateChanged(); } private boolean shouldUpdate(Set<GithubTagInfo> newTags) { if (myComboBox.getItemCount() == 0) { return true; } int count = myComboBox.getItemCount(); Set<GithubTagInfo> oldTags = new HashSet<>(); for (int i = 1; i < count; i++) { GithubTagInfo item = myComboBox.getItemAt(i); if (item != null) { oldTags.add(item); } } return !oldTags.equals(newTags); } @NotNull @Override protected JComboBox<GithubTagInfo> createValuesComboBox() { JComboBox<GithubTagInfo> box = super.createValuesComboBox(); box.setRenderer(SimpleListCellRenderer.create((label, tag, index) -> { final String text; if (tag == null) { text = isBackgroundJobRunning() ? CommonBundle.getLoadingTreeNodeText() : LangBundle.message("label.unavailable"); } else { text = tag.getName(); } label.setText(text); })); return box; } }; myVersionPanel = myReloadableComboBoxPanel.getMainPanel(); }