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

项目: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);
}
项目: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    文件: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    文件:LibraryEditingUtil.java   
public static BaseListPopupStep<LibraryType> createChooseTypeStep(final ClasspathPanel classpathPanel,
                                                                  final ParameterizedRunnable<LibraryType> action) {
  return new BaseListPopupStep<LibraryType>(IdeBundle.message("popup.title.select.library.type"), getSuitableTypes(classpathPanel)) {
        @NotNull
        @Override
        public String getTextFor(LibraryType value) {
          return value != null ? value.getCreateActionName() : IdeBundle.message("create.default.library.type.action.name");
        }

        @Override
        public Icon getIconFor(LibraryType aValue) {
          return aValue != null ? aValue.getIcon(null) : PlatformIcons.LIBRARY_ICON;
        }

        @Override
        public PopupStep onChosen(final LibraryType selectedValue, boolean finalChoice) {
          return doFinalStep(new Runnable() {
            @Override
            public void run() {
              action.run(selectedValue);
            }
          });
        }
      };
}
项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目: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    文件:ExpressionInputComponent.java   
private void showHistory() {
  List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
  if (!expressions.isEmpty()) {
    ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
      @Override
      public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
        myExpressionEditor.setExpression(selectedValue);
        myExpressionEditor.requestFocusInEditor();
        return FINAL_CHOICE;
      }
    }) {
      @Override
      protected ListCellRenderer getListElementRenderer() {
        return new ColoredListCellRenderer<XExpression>() {
          @Override
          protected void customizeCellRenderer(JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
            append(value.getExpression());
          }
        };
      }
    };
    popup.getList().setFont(EditorUtil.getEditorFont());
    popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
  }
}
项目:intellij-ce-playground    文件:DetectionExcludesConfigurable.java   
private PopupStep addExcludedFramework(final @NotNull FrameworkType frameworkType) {
  final String projectItem = "In the whole project";
  return new BaseListPopupStep<String>(null, new String[]{projectItem, "In directory..."}) {
    @Override
    public PopupStep onChosen(String selectedValue, boolean finalChoice) {
      if (selectedValue.equals(projectItem)) {
        addAndRemoveDuplicates(frameworkType, null);
        return FINAL_CHOICE;
      }
      else {
        return doFinalStep(new Runnable() {
          @Override
          public void run() {
            chooseDirectoryAndAdd(frameworkType);
          }
        });
      }
    }
  };
}
项目:intellij-ce-playground    文件:RegisterExtensionFix.java   
private void doFix(Editor editor, final DomFileElement<IdeaPlugin> element) {
  if (myEPCandidates.size() == 1) {
    registerExtension(element, myEPCandidates.get(0));
  }
  else {
    final BaseListPopupStep<ExtensionPointCandidate> popupStep =
      new BaseListPopupStep<ExtensionPointCandidate>("Choose Extension Point", myEPCandidates) {
        @Override
        public PopupStep onChosen(ExtensionPointCandidate selectedValue, boolean finalChoice) {
          registerExtension(element, selectedValue);
          return FINAL_CHOICE;
        }
      };
    JBPopupFactory.getInstance().createListPopup(popupStep).showInBestPositionFor(editor);
  }
}
项目: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);
}
项目:tools-idea    文件: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);
  }
}
项目:tools-idea    文件: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);
}
项目:tools-idea    文件:LibraryEditingUtil.java   
public static BaseListPopupStep<LibraryType> createChooseTypeStep(final ClasspathPanel classpathPanel,
                                                                  final ParameterizedRunnable<LibraryType> action) {
  return new BaseListPopupStep<LibraryType>(IdeBundle.message("popup.title.select.library.type"), getSuitableTypes(classpathPanel)) {
        @NotNull
        @Override
        public String getTextFor(LibraryType value) {
          return value != null ? value.getCreateActionName() : IdeBundle.message("create.default.library.type.action.name");
        }

        @Override
        public Icon getIconFor(LibraryType aValue) {
          return aValue != null ? aValue.getIcon() : PlatformIcons.LIBRARY_ICON;
        }

        @Override
        public PopupStep onChosen(final LibraryType selectedValue, boolean finalChoice) {
          return doFinalStep(new Runnable() {
            @Override
            public void run() {
              action.run(selectedValue);
            }
          });
        }
      };
}
项目:tools-idea    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目: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    文件:DetectionExcludesConfigurable.java   
private PopupStep addExcludedFramework(final @NotNull FrameworkType frameworkType) {
  final String projectItem = "In the whole project";
  return new BaseListPopupStep<String>(null, new String[]{projectItem, "In directory..."}) {
    @Override
    public PopupStep onChosen(String selectedValue, boolean finalChoice) {
      if (selectedValue.equals(projectItem)) {
        addAndRemoveDuplicates(frameworkType, null);
        return FINAL_CHOICE;
      }
      else {
        return doFinalStep(new Runnable() {
          @Override
          public void run() {
            chooseDirectoryAndAdd(frameworkType);
          }
        });
      }
    }
  };
}
项目:tools-idea    文件:RegisterExtensionFix.java   
private void doFix(Editor editor, final DomFileElement<IdeaPlugin> element) {
  if (myEPCandidates.size() == 1) {
    registerExtension(element, myEPCandidates.get(0));
  }
  else {
    final BaseListPopupStep<ExtensionPointCandidate> popupStep =
      new BaseListPopupStep<ExtensionPointCandidate>("Choose Extension Point", myEPCandidates) {
        @Override
        public PopupStep onChosen(ExtensionPointCandidate selectedValue, boolean finalChoice) {
          registerExtension(element, selectedValue);
          return FINAL_CHOICE;
        }
      };
    JBPopupFactory.getInstance().createListPopup(popupStep).showInBestPositionFor(editor);
  }
}
项目:consulo    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@Nonnull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, pair -> {
    final AnAction action = pair.getFirst();
    final Presentation presentation = action.getTemplatePresentation().clone();
    AnActionEvent event = new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, presentation, ActionManager.getInstance(), 0);

    ActionUtil.performDumbAwareUpdate(LaterInvocator.isInModalContext(), action, event, true);
    return presentation.isEnabled() && presentation.isVisible();
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目:consulo    文件: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) {
    @Nonnull
    @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);
}
项目:consulo    文件:ExpressionInputComponent.java   
private void showHistory() {
  List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
  if (!expressions.isEmpty()) {
    ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
      @Override
      public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
        myExpressionEditor.setExpression(selectedValue);
        myExpressionEditor.requestFocusInEditor();
        return FINAL_CHOICE;
      }
    }) {
      @Override
      protected ListCellRenderer getListElementRenderer() {
        return new ColoredListCellRenderer<XExpression>() {
          @Override
          protected void customizeCellRenderer(@Nonnull JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
            append(value.getExpression());
          }
        };
      }
    };
    popup.getList().setFont(EditorUtil.getEditorFont());
    popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
  }
}
项目:consulo    文件:ProjectConfigurationProblem.java   
@Override
public void fix(final JComponent contextComponent, RelativePoint relativePoint) {
  JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myDescription.getFixes()) {
    @Nonnull
    @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);
}
项目:consulo    文件:LibraryEditingUtil.java   
public static BaseListPopupStep<LibraryType> createChooseTypeStep(final ClasspathPanel classpathPanel,
                                                                  final ParameterizedRunnable<LibraryType> action) {
  return new BaseListPopupStep<LibraryType>(IdeBundle.message("popup.title.select.library.type"), getSuitableTypes(classpathPanel)) {
        @Nonnull
        @Override
        public String getTextFor(LibraryType value) {
          String createActionName = value != null ? value.getCreateActionName() : null;
          return createActionName != null ? createActionName : IdeBundle.message("create.default.library.type.action.name");
        }

        @Override
        public Icon getIconFor(LibraryType aValue) {
          return aValue != null ? aValue.getIcon() : AllIcons.Nodes.PpLib;
        }

        @Override
        public PopupStep onChosen(final LibraryType selectedValue, boolean finalChoice) {
          return doFinalStep(new Runnable() {
            @Override
            public void run() {
              action.run(selectedValue);
            }
          });
        }
      };
}
项目:consulo-java    文件: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);
  }
}
项目:otto-intellij-plugin    文件:PickAction.java   
public static void startPicker(Type[] displayedTypes, RelativePoint relativePoint,
                               final Callback callback) {

  ListPopup listPopup = JBPopupFactory.getInstance()
      .createListPopup(new BaseListPopupStep<Type>("Select Type", displayedTypes) {
        @NotNull @Override public String getTextFor(Type value) {
          return value.toString();
        }

        @Override public PopupStep onChosen(Type selectedValue, boolean finalChoice) {
          callback.onTypeChose(selectedValue);
          return super.onChosen(selectedValue, finalChoice);
        }
      });

  listPopup.show(relativePoint);
}
项目:intellij-ce-playground    文件:AddMethodQualifierFix.java   
private void chooseAndQualify(final Editor editor) {
  final BaseListPopupStep<PsiVariable> step =
    new BaseListPopupStep<PsiVariable>(QuickFixBundle.message("add.qualifier"), myCandidates) {
      @Override
      public PopupStep onChosen(final PsiVariable selectedValue, final boolean finalChoice) {
        if (selectedValue != null && finalChoice) {
          WriteCommandAction.runWriteCommandAction(selectedValue.getProject(), new Runnable() {
            @Override
            public void run() {
              qualify(selectedValue, editor);
            }
          });
        }
        return FINAL_CHOICE;
      }

      @NotNull
      @Override
      public String getTextFor(final PsiVariable value) {
        return value.getName();
      }

      @Override
      public Icon getIconFor(final PsiVariable aValue) {
        return aValue.getIcon(0);
      }
    };

  final ListPopupImpl popup = new ListPopupImpl(step);
  popup.showInBestPositionFor(editor);
}
项目:intellij-ce-playground    文件:ExpandStaticImportAction.java   
public void invoke(final Project project, final PsiFile file, final Editor editor, PsiElement element) {
  if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;

  final PsiJavaCodeReferenceElement refExpr = (PsiJavaCodeReferenceElement)element.getParent();
  final PsiImportStaticStatement staticImport = (PsiImportStaticStatement)refExpr.advancedResolve(true).getCurrentFileResolveScope();
  final List<PsiJavaCodeReferenceElement> expressionToExpand = collectReferencesThrough(file, refExpr, staticImport);

  if (expressionToExpand.isEmpty()) {
    expand(refExpr, staticImport);
    staticImport.delete();
  }
  else {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
    }
    else {
      final BaseListPopupStep<String> step =
        new BaseListPopupStep<String>("Multiple Similar Calls Found",
                                      new String[]{REPLACE_THIS_OCCURRENCE, REPLACE_ALL_AND_DELETE_IMPORT}) {
          @Override
          public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
            new WriteCommandAction(project, ExpandStaticImportAction.this.getText()) {
              @Override
              protected void run(@NotNull Result result) throws Throwable {
                if (selectedValue == REPLACE_THIS_OCCURRENCE) {
                  expand(refExpr, staticImport);
                }
                else {
                  replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
                }
              }
            }.execute();
            return FINAL_CHOICE;
          }
        };
      JBPopupFactory.getInstance().createListPopup(step).showInBestPositionFor(editor);
    }
  }
}
项目:intellij-ce-playground    文件:DeannotateIntentionAction.java   
@Override
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
  final PsiModifierListOwner listOwner = getContainer(editor, file);
  LOG.assertTrue(listOwner != null); 
  final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
  final PsiAnnotation[] externalAnnotations = annotationsManager.findExternalAnnotations(listOwner);
  LOG.assertTrue(externalAnnotations != null && externalAnnotations.length > 0);
  if (externalAnnotations.length == 1) {
    deannotate(externalAnnotations[0], project, file, annotationsManager, listOwner);
    return;
  }
  JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PsiAnnotation>(CodeInsightBundle.message("deannotate.intention.chooser.title"), externalAnnotations) {
    @Override
    public PopupStep onChosen(final PsiAnnotation selectedValue, final boolean finalChoice) {
      deannotate(selectedValue, project, file, annotationsManager, listOwner);
      return PopupStep.FINAL_CHOICE;
    }

    @Override
    @NotNull
    public String getTextFor(final PsiAnnotation value) {
      final String qualifiedName = value.getQualifiedName();
      LOG.assertTrue(qualifiedName != null);
      return qualifiedName;
    }
  }).showInBestPositionFor(editor);
}
项目:intellij-ce-playground    文件:ArtifactErrorPanel.java   
public ArtifactErrorPanel(final ArtifactEditorImpl artifactEditor) {
  myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning);
  new UiNotifyConnector(myMainPanel, new Activatable.Adapter() {
    @Override
    public void showNotify() {
      if (myErrorText != null) {
        myErrorLabel.setText(myErrorText);
        myErrorText = null;
      }
    }
  });
  myFixButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      if (!myCurrentQuickFixes.isEmpty()) {
        if (myCurrentQuickFixes.size() == 1) {
          performFix(ContainerUtil.getFirstItem(myCurrentQuickFixes, null), artifactEditor);
        }
        else {
          JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myCurrentQuickFixes) {
            @NotNull
            @Override
            public String getTextFor(ConfigurationErrorQuickFix value) {
              return value.getActionName();
            }

            @Override
            public PopupStep onChosen(ConfigurationErrorQuickFix selectedValue, boolean finalChoice) {
              performFix(selectedValue, artifactEditor);
              return FINAL_CHOICE;
            }
          }).showUnderneathOf(myFixButton);
        }
      }
    }
  });
  clearError();
}
项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
@NotNull
@Override
public ListPopup createConfirmation(String title,
                                    final String yesText,
                                    String noText,
                                    final Runnable onYes,
                                    final Runnable onNo,
                                    int defaultOptionIndex)
{

  final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
    @Override
    public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
      if (selectedValue.equals(yesText)) {
        onYes.run();
      }
      else {
        onNo.run();
      }
      return FINAL_CHOICE;
    }

    @Override
    public void canceled() {
      onNo.run();
    }

    @Override
    public boolean isMnemonicsNavigationEnabled() {
      return true;
    }
  };
  step.setDefaultOptionIndex(defaultOptionIndex);

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}
项目:intellij-ce-playground    文件:XDebuggerSmartStepIntoHandler.java   
private static <V extends XSmartStepIntoVariant> void doSmartStepInto(final XSmartStepIntoHandler<V> handler,
                                                                      XSourcePosition position,
                                                                      final XDebugSession session,
                                                                      Editor editor) {
  List<V> variants = handler.computeSmartStepVariants(position);
  if (variants.isEmpty()) {
    session.stepInto();
    return;
  }
  else if (variants.size() == 1) {
    session.smartStepInto(handler, variants.get(0));
    return;
  }

  ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<V>(handler.getPopupTitle(position), variants) {
    @Override
    public Icon getIconFor(V aValue) {
      return aValue.getIcon();
    }

    @NotNull
    @Override
    public String getTextFor(V value) {
      return value.getText();
    }

    @Override
    public PopupStep onChosen(V selectedValue, boolean finalChoice) {
      session.smartStepInto(handler, selectedValue);
      return FINAL_CHOICE;
    }
  });
  DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
}
项目:intellij-ce-playground    文件:ExportHTMLAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final ListPopup popup = JBPopupFactory.getInstance().createListPopup(
    new BaseListPopupStep<String>(InspectionsBundle.message("inspection.action.export.popup.title"), new String[]{HTML, XML}) {
      @Override
      public PopupStep onChosen(final String selectedValue, final boolean finalChoice) {
        exportHTML(Comparing.strEqual(selectedValue, HTML));
        return PopupStep.FINAL_CHOICE;
      }
    });
  InspectionResultsView.showPopup(e, popup);
}
项目:intellij-ce-playground    文件:CodeStyleSchemeExporterUI.java   
void export() {
  ListPopup popup = JBPopupFactory.getInstance().createListPopup(
    new BaseListPopupStep<String>(ApplicationBundle.message("scheme.exporter.ui.export.as.title"), enumExporters()) {
      @Override
      public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
        return doFinalStep(new Runnable() {
          @Override
          public void run() {
            exportSchemeUsing(selectedValue);
          }
        });
      }
    });
  popup.showInCenterOf(myParentComponent);
}
项目:intellij-ce-playground    文件:ExternalJavaDocAction.java   
public static void showExternalJavadoc(@NotNull List<String> urls, Component component) {
  Set<String> set = new THashSet<String>(urls);
  if (set.size() > 1) {
    JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Choose external documentation root", ArrayUtil.toStringArray(set)) {
      @Override
      public PopupStep onChosen(final String selectedValue, final boolean finalChoice) {
        BrowserUtil.browse(selectedValue);
        return FINAL_CHOICE;
      }
    }).showInBestPositionFor(DataManager.getInstance().getDataContext(component));
  }
  else if (set.size() == 1) {
    BrowserUtil.browse(urls.get(0));
  }
}
项目:intellij-ce-playground    文件:ResourceQualifierSwitcher.java   
public ResourceQualifierSwitcherPanel(final Project project, @NotNull final VirtualFile file, BidirectionalMap<String, VirtualFile> qualifiers) {
  super(new BorderLayout());
  myProject = project;
  myFile = file;
  myQualifiers = qualifiers;

  final String currentFileQualifier = qualifiers.getKeysByValue(file).get(0);
  final JLabel label = new JLabel(currentFileQualifier);
  label.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent event) {
      if (event.getButton() != MouseEvent.BUTTON1 || event.getClickCount() != 1) {
        return;
      }
      BidirectionalMap<String, VirtualFile> map = collectQualifiers(file.getParent().getParent(), file);
      ListPopupStep popupStep = new BaseListPopupStep<String>("Choose Qualifier", new ArrayList<String>(map.keySet())) {
        @Override
        public PopupStep onChosen(String selectedValue, boolean finalChoice) {
          switchToFile(selectedValue);
          return FINAL_CHOICE;
        }
      };
      ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep);
      popup.showUnderneathOf(label);
    }
  });
  add(label, BorderLayout.WEST);
}
项目:intellij-ce-playground    文件:ExtendedDeviceChooserDialog.java   
@Override
public void actionPerformed(ActionEvent e) {
  if (!CloudConfigurationProvider.isEnabled()) {
    promptToLaunchEmulator();
    return;
  }

  ListPopup popup = JBPopupFactory.getInstance()
    .createListPopup(new BaseListPopupStep<String>("Launch a Device", new String[]{EMULATOR, CLOUD_DEVICE}) {
      @Override
      public PopupStep onChosen(String selectedValue, boolean finalChoice) {
        if (selectedValue.equals(EMULATOR)) {
          doFinalStep(new Runnable() {
            @Override
            public void run() {
              promptToLaunchEmulator();
            }
          });
        }
        else if (selectedValue.equals(CLOUD_DEVICE)) {
          doFinalStep(new Runnable() {
            @Override
            public void run() {
              promptToLaunchCloudDevice();
            }
          });
        }
        return FINAL_CHOICE;
      }
    });

  popup.showUnderneathOf(myLaunchEmulatorButton);
}
项目:intellij-ce-playground    文件:GitPushTargetPanel.java   
private void showRemoteSelector(@NotNull Component component, @NotNull Point point) {
  final List<String> remotes = getRemotes();
  if (remotes.size() <= 1) {
    return;
  }
  ListPopup popup = new ListPopupImpl(new BaseListPopupStep<String>(null, remotes) {
    @Override
    public PopupStep onChosen(String selectedValue, boolean finalChoice) {
      myRemoteRenderer.updateLinkText(selectedValue);
      if (myFireOnChangeAction != null && !myTargetEditor.isShowing()) {
        //fireOnChange only when editing completed
        myFireOnChangeAction.run();
      }
      return super.onChosen(selectedValue, finalChoice);
    }
  }) {
    @Override
    public void cancel(InputEvent e) {
      super.cancel(e);
      if (myTargetEditor.isShowing()) {
        //repaint and force move focus to target editor component
        GitPushTargetPanel.this.repaint();
        IdeFocusManager.getInstance(myProject).requestFocus(myTargetEditor, true);
      }
    }
  };
  popup.show(new RelativePoint(component, point));
}
项目:tools-idea    文件:ExpandStaticImportAction.java   
public void invoke(final Project project, final PsiFile file, final Editor editor, PsiElement element) {
  if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;

  final PsiJavaCodeReferenceElement refExpr = (PsiJavaCodeReferenceElement)element.getParent();
  final PsiImportStaticStatement staticImport = (PsiImportStaticStatement)refExpr.advancedResolve(true).getCurrentFileResolveScope();
  final List<PsiJavaCodeReferenceElement> expressionToExpand = collectReferencesThrough(file, refExpr, staticImport);

  if (expressionToExpand.isEmpty()) {
    expand(refExpr, staticImport);
    staticImport.delete();
  }
  else {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
    }
    else {
      final BaseListPopupStep<String> step =
        new BaseListPopupStep<String>("Multiple Similar Calls Found",
                                      new String[]{REPLACE_THIS_OCCURRENCE, REPLACE_ALL_AND_DELETE_IMPORT}) {
          @Override
          public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
            new WriteCommandAction(project, ExpandStaticImportAction.this.getText()) {
              @Override
              protected void run(Result result) throws Throwable {
                if (selectedValue == REPLACE_THIS_OCCURRENCE) {
                  expand(refExpr, staticImport);
                }
                else {
                  replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
                }
              }
            }.execute();
            return FINAL_CHOICE;
          }
        };
      JBPopupFactory.getInstance().createListPopup(step).showInBestPositionFor(editor);
    }
  }
}
项目:tools-idea    文件:DeannotateIntentionAction.java   
@Override
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
  final PsiModifierListOwner listOwner = getContainer(editor, file);
  LOG.assertTrue(listOwner != null); 
  final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
  final PsiAnnotation[] externalAnnotations = annotationsManager.findExternalAnnotations(listOwner);
  LOG.assertTrue(externalAnnotations != null && externalAnnotations.length > 0);
  if (externalAnnotations.length == 1) {
    deannotate(externalAnnotations[0], project, file, annotationsManager, listOwner);
    return;
  }
  JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PsiAnnotation>(CodeInsightBundle.message("deannotate.intention.chooser.title"), externalAnnotations) {
    @Override
    public PopupStep onChosen(final PsiAnnotation selectedValue, final boolean finalChoice) {
      deannotate(selectedValue, project, file, annotationsManager, listOwner);
      return PopupStep.FINAL_CHOICE;
    }

    @Override
    @NotNull
    public String getTextFor(final PsiAnnotation value) {
      final String qualifiedName = value.getQualifiedName();
      LOG.assertTrue(qualifiedName != null);
      return qualifiedName;
    }
  }).showInBestPositionFor(editor);
}
项目:tools-idea    文件:ArtifactErrorPanel.java   
public ArtifactErrorPanel(final ArtifactEditorImpl artifactEditor) {
  myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning);
  new UiNotifyConnector(myMainPanel, new Activatable.Adapter() {
    @Override
    public void showNotify() {
      if (myErrorText != null) {
        myErrorLabel.setText(myErrorText);
        myErrorText = null;
      }
    }
  });
  myFixButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      if (!myCurrentQuickFixes.isEmpty()) {
        if (myCurrentQuickFixes.size() == 1) {
          performFix(ContainerUtil.getFirstItem(myCurrentQuickFixes, null), artifactEditor);
        }
        else {
          JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myCurrentQuickFixes) {
            @NotNull
            @Override
            public String getTextFor(ConfigurationErrorQuickFix value) {
              return value.getActionName();
            }

            @Override
            public PopupStep onChosen(ConfigurationErrorQuickFix selectedValue, boolean finalChoice) {
              performFix(selectedValue, artifactEditor);
              return FINAL_CHOICE;
            }
          }).showUnderneathOf(myFixButton);
        }
      }
    }
  });
  clearError();
}
项目:tools-idea    文件:PopupFactoryImpl.java   
@NotNull
@Override
public ListPopup createConfirmation(String title,
                                    final String yesText,
                                    String noText,
                                    final Runnable onYes,
                                    final Runnable onNo,
                                    int defaultOptionIndex)
{

  final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
    @Override
    public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
      if (selectedValue.equals(yesText)) {
        onYes.run();
      }
      else {
        onNo.run();
      }
      return FINAL_CHOICE;
    }

    @Override
    public void canceled() {
      onNo.run();
    }

    @Override
    public boolean isMnemonicsNavigationEnabled() {
      return true;
    }
  };
  step.setDefaultOptionIndex(defaultOptionIndex);

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}