void (@NotNull AnnotationPanelModel model) { // No project-specific annotations are possible for default project if (myProject.isDefault()) return; String loading = JavaBundle.message("loading.additional.annotations"); myCombo.addItem(loading); DumbService.getInstance(myProject).runWhenSmart(() -> { ReadAction.nonBlocking(model::getAdvancedAnnotations) .finishOnUiThread(ModalityState.any(), advancedAnnotations -> { myCombo.removeItem(loading); int count = myCombo.getItemCount(); Object selectedItem = myCombo.getSelectedItem(); List<String> newItems = Stream.concat( IntStream.range(0, count).mapToObj(myCombo::getItemAt), advancedAnnotations.stream()).sorted().distinct().toList(); myCombo.removeAllItems(); newItems.forEach(myCombo::addItem); myCombo.setSelectedItem(selectedItem); }).submit(AppExecutorUtil.getAppExecutorService()); }); myCombo.addActionListener(new ActionListener() { Object previous = myCombo.getSelectedItem(); @Override public void actionPerformed(ActionEvent e) { Object item = myCombo.getSelectedItem(); if (item == loading) { myCombo.setSelectedItem(previous); } else { previous = item; } } }); }