List of usage examples for com.intellij.openapi.ui.popup ListPopupStep getDefaultOptionIndex
int getDefaultOptionIndex();
From source file:com.intellij.ui.popup.list.ListPopupImpl.java
License:Apache License
private boolean tryToAutoSelect(boolean handleFinalChoices) { ListPopupStep<Object> listStep = getListStep(); boolean selected = false; if (listStep instanceof MultiSelectionListPopupStep<?>) { int[] indices = ((MultiSelectionListPopupStep) listStep).getDefaultOptionIndices(); if (indices.length > 0) { ListScrollingUtil.ensureIndexIsVisible(myList, indices[0], 0); myList.setSelectedIndices(indices); selected = true;/*from ww w . java 2 s .c o m*/ } } else { final int defaultIndex = listStep.getDefaultOptionIndex(); if (defaultIndex >= 0 && defaultIndex < myList.getModel().getSize()) { ListScrollingUtil.selectItem(myList, defaultIndex); selected = true; } } if (!selected) { selectFirstSelectableItem(); } if (listStep.isAutoSelectionEnabled()) { if (!isVisible() && getSelectableCount() == 1) { return _handleSelect(handleFinalChoices, null); } else if (isVisible() && hasSingleSelectableItemWithSubmenu()) { return _handleSelect(handleFinalChoices, null); } } return false; }