本文整理汇总了Java中com.intellij.openapi.ui.popup.PopupChooserBuilder.setFilteringEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java PopupChooserBuilder.setFilteringEnabled方法的具体用法?Java PopupChooserBuilder.setFilteringEnabled怎么用?Java PopupChooserBuilder.setFilteringEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.popup.PopupChooserBuilder
的用法示例。
在下文中一共展示了PopupChooserBuilder.setFilteringEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installSpeedSearch
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public void installSpeedSearch(PopupChooserBuilder builder, final boolean includeContainerText) {
builder.setFilteringEnabled(new Function<Object, String>() {
@Override
public String fun(Object o) {
if (o instanceof PsiElement) {
final String elementText = getElementText((T)o);
if (includeContainerText) {
return elementText + " " + getContainerText((T)o, elementText);
}
return elementText;
}
else {
return o.toString();
}
}
});
}
示例2: buildPopup
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
private JBPopup buildPopup(final JBList list,
final Map<Object, String> filterIndex)
{
final PopupChooserBuilder listPopupBuilder = JBPopupFactory.getInstance().createListPopupBuilder(list);
listPopupBuilder.setTitle("Run a Forge command");
listPopupBuilder.setResizable(true);
listPopupBuilder.addListener(new JBPopupAdapter()
{
@Override
public void onClosed(LightweightWindowEvent event)
{
CommandListPopupBuilder.active = false;
}
});
listPopupBuilder.setItemChoosenCallback((Runnable) () -> {
Object selectedObject = list.getSelectedValue();
if (selectedObject instanceof UICommand)
{
UICommand selectedCommand = (UICommand) selectedObject;
// Make sure that this cached command is still enabled
if (selectedCommand.isEnabled(uiContext))
{
openWizard(selectedCommand);
}
}
});
listPopupBuilder.setFilteringEnabled(filterIndex::get);
return listPopupBuilder.createPopup();
}
示例3: installSpeedSearch
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public void installSpeedSearch(PopupChooserBuilder builder, final boolean includeContainerText) {
builder.setFilteringEnabled(o -> {
if (o instanceof PsiElement) {
final String elementText = getElementText((T)o);
if (includeContainerText) {
return elementText + " " + getContainerText((T)o, elementText);
}
return elementText;
}
else {
return o.toString();
}
});
}
示例4: selectTargets
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
@Override
protected void selectTargets(final List<PsiMember> targets, final Consumer<List<PsiMember>> selectionConsumer) {
if (targets.isEmpty()) {
selectionConsumer.consume(Collections.<PsiMember>emptyList());
return;
}
if (targets.size() == 1) {
selectionConsumer.consume(Collections.singletonList(targets.get(0)));
return;
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
selectionConsumer.consume(targets);
return;
}
Collections.sort(targets, new PsiMemberComparator());
final List<Object> model = new ArrayList<Object>();
model.add(CodeInsightBundle.message("highlight.thrown.exceptions.chooser.all.entry"));
model.addAll(targets);
final JList list = new JBList(model);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final ListCellRenderer renderer = new NavigationItemListCellRenderer();
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
builder.setFilteringEnabled(new Function<Object, String>() {
@Override
public String fun(Object o) {
if (o instanceof PsiMember) {
final PsiMember member = (PsiMember)o;
return member.getName();
}
return o.toString();
}
});
if (myImportStatic) {
builder.setTitle(CodeInsightBundle.message("highlight.imported.members.chooser.title"));
} else {
builder.setTitle(CodeInsightBundle.message("highlight.imported.classes.chooser.title"));
}
builder.setItemChoosenCallback(new Runnable() {
@Override
public void run() {
final int index= list.getSelectedIndex();
if (index == 0) {
selectionConsumer.consume(targets);
}
else {
selectionConsumer.consume(Collections.singletonList(targets.get(index - 1)));
}
}
});
final JBPopup popup = builder.createPopup();
popup.showInBestPositionFor(myEditor);
}