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


Java ComponentPopupBuilder类代码示例

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


ComponentPopupBuilder类属于com.intellij.openapi.ui.popup包,在下文中一共展示了ComponentPopupBuilder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPopup

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

示例2: createPopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
@Nonnull
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 JBDimension(200, 90));
  AnAction okAction = new DumbAwareAction() {
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      unregisterCustomShortcutSet(popup.getContent());
      popup.closeOk(e.getInputEvent());
    }
  };
  okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
  return popup;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:MultilinePopupBuilder.java

示例3: showNotePopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
private void showNotePopup(Project project,
                           final DnDAwareTree tree,
                           final Consumer<String> after, final String initText) {
  final JTextArea textArea = new JTextArea(3, 50);
  textArea.setFont(UIUtil.getTreeFont());
  textArea.setText(initText);
  final JBScrollPane pane = new JBScrollPane(textArea);
  final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea)
    .setCancelOnClickOutside(true)
    .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
    .setTitle("Comment")
    .setMovable(true)
    .setRequestFocus(true).setResizable(true).setMayBeParent(true);
  final JBPopup popup = builder.createPopup();
  final JComponent content = popup.getContent();
  final AnAction action = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      popup.closeOk(e.getInputEvent());
      unregisterCustomShortcutSet(content);
      after.consume(textArea.getText());
    }
  };
  action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      popup.showInCenterOf(tree);
    }
  }, ModalityState.NON_MODAL, project.getDisposed());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:TaskDefaultFavoriteListProvider.java

示例4: showPopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
/** Opens up the Google Login panel as a popup. */
private static void showPopup(AnActionEvent event) {
  GoogleLoginUsersPanel usersPanel = new GoogleLoginUsersPanel();
  ComponentPopupBuilder popupBuilder =
      JBPopupFactory.getInstance().createComponentPopupBuilder(usersPanel, usersPanel.getList());
  JBPopup popup = popupBuilder.setCancelOnWindowDeactivation(true).createPopup();
  JComponent source = (JComponent) event.getInputEvent().getSource();
  popup.showUnderneathOf(source);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:10,代码来源:GoogleLoginAction.java

示例5: createRegExHelpPopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
public static JBPopup createRegExHelpPopup() throws BadLocationException {
  final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(new RegExHelpPopup(), null);
  return builder.setCancelOnClickOutside(false).setBelongsToGlobalPopupStack(true).setFocusable(true).setRequestFocus(true).setMovable(true).setResizable(true)
    .setCancelOnOtherWindowOpen(false).setCancelButton(new MinimizeButton("Hide"))
    .setTitle("Regular expressions syntax").setDimensionServiceKey(null, "RegExHelpPopup", true).createPopup();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:RegExHelpPopup.java

示例6: showUI

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
@Override
public void showUI() {
  if (myBalloon != null && myBalloon.isVisible()) {
    return;
  }
  if (myBalloon != null && !myBalloon.isDisposed()) {
    myBalloon.cancel();
  }
  if (myBalloon == null || myBalloon.isDisposed()) {
    final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(this, mySearchComponent);
    myBalloon = builder
            .setProject(myHelper.getProject())
            .setMovable(true)
            .setResizable(true)
            .setMayBeParent(true)
            .setCancelOnClickOutside(true)
            .setRequestFocus(true)
            .setCancelKeyEnabled(false)
            .setCancelCallback(() -> {
              if (!myCanClose.get()) return false;
              if (myIsPinned.get()) return false;
              if (!ApplicationManager.getApplication().isActive()) return false;
              if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() == null) return false;
              List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(this);
              if (!popups.isEmpty()) {
                for (JBPopup popup : popups) {
                  popup.cancel();
                }
                return false;
              }
              if (myScopeUI.hideAllPopups()) {
                return false;
              }
              DimensionService.getInstance().setSize(SERVICE_KEY, myBalloon.getSize(), myHelper.getProject() );
              DimensionService.getInstance().setLocation(SERVICE_KEY, myBalloon.getLocationOnScreen(), myHelper.getProject() );
              ((FindManagerImpl)FindManager.getInstance(myProject)).changeGlobalSettings(myHelper.getModel());
              return true;
            })
            .createPopup();
    Disposer.register(myBalloon, myDisposable);
    registerCloseAction(myBalloon);
    final Window window = WindowManager.getInstance().suggestParentWindow(myProject);
    Component parent = UIUtil.findUltimateParent(window);
    RelativePoint showPoint = null;
    Point screenPoint = DimensionService.getInstance().getLocation(SERVICE_KEY);
    if (screenPoint != null) {
      showPoint = new RelativePoint(screenPoint);
    }
    if (parent != null && showPoint == null) {
      int height = UISettings.getInstance().getShowNavigationBar() ? 135 : 115;
      if (parent instanceof IdeFrameImpl && ((IdeFrameImpl)parent).isInFullScreen()) {
        height -= 20;
      }
      showPoint = new RelativePoint(parent, new Point((parent.getSize().width - getPreferredSize().width) / 2, height));
    }
    mySearchComponent.selectAll();
    WindowMoveListener windowListener = new WindowMoveListener(this);
    myTitlePanel.addMouseListener(windowListener);
    myTitlePanel.addMouseMotionListener(windowListener);
    Dimension panelSize = getPreferredSize();
    Dimension prev = DimensionService.getInstance().getSize(SERVICE_KEY);
    if (!myCbPreserveCase.isVisible()) {
      panelSize.width += myCbPreserveCase.getPreferredSize().width + 8;
    }
    panelSize.width += JBUI.scale(24);//hidden 'loading' icon
    panelSize.height *= 2;
    if (prev != null && prev.height < panelSize.height) prev.height = panelSize.height;
    myBalloon.setMinimumSize(panelSize);
    if (prev == null) {
      panelSize.height *= 1.5;
      panelSize.width *= 1.15;
    }
    myBalloon.setSize(prev != null ? prev : panelSize);

    if (showPoint != null && showPoint.getComponent() != null) {
      myBalloon.show(showPoint);
    } else {
      myBalloon.showCenteredInCurrentWindow(myProject);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:82,代码来源:FindPopupPanel.java

示例7: createRegExHelpPopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
public static JBPopup createRegExHelpPopup() throws BadLocationException {
  final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(new RegExHelpPopup(), null);
  return builder.setCancelOnClickOutside(false).setBelongsToGlobalPopupStack(true).setFocusable(true).setRequestFocus(true).setMovable(true).setResizable(true)
          .setCancelOnOtherWindowOpen(false).setCancelButton(new MinimizeButton("Hide"))
          .setTitle("Regular expressions syntax").setDimensionServiceKey(null, "RegExHelpPopup", true).createPopup();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:RegExHelpPopup.java

示例8: updatePopup

import com.intellij.openapi.ui.popup.ComponentPopupBuilder; //导入依赖的package包/类
@SuppressWarnings("SSBasedInspection")
private void updatePopup() {
  check();
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      myListModel.update();
      myList.revalidate();
      myList.repaint();

      myRenderer.recalculateWidth();
      if (myBalloon == null || myBalloon.isDisposed()) {
        return;
      }
      if (myPopup == null || !myPopup.isVisible()) {
        final ActionCallback callback = ListDelegationUtil.installKeyboardDelegation(getField().getTextEditor(), myList);
        JBScrollPane content = new JBScrollPane(myList);
        content.setMinimumSize(new Dimension(myBalloon.getSize().width, 30));
        final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(content, null);
        myPopup = builder.setRequestFocus(false).setCancelKeyEnabled(false).setCancelCallback(new Computable<Boolean>() {
          @Override
          public Boolean compute() {
            return myBalloon == null || myBalloon.isDisposed() || (!getField().getTextEditor().hasFocus() && !mySkipFocusGain);
          }
        }).createPopup();
        myPopup.setMinimumSize(new Dimension(myBalloon.getSize().width, 30));
        myPopup.getContent().setBorder(new EmptyBorder(0, 0, 0, 0));
        Disposer.register(myPopup, new Disposable() {
          @Override
          public void dispose() {
            callback.setDone();
            resetFields();
            myNonProjectCheckBox.setSelected(false);
            ActionToolbarImpl.updateAllToolbarsImmediately();
            if (myActionEvent != null && myActionEvent.getInputEvent() instanceof MouseEvent) {
              final Component component = myActionEvent.getInputEvent().getComponent();
              if (component != null) {
                final JLabel label = UIUtil.getParentOfType(JLabel.class, component);
                if (label != null) {
                  label.setIcon(AllIcons.Actions.FindPlain);
                }
              }
            }
            myActionEvent = null;
          }
        });
        myPopup.show(new RelativePoint(getField().getParent(), new Point(0, getField().getParent().getHeight())));
        //updatePopupBounds();

        ActionManager.getInstance().addAnActionListener(new AnActionListener.Adapter() {
          @Override
          public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
            if (action instanceof TextComponentEditorAction) {
              return;
            }
            myPopup.cancel();
          }
        }, myPopup);
      }
      else {
        myList.revalidate();
        myList.repaint();
      }
      ScrollingUtil.ensureSelectionExists(myList);
      if (myList.getModel().getSize() > 0) {
        updatePopupBounds();
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:71,代码来源:SearchEverywhereAction.java


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