use of com.intellij.openapi.ui.popup.ListPopup in project android by JetBrains.
the class FlatComboAction method createPopup.
protected JBPopup createPopup(Runnable onDispose, DataContext context) {
DefaultActionGroup group = createPopupActionGroup();
JBPopupFactory factory = JBPopupFactory.getInstance();
ListPopup popup = factory.createActionGroupPopup(null, group, context, true, onDispose, getMaxRows());
popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
return popup;
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-plugins by JetBrains.
the class CucumberCreateStepFixBase method applyFix.
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
final GherkinStep step = (GherkinStep) descriptor.getPsiElement();
final GherkinFile featureFile = (GherkinFile) step.getContainingFile();
// TODO + step defs pairs from other content roots
final List<Pair<PsiFile, BDDFrameworkType>> pairs = ContainerUtil.newArrayList(getStepDefinitionContainers(featureFile));
if (!pairs.isEmpty()) {
pairs.add(0, null);
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
final ListPopup popupStep = popupFactory.createListPopup(new BaseListPopupStep<Pair<PsiFile, BDDFrameworkType>>(CucumberBundle.message("choose.step.definition.file"), ContainerUtil.newArrayList(pairs)) {
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@NotNull
@Override
public String getTextFor(Pair<PsiFile, BDDFrameworkType> value) {
if (value == null) {
return CucumberBundle.message("create.new.file");
}
final VirtualFile file = value.getFirst().getVirtualFile();
assert file != null;
CucumberStepsIndex stepsIndex = CucumberStepsIndex.getInstance(value.getFirst().getProject());
StepDefinitionCreator stepDefinitionCreator = stepsIndex.getExtensionMap().get(value.getSecond()).getStepDefinitionCreator();
return stepDefinitionCreator.getStepDefinitionFilePath(value.getFirst());
}
@Override
public Icon getIconFor(Pair<PsiFile, BDDFrameworkType> value) {
return value == null ? AllIcons.Actions.CreateFromUsage : value.getFirst().getIcon(0);
}
@Override
public PopupStep onChosen(final Pair<PsiFile, BDDFrameworkType> selectedValue, boolean finalChoice) {
return doFinalStep(() -> createStepOrSteps(step, selectedValue));
}
});
if (!ApplicationManager.getApplication().isUnitTestMode()) {
popupStep.showCenteredInCurrentWindow(step.getProject());
} else {
createStepOrSteps(step, pairs.get(1));
}
} else {
createFileOrStepDefinition(step, null);
}
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class WelcomePopupAction method showPopup.
private void showPopup(final AnActionEvent e) {
final DefaultActionGroup group = new DefaultActionGroup();
fillActions(group);
if (group.getChildrenCount() == 1 && isSilentlyChooseSingleOption()) {
final AnAction[] children = group.getChildren(null);
children[0].actionPerformed(e);
return;
}
if (group.getChildrenCount() == 0) {
group.add(new AnAction(getTextForEmpty()) {
public void actionPerformed(AnActionEvent e) {
group.setPopup(false);
}
});
}
final DataContext context = e.getDataContext();
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(getCaption(), group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
JComponent contextComponent = null;
InputEvent inputEvent = e.getInputEvent();
if (inputEvent instanceof MouseEvent) {
if (inputEvent.getSource() instanceof JComponent) {
contextComponent = (JComponent) inputEvent.getSource();
}
}
showPopup(context, popup, contextComponent);
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class XDebuggerSmartStepIntoHandler method doSmartStepInto.
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());
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class QuickSwitchSchemeAction method showPopup.
private void showPopup(AnActionEvent e, DefaultActionGroup group) {
if (!myShowPopupWithNoActions && group.getChildrenCount() == 0)
return;
JBPopupFactory.ActionSelectionAid aid = getAidMethod();
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(getPopupTitle(e), group, e.getDataContext(), aid, true, null, -1, (a) -> a.getTemplatePresentation().getIcon() != ourCurrentAction, myActionPlace);
showPopup(e, popup);
}
Aggregations