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

项目:intellij-ce-playground    文件:DebuggerEditorImpl.java   
private ListPopup createLanguagePopup() {
  DefaultActionGroup actions = new DefaultActionGroup();
  for (final CodeFragmentFactory fragmentFactory : DebuggerUtilsEx.getCodeFragmentFactories(myContext)) {
    actions.add(new AnAction(fragmentFactory.getFileType().getLanguage().getDisplayName(), null, fragmentFactory.getFileType().getIcon()) {
      @Override
      public void actionPerformed(AnActionEvent e) {
        setFactory(fragmentFactory);
        setText(getText());
        IdeFocusManager.getInstance(getProject()).requestFocus(DebuggerEditorImpl.this, true);
      }
    });
  }

  DataContext dataContext = DataManager.getInstance().getDataContext(this);
  return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext,
                                                             JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                             false);
}
项目: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    文件:VcsLogQuickSettingsActions.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  VcsLogUi logUi = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogSettings settings = ServiceManager.getService(project, VcsLogSettings.class);

  ListPopup popup = JBPopupFactory.getInstance()
    .createActionGroupPopup(null, new MySettingsActionGroup(settings, logUi), e.getDataContext(),
                            JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUi.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}
项目:intellij-ce-playground    文件:IntelliSortChooserPopupAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final VcsLogUi logUI = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);

  ActionGroup settingsGroup =
    new DefaultActionGroup(ContainerUtil.map(PermanentGraph.SortType.values(), new Function<PermanentGraph.SortType, AnAction>() {
      @Override
      public AnAction fun(PermanentGraph.SortType sortType) {
        return new SelectIntelliSortTypeAction(logUI, sortType);
      }
    }));


  ListPopup popup = JBPopupFactory.getInstance()
    .createActionGroupPopup(null, settingsGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true,
                            ToolWindowContentUi.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}
项目:intellij-ce-playground    文件:WelcomePopupAction.java   
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
  Component focusedComponent = contextComponent != null ? contextComponent : PlatformDataKeys.CONTEXT_COMPONENT.getData(context);
  if (focusedComponent != null) {
    if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
      ((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
    } else {
      popup.showUnderneathOf(focusedComponent);
    }
  }
  else {
    Rectangle r;
    int x;
    int y;
    focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
    r = WindowManagerEx.getInstanceEx().getScreenBounds();
    x = r.x + r.width / 2;
    y = r.y + r.height / 2;
    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());

    popup.showInScreenCoordinates(focusedComponent.getParent(), point);
  }
}
项目:intellij-ce-playground    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@NotNull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:intellij-ce-playground    文件:LineSeparatorPanel.java   
private void showPopup(MouseEvent e) {
  if (!myActionEnabled) {
    return;
  }
  DataContext dataContext = getContext();
  AnAction group = ActionManager.getInstance().getAction("ChangeLineSeparators");
  if (!(group instanceof ActionGroup)) {
    return;
  }

  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
    "Line separator",
    (ActionGroup)group,
    dataContext,
    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
    false
  );
  Dimension dimension = popup.getContent().getPreferredSize();
  Point at = new Point(0, -dimension.height);
  popup.show(new RelativePoint(e.getComponent(), at));
  Disposer.register(this, popup); // destroy popup on unexpected project close
}
项目: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    文件:ShowFilePathAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  show(getFile(e), new ShowAction() {
    @Override
    public void show(final ListPopup popup) {
      DataManager dataManager = DataManager.getInstance();
      if (dataManager != null) {
        dataManager.getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
          @Override
          public void consume(DataContext context) {
            popup.showInBestPositionFor(context);
          }
        });
      }
    }
  });
}
项目:intellij-ce-playground    文件:ShowFilePathAction.java   
private static ListPopup createPopup(final ArrayList<VirtualFile> files, final ArrayList<Icon> icons) {
  final BaseListPopupStep<VirtualFile> step = new BaseListPopupStep<VirtualFile>("File Path", files, icons) {
    @NotNull
    @Override
    public String getTextFor(final VirtualFile value) {
      return value.getPresentableName();
    }

    @Override
    public PopupStep onChosen(final VirtualFile selectedValue, final boolean finalChoice) {
      final File selectedFile = new File(getPresentableUrl(selectedValue));
      if (selectedFile.exists()) {
        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
          @Override
          public void run() {
            openFile(selectedFile);
          }
        });
      }
      return FINAL_CHOICE;
    }
  };

  return JBPopupFactory.getInstance().createListPopup(step);
}
项目: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    文件:AddDomElementAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final AnAction[] actions = getChildren(e);
  if (actions.length > 1) {
    final DefaultActionGroup group = new DefaultActionGroup();
    for (final AnAction action : actions) {
      group.add(action);
    }

    final DataContext dataContext = e.getDataContext();
    final ListPopup groupPopup =
      JBPopupFactory.getInstance().createActionGroupPopup(null,
                                                          group, dataContext, JBPopupFactory.ActionSelectionAid.NUMBERING, true);

    showPopup(groupPopup, e);
  }
  else if (actions.length == 1) {
    actions[0].actionPerformed(e);
  }
}
项目:intellij-ce-playground    文件:AbstractComboBoxAction.java   
@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);
}
项目: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    文件: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    文件:DeepCompareAction.java   
private static void selectBranchAndPerformAction(@NotNull VcsLogDataPack dataPack,
                                                 @NotNull AnActionEvent event,
                                                 @NotNull final Consumer<String> consumer,
                                                 @NotNull Collection<VirtualFile> visibleRoots) {
  ActionGroup actionGroup = BranchFilterPopupComponent.constructActionGroup(dataPack, null, new Function<String, AnAction>() {
    @Override
    public AnAction fun(final String s) {
      return new DumbAwareAction(s) {
        @Override
        public void actionPerformed(AnActionEvent e) {
          consumer.consume(s);
        }
      };
    }
  }, visibleRoots);
  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Select branch to compare", actionGroup, event.getDataContext(),
                                                                        false, false, false, null, -1, null);
  InputEvent inputEvent = event.getInputEvent();
  if (inputEvent instanceof MouseEvent) {
    popup.show(new RelativePoint((MouseEvent)inputEvent));
  }
  else {
    popup.showInBestPositionFor(event.getDataContext());
  }
}
项目:intellij-ce-playground    文件:AbstractComboBoxAction.java   
@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);
}
项目:tools-idea    文件:JvmSmartStepIntoHandler.java   
/**
 * Override this if you haven't PsiMethod, like in Kotlin.
 * @param position
 * @param session
 * @param fileEditor
 * @return false to continue for another handler or for default action (step into)
 */
public boolean doSmartStep(SourcePosition position, final DebuggerSession session, TextEditor fileEditor) {
  final List<PsiMethod> methods = findReferencedMethods(position);
  if (methods.size() > 0) {
    if (methods.size() == 1) {
      session.stepInto(true, getSmartStepFilter(methods.get(0)));
    }
    else {
      final PsiMethodListPopupStep popupStep = new PsiMethodListPopupStep(methods, new PsiMethodListPopupStep.OnChooseRunnable() {
        public void execute(PsiMethod chosenMethod) {
          session.stepInto(true, getSmartStepFilter(chosenMethod));
        }
      });
      final ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep);
      final RelativePoint point = DebuggerUIUtil.calcPopupLocation(((TextEditor)fileEditor).getEditor(), position.getLine());
      popup.show(point);
    }
    return true;
  }
  return false;
}
项目:tools-idea    文件:DebuggerEditorImpl.java   
private ListPopup createLanguagePopup() {
  DefaultActionGroup actions = new DefaultActionGroup();
  for (final CodeFragmentFactory fragmentFactory : DebuggerUtilsEx.getCodeFragmentFactories(myContext)) {
    actions.add(new AnAction(fragmentFactory.getFileType().getLanguage().getDisplayName(), null, fragmentFactory.getFileType().getIcon()) {
      @Override
      public void actionPerformed(AnActionEvent e) {
        setFactory(fragmentFactory);
        setText(getText());
        IdeFocusManager.getInstance(getProject()).requestFocus(DebuggerEditorImpl.this, true);
      }
    });
  }

  DataContext dataContext = DataManager.getInstance().getDataContext(this);
  return JBPopupFactory.getInstance().createActionGroupPopup("Choose language", actions, dataContext,
                                                                        JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                                        false);
}
项目:tools-idea    文件: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);
  }
}
项目:tools-idea    文件:WelcomePopupAction.java   
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
  Component focusedComponent = contextComponent != null ? contextComponent : PlatformDataKeys.CONTEXT_COMPONENT.getData(context);
  if (focusedComponent != null) {
    popup.showUnderneathOf(focusedComponent);
  }
  else {
    Rectangle r;
    int x;
    int y;
    focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
    r = WindowManagerEx.getInstanceEx().getScreenBounds();
    x = r.x + r.width / 2;
    y = r.y + r.height / 2;
    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());

    popup.showInScreenCoordinates(focusedComponent.getParent(), point);
  }
}
项目:tools-idea    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@NotNull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:tools-idea    文件:LineSeparatorPanel.java   
private void showPopup(MouseEvent e) {
  if (!myActionEnabled) {
    return;
  }
  DataContext dataContext = getContext();
  AnAction group = ActionManager.getInstance().getAction("ChangeLineSeparators");
  if (!(group instanceof ActionGroup)) {
    return;
  }

  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
    "Line separator",
    (ActionGroup)group,
    dataContext,
    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
    false
  );
  Dimension dimension = popup.getContent().getPreferredSize();
  Point at = new Point(0, -dimension.height);
  popup.show(new RelativePoint(e.getComponent(), at));
  Disposer.register(this, popup); // destroy popup on unexpected project close
}
项目:tools-idea    文件:ChangeFileEncodingAction.java   
@Nullable
public ListPopup createPopup(@NotNull DataContext dataContext) {
  final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
  if (virtualFile == null) return null;
  boolean enabled = checkEnabled(virtualFile);
  if (!enabled) return null;
  Editor editor = PlatformDataKeys.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);
}
项目:tools-idea    文件:ShowFilePathAction.java   
private static ListPopup createPopup(final ArrayList<VirtualFile> files, final ArrayList<Icon> icons) {
  final BaseListPopupStep<VirtualFile> step = new BaseListPopupStep<VirtualFile>("File Path", files, icons) {
    @NotNull
    @Override
    public String getTextFor(final VirtualFile value) {
      return value.getPresentableName();
    }

    @Override
    public PopupStep onChosen(final VirtualFile selectedValue, final boolean finalChoice) {
      final File selectedFile = new File(getPresentableUrl(selectedValue));
      if (selectedFile.exists()) {
        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
          public void run() {
            openFile(selectedFile);
          }
        });
      }
      return FINAL_CHOICE;
    }
  };

  return JBPopupFactory.getInstance().createListPopup(step);
}
项目:tools-idea    文件: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());
  }
}
项目:tools-idea    文件:AddDomElementAction.java   
public void actionPerformed(AnActionEvent e) {
  final AnAction[] actions = getChildren(e);
  if (actions.length > 1) {
    final DefaultActionGroup group = new DefaultActionGroup();
    for (final AnAction action : actions) {
      group.add(action);
    }

    final DataContext dataContext = e.getDataContext();
    final ListPopup groupPopup =
      JBPopupFactory.getInstance().createActionGroupPopup(null,
                                                          group, dataContext, JBPopupFactory.ActionSelectionAid.NUMBERING, true);

    showPopup(groupPopup, e);
  }
  else if (actions.length == 1) {
    actions[0].actionPerformed(e);
  }
}
项目:tools-idea    文件: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());
}
项目:tools-idea    文件: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());
  }
}
项目:tools-idea    文件:AbstractComboBoxAction.java   
@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);
}
项目:cordovastudio    文件:AbstractComboBoxAction.java   
@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);
}
项目:idea-file-language    文件:FileLanguagePanel.java   
private void showPopup(MouseEvent e) {
    if (!myActionEnabled) {
        return;
    }
    DataContext dataContext = getContext();
    AnAction group = ActionManager.getInstance().getAction("ChangeFileLanguage");
    if (!(group instanceof ActionGroup)) {
        return;
    }

    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            "Language",
            (ActionGroup) group,
            dataContext,
            JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
            false
    );
    Dimension dimension = popup.getContent().getPreferredSize();
    Point at = new Point(0, -dimension.height);
    popup.show(new RelativePoint(e.getComponent(), at));
    Disposer.register(this, popup); // destroy popup on unexpected project close
}
项目:consulo-ui-designer    文件: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());
}
项目:consulo-ui-designer    文件: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());
  }
}
项目:consulo    文件:IntelliSortChooserPopupAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  VcsLogUi logUI = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getRequiredData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);

  ActionGroup settingsGroup = new DefaultActionGroup(
          ContainerUtil.map(PermanentGraph.SortType.values(), (Function<PermanentGraph.SortType, AnAction>)sortType -> new SelectIntelliSortTypeAction(logUI, properties, sortType)));


  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, settingsGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUI.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}
项目:consulo    文件:WelcomePopupAction.java   
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
  Component focusedComponent = contextComponent != null ? contextComponent : context.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  if (focusedComponent != null) {
    if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
      ((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
    } else {
      popup.showUnderneathOf(focusedComponent);
    }
  }
  else {
    Rectangle r;
    int x;
    int y;
    focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
    r = WindowManagerEx.getInstanceEx().getScreenBounds();
    x = r.x + r.width / 2;
    y = r.y + r.height / 2;
    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());

    popup.showInScreenCoordinates(focusedComponent.getParent(), point);
  }
}
项目:consulo    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@Nonnull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:consulo    文件:LineSeparatorPanel.java   
private void showPopup(MouseEvent e) {
  if (!myActionEnabled) {
    return;
  }
  DataContext dataContext = getContext();
  AnAction group = ActionManager.getInstance().getAction("ChangeLineSeparators");
  if (!(group instanceof ActionGroup)) {
    return;
  }

  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Line separator", (ActionGroup)group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
  Dimension dimension = popup.getContent().getPreferredSize();
  Point at = new Point(0, -dimension.height);
  popup.show(new RelativePoint(e.getComponent(), at));
  Disposer.register(this, popup); // destroy popup on unexpected project close
}
项目:consulo    文件:ChangeFileEncodingAction.java   
@Nullable
@RequiredDispatchThread
public ListPopup createPopup(@Nonnull DataContext dataContext) {
  final VirtualFile virtualFile = dataContext.getData(CommonDataKeys.VIRTUAL_FILE);
  if (virtualFile == null) return null;
  boolean enabled = checkEnabled(virtualFile);
  if (!enabled) return null;
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  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);
}