本文整理汇总了Java中com.intellij.ide.util.PsiElementListCellRenderer.installSpeedSearch方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElementListCellRenderer.installSpeedSearch方法的具体用法?Java PsiElementListCellRenderer.installSpeedSearch怎么用?Java PsiElementListCellRenderer.installSpeedSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.util.PsiElementListCellRenderer
的用法示例。
在下文中一共展示了PsiElementListCellRenderer.installSpeedSearch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseTargetClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseTargetClass(List<PsiClass> classes, final Editor editor) {
final PsiClass firstClass = classes.get(0);
final Project project = firstClass.getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
final PsiClass preselection = AnonymousTargetClassPreselectionUtil.getPreselection(classes, firstClass);
if (preselection != null) {
list.setSelectedValue(preselection, true);
}
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass) list.getSelectedValue();
AnonymousTargetClassPreselectionUtil.rememberSelection(aClass, firstClass);
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
doInvoke(project, aClass);
}
}, getText(), null);
}
};
builder.
setTitle(QuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}
示例2: chooseClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseClass(List<PsiClass> classes, Editor editor) {
final Project project = classes.get(0).getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass)list.getSelectedValue();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
invokeImpl(project, aClass);
}
});
}
}, getText(), null);
}
};
builder.
setTitle(QuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}
示例3: chooseTargetClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseTargetClass(List<PsiClass> classes, final Editor editor) {
final Project project = classes.get(0).getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass) list.getSelectedValue();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
doInvoke(project, aClass);
}
}, getText(), null);
}
};
builder.
setTitle(QuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}
示例4: getPsiElementPopup
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
@NotNull
public static <T extends PsiElement> JBPopup getPsiElementPopup(@NotNull T[] elements,
@NotNull final PsiElementListCellRenderer<T> renderer,
@Nullable final String title,
@NotNull final PsiElementProcessor<T> processor,
@Nullable final T selection) {
final JList list = new JBListWithHintProvider(elements) {
@Nullable
@Override
protected PsiElement getPsiElementForHint(Object selectedValue) {
return (PsiElement)selectedValue;
}
};
list.setCellRenderer(renderer);
if (selection != null) {
list.setSelectedValue(selection, true);
}
final Runnable runnable = new Runnable() {
@Override
public void run() {
int[] ids = list.getSelectedIndices();
if (ids == null || ids.length == 0) return;
for (Object element : list.getSelectedValues()) {
if (element != null) {
processor.execute((T)element);
}
}
}
};
PopupChooserBuilder builder = new PopupChooserBuilder(list);
if (title != null) {
builder.setTitle(title);
}
renderer.installSpeedSearch(builder, true);
return builder.setItemChoosenCallback(runnable).createPopup();
}
示例5: chooseTargetClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseTargetClass(List<PsiClass> classes, final Editor editor) {
final Project project = classes.get(0).getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass) list.getSelectedValue();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
doInvoke(project, aClass);
}
}, getText(), null);
}
};
builder.
setTitle(JavaQuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}
示例6: chooseTargetClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseTargetClass(PsiClass[] classes, final Editor editor, final String superClassName) {
final Project project = classes[0].getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass)list.getSelectedValue();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
doInvoke(aClass, superClassName);
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
});
}
}, getText(), null);
}
};
builder.
setTitle(QuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}
示例7: run
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
@Override
public void run() {
if (myClasses.length == 1) {
//TODO: cdr this place should produce at least warning
// selected(myClasses[0]);
selected((T[])ArrayUtil.toObjectArray(myClasses[0].getClass(), myClasses[0]));
}
else if (myClasses.length > 0) {
PsiElementListCellRenderer<T> renderer = createRenderer();
Arrays.sort(myClasses, renderer.getComparator());
if (ApplicationManager.getApplication().isUnitTestMode()) {
selected(myClasses);
return;
}
Vector<Object> model = new Vector<Object>(Arrays.asList(myClasses));
model.insertElementAt(CodeInsightBundle.message("highlight.thrown.exceptions.chooser.all.entry"), 0);
myList = new JBList(model);
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myList.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(myList);
renderer.installSpeedSearch(builder);
final Runnable callback = new Runnable() {
@Override
public void run() {
int idx = myList.getSelectedIndex();
if (idx < 0) return;
if (idx > 0) {
selected((T[])ArrayUtil.toObjectArray(myClasses[idx-1].getClass(), myClasses[idx-1]));
}
else {
selected(myClasses);
}
}
};
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
builder.
setTitle(myTitle).
setItemChoosenCallback(callback).
createPopup().
showInBestPositionFor(myEditor);
}
});
}
}
示例8: getPsiElementPopup
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
@NotNull
public static <T extends PsiElement> JBPopup getPsiElementPopup(@NotNull T[] elements,
@NotNull final PsiElementListCellRenderer<T> renderer,
@Nullable final String title,
@NotNull final PsiElementProcessor<T> processor,
@Nullable final T selection) {
final JList list = new JBListWithHintProvider(elements) {
@Nullable
@Override
protected PsiElement getPsiElementForHint(Object selectedValue) {
return (PsiElement)selectedValue;
}
};
list.setCellRenderer(renderer);
list.setFont(EditorUtil.getEditorFont());
if (selection != null) {
list.setSelectedValue(selection, true);
}
final Runnable runnable = new Runnable() {
@Override
public void run() {
int[] ids = list.getSelectedIndices();
if (ids == null || ids.length == 0) return;
for (Object element : list.getSelectedValues()) {
if (element != null) {
processor.execute((T)element);
}
}
}
};
PopupChooserBuilder builder = new PopupChooserBuilder(list);
if (title != null) {
builder.setTitle(title);
}
renderer.installSpeedSearch(builder, true);
JBPopup popup = builder.setItemChoosenCallback(runnable).createPopup();
builder.getScrollPane().setBorder(null);
builder.getScrollPane().setViewportBorder(null);
return popup;
}
示例9: getPsiElementPopup
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
@Nonnull
public static <T extends PsiElement> JBPopup getPsiElementPopup(@Nonnull T[] elements,
@Nonnull final PsiElementListCellRenderer<T> renderer,
@Nullable final String title,
@Nonnull final PsiElementProcessor<T> processor,
@Nullable final T selection) {
final JList list = new JBList(elements);
HintUpdateSupply.installSimpleHintUpdateSupply(list);
list.setCellRenderer(renderer);
list.setFont(EditorUtil.getEditorFont());
if (selection != null) {
list.setSelectedValue(selection, true);
}
final Runnable runnable = () -> {
int[] ids = list.getSelectedIndices();
if (ids == null || ids.length == 0) return;
for (Object element : list.getSelectedValues()) {
if (element != null) {
processor.execute((T)element);
}
}
};
PopupChooserBuilder builder = new PopupChooserBuilder(list);
if (title != null) {
builder.setTitle(title);
}
renderer.installSpeedSearch(builder, true);
JBPopup popup = builder.setItemChoosenCallback(runnable).createPopup();
builder.getScrollPane().setBorder(null);
builder.getScrollPane().setViewportBorder(null);
hidePopupIfDumbModeStarts(popup, elements[0].getProject());
return popup;
}
示例10: chooseTargetClass
import com.intellij.ide.util.PsiElementListCellRenderer; //导入方法依赖的package包/类
private void chooseTargetClass(PsiClass[] classes, final Editor editor, final String superClassName) {
final Project project = classes[0].getProject();
final JList list = new JBList(classes);
PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(renderer);
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
renderer.installSpeedSearch(builder);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = list.getSelectedIndex();
if (index < 0) return;
final PsiClass aClass = (PsiClass)list.getSelectedValue();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
doInvoke(aClass, superClassName);
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
});
}
}, getText(), null);
}
};
builder.
setTitle(JavaQuickFixBundle.message("target.class.chooser.title")).
setItemChoosenCallback(runnable).
createPopup().
showInBestPositionFor(editor);
}