Java 类com.intellij.openapi.ui.popup.JBPopupFactory 实例源码

项目:intellij-randomness    文件:PopupAction.java   
@Override
public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return;
    }

    final ListPopupImpl popup = (ListPopupImpl) JBPopupFactory.getInstance()
            .createActionGroupPopup(TITLE, new PopupGroup(), event.getDataContext(),
                    JBPopupFactory.ActionSelectionAid.NUMBERING, true, event.getPlace());
    JBPopupHelper.disableSpeedSearch(popup);
    JBPopupHelper.registerShiftActions(popup, TITLE, SHIFT_TITLE);
    JBPopupHelper.registerCtrlActions(popup, TITLE, CTRL_TITLE);

    popup.setAdText(AD_TEXT);
    popup.showCenteredInCurrentWindow(project);
}
项目:AndroidSourceViewer    文件:PopListView.java   
/**
 * create ListPop
 *
 * @param title
 * @param data
 * @param listener
 */
public void createList(String title, String[] data, OnItemClickListener listener) {
    DefaultActionGroup group = new DefaultActionGroup();
    if (data != null && data.length > 0) {
        for (int i = 0; i < data.length; i++) {
            if (!Utils.isEmpty(data[i])) {
                if (data[i].contains("-")) {
                    group.add(new ListItemAction(i, data[i], listener));
                } else {
                    group.addSeparator(data[i]);
                }
            }
        }
    }
    listPopup = JBPopupFactory.getInstance().createActionGroupPopup(title, group,
            anActionEvent.getDataContext(), aid, true, null, -1, null, "unknown");
    show();
}
项目:hybris-integration-intellij-idea-plugin    文件:ExecuteHybrisConsole.java   
private void handleBadRequest(final HybrisHttpResult httpResult, final Project project) {
    if (httpResult.getStatusCode() != SC_OK) {
        final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

        if (httpResult.getStatusCode() == SC_NOT_FOUND || httpResult.getStatusCode() == SC_MOVED_TEMPORARILY) {
            JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(
                "Hybris Host URL '" + httpResult.getErrorMessage() + "' was incorrect. Please, check your settings.",
                MessageType.ERROR,
                null
            ).setFadeoutTime(FADEOUT_TIME)
                          .createBalloon().show(
                RelativePoint.getCenterOf(statusBar.getComponent()),
                Balloon.Position.atRight
            );
        }
    }
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
public void showComponent(RelativePoint point) {
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(this, this)
    .setRequestFocus(true)
    .setCancelOnOtherWindowOpen(true)
    .setCancelOnClickOutside(true)
    .setShowBorder(true)
    .createPopup();

  Disposer.register(ApplicationManager.getApplication(), new Disposable() {
    @Override
    public void dispose() {
      Disposer.dispose(myPopup);
    }
  });

  myPopup.show(point);
}
项目:CodeGen    文件:TemplateAddAction.java   
@Override
public void run(AnActionButton button) {
    // 获取选中节点
    final DefaultMutableTreeNode selectedNode = getSelectedNode();
    if (selectedNode == null) {
        return;
    }
    List<AnAction> actions = getMultipleActions(selectedNode);
    if (actions == null || actions.isEmpty()) {
        return;
    }
    // 显示新增按钮
    final DefaultActionGroup group = new DefaultActionGroup(actions);
    JBPopupFactory.getInstance()
            .createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()),
                    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
}
项目:GravSupport    文件:GravProjectGenerator.java   
@Override
public void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull GravProjectSettings settings, @NotNull Module module) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(settings.gravInstallationPath));
    if (vf == null || !GravSdkType.isValidGravSDK(vf)) {
        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder("Project couldn't be created because Grav Installation isn't valid", MessageType.ERROR, null)
                .setFadeoutTime(3500)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
    } else {
        storage.setDefaultGravDownloadPath(settings.gravInstallationPath);
        PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(settings.gravInstallationPath).getAbsolutePath());
        GravProjectGeneratorUtil projectGenerator = new GravProjectGeneratorUtil();
        projectGenerator.generateProject(project, baseDir, settings, module);
        try {
            List<String> includePath = new ArrayList<>();
            includePath.add(baseDir.getPath());
            PhpIncludePathManager.getInstance(project).setIncludePath(includePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:GravSupport    文件:GravModuleBuilder.java   
@Override
    public void moduleCreated(@NotNull Module module) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
        String msg = String.format("Please wait while module for project %s is created", project.getName());
        settings = GravProjectSettings.getInstance(project);

        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder(msg, MessageType.WARNING, null)
                .setFadeoutTime(4000)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);

        VirtualFile[] roots1 = ModuleRootManager.getInstance(module).getContentRoots();
        if (roots1.length != 0) {
            final VirtualFile src = roots1[0];
            settings.withSrcDirectory = withSrcDirectory;
            settings.gravInstallationPath = getGravInstallPath().getPath();
//            settings.withSrcDirectory =
            GravProjectGeneratorUtil generatorUtil = new GravProjectGeneratorUtil();
            generatorUtil.generateProject(project, src, settings, module);
        }
    }
项目:weex-language-support    文件:DocumentIntention.java   
@Override
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement psiElement) throws IncorrectOperationException {

    JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Chosen", "Document", "Sample") {

        @Override
        public PopupStep onChosen(String selectedValue, boolean finalChoice) {

            if ("Document".equals(selectedValue)) {
                openDocument(psiElement.getText());
            } else if ("Sample".equals(selectedValue)) {
                openSample(project, editor);
            }

            return super.onChosen(selectedValue, finalChoice);
        }
    }).showInBestPositionFor(editor);
}
项目:weex-language-support    文件:DocumentIntention.java   
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);
    }
项目:gtm-jetbrains-plugin    文件:GTMProject.java   
private void installGtmWidget() {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (statusBar != null) {
        statusBar.addWidget(myStatusWidget, myProject);
        myStatusWidget.installed();
        if (!GTMRecord.initGtmExePath()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmNotFound, ERROR, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
            return;
        }
        if (!GTMRecord.checkVersion()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmVerOutdated, WARNING, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
        }
    }
}
项目:IntelliJ-OnlineSearch    文件:ShowSearchEnginesAction.java   
@Override
public void actionPerformed(AnActionEvent e) {

    ActionManager am = ActionManager.getInstance();
    DefaultActionGroup actionGroup = (DefaultActionGroup) am.getAction(LaunchSearchActionRegistration.COMPONENT_GROUP);

    // https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Popups
    // https://github.com/linux-china/idea-string-manipulation/blob/master/src/main/java/osmedile/intellij/stringmanip/PopupChoiceAction.java#L23
    JBPopupFactory
            .getInstance()
            .createActionGroupPopup("OnlineSearch",
                                    actionGroup,
                                    e.getDataContext(),
                                    JBPopupFactory.ActionSelectionAid.NUMBERING,
                                    false)
            .showInBestPositionFor(e.getDataContext());
}
项目:samebug-idea-plugin    文件:IncomingTipPopupController.java   
public void showIncomingChatInvitation(@NotNull IncomingAnswer incomingTip, @NotNull IncomingTipNotification notification) {
    IIncomingTipPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertIncomingTipPopup(incomingTip);
    IncomingTipPopup popup = new IncomingTipPopup(popupModel);
    DataService.putData(popup, TrackingKeys.Location, new Locations.TipAnswerNotification(incomingTip.getSolution().getId()));

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    data.put(popup, incomingTip);
    notifications.put(popup, notification);
    balloons.put(popup, balloon);
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:samebug-idea-plugin    文件:HelpRequestPopupController.java   
public void showIncomingHelpRequest(@NotNull IncomingHelpRequest helpRequest, @NotNull IncomingHelpRequestNotification notification) {
    IHelpRequestPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertHelpRequestPopup(helpRequest);
    HelpRequestPopup popup = new HelpRequestPopup(popupModel);
    DataService.putData(popup, TrackingKeys.Location, new Locations.HelpRequestNotification(helpRequest.getMatch().getHelpRequest().getId()));
    DataService.putData(popup, TrackingKeys.WriteTipTransaction, Funnels.newTransactionId());
    HelpRequestPopupListener helpRequestPopupListener = new HelpRequestPopupListener(this);
    ListenerService.putListenerToComponent(popup, IHelpRequestPopup.Listener.class, helpRequestPopupListener);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    data.put(popup, helpRequest);
    notifications.put(popup, notification);
    balloons.put(popup, balloon);
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:intellij-ce-playground    文件:HighlightSuppressedWarningsHandler.java   
@Override
protected void selectTargets(List<PsiLiteralExpression> targets, final Consumer<List<PsiLiteralExpression>> selectionConsumer) {
  if (targets.size() == 1) {
    selectionConsumer.consume(targets);
  } else {
    JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PsiLiteralExpression>("Choose Inspections to Highlight Suppressed Problems from", targets){
      @Override
      public PopupStep onChosen(PsiLiteralExpression selectedValue, boolean finalChoice) {
        selectionConsumer.consume(Collections.singletonList(selectedValue));
        return FINAL_CHOICE;
      }

      @NotNull
      @Override
      public String getTextFor(PsiLiteralExpression value) {
        final Object o = value.getValue();
        LOG.assertTrue(o instanceof String);
        return (String)o;
      }
    }).showInBestPositionFor(myEditor);
  }
}
项目:intellij-ce-playground    文件:FindJarFix.java   
@Override
public void invoke(@NotNull Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
  final List<String> fqns = getPossibleFqns(myRef);
  myEditorComponent = editor.getComponent();
  if (fqns.size() > 1) {
    final JBList listOfFqns = new JBList(fqns);
    JBPopupFactory.getInstance()
      .createListPopupBuilder(listOfFqns)
      .setTitle("Select Qualified Name")
      .setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          final Object value = listOfFqns.getSelectedValue();
          if (value instanceof String) {
            findJarsForFqn(((String)value), editor);
          }
        }
      }).createPopup().showInBestPositionFor(editor);
  }
  else if (fqns.size() == 1) {
    findJarsForFqn(fqns.get(0), editor);
  }
}
项目:intellij-ce-playground    文件:ChooseByNameFilter.java   
/**
 * Create and show popup
 */
private void createPopup() {
  if (myPopup != null) {
    return;
  }
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myChooserPanel, myChooser).setModalContext(false).setFocusable(false)
      .setResizable(true).setCancelOnClickOutside(false).setMinSize(new Dimension(200, 200))
      .setDimensionServiceKey(myProject, "GotoFile_FileTypePopup", false).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      myPopup = null;
    }
  });
  myPopup.showUnderneathOf(myToolbar.getComponent());
}
项目:intellij-ce-playground    文件:ProjectConfigurationProblem.java   
@Override
public void fix(final JComponent contextComponent, RelativePoint relativePoint) {
  JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myDescription.getFixes()) {
    @NotNull
    @Override
    public String getTextFor(ConfigurationErrorQuickFix value) {
      return value.getActionName();
    }

    @Override
    public PopupStep onChosen(final ConfigurationErrorQuickFix selectedValue, boolean finalChoice) {
      return doFinalStep(new Runnable() {
        @Override
        public void run() {
          selectedValue.performFix();
        }
      });
    }
  }).show(relativePoint);
}
项目:intellij-ce-playground    文件:AddNewLibraryDependencyAction.java   
public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel,
                                       final StructureConfigurableContext context,
                                       final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
  if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
    final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, new ParameterizedRunnable<LibraryType>() {
      @Override
      public void run(LibraryType libraryType) {
        doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType);
      }
    }));
    popup.showUnderneathOf(contextButton);
  }
  else {
    doCreateLibrary(classpathPanel, context, callback, contextButton, null);
  }
}
项目:intellij-ce-playground    文件:LivePreview.java   
private void showBalloon(Editor editor, String replacementPreviewText) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    myReplacementPreviewText = replacementPreviewText;
    return;
  }

  ReplacementView replacementView = new ReplacementView(replacementPreviewText);

  BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView);
  balloonBuilder.setFadeoutTime(0);
  balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR);
  balloonBuilder.setAnimationCycle(0);
  balloonBuilder.setHideOnClickOutside(false);
  balloonBuilder.setHideOnKeyOutside(false);
  balloonBuilder.setHideOnAction(false);
  balloonBuilder.setCloseButtonEnabled(true);
  myReplacementBalloon = balloonBuilder.createBalloon();

  myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.below);
}
项目:intellij-ce-playground    文件:CloudAccountSelectionEditor.java   
private void onNewButton() {
  if (myCloudTypes.size() == 1) {
    createAccount(ContainerUtil.getFirstItem(myCloudTypes));
    return;
  }

  DefaultActionGroup group = new DefaultActionGroup();
  for (final ServerType<?> cloudType : myCloudTypes) {
    group.add(new AnAction(cloudType.getPresentableName(), cloudType.getPresentableName(), cloudType.getIcon()) {

      @Override
      public void actionPerformed(AnActionEvent e) {
        createAccount(cloudType);
      }
    });
  }
  JBPopupFactory.getInstance().createActionGroupPopup("New Account", group, DataManager.getInstance().getDataContext(myMainPanel),
                                                      JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
    .showUnderneathOf(myNewButton);
}
项目:intellij-ce-playground    文件:PopupUtil.java   
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type,
                                           final boolean atTop, @Nullable final Disposable disposable) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  if (popupFactory == null) return;
  BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
  balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
  Balloon balloon = balloonBuilder.createBalloon();
  Dimension size = component.getSize();
  Balloon.Position position;
  int x;
  int y;
  if (size == null) {
    x = y = 0;
    position = Balloon.Position.above;
  }
  else {
    x = Math.min(10, size.width / 2);
    y = size.height;
    position = Balloon.Position.below;
  }
  balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
项目:intellij-ce-playground    文件:NavigateToTestDataAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  List<String> fileNames = findTestDataFiles(dataContext);
  if (fileNames == null || fileNames.isEmpty()) {
    String testData = guessTestData(dataContext);
    if (testData == null) {
      String message = "Cannot find testdata files for class";
      final Notification notification = new Notification("testdata", "Found no testdata files", message, NotificationType.INFORMATION);
      Notifications.Bus.notify(notification, project);
      return;
    }
    fileNames = Collections.singletonList(testData);
  }

  final Editor editor = e.getData(CommonDataKeys.EDITOR);
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  final RelativePoint point = editor != null ? popupFactory.guessBestPopupLocation(editor) : popupFactory.guessBestPopupLocation(dataContext);

  TestDataNavigationHandler.navigate(point, fileNames, project);
}
项目:intellij-ce-playground    文件:PyStudyExecutor.java   
public void showNoSdkNotification(@NotNull final Project project) {
  final String text = "<html>No Python interpreter configured for the project<br><a href=\"\">Configure interpreter</a></html>";
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().
    createHtmlTextBalloonBuilder(text, null,
                                 MessageType.WARNING.getPopupBackground(),
                                 new HyperlinkListener() {
                                   @Override
                                   public void hyperlinkUpdate(HyperlinkEvent event) {
                                     if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                                       ApplicationManager.getApplication()
                                         .invokeLater(new Runnable() {
                                           @Override
                                           public void run() {
                                             ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter");
                                           }
                                         });
                                     }
                                   }
                                 });
  balloonBuilder.setHideOnLinkClick(true);
  final Balloon balloon = balloonBuilder.createBalloon();
  StudyUtils.showCheckPopUp(project, balloon);
}
项目:intellij-ce-playground    文件:MultilinePopupBuilder.java   
@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;
}
项目:intellij-ce-playground    文件:ExternalSystemUiUtil.java   
/**
 * Asks to show balloon that contains information related to the given component.
 *
 * @param component    component for which we want to show information
 * @param messageType  balloon message type
 * @param message      message to show
 */
public static void showBalloon(@NotNull JComponent component, @NotNull MessageType messageType, @NotNull String message) {
  final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, null)
    .setDisposable(ApplicationManager.getApplication())
    .setFadeoutTime(BALLOON_FADEOUT_TIME);
  Balloon balloon = builder.createBalloon();
  Dimension size = component.getSize();
  Balloon.Position position;
  int x;
  int y;
  if (size == null) {
    x = y = 0;
    position = Balloon.Position.above;
  }
  else {
    x = Math.min(10, size.width / 2);
    y = size.height;
    position = Balloon.Position.below;
  }
  balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
项目:intellij-ce-playground    文件:FlatWelcomeFrame.java   
private JComponent createActionLink(final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
  final Ref<ActionLink> ref = new Ref<ActionLink>(null);
  AnAction action = new AnAction() {
    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
      ActionGroup configureGroup = (ActionGroup)ActionManager.getInstance().getAction(groupId);
      final PopupFactoryImpl.ActionGroupPopup popup = (PopupFactoryImpl.ActionGroupPopup)JBPopupFactory.getInstance()
        .createActionGroupPopup(null, new IconsFreeActionGroup(configureGroup), e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
                                ActionPlaces.WELCOME_SCREEN);
      popup.showUnderneathOfLabel(ref.get());
      UsageTrigger.trigger("welcome.screen." + groupId);
    }
  };
  ref.set(new ActionLink(text, icon, action));
  ref.get().setPaintUnderline(false);
  ref.get().setNormalColor(getLinkNormalColor());
  NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
  panel.setBorder(JBUI.Borders.empty(4, 6, 4, 6));
  panel.add(ref.get());
  panel.add(createArrow(ref.get()), BorderLayout.EAST);
  installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
  return panel;
}
项目:intellij-ce-playground    文件:QuickFixManager.java   
final void showIntentionPopup(){
  LOG.debug("showIntentionPopup()");
  if(myHint == null || !myHint.isVisible()){
    return;
  }
  final ErrorInfo[] errorInfos = getErrorInfos();
  if(!haveFixes(errorInfos)){
    return;
  }

  final ArrayList<ErrorWithFix> fixList = new ArrayList<ErrorWithFix>();
  for(ErrorInfo errorInfo: errorInfos) {
    final QuickFix[] quickFixes = errorInfo.myFixes;
    if (quickFixes.length > 0) {
      for (QuickFix fix: quickFixes) {
        fixList.add(new ErrorWithFix(errorInfo, fix));
      }
    }
    else if (errorInfo.getInspectionId() != null) {
      buildSuppressFixes(errorInfo, fixList, true);
    }
  }

  final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new QuickFixPopupStep(fixList, true));
  popup.showUnderneathOf(myHint.getComponent());
}
项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
@Override
public void performAction(@NotNull InputEvent e, @NotNull AnAction action, @NotNull AnActionEvent actionEvent) {
  e.consume();

  DataContext ctx = actionEvent.getDataContext();
  if (action instanceof ActionGroup && !((ActionGroup)action).canBePerformed(ctx)) {
    ActionGroup group = (ActionGroup)action;
    JBPopupFactory.getInstance()
      .createActionGroupPopup(group.getTemplatePresentation().getText(), group, ctx, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
      .showInBestPositionFor(ctx);
  }
  else {
    action.actionPerformed(actionEvent);
  }

  if (Registry.is("actionSystem.fixLostTyping")) {
    IdeEventQueue.getInstance().doWhenReady(new Runnable() {
      @Override
      public void run() {
        IdeEventQueue.getInstance().getKeyEventDispatcher().resetState();
      }
    });
  }
}
项目:intellij-ce-playground    文件:ChangeFileEncodingAction.java   
@Nullable
public ListPopup createPopup(@NotNull DataContext dataContext) {
  final VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  if (virtualFile == null) return null;
  boolean enabled = checkEnabled(virtualFile);
  if (!enabled) return null;
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  FileDocumentManager documentManager = FileDocumentManager.getInstance();
  final Document document = documentManager.getDocument(virtualFile);
  if (!allowDirectories && virtualFile.isDirectory() || document == null && !virtualFile.isDirectory()) return null;

  final byte[] bytes;
  try {
    bytes = virtualFile.isDirectory() ? null : virtualFile.contentsToByteArray();
  }
  catch (IOException e) {
    return null;
  }
  DefaultActionGroup group = createActionGroup(virtualFile, editor, document, bytes, null);

  return JBPopupFactory.getInstance().createActionGroupPopup(getTemplatePresentation().getText(),
    group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
项目:intellij-ce-playground    文件:ShowPopupMenuAction.java   
public void actionPerformed(AnActionEvent e) {
  final RelativePoint relPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());

  KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
  Component focusOwner = focusManager.getFocusOwner();

  Point popupMenuPoint = relPoint.getPoint(focusOwner);

  final Editor editor = e.getData(CommonDataKeys.EDITOR);
  int coord = editor != null
              ? Math.max(0, popupMenuPoint.y - 1) //To avoid cursor jump to the line below. http://www.jetbrains.net/jira/browse/IDEADEV-10644
              : popupMenuPoint.y;

  focusOwner.dispatchEvent(
    new MouseEvent(
      focusOwner,
      MouseEvent.MOUSE_PRESSED,
      System.currentTimeMillis(), 0,
      popupMenuPoint.x,
      coord,
      1,
      true
    )
  );
}
项目:intellij-ce-playground    文件:ManageRecentProjectsAction.java   
@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);
}
项目:intellij-ce-playground    文件:AnnotateCapitalizationIntention.java   
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
  final PsiModifierListOwner modifierListOwner = getElement(editor, file);
  if (modifierListOwner == null) throw new IncorrectOperationException();

  BaseListPopupStep<Nls.Capitalization> step =
    new BaseListPopupStep<Nls.Capitalization>(null, Nls.Capitalization.Title, Nls.Capitalization.Sentence) {
      @Override
      public PopupStep onChosen(final Nls.Capitalization selectedValue, boolean finalChoice) {
        new WriteCommandAction.Simple(project) {
          @Override
          protected void run() throws Throwable {
            String nls = Nls.class.getName();
            PsiAnnotation annotation = JavaPsiFacade.getInstance(project).getElementFactory()
              .createAnnotationFromText("@" + nls + "(capitalization = " +
                                        nls + ".Capitalization." + selectedValue.toString() + ")", modifierListOwner);
            new AddAnnotationFix(Nls.class.getName(), modifierListOwner, annotation.getParameterList().getAttributes()).applyFix();
          }
        }.execute();
        return FINAL_CHOICE;
      }
    };
  JBPopupFactory.getInstance().createListPopup(step).showInBestPositionFor(editor);
}
项目:intellij-ce-playground    文件:VcsCommitInfoBalloon.java   
public VcsCommitInfoBalloon(@NotNull JTree tree) {
  myTree = tree;
  myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
  myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  myEditorPane.setEditable(false);
  myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
  myEditorPane.setFont(UIUtil.getToolTipFont());
  myEditorPane.setBorder(HintUtil.createHintBorder());
  Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
  myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
  myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      BrowserUtil.browse(e.getURL());
    }
  });
  myWrapper = new Wrapper(myEditorPane);
  myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
  myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
    .setMinSize(new Dimension(80, 30));
}
项目:intellij-ce-playground    文件:XDebuggerEditorBase.java   
private ListPopup createLanguagePopup() {
  DefaultActionGroup actions = new DefaultActionGroup();
  for (final Language language : getEditorsProvider().getSupportedLanguages(myProject, mySourcePosition)) {
    //noinspection ConstantConditions
    actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        XExpression currentExpression = getExpression();
        setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
        requestFocusInEditor();
      }
    });
  }

  DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
  return JBPopupFactory.getInstance().createActionGroupPopup("Choose language", actions, dataContext,
                                                             JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                             false);
}
项目:intellij-ce-playground    文件:ChangesFragmentedDiffPanel.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DefaultActionGroup dag = new DefaultActionGroup();
  dag.add(myUsual);
  dag.add(myNumbered);
  dag.add(new Separator());
  dag.add(mySoftWrapsAction);
  final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, dag, e.getDataContext(),
                                                                                   JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                                                   false);
  if (e.getInputEvent() instanceof MouseEvent) {
    popup.show(new RelativePoint((MouseEvent)e.getInputEvent()));
  } else {
    // todo correct
    /*final Dimension dimension = popup.getContent().getPreferredSize();
    final Point at = new Point(-dimension.width / 2, 0);
    popup.show(new RelativePoint(myParent, at));*/
    popup.showInBestPositionFor(e.getDataContext());
  }
}
项目:intellij-ce-playground    文件:JavaFxInjectPageLanguageIntention.java   
@Override
public void invoke(@NotNull final Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
  final XmlFile containingFile = (XmlFile)element.getContainingFile();
  final Set<String> availableLanguages = getAvailableLanguages(project);

  LOG.assertTrue(availableLanguages != null);

  if (availableLanguages.size() == 1) {
    registerPageLanguage(project, containingFile, availableLanguages.iterator().next());
  } else {
    final JBList list = new JBList(availableLanguages);
    JBPopupFactory.getInstance().createListPopupBuilder(list)
      .setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          registerPageLanguage(project, containingFile, (String)list.getSelectedValue());
        }
      }).createPopup().showInBestPositionFor(editor);
  }
}
项目:intellij-ce-playground    文件:CreateComponentAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  Processor<ComponentItem> processor = new Processor<ComponentItem>() {
    public boolean process(final ComponentItem selectedValue) {
      if (selectedValue != null) {
        myLastCreatedComponent = selectedValue;
        editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
      }
      return true;
    }
  };

  PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor,
                                                       UIDesignerBundle.message("create.component.title"));
  final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);

  if (selection.size() > 0) {
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
  }
  else {
    listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
  }
}
项目:intellij-ce-playground    文件:NavBarListener.java   
private void processFocusLost(FocusEvent e) {
  final Component opposite = e.getOppositeComponent();

  if (myPanel.isInFloatingMode() && opposite != null && DialogWrapper.findInstance(opposite) != null) {
    myPanel.hideHint();
    return;
  }

  final boolean nodePopupInactive = !myPanel.isNodePopupActive();
  boolean childPopupInactive = !JBPopupFactory.getInstance().isChildPopupFocused(myPanel);
  if (nodePopupInactive && childPopupInactive) {
    if (opposite != null && opposite != myPanel && !myPanel.isAncestorOf(opposite) && !e.isTemporary()) {
      myPanel.setContextComponent(null);
      myPanel.hideHint();
    }
  }

  myPanel.updateItems();
}
项目:intellij-ce-playground    文件:LookupImpl.java   
@Override
public boolean showElementActions() {
  if (!isVisible()) return false;

  final LookupElement element = getCurrentItem();
  if (element == null) {
    return false;
  }

  final Collection<LookupElementAction> actions = getActionsFor(element);
  if (actions.isEmpty()) {
    return false;
  }

  showItemPopup(JBPopupFactory.getInstance().createListPopup(new LookupActionsStep(actions, this, element)));
  return true;
}
项目:intellij-ce-playground    文件:ProjectStartupConfigurable.java   
private void addConfiguration(RunnerAndConfigurationSettings configuration) {
  if (!ProjectStartupRunner.canBeRun(configuration)) {
    final String message = "Can not add Run Configuration '" + configuration.getName() + "' to Startup Tasks," +
                           " since it can not be started with 'Run' action.";
    final Balloon balloon = JBPopupFactory.getInstance()
      .createHtmlTextBalloonBuilder(message, MessageType.ERROR, null)
      .setHideOnClickOutside(true)
      .setFadeoutTime(3000)
      .setCloseButtonEnabled(true)
      .createBalloon();
    final RelativePoint rp = new RelativePoint(myDecorator.getActionsPanel(), new Point(5, 5));
    balloon.show(rp, Balloon.Position.atLeft);
    return;
  }
  myModel.addConfiguration(configuration);
  refreshDataUpdateSelection(configuration);
}