use of com.intellij.openapi.ui.popup.PopupStep in project intellij-community by JetBrains.
the class DetectionExcludesConfigurable method doAddAction.
private void doAddAction(AnActionButton button) {
final List<FrameworkType> types = new ArrayList<>();
for (FrameworkType type : FrameworkDetectorRegistry.getInstance().getFrameworkTypes()) {
if (!isExcluded(type)) {
types.add(type);
}
}
Collections.sort(types, (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
types.add(0, null);
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<FrameworkType>("Framework to Exclude", types) {
@Override
public Icon getIconFor(FrameworkType value) {
return value != null ? value.getIcon() : null;
}
@NotNull
@Override
public String getTextFor(FrameworkType value) {
return value != null ? value.getPresentableName() : "All Frameworks...";
}
@Override
public boolean hasSubstep(FrameworkType selectedValue) {
return selectedValue != null;
}
@Override
public PopupStep onChosen(final FrameworkType frameworkType, boolean finalChoice) {
if (frameworkType == null) {
return doFinalStep(() -> chooseDirectoryAndAdd(null));
} else {
return addExcludedFramework(frameworkType);
}
}
});
final RelativePoint popupPoint = button.getPreferredPopupPoint();
if (popupPoint != null) {
popup.show(popupPoint);
} else {
popup.showInCenterOf(myMainPanel);
}
}
use of com.intellij.openapi.ui.popup.PopupStep in project intellij-community by JetBrains.
the class BaseRunConfigurationAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
final RunnerAndConfigurationSettings existing = context.findExisting();
if (existing == null) {
final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
if (producers.isEmpty())
return;
if (producers.size() > 1) {
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
Collections.sort(producers, ConfigurationFromContext.NAME_COMPARATOR);
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationFromContext>(ExecutionBundle.message("configuration.action.chooser.title"), producers) {
@Override
@NotNull
public String getTextFor(final ConfigurationFromContext producer) {
return childActionName(producer.getConfigurationType(), producer.getConfiguration());
}
@Override
public Icon getIconFor(final ConfigurationFromContext producer) {
return producer.getConfigurationType().getIcon();
}
@Override
public PopupStep onChosen(final ConfigurationFromContext producer, final boolean finalChoice) {
perform(producer, context);
return FINAL_CHOICE;
}
});
final InputEvent event = e.getInputEvent();
if (event instanceof MouseEvent) {
popup.show(new RelativePoint((MouseEvent) event));
} else if (editor != null) {
popup.showInBestPositionFor(editor);
} else {
popup.showInBestPositionFor(dataContext);
}
} else {
perform(producers.get(0), context);
}
return;
}
perform(context);
}
use of com.intellij.openapi.ui.popup.PopupStep in project android by JetBrains.
the class ModuleDependenciesPanel method createTableWithButtons.
@NotNull
private JComponent createTableWithButtons() {
myEntryTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) {
return;
}
updateButtons();
});
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable);
decorator.setAddAction(button -> {
ImmutableList<PopupAction> popupActions = ImmutableList.of(new PopupAction(AndroidIcons.MavenLogo, 1, "Library dependency") {
@Override
public void run() {
addExternalDependency();
}
}, new PopupAction(PlatformIcons.LIBRARY_ICON, 2, "Jar dependency") {
@Override
public void run() {
addFileDependency();
}
}, new PopupAction(AllIcons.Nodes.Module, 3, "Module dependency") {
@Override
public void run() {
addModuleDependency();
}
});
final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<PopupAction>(null, popupActions) {
@Override
public Icon getIconFor(PopupAction value) {
return value.myIcon;
}
@Override
public boolean hasSubstep(PopupAction value) {
return false;
}
@Override
public boolean isMnemonicsNavigationEnabled() {
return true;
}
@Override
public PopupStep onChosen(final PopupAction value, final boolean finalChoice) {
return doFinalStep(value);
}
@Override
@NotNull
public String getTextFor(PopupAction value) {
return "&" + value.myIndex + " " + value.myTitle;
}
});
popup.show(button.getPreferredPopupPoint());
});
decorator.setRemoveAction(button -> removeSelectedItems());
decorator.setMoveUpAction(button -> moveSelectedRows(-1));
decorator.setMoveDownAction(button -> moveSelectedRows(+1));
final JPanel panel = decorator.createPanel();
myRemoveButton = ToolbarDecorator.findRemoveButton(panel);
return panel;
}
use of com.intellij.openapi.ui.popup.PopupStep 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.PopupStep in project intellij-plugins by JetBrains.
the class DependenciesConfigurable method addItem.
private void addItem(AnActionButton button) {
initPopupActions();
final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<AddItemPopupAction>(FlexBundle.message("add.dependency.popup.title"), myPopupActions) {
@Override
public Icon getIconFor(AddItemPopupAction aValue) {
return aValue.getIcon();
}
@Override
public boolean hasSubstep(AddItemPopupAction selectedValue) {
return selectedValue.hasSubStep();
}
public boolean isMnemonicsNavigationEnabled() {
return true;
}
public PopupStep onChosen(final AddItemPopupAction selectedValue, final boolean finalChoice) {
if (selectedValue.hasSubStep()) {
return selectedValue.createSubStep();
}
return doFinalStep(() -> selectedValue.run());
}
@NotNull
public String getTextFor(AddItemPopupAction value) {
return "&" + value.getIndex() + " " + value.getTitle();
}
});
popup.show(button.getPreferredPopupPoint());
}
Aggregations