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


Java PopupChooserBuilder.setItemChoosenCallback方法代码示例

本文整理汇总了Java中com.intellij.openapi.ui.popup.PopupChooserBuilder.setItemChoosenCallback方法的典型用法代码示例。如果您正苦于以下问题:Java PopupChooserBuilder.setItemChoosenCallback方法的具体用法?Java PopupChooserBuilder.setItemChoosenCallback怎么用?Java PopupChooserBuilder.setItemChoosenCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.ui.popup.PopupChooserBuilder的用法示例。


在下文中一共展示了PopupChooserBuilder.setItemChoosenCallback方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAmbigTreesPopup

import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public static JBPopup createAmbigTreesPopup(final PreviewState previewState,
                                            final AmbiguityInfo ambigInfo) {
	final JBList list = new JBList("Show all phrase interpretations");
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	JBPopupFactory factory = JBPopupFactory.getInstance();
	PopupChooserBuilder builder = factory.createListPopupBuilder(list);
	builder.setItemChoosenCallback(
		new Runnable() {
			@Override
			public void run() {
				popupAmbigTreesDialog(previewState, ambigInfo);
			}
		}
	                              );
	JBPopup popup = builder.createPopup();
	return popup;
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:18,代码来源:ShowAmbigTreesDialog.java

示例2: createLookaheadTreesPopup

import com.intellij.openapi.ui.popup.PopupChooserBuilder; //导入方法依赖的package包/类
public static JBPopup createLookaheadTreesPopup(final PreviewState previewState,
                                                final LookaheadEventInfo lookaheadInfo) {
	final JBList list = new JBList("Show all lookahead interpretations");
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	JBPopupFactory factory = JBPopupFactory.getInstance();
	PopupChooserBuilder builder = factory.createListPopupBuilder(list);
	builder.setItemChoosenCallback(
		new Runnable() {
			@Override
			public void run() {
				popupLookaheadTreesDialog(previewState, lookaheadInfo);
			}
		}
	                              );

	JBPopup popup = builder.createPopup();
	return popup;
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:19,代码来源:ShowAmbigTreesDialog.java

示例3: 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

示例4: 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

示例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: 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


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