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


Java JBPopup.showInBestPositionFor方法代码示例

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


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

示例1: openSample

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
private void openSample(Project project, Editor editor) {

        EditorTextField field = new EditorTextField(editor.getDocument(), project, WeexFileType.INSTANCE, true, false) {
            @Override
            protected EditorEx createEditor() {
                EditorEx editor1 = super.createEditor();
                editor1.setVerticalScrollbarVisible(true);
                editor1.setHorizontalScrollbarVisible(true);
                return editor1;

            }
        };

        field.setFont(editor.getContentComponent().getFont());

        JBPopup jbPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(field, null)
                .createPopup();

        jbPopup.setSize(new Dimension(500, 500));
        jbPopup.showInBestPositionFor(editor);
    }
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:22,代码来源:DocumentIntention.java

示例2: invoke

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的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

示例3: invoke

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @Nullable final Editor editor, PsiFile file) {
  if (myModules.size() == 1) {
    addDependencyOnModule(project, editor, ContainerUtil.getFirstItem(myModules));
  }
  else {
    final JBList list = new JBList(myModules);
    list.setCellRenderer(new ModuleListCellRenderer());
    final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list)
      .setTitle("Choose Module to Add Dependency on")
      .setMovable(false)
      .setResizable(false)
      .setRequestFocus(true)
      .setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          final Object value = list.getSelectedValue();
          if (value instanceof Module) {
            addDependencyOnModule(project, editor, (Module)value);
          }
        }
      }).createPopup();
    if (editor != null) {
      popup.showInBestPositionFor(editor);
    } else {
      popup.showCenteredInCurrentWindow(project);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:AddModuleDependencyFix.java

示例4: show

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
protected void show(AnActionEvent e, JPanel result, JBPopup popup, InputEvent inputEvent) {
  if (inputEvent instanceof MouseEvent) {
    int width = result.getPreferredSize().width;
    MouseEvent inputEvent1 = (MouseEvent)inputEvent;
    Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY());
    RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1);
    popup.show(point);
  } else {
    popup.showInBestPositionFor(e.getDataContext());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SliderSelectorAction.java

示例5: onSuccess

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
@Override
public void onSuccess() {
  if (myProject.isDisposed() || ! myProject.isOpen()) return;

  if (myDescription != null) {
    NotificationPanel panel = new NotificationPanel();
    panel.setText(createMessage(myDescription, selectedFile));
    final JBPopup message = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel.getLabel()).createPopup();
    if (vcsContext.getEditor() != null) {
      message.showInBestPositionFor(vcsContext.getEditor());
    } else {
      message.showCenteredInCurrentWindow(vcsContext.getProject());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ShowBaseRevisionAction.java

示例6: showPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
public static void showPopup(AnActionEvent e, JBPopup popup) {
  final InputEvent event = e.getInputEvent();
  if (event instanceof MouseEvent) {
    popup.showUnderneathOf(event.getComponent());
  } else {
    popup.showInBestPositionFor(e.getDataContext());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:InspectionResultsView.java

示例7: positionPopupInBestPosition

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
public static void positionPopupInBestPosition(final JBPopup hint,
                                               @Nullable final Editor editor,
                                               @Nullable DataContext dataContext) {
  final LookupEx lookup = LookupManager.getActiveLookup(editor);
  if (lookup != null && lookup.getCurrentItem() != null && lookup.getComponent().isShowing()) {
    new PositionAdjuster(lookup.getComponent()).adjust(hint);
    lookup.addLookupListener(new LookupAdapter() {
      @Override
      public void lookupCanceled(LookupEvent event) {
        if (hint.isVisible()) {
          hint.cancel();
        }
      }
    });
    return;
  }

  final PositionAdjuster positionAdjuster = createPositionAdjuster();
  if (positionAdjuster != null) {
    positionAdjuster.adjust(hint);
    return;
  }

  if (editor != null && editor.getComponent().isShowing()) {
    hint.showInBestPositionFor(editor);
    return;
  }

  if (dataContext != null) {
    hint.showInBestPositionFor(dataContext);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PopupPositionManager.java

示例8: showHintPopUp

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
private static void showHintPopUp(Project project, Editor editor, DocumentationComponent component) {
  final JBPopup popup =
    JBPopupFactory.getInstance().createComponentPopupBuilder(component, component)
      .setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
      .setResizable(true)
      .setMovable(true)
      .setRequestFocus(true)
      .createPopup();
  component.setHint(popup);
  popup.showInBestPositionFor(editor);
  Disposer.dispose(component);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:StudyShowHintAction.java

示例9: applyFix

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiDirectory[] dirs = getDirectories();
  final List<VirtualFile> virtualFiles = getPotentialRoots(myModule, dirs);
  final VirtualFile[] roots = prepare(VfsUtilCore.toVirtualFileArray(virtualFiles));
  if (roots.length == 1) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        createDescription(roots[0]);
      }
    });
  }
  else {
    List<String> options = new ArrayList<String>();
    for (VirtualFile file : roots) {
      String path = getPath(file);
      options.add(path);
    }
    final JBList files = new JBList(ArrayUtil.toStringArray(options));
    files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JBPopup popup = JBPopupFactory.getInstance()
      .createListPopupBuilder(files)
      .setTitle(DevKitBundle.message("select.target.location.of.description", myFilename))
      .setItemChoosenCallback(new Runnable() {
        public void run() {
          final int index = files.getSelectedIndex();
          if (0 <= index && index < roots.length) {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
              public void run() {
                createDescription(roots[index]);
              }
            });
          }
        }
      }).createPopup();
    final Editor editor = FileEditorManager.getInstance(myModule.getProject()).getSelectedTextEditor();
    if (editor == null) return;
    popup.showInBestPositionFor(editor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:CreateHtmlDescriptionFix.java

示例10: performForContext

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
@Override
public void performForContext(@NotNull DataContext dataContext, final boolean invokedByShortcut) {
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);

  if (project == null) return;

  PsiDocumentManager.getInstance(project).commitAllDocuments();
  final Editor editor = getEditor(dataContext);

  PsiElement element = getElement(project, file, editor, CommonDataKeys.PSI_ELEMENT.getData(dataContext));

  if (element == null && file == null) return;
  PsiFile containingFile = element != null ? element.getContainingFile() : file;
  if (containingFile == null || !containingFile.getViewProvider().isPhysical()) return;


  if (editor != null) {
    PsiReference ref = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
    if (element == null && ref != null) {
      element = TargetElementUtil.getInstance().adjustReference(ref);
    }
  }

  final NavigatablePsiElement[] superElements = (NavigatablePsiElement[])findSuperElements(element);
  if (superElements.length == 0) return;

  final boolean isMethod = superElements[0] instanceof PsiMethod;
  final JBPopup popup = PsiElementListNavigator.navigateOrCreatePopup(superElements, "Choose super " + (isMethod ? "method" : "class or interface"), "Super " + (isMethod ? "methods" : "classes/interfaces"),
                                                                     isMethod ? new MethodCellRenderer(false) : new PsiClassListCellRenderer(), null, new Consumer<Object[]>() {
    @Override
    public void consume(Object[] objects) {
      showSiblings(invokedByShortcut, project, editor, file, editor != null, (PsiElement)objects[0]);
    }
  });
  if (popup != null) {
    if (editor != null) {
      popup.showInBestPositionFor(editor);
    } else {
      popup.showCenteredInCurrentWindow(project);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:ShowSiblingsAction.java

示例11: selectTargets

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的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

示例12: showDetailsPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
public static void showDetailsPopup(final Project project, final CommittedChangeList changeList) {
  StringBuilder detailsBuilder = new StringBuilder("<html><head>");
  detailsBuilder.append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())).append("</head><body>");
  final AbstractVcs vcs = changeList.getVcs();
  CachingCommittedChangesProvider provider = null;
  if (vcs != null) {
    provider = vcs.getCachingCommittedChangesProvider();
    if (provider != null && provider.getChangelistTitle() != null) {
      detailsBuilder.append(provider.getChangelistTitle()).append(" #").append(changeList.getNumber()).append("<br>");
    }
  }
  @NonNls String committer = "<b>" + changeList.getCommitterName() + "</b>";
  detailsBuilder.append(VcsBundle.message("changelist.details.committed.format", committer,
                                          DateFormatUtil.formatPrettyDateTime(changeList.getCommitDate())));
  detailsBuilder.append("<br>");

  if (provider != null) {
    final CommittedChangeList originalChangeList = ReceivedChangeList.unwrap(changeList);
    for(ChangeListColumn column: provider.getColumns()) {
      if (ChangeListColumn.isCustom(column)) {
        String value = column.getValue(originalChangeList).toString();
        if (value.length() == 0) {
          value = "<none>";
        }
        detailsBuilder.append(column.getTitle()).append(": ").append(XmlStringUtil.escapeString(value)).append("<br>");
      }
    }
  }

  detailsBuilder.append(IssueLinkHtmlRenderer.formatTextWithLinks(project, changeList.getComment()));
  detailsBuilder.append("</body></html>");

  JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, detailsBuilder.toString());
  editorPane.setEditable(false);
  editorPane.setBackground(HintUtil.INFORMATION_COLOR);
  editorPane.select(0, 0);
  editorPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(editorPane);
  final JBPopup hint =
    JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, editorPane)
      .setDimensionServiceKey(project, "changelist.details.popup", false)
      .setResizable(true)
      .setMovable(true)
      .setRequestFocus(true)
      .setTitle(VcsBundle.message("changelist.details.title"))
      .createPopup();
  hint.showInBestPositionFor(DataManager.getInstance().getDataContext());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:ChangeListDetailsAction.java

示例13: openTargets

import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
public static void openTargets(Editor e, NavigatablePsiElement[] targets, String title, final String findUsagesTitle, ListCellRenderer listRenderer) {
  JBPopup popup = navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, null);
  if (popup != null) popup.showInBestPositionFor(e);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PsiElementListNavigator.java


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