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(); } }
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()); } }
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()); } }
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); } }); }
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); } }); }
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; }
@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); }
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; }
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(); } }
@Override public void update(AnActionEvent e) { final boolean searchActive = ListWithFilter.isSearchActive(myList); e.getPresentation().setEnabled(!searchActive && BookmarksAction.getSelectedBookmarks(myList).size() > 0); }