本文整理汇总了Java中com.intellij.openapi.ui.popup.PopupChooserBuilder.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java PopupChooserBuilder.setTitle方法的具体用法?Java PopupChooserBuilder.setTitle怎么用?Java PopupChooserBuilder.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.popup.PopupChooserBuilder
的用法示例。
在下文中一共展示了PopupChooserBuilder.setTitle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
// filter libraries to only be Camel libraries
Set<String> artifacts = ServiceManager.getService(project, CamelService.class).getLibraries();
// find the camel component from those libraries
boolean consumerOnly = getCamelIdeaUtils().isConsumerEndpoint(element);
List<String> names = findCamelComponentNamesInArtifact(artifacts, consumerOnly, project);
// no camel endpoints then exit
if (names.isEmpty()) {
return;
}
// show popup to chose the component
JBList list = new JBList(names.toArray(new Object[names.size()]));
PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
builder.setAdText(names.size() + " components");
builder.setTitle("Add Camel Endpoint");
builder.setItemChoosenCallback(() -> {
String line = (String) list.getSelectedValue();
int pos = editor.getCaretModel().getCurrentCaret().getOffset();
if (pos > 0) {
// must run this as write action because we change the source code
new WriteCommandAction(project, element.getContainingFile()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
String text = line + ":";
editor.getDocument().insertString(pos, text);
editor.getCaretModel().moveToOffset(pos + text.length());
}
}.execute();
}
});
JBPopup popup = builder.createPopup();
popup.showInBestPositionFor(editor);
}
示例2: showCompletionPopup
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public static void showCompletionPopup(JComponent toolbarComponent,
final JList list,
String title,
final JTextComponent textField,
String ad) {
final Runnable callback = new Runnable() {
@Override
public void run() {
String selectedValue = (String)list.getSelectedValue();
if (selectedValue != null) {
textField.setText(selectedValue);
}
}
};
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
if (title != null) {
builder.setTitle(title);
}
final JBPopup popup = builder.setMovable(false).setResizable(false)
.setRequestFocus(true).setItemChoosenCallback(callback).createPopup();
if (ad != null) {
popup.setAdText(ad, SwingConstants.LEFT);
}
if (toolbarComponent != null) {
popup.showUnderneathOf(toolbarComponent);
}
else {
popup.showUnderneathOf(textField);
}
}
示例3: processIntention
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
protected void processIntention(PsiElement psiElement) {
GLSLIdentifier elementTemp = null;
if(psiElement instanceof GLSLIdentifier){
elementTemp = (GLSLIdentifier) psiElement;
}else{
PsiElement parent = psiElement.getParent();
if(parent instanceof GLSLIdentifier){
elementTemp = (GLSLIdentifier) parent;
}
}
if(elementTemp == null){
Logger.getInstance(VectorComponentsIntention.class).warn("Could not find GLSLIdentifier for psiElement: "+psiElement);
return;
}
final GLSLIdentifier element = elementTemp;
String components = element.getText();
createComponentVariants(components);
String[] variants = new String[]{components + " -> " + results[0], components + " -> " + results[1]};
//http://www.jetbrains.net/devnet/message/5208622#5208622
final JBList list = new JBList((Object[])variants);
PopupChooserBuilder builder = new PopupChooserBuilder(list);
builder.setTitle("Select Variant");
builder.setItemChoosenCallback(new Runnable() {
public void run() {
WriteCommandAction writeAction = new WriteCommandAction(element.getProject(), element.getContainingFile()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
replaceIdentifierElement(element, results[list.getSelectedIndex()]);
}
};
writeAction.execute();
}
});
JBPopup popup = builder.createPopup();
popup.showInBestPositionFor(getEditor());
}
示例4: getPsiElementPopup
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的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: 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();
}
示例6: showCompletionPopup
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public static void showCompletionPopup(JComponent toolbarComponent,
final JList list,
String title,
final JTextComponent textField,
String ad) {
final Runnable callback = new Runnable() {
@Override
public void run() {
String selectedValue = (String)list.getSelectedValue();
if (selectedValue != null) {
textField.setText(selectedValue);
}
}
};
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
if (title != null) {
builder.setTitle(title);
}
final JBPopup popup = builder.setMovable(false).setResizable(false)
.setRequestFocus(true).setItemChoosenCallback(callback).createPopup();
if (ad != null) {
popup.setAdText(ad, SwingConstants.LEFT);
}
if (toolbarComponent != null) {
popup.showUnderneathOf(toolbarComponent);
}
else {
popup.showUnderneathOf(textField);
}
}
示例7: 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);
}
示例8: getPsiElementPopup
import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的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.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的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;
}