当前位置: 首页>>代码示例>>Java>>正文


Java PopupChooserBuilder.setTitle方法代码示例

本文整理汇总了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);
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:39,代码来源:CamelAddEndpointIntention.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:Utils.java

示例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());
}
 
开发者ID:Darkyenus,项目名称:glsl4idea,代码行数:40,代码来源:VectorComponentsIntention.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:NavigationUtil.java

示例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();
}
 
开发者ID:forge,项目名称:intellij-idea-plugin,代码行数:32,代码来源:CommandListPopupBuilder.java

示例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);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:35,代码来源:Utils.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:HighlightImportedElementsHandler.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:NavigationUtil.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:42,代码来源:NavigationUtil.java


注:本文中的com.intellij.openapi.ui.popup.PopupChooserBuilder.setTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。