boolean (List<? extends XExecutionStack> executionStacks, boolean addBeforeSelection) { int count = myThreadComboBox.getItemCount(); boolean loading = count > 0 && myThreadComboBox.getItemAt(count - 1) == null; Object selectedItem = myThreadComboBox.getSelectedItem(); for (XExecutionStack executionStack : executionStacks) { if (addBeforeSelection && executionStack.equals(selectedItem)) { addBeforeSelection = false; } if (!myExecutionStacksWithSelection.containsKey(executionStack)) { if (addBeforeSelection) { myThreadComboBox.insertItemAt(executionStack, myThreadComboBox.getSelectedIndex()); // add right before the selected node } else { if (loading) { myThreadComboBox.insertItemAt(executionStack, myThreadComboBox.getItemCount() - 1); // add right before the loading node } else { myThreadComboBox.addItem(executionStack); } } myExecutionStacksWithSelection.put(executionStack, 0); } } return addBeforeSelection; }