protected void onSpeedSearchPatternChanged() { myListModel.refilter(); if (myListModel.getSize() > 0) { if (!autoSelectUsingStatistics()) { int fullMatchIndex = myListModel.getClosestMatchIndex(); if (fullMatchIndex != -1) { myList.setSelectedIndex(fullMatchIndex); } if (myListModel.getSize() <= myList.getSelectedIndex() || !myListModel.isVisible(myList.getSelectedValue())) { myList.setSelectedIndex(0); } } } }
private void selectFirstSelectableItem() { for (int i = 0; i < myListModel.getSize(); i++) { if (getListStep().isSelectable(myListModel.getElementAt(i))) { myList.setSelectedIndex(i); break; } } }
protected JComponent createContent() { myMouseMotionListener = new MyMouseMotionListener(); myMouseListener = new MyMouseListener(); myListModel = new ListPopupModel(this, getSpeedSearch(), getListStep()); myList = new MyList(); if (myStep.getTitle() != null) { myList.getAccessibleContext().setAccessibleName(myStep.getTitle()); } myList.setSelectionMode( isMultiSelectionEnabled() ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION); myList.setSelectedIndex(0); Insets padding = UIUtil.getListViewportPadding(); myList.setBorder(new EmptyBorder(padding)); ListScrollingUtil.installActions(myList); myList.setCellRenderer(getListElementRenderer()); myList.getActionMap().get("selectNextColumn").setEnabled(false); myList.getActionMap().get("selectPreviousColumn").setEnabled(false); registerAction( "handleSelection1", KeyEvent.VK_ENTER, 0, new AbstractAction() { public void actionPerformed(ActionEvent e) { handleSelect(true); } }); registerAction( "handleSelection2", KeyEvent.VK_RIGHT, 0, new AbstractAction() { public void actionPerformed(ActionEvent e) { handleSelect(false); } }); registerAction( "goBack2", KeyEvent.VK_LEFT, 0, new AbstractAction() { public void actionPerformed(ActionEvent e) { if (isClosableByLeftArrow()) { goBack(); } } }); myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return myList; }