Java 类com.intellij.ui.speedSearch.ListWithFilter 实例源码

项目:MissingInActions    文件:ContentChooser.java   
private void rebuildListContent() {
    ArrayList<Item> items = new ArrayList<>();
    int i = 0;
    List<Data> contents = new ArrayList<>(getContents());
    for (Data content : contents) {
        String fullString = getStringRepresentationFor(content);
        if (fullString != null) {
            fullString = StringUtil.convertLineSeparators(fullString);
            String shortString = getShortStringFor(content, fullString);
            items.add(new Item(i++, shortString, fullString));
        }
    }
    myAllContents = contents;
    FilteringListModel listModel = (FilteringListModel) myList.getModel();
    ((CollectionListModel) listModel.getOriginalModel()).removeAll();
    listModel.addAll(items);
    ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
    if (listWithFilter != null) {
        listWithFilter.getSpeedSearch().update();
        if (listModel.getSize() == 0) listWithFilter.resetFilter();
    }
}
项目:intellij-ce-playground    文件:NewRecentProjectPanel.java   
public NewRecentProjectPanel(Disposable parentDisposable) {
  super(parentDisposable);
  setBorder(null);
  setBackground(FlatWelcomeFrame.getProjectsBackground());
  JScrollPane scrollPane = UIUtil.findComponentOfType(this, JScrollPane.class);
  if (scrollPane != null) {
    scrollPane.setBackground(FlatWelcomeFrame.getProjectsBackground());
    final int width = 300;
    final int height = 460;
    scrollPane.setSize(JBUI.size(width, height));
    scrollPane.setMinimumSize(JBUI.size(width, height));
    scrollPane.setPreferredSize(JBUI.size(width, height));
  }
  ListWithFilter panel = UIUtil.findComponentOfType(this, ListWithFilter.class);
  if (panel != null) {
    panel.setBackground(FlatWelcomeFrame.getProjectsBackground());
  }
}
项目:consulo    文件:NewRecentProjectPanel.java   
public NewRecentProjectPanel(Disposable parentDisposable) {
  super(parentDisposable);
  setBorder(null);
  setBackground(WelcomeScreenConstants.getProjectsBackground());
  JScrollPane scrollPane = UIUtil.findComponentOfType(this, JScrollPane.class);
  if (scrollPane != null) {
    scrollPane.setBackground(WelcomeScreenConstants.getProjectsBackground());
    JBDimension size = JBUI.size(300, 460);
    scrollPane.setSize(size);
    scrollPane.setMinimumSize(size);
    scrollPane.setPreferredSize(size);
  }
  ListWithFilter panel = UIUtil.findComponentOfType(this, ListWithFilter.class);
  if (panel != null) {
    panel.setBackground(WelcomeScreenConstants.getProjectsBackground());
  }
}
项目:intellij-ce-playground    文件:PopupChooserBuilder.java   
private void registerClosePopupKeyboardAction(final KeyStroke keyStroke, final boolean shouldPerformAction) {
  registerPopupKeyboardAction(keyStroke, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      if (!shouldPerformAction && myChooserComponent instanceof ListWithFilter) {
        if (((ListWithFilter)myChooserComponent).resetFilter()) return;
      }
      closePopup(shouldPerformAction, null, shouldPerformAction);
    }
  });
}
项目:intellij-ce-playground    文件:FinderRecursivePanel.java   
protected JComponent createLeftComponent() {
  myList = createList();

  final JScrollPane pane =
    ScrollPaneFactory.createScrollPane(myList,
                                       ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                       ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  return ListWithFilter.wrap(myList, pane, new Function<T, String>() {
    @Override
    public String fun(T o) {
      return getItemText(o);
    }
  });
}
项目:intellij-ce-playground    文件:NavBarPopup.java   
private static JComponent createPopupContent(final NavBarPanel panel, Object[] siblings) {
  final JBListWithHintProvider list = new NavbarPopupList(panel, siblings);
  list.setDataProvider(new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      return panel.getData(dataId);
    }
  });
  final List<Disposable> disposables = new ArrayList<Disposable>();
  list.putClientProperty(DISPOSED_OBJECTS, disposables);
  list.installCellRenderer(new NotNullFunction<Object, JComponent>() {
    @NotNull
    @Override
    public JComponent fun(Object obj) {
      final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
      disposables.add(navBarItem);
      return navBarItem;
    }
  });
  list.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
  installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
  installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
  installEnterAction(list, panel, KeyEvent.VK_ENTER);
  installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
  final JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), new Function<Object, String>() {
    @Override
    public String fun(Object o) {
      return panel.getPresentation().getPresentableText(o);
    }
  });
  component.putClientProperty(JBLIST_KEY, list);
  return component;
}
项目:intellij-ce-playground    文件:ChooseFromFileListDialog.java   
@Nullable
@Override
protected JComponent createCenterPanel() {
  final JBList list = new JBList();
  list.setModel(getListModel(myFiles));
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      myChosenFile = (FileListItem)list.getSelectedValue();
    }
  });
  return ListWithFilter.wrap(list);
}
项目:tools-idea    文件:PopupChooserBuilder.java   
private void registerClosePopupKeyboardAction(final KeyStroke keyStroke, final boolean shouldPerformAction) {
  registerPopupKeyboardAction(keyStroke, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      if (!shouldPerformAction && myChooserComponent instanceof ListWithFilter) {
        if (((ListWithFilter)myChooserComponent).resetFilter()) return;
      }
      closePopup(shouldPerformAction, null, shouldPerformAction);
    }
  });
}
项目:tools-idea    文件:NavBarPopup.java   
private static JComponent createPopupContent(final NavBarPanel panel, Object[] siblings) {
  final JBListWithHintProvider list = new NavbarPopupList(panel, siblings);
  list.setDataProvider(new DataProvider() {
    @Override
    public Object getData(@NonNls String dataId) {
      return panel.getData(dataId);
    }
  });
  final List<Disposable> disposables = new ArrayList<Disposable>();
  list.putClientProperty(DISPOSED_OBJECTS, disposables);
  list.installCellRenderer(new NotNullFunction<Object, JComponent>() {
    @NotNull
    @Override
    public JComponent fun(Object obj) {
      final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
      disposables.add(navBarItem);
      return navBarItem;
    }
  });
  list.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
  installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
  installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
  installEnterAction(list, panel, KeyEvent.VK_ENTER);
  installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
  final JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), new Function<Object, String>() {
    @Override
    public String fun(Object o) {
      return panel.getPresentation().getPresentableText(o);
    }
  });
  component.putClientProperty(JBLIST_KEY, list);
  return component;
}
项目:consulo    文件:PopupChooserBuilder.java   
private void registerClosePopupKeyboardAction(final KeyStroke keyStroke, final boolean shouldPerformAction) {
  registerPopupKeyboardAction(keyStroke, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      if (!shouldPerformAction && myChooserComponent instanceof ListWithFilter) {
        if (((ListWithFilter)myChooserComponent).resetFilter()) return;
      }
      closePopup(shouldPerformAction, null, shouldPerformAction);
    }
  });
}
项目:consulo    文件:NavBarPopup.java   
private static JComponent createPopupContent(NavBarPanel panel, Object[] siblings) {
  class MyList<E> extends JBList<E> implements DataProvider, Queryable {
    @Override
    public void putInfo(@Nonnull Map<String, String> info) {
      panel.putInfo(info);
    }

    @Nullable
    @Override
    public Object getData(Key dataId) {
      return panel.getDataImpl(dataId, () -> JBIterable.of(getSelectedValuesList()));
    }
  }
  JBList<Object> list = new MyList<>();
  list.setModel(new CollectionListModel<>(siblings));
  HintUpdateSupply.installSimpleHintUpdateSupply(list);
  List<Disposable> disposables = new ArrayList<>();
  list.putClientProperty(DISPOSED_OBJECTS, disposables);
  list.installCellRenderer(obj -> {
    final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
    disposables.add(navBarItem);
    return navBarItem;
  });
  list.setBorder(JBUI.Borders.empty(5));
  installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
  installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
  installEnterAction(list, panel, KeyEvent.VK_ENTER);
  installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
  JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), o -> panel.getPresentation().getPresentableText(o));
  component.putClientProperty(JBLIST_KEY, list);
  return component;
}
项目:intellij-ce-playground    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:intellij-ce-playground    文件:DeleteBookmarkAction.java   
@Override
public void update(AnActionEvent e) {
  final boolean searchActive = ListWithFilter.isSearchActive(myList);
  e.getPresentation().setEnabled(!searchActive && BookmarksAction.getSelectedBookmarks(myList).size() > 0);
}
项目:tools-idea    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:tools-idea    文件:DeleteBookmarkAction.java   
@Override
public void update(AnActionEvent e) {
  final boolean searchActive = ListWithFilter.isSearchActive(myList);
  e.getPresentation().setEnabled(!searchActive && BookmarksAction.getSelectedBookmarks(myList).size() > 0);
}
项目:consulo    文件:ContentChooser.java   
private void rebuildListContent() {
  ArrayList<Item> items = new ArrayList<Item>();
  int i = 0;
  List<Data> contents = new ArrayList<Data>(getContents());
  for (Data content : contents) {
    String fullString = getStringRepresentationFor(content);
    if (fullString != null) {
      String shortString;
      fullString = StringUtil.convertLineSeparators(fullString);
      int newLineIdx = fullString.indexOf('\n');
      if (newLineIdx == -1) {
        shortString = fullString.trim(); 
      }
      else {
        int lastLooked = 0;
        do  {
          int nextLineIdx = fullString.indexOf("\n", lastLooked);
          if (nextLineIdx > lastLooked) {
            shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
            break;
          }
          else if (nextLineIdx == -1) {
            shortString = " ...";
            break;
          }
          lastLooked = nextLineIdx + 1;
        } while (true);
      }
      items.add(new Item(i ++, shortString, fullString));
    }
  }
  myAllContents = contents;
  FilteringListModel listModel = (FilteringListModel)myList.getModel();
  ((CollectionListModel)listModel.getOriginalModel()).removeAll();
  listModel.addAll(items);
  ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
  if (listWithFilter != null) {
    listWithFilter.getSpeedSearch().update();
    if (listModel.getSize() == 0) listWithFilter.resetFilter();
  }
}
项目:consulo    文件:DeleteBookmarkAction.java   
@Override
public void update(AnActionEvent e) {
  final boolean searchActive = ListWithFilter.isSearchActive(myList);
  e.getPresentation().setEnabled(!searchActive && BookmarksAction.getSelectedBookmarks(myList).size() > 0);
}