Java 类com.intellij.ui.ListSpeedSearch 实例源码

项目:intellij-ce-playground    文件:FileTemplateTabAsList.java   
FileTemplateTabAsList(String title) {
  super(title);
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new MyListCellRenderer());
  myList.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      onTemplateSelected();
    }
  });
  new ListSpeedSearch(myList, new Function<Object, String>() {
    @Override
    public String fun(final Object o) {
      if (o instanceof FileTemplate) {
        return ((FileTemplate)o).getName();
      }
      return null;
    }
  });
}
项目:tools-idea    文件:FileTemplateTabAsList.java   
FileTemplateTabAsList(String title) {
  super(title);
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new MyListCellRenderer());
  myList.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      onTemplateSelected();
    }
  });
  new ListSpeedSearch(myList, new Function<Object, String>() {
    @Override
    public String fun(final Object o) {
      if (o instanceof FileTemplate) {
        return ((FileTemplate)o).getName();
      }
      return null;
    }
  });
}
项目:tools-idea    文件:UsersPopup.java   
public static void showUsersPopup(final List<String> knownUsers, final Consumer<String> continuation, DataContext dc) {
  // todo pattern to come
  final JList list = new JBList();
  list.setListData(ArrayUtil.toObjectArray(knownUsers));
  new ListSpeedSearch(list);

  JBPopupFactory.getInstance().createListPopupBuilder(list)
          .setTitle("Select author or committer")
          .setResizable(true)
          //.setDimensionServiceKey("Git.Select user")
          .setItemChoosenCallback(new Runnable() {
            public void run() {
              if (list.getSelectedIndices().length > 0) {
                continuation.consume((String) list.getSelectedValue());
              }
            }
          })
          .createPopup().showInBestPositionFor(dc);
}
项目:consulo    文件:ProjectLibraryTabContext.java   
public ProjectLibraryTabContext(final ClasspathPanel classpathPanel, StructureConfigurableContext context) {
  super(classpathPanel, context);

  StructureLibraryTableModifiableModelProvider projectLibrariesProvider = context.getProjectLibrariesProvider();
  Library[] libraries = projectLibrariesProvider.getModifiableModel().getLibraries();
  final Condition<Library> condition = LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());

  myItems = ContainerUtil.filter(libraries, condition);
  ContainerUtil.sort(myItems, new Comparator<Library>() {
    @Override
    public int compare(Library o1, Library o2) {
      return StringUtil.compare(o1.getName(), o2.getName(), false);
    }
  });

  myLibraryList = new JBList(myItems);
  myLibraryList.setCellRenderer(new ColoredListCellRendererWrapper<Library>() {
    @Override
    protected void doCustomize(JList list, Library value, int index, boolean selected, boolean hasFocus) {
      final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance().forLibrary(classpathPanel.getProject(), value, false);

      appearance.customize(this);
    }
  });
  new ListSpeedSearch(myLibraryList);
}
项目:consulo    文件:FileTemplateTabAsList.java   
FileTemplateTabAsList(String title) {
  super(title);
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new MyListCellRenderer());
  myList.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      onTemplateSelected();
    }
  });
  new ListSpeedSearch(myList, new Function<Object, String>() {
    @Override
    public String fun(final Object o) {
      if (o instanceof FileTemplate) {
        return ((FileTemplate)o).getName();
      }
      return null;
    }
  });
}
项目:consulo    文件:PsiElementListCellRenderer.java   
/**
 * User {@link #installSpeedSearch(com.intellij.openapi.ui.popup.PopupChooserBuilder)} instead
 */
@Deprecated
public void installSpeedSearch(JList list) {
  new ListSpeedSearch(list) {
    @Override
    protected String getElementText(Object o) {
      if (o instanceof PsiElement) {
        final String elementText = PsiElementListCellRenderer.this.getElementText((T)o);
        return elementText + " " + getContainerText((T)o, elementText);
      }
      else {
        return o.toString();
      }
    }
  };
}
项目:intellij-ce-playground    文件:ChooseClassDialog.java   
public ChooseClassDialog(Module module, String title, boolean includeAll, String... classes) {
  super(module.getProject());

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (myList.getSelectedValue() != null) {
        close(OK_EXIT_CODE);
        return true;
      }
      return false;
    }
  }.installOn(myList);

  DefaultListModel model = new DefaultListModel();
  findClasses(module, includeAll, model, classes);
  myList.setModel(model);
  myList.setCellRenderer(new DefaultPsiElementCellRenderer());

  ListSelectionModel selectionModel = myList.getSelectionModel();
  selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  selectionModel.addListSelectionListener(this);

  new ListSpeedSearch(myList) {
    @Override
    protected boolean isMatchingElement(Object element, String pattern) {
      PsiClass psiClass = (PsiClass)element;
      return compare(psiClass.getName(), pattern) || compare(psiClass.getQualifiedName(), pattern);
    }
  };

  setTitle(title);
  setOKActionEnabled(false);

  init();

  Dimension size = myComponent.getPreferredSize();
  size.height = myList.getPreferredSize().height + 20;
  myComponent.setPreferredSize(size);
}
项目:intellij-ce-playground    文件:GradleSignStep.java   
public GradleSignStep(@NotNull ExportSignedPackageWizard exportSignedPackageWizard) {
  myWizard = exportSignedPackageWizard;

  myFlavorsList.setModel(myFlavorsListModel);
  myFlavorsList.setEmptyText(AndroidBundle.message("android.apk.sign.gradle.no.flavors"));
  new ListSpeedSearch(myFlavorsList);

  myBuildTypeCombo.setModel(myBuildTypeComboModel);
}
项目:tools-idea    文件:FontOptions.java   
protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
  super(new GridBagLayout());
  myOptions = options;
  myTitle = title;
  add(createEditorFontPanel(), new GridBag().weightx(1).weighty(1).fillCell().coverLine());
  add(new JLabel(ApplicationBundle.message("label.fallback.fonts.list.description"),
                 MessageType.INFO.getDefaultIcon(),
                 SwingConstants.LEFT),
      new GridBag().anchor(GridBagConstraints.WEST));
  myFontsControl.setShowButtons(JBMovePanel.ButtonType.LEFT, JBMovePanel.ButtonType.RIGHT);
  myFontsControl.setListLabels(ApplicationBundle.message("title.font.available"), ApplicationBundle.message("title.font.selected"));
  myFontsControl.setEnabled(false); // Disable the controls until fonts are loaded.
  myFontsControl.setLeftInsertionStrategy(JBMovePanel.NATURAL_ORDER);
  myOnlyMonospacedCheckBox.setSelected(EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
  new ListSpeedSearch(myAllFontsList);
  new ListSpeedSearch(mySelectedFontsList);

  // Almost all other color scheme pages use the following pattern:
  //
  //    __________________________________________
  //   |  color keys  |  color and font settings  |
  //
  // Here page's height is calculated on the 'color and font settings' preferred height (debugged a lot to ensure that).
  // The idea is to configure current page to use the same height as other pages. That's why we set it up to use the same preferred
  // size as 'color and font settings' control.
  myPreferredSize = new ColorAndFontDescriptionPanel().getPreferredSize();
  if (myFontNames != null) {
    onFontsInit();
  }
  initListeners();
}
项目:tools-idea    文件:ColorEditor.java   
protected void buildChooser() {
  setLayout(new BorderLayout());
  myDescriptorList = new JBList(myColorDescriptors);
  myDescriptorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myDescriptorList.setVisibleRowCount(15);
  myDescriptorList.setCellRenderer(new ColorRenderer());
  myDescriptorList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      ColorDescriptor descriptor = (ColorDescriptor)myDescriptorList.getSelectedValue();
      getColorSelectionModel().setSelectedColor(new ColorDescriptorWrapper(descriptor));
    }
  });
  new ListSpeedSearch(myDescriptorList);
  add(ScrollPaneFactory.createScrollPane(myDescriptorList), BorderLayout.CENTER);
}
项目:consulo-ui-designer    文件:ColorEditor.java   
protected void buildChooser() {
  setLayout(new BorderLayout());
  myDescriptorList = new JBList(myColorDescriptors);
  myDescriptorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myDescriptorList.setVisibleRowCount(15);
  myDescriptorList.setCellRenderer(new ColorRenderer());
  myDescriptorList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      ColorDescriptor descriptor = (ColorDescriptor)myDescriptorList.getSelectedValue();
      getColorSelectionModel().setSelectedColor(new ColorDescriptorWrapper(descriptor));
    }
  });
  new ListSpeedSearch(myDescriptorList);
  add(ScrollPaneFactory.createScrollPane(myDescriptorList), BorderLayout.CENTER);
}
项目:consulo    文件:ModuleDependencyTabContext.java   
public ModuleDependencyTabContext(ClasspathPanel panel, StructureConfigurableContext context) {
  super(panel, context);
  myNotAddedModules = getNotAddedModules();
  myModuleList = new JBList(myNotAddedModules);
  myModuleList.setCellRenderer(new ModuleListCellRenderer());

  new ListSpeedSearch(myModuleList);
}
项目:consulo-java    文件:ThreadDumpPanel.java   
public ThreadDumpPanel(Project project, final ConsoleView consoleView, final DefaultActionGroup toolbarActions, final List<ThreadState> threadDump) {
  super(new BorderLayout());
  final ThreadState[] data = threadDump.toArray(new ThreadState[threadDump.size()]);
  DefaultListModel model = new DefaultListModel();
  for (ThreadState threadState : data) {
    model.addElement(threadState);
  }
  myThreadList = new JBList(model);
  myThreadList.setCellRenderer(new ThreadListCellRenderer());
  myThreadList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myThreadList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      int index = myThreadList.getSelectedIndex();
      if (index >= 0) {
        ThreadState selection = (ThreadState)myThreadList.getModel().getElementAt(index);
        AnalyzeStacktraceUtil.printStacktrace(consoleView, selection.getStackTrace());
      }
      else {
        AnalyzeStacktraceUtil.printStacktrace(consoleView, "");
      }
      myThreadList.repaint();
    }
  });
  toolbarActions.add(new CopyToClipboardAction(threadDump, project));
  toolbarActions.add(new SortThreadsAction());
  //toolbarActions.add(new ShowRecentlyChanged());
  add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false).getComponent(), BorderLayout.WEST);

  final Splitter splitter = new Splitter(false, 0.3f);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myThreadList, SideBorder.LEFT | SideBorder.RIGHT));
  splitter.setSecondComponent(consoleView.getComponent());

  add(splitter, BorderLayout.CENTER);

  new ListSpeedSearch(myThreadList).setComparator(new SpeedSearchComparator(false, true));
}
项目:tools-idea    文件:ContainedInBranchesConfigDialog.java   
private void initUi(Project project, Collection<String> localBranches, Collection<String> remoteBranches, final String currentLocal,
                    final String currentRemote) {
  myPanel = new JPanel(new GridBagLayout());
  final GridBagConstraints gb =
    new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0);
  myLocalBranches = new MyCheckBoxList(currentLocal);
  myRemoteBranches = new MyCheckBoxList(currentRemote);

  gb.gridwidth = 2;
  JLabel label = new JLabel("Select branches for \"Contained in branches\" field:");
  label.setBorder(BorderFactory.createEmptyBorder(0,0,2,0));
  myPanel.add(label, gb);

  final ButtonGroup bg = new ButtonGroup();
  myHighlight = new JRadioButton("Highlight them");
  myFilter = new JRadioButton("Filter others out");
  bg.add(myHighlight);
  bg.add(myFilter);
  gb.gridwidth = 1;
  gb.gridx = 0;
  ++ gb.gridy; 
  myPanel.add(myHighlight, gb);
  ++ gb.gridy;
  myPanel.add(myFilter, gb);

  gb.insets.top = 10;
  gb.gridwidth = 1;
  ++ gb.gridy;
  myPanel.add(new JLabel("Local branches"), gb);
  ++ gb.gridx;
  myPanel.add(new JLabel("Remote branches"), gb);

  gb.insets.top = 0;
  ++ gb.gridy;
  gb.gridx = 0;
  gb.fill = GridBagConstraints.BOTH;
  gb.weightx = 0.5;
  gb.weighty = 1;
  myLocalBranches.setBorder(null);
  myRemoteBranches.setBorder(null);
  myPanel.add(ScrollPaneFactory.createScrollPane(myLocalBranches), gb);
  ++ gb.gridx;
  myPanel.add(ScrollPaneFactory.createScrollPane(myRemoteBranches), gb);

  final GitLogSettings gitLogSettings = GitLogSettings.getInstance(project);
  setItems(localBranches, gitLogSettings.getLocalBranchesCopy(), myLocalBranches);
  setItems(remoteBranches, gitLogSettings.getRemoteBranchesCopy(), myRemoteBranches);

  myHighlight.setSelected(gitLogSettings.isHighlight());
  myFilter.setSelected(! gitLogSettings.isHighlight());

  new ListSpeedSearch(myLocalBranches);
  new ListSpeedSearch(myRemoteBranches);

  focus(myLocalBranches);
  focus(myRemoteBranches);
}
项目:consulo    文件:GutterIconsConfigurable.java   
private void createUIComponents() {
  myList = new CheckBoxList<GutterIconDescriptor>() {
    @Override
    protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) {
      JPanel panel = new JPanel(new BorderLayout());
      panel.setBorder(BorderFactory.createEmptyBorder());
      GutterIconDescriptor descriptor = myList.getItemAt(index);
      Icon icon = descriptor == null ? null : descriptor.getIcon();
      JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon);
      label.setOpaque(true);
      label.setPreferredSize(new Dimension(25, -1));
      label.setHorizontalAlignment(SwingConstants.CENTER);
      panel.add(label, BorderLayout.WEST);
      panel.add(checkBox, BorderLayout.CENTER);
      panel.setBackground(getBackground(false));
      label.setBackground(getBackground(selected));
      if (!checkBox.isOpaque()) {
        checkBox.setOpaque(true);
      }
      checkBox.setBorder(null);

      PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor);
      if (pluginDescriptor instanceof IdeaPluginDescriptor) {
        SeparatorWithText separator = new SeparatorWithText();
        String name = ((IdeaPluginDescriptor)pluginDescriptor).getName();
        separator.setCaption("IDEA CORE".equals(name) ? "Common" : name);
        panel.add(separator, BorderLayout.NORTH);
      }

      return panel;
    }

    @Nullable
    @Override
    protected Point findPointRelativeToCheckBox(int x, int y, @Nonnull JCheckBox checkBox, int index) {
      return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index);
    }
  };
  myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  myList.setBorder(BorderFactory.createEmptyBorder());
  new ListSpeedSearch(myList, (Convertor<Object, String>)o -> o instanceof JCheckBox ? ((JCheckBox)o).getText() : null);
}