コード例 #1
0
  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;
      }
    } 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;
  }
コード例 #2
0
 protected void onAutoSelectionTimer() {
   if (myList.getModel().getSize() > 0 && !myList.isSelectionEmpty()) {
     handleSelect(false);
   } else {
     disposeChildren();
     setIndexForShowingChild(-1);
   }
 }
コード例 #3
0
  private boolean _handleSelect(final boolean handleFinalChoices, InputEvent e) {
    if (myList.getSelectedIndex() == -1) return false;

    if (getSpeedSearch().isHoldingFilter() && myList.getModel().getSize() == 0) return false;

    if (myList.getSelectedIndex() == getIndexForShowingChild()) {
      if (myChild != null && !myChild.isVisible()) setIndexForShowingChild(-1);
      return false;
    }

    final Object[] selectedValues = myList.getSelectedValues();
    final ListPopupStep<Object> listStep = getListStep();
    if (!listStep.isSelectable(selectedValues[0])) return false;

    if ((listStep instanceof MultiSelectionListPopupStep<?>
                && !((MultiSelectionListPopupStep<Object>) listStep)
                    .hasSubstep(Arrays.asList(selectedValues))
            || !listStep.hasSubstep(selectedValues[0]))
        && !handleFinalChoices) return false;

    disposeChildren();

    if (myListModel.getSize() == 0) {
      setFinalRunnable(myStep.getFinalRunnable());
      setOk(true);
      disposeAllParents(e);
      setIndexForShowingChild(-1);
      return true;
    }

    valuesSelected(selectedValues);

    final PopupStep nextStep =
        listStep instanceof MultiSelectionListPopupStep<?>
            ? ((MultiSelectionListPopupStep<Object>) listStep)
                .onChosen(Arrays.asList(selectedValues), handleFinalChoices)
            : listStep.onChosen(selectedValues[0], handleFinalChoices);
    return handleNextStep(nextStep, selectedValues.length == 1 ? selectedValues[0] : null, e);
  }