• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JBPopup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JBPopup类属于com.intellij.openapi.ui.popup包,在下文中一共展示了JBPopup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: evaluate

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) throws Exception {
  final T data = getData();
  DebuggerUIUtil.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (callback.isObsolete()) return;
      final JComponent comp = createComponent(data);
      Project project = getEvaluationContext().getProject();
      JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
      JFrame frame = WindowManager.getInstance().getFrame(project);
      Dimension frameSize = frame.getSize();
      Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
      popup.setSize(size);
      if (comp instanceof Disposable) {
        Disposer.register(popup, (Disposable)comp);
      }
      callback.evaluated("");
      popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CustomPopupFullValueEvaluator.java


示例3: navigate

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void navigate(MouseEvent e, PsiElement nameIdentifier) {
  final PsiElement listOwner = nameIdentifier.getParent();
  final PsiFile containingFile = listOwner.getContainingFile();
  final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(listOwner);

  if (virtualFile != null && containingFile != null) {
    final Project project = listOwner.getProject();
    final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();

    if (editor != null) {
      editor.getCaretModel().moveToOffset(nameIdentifier.getTextOffset());
      final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

      if (file != null && virtualFile.equals(file.getVirtualFile())) {
        final JBPopup popup = createActionGroupPopup(containingFile, project, editor);
        if (popup != null) {
          popup.show(new RelativePoint(e));
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ExternalAnnotationsLineMarkerProvider.java


示例4: createActionGroupPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor) {
  final DefaultActionGroup group = new DefaultActionGroup();
  for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
    if (shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file)) {
      group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
    }
  }

  if (group.getChildrenCount() > 0) {
    final DataContext context = SimpleDataContext.getProjectContext(null);
    return JBPopupFactory.getInstance()
      .createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExternalAnnotationsLineMarkerProvider.java


示例5: getOwner

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
public static Component getOwner(@Nullable Component c) {
  if (c == null) return null;

  final Window wnd = SwingUtilities.getWindowAncestor(c);
  if (wnd instanceof JWindow) {
    final JRootPane root = ((JWindow)wnd).getRootPane();
    final JBPopup popup = (JBPopup)root.getClientProperty(JBPopup.KEY);
    if (popup == null) return c;

    final Component owner = popup.getOwner();
    if (owner == null) return c;

    return getOwner(owner);
  }
  else {
    return c;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PopupUtil.java


示例6: createPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
JBPopup createPopup() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.add(myTextField, BorderLayout.CENTER);
  ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField)
    .setCancelOnClickOutside(true)
    .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
    .setRequestFocus(true)
    .setResizable(true)
    .setMayBeParent(true);

  final JBPopup popup = builder.createPopup();
  popup.setMinimumSize(new Dimension(200, 90));
  AnAction okAction = new DumbAwareAction() {
    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
      unregisterCustomShortcutSet(popup.getContent());
      popup.closeOk(e.getInputEvent());
    }
  };
  okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
  return popup;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MultilinePopupBuilder.java


示例7: adjustContainerWindow

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize) {
  if (c == null) return;

  Window wnd = SwingUtilities.getWindowAncestor(c);

  if (wnd instanceof JWindow) {
    JBPopup popup = (JBPopup)((JWindow)wnd).getRootPane().getClientProperty(JBPopup.KEY);
    if (popup != null) {
      if (oldSize.height < newSize.height) {
        Dimension size = popup.getSize();
        size.height += newSize.height - oldSize.height;
        popup.setSize(size);
        popup.moveToFitScreen();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:WindowManagerImpl.java


示例8: DialogPopupWrapper

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
public DialogPopupWrapper(Component owner, Component content, int x, int y, JBPopup jbPopup) {
  if (!owner.isShowing()) {
    throw new IllegalArgumentException("Popup owner must be showing");
  }

  final Window wnd = UIUtil.getWindow(owner);
  if (wnd instanceof Frame) {
    myDialog = new JDialog((Frame)wnd);
  } else if (wnd instanceof Dialog) {
    myDialog = new JDialog((Dialog)wnd);
  } else {
    myDialog = new JDialog();
  }

  myDialog.getContentPane().setLayout(new BorderLayout());
  myDialog.getContentPane().add(content, BorderLayout.CENTER);
  myDialog.getRootPane().putClientProperty(JBPopup.KEY, jbPopup);
  myDialog.setUndecorated(true);
  myDialog.setBackground(UIUtil.getPanelBackground());
  myDialog.pack();
  myDialog.setLocation(x, y);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PopupComponent.java


示例9: getChildPopups

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
public static List<JBPopup> getChildPopups(@NotNull final Component component) {
  List<JBPopup> result = new ArrayList<JBPopup>();

  final Window window = UIUtil.getWindow(component);
  if (window == null) return result;

  final List<FocusTrackback> stack = getCleanStackForRoot(findUtlimateParent(window));

  for (FocusTrackback each : stack) {
    if (each.isChildFor(component) && each.getRequestor() instanceof JBPopup) {
      result.add((JBPopup)each.getRequestor());
    }
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FocusTrackback.java


示例10: actionPerformed

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  Disposable disposable = Disposer.newDisposable();
  NewRecentProjectPanel panel = new NewRecentProjectPanel(disposable);
  JList list = UIUtil.findComponentOfType(panel, JList.class);
  JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, list)
    .setTitle("Recent Projects")
    .setFocusable(true)
    .setRequestFocus(true)
    .setMayBeParent(true)
    .setMovable(true)
    .createPopup();
  Disposer.register(popup, disposable);
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  popup.showCenteredInCurrentWindow(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ManageRecentProjectsAction.java


示例11: createPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
@Override
protected JBPopup createPopup(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) project = ProjectManager.getInstance().getDefaultProject();

  Ref<JBPopup> popup = new Ref<JBPopup>();
  ChangesBrowser cb = new MyChangesBrowser(project, getChanges(), getCurrentSelection(), popup);

  popup.set(JBPopupFactory.getInstance()
              .createComponentPopupBuilder(cb, cb.getPreferredFocusedComponent())
              .setResizable(true)
              .setModalContext(false)
              .setFocusable(true)
              .setRequestFocus(true)
              .setCancelOnWindowDeactivation(true)
              .setCancelOnOtherWindowOpen(true)
              .setMovable(true)
              .setCancelKeyEnabled(true)
              .setCancelOnClickOutside(true)
              .setDimensionServiceKey(project, "Diff.GoToChangePopup", false)
              .createPopup());

  return popup.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ChangeGoToChangePopupAction.java


示例12: MyChangesBrowser

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
public MyChangesBrowser(@NotNull Project project,
                        @NotNull List<Change> changes,
                        @Nullable final Change currentChange,
                        @NotNull Ref<JBPopup> popup) {
  super(project, null, changes, null, false, false, null, MyUseCase.LOCAL_CHANGES, null);
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  setChangesToDisplay(changes);

  UiNotifyConnector.doWhenFirstShown(this, new Runnable() {
    @Override
    public void run() {
      if (currentChange != null) select(Collections.singletonList(currentChange));
    }
  });

  myPopup = popup;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ChangeGoToChangePopupAction.java


示例13: createComboBoxButton

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
protected FlatComboButton createComboBoxButton(Presentation presentation) {
  if (myShowDisabledActions) {
    return new FlatComboButton(presentation) {
      @Override
      protected JBPopup createPopup(Runnable onDispose) {
        ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
          null, createPopupActionGroup(this), getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true, onDispose,
          getMaxRows());
        popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
        return popup;
      }
    };
  }
  return super.createComboBoxButton(presentation);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AbstractComboBoxAction.java


示例14: getActiveDocComponent

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
public static DocumentationComponent getActiveDocComponent(@NotNull Project project) {
  DocumentationManager documentationManager = DocumentationManager.getInstance(project);
  DocumentationComponent component;
  JBPopup hint = documentationManager.getDocInfoHint();
  if (hint != null) {
    component = (DocumentationComponent)((AbstractPopup)hint).getComponent();
  }
  else if (documentationManager.hasActiveDockedDocWindow()) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
    Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent();
    component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent();
  }
  else {
    component = null;
  }
  return component;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:QuickDocUtil.java


示例15: getRelatedItemsPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
public static JBPopup getRelatedItemsPopup(final List<? extends GotoRelatedItem> items, String title) {
  Object[] elements = new Object[items.size()];
  //todo[nik] move presentation logic to GotoRelatedItem class
  final Map<PsiElement, GotoRelatedItem> itemsMap = new HashMap<PsiElement, GotoRelatedItem>();
  for (int i = 0; i < items.size(); i++) {
    GotoRelatedItem item = items.get(i);
    elements[i] = item.getElement() != null ? item.getElement() : item;
    itemsMap.put(item.getElement(), item);
  }

  return getPsiElementPopup(elements, itemsMap, title, new Processor<Object>() {
    @Override
    public boolean process(Object element) {
      if (element instanceof PsiElement) {
        //noinspection SuspiciousMethodCalls
        itemsMap.get(element).navigate();
      }
      else {
        ((GotoRelatedItem)element).navigate();
      }
      return true;
    }
  }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:NavigationUtil.java


示例16: navigateOrCreatePopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
private static JBPopup navigateOrCreatePopup(final NavigatablePsiElement[] targets,
                                             final String title,
                                             final String findUsagesTitle,
                                             final ListCellRenderer listRenderer,
                                             @Nullable final ListBackgroundUpdaterTask listUpdaterTask) {
  return navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask, new Consumer<Object[]>() {
    @Override
    public void consume(Object[] selectedElements) {
      for (Object element : selectedElements) {
        PsiElement selected = (PsiElement)element;
        LOG.assertTrue(selected.isValid());
        ((NavigatablePsiElement)selected).navigate(true);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiElementListNavigator.java


示例17: discoverPopup

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
private static Component discoverPopup(final DataKey<JBPopup> datakey, Component focusOwner) {
  if (focusOwner == null) {
    focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  }

  if (focusOwner == null) return null;

  final DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  if (dataContext == null) return null;

  final JBPopup popup = datakey.getData(dataContext);
  if (popup != null && popup.isVisible()) {
    return popup.getContent();
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PopupPositionManager.java


示例18: createComboBoxButton

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
protected ComboBoxButton createComboBoxButton(Presentation presentation) {
  if (myShowDisabledActions) {
    return new ComboBoxButton(presentation) {
      @Override
      protected JBPopup createPopup(Runnable onDispose) {
        ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
          null, createPopupActionGroup(this), getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true, onDispose,
          getMaxRows());
        popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
        return popup;
      }
    };
  }
  return super.createComboBoxButton(presentation);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AbstractComboBoxAction.java


示例19: showHintPopUp

import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
private static void showHintPopUp(Project project, StudyState studyState, Editor editor, StudyToolWindow hintComponent) {
  final JBPopup popup =
    JBPopupFactory.getInstance().createComponentPopupBuilder(hintComponent, hintComponent)
      .setDimensionServiceKey(project, "StudyHint", false)
      .setResizable(true)
      .setMovable(true)
      .setRequestFocus(true)
      .setTitle(studyState.getTask().getName())
      .createPopup();
  Disposer.register(popup, hintComponent);

  final Component focusOwner = IdeFocusManager.getInstance(project).getFocusOwner();
  DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
  PopupPositionManager.positionPopupInBestPosition(popup, editor, dataContext);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:16,代码来源:StudyShowHintAction.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JspUtil类代码示例发布时间:2022-05-21
下一篇:
Java BuildWrapperDescriptor类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap