use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.
the class PyActiveSdkConfigurable method updateSdkList.
private void updateSdkList(boolean preserveSelection) {
final List<Sdk> sdkList = myInterpreterList.getAllPythonSdks(myProject);
Sdk selection = preserveSelection ? (Sdk) mySdkCombo.getSelectedItem() : null;
if (!sdkList.contains(selection)) {
selection = null;
}
VirtualEnvProjectFilter.removeNotMatching(myProject, sdkList);
// if the selection is a non-matching virtualenv, show it anyway
if (selection != null && !sdkList.contains(selection)) {
sdkList.add(0, selection);
}
List<Object> items = new ArrayList<>();
items.add(null);
boolean remoteSeparator = true;
boolean separator = true;
boolean detectedSeparator = true;
for (Sdk sdk : sdkList) {
if (!PythonSdkType.isVirtualEnv(sdk) && !PythonSdkType.isRemote(sdk) && !(sdk instanceof PyDetectedSdk) && separator) {
items.add(PySdkListCellRenderer.SEPARATOR);
separator = false;
}
if (PythonSdkType.isRemote(sdk) && remoteSeparator) {
items.add(PySdkListCellRenderer.SEPARATOR);
remoteSeparator = false;
}
if (sdk instanceof PyDetectedSdk && detectedSeparator) {
items.add(PySdkListCellRenderer.SEPARATOR);
detectedSeparator = false;
}
items.add(sdk);
}
items.add(PySdkListCellRenderer.SEPARATOR);
items.add(SHOW_ALL);
mySdkCombo.setRenderer(new PySdkListCellRenderer(false));
//noinspection unchecked
mySdkCombo.setModel(new CollectionComboBoxModel(items, selection));
}
Aggregations