use of com.intellij.openapi.ui.popup.util.BaseListPopupStep 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.util.BaseListPopupStep in project yii2support by nvlad.
the class OpenViewCalls method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
// TODO: insert action logic here
PsiFile psiFile = e.getData(PlatformDataKeys.PSI_FILE);
if (psiFile == null) {
return;
}
Collection<PsiReference> references = ReferencesSearch.search(psiFile).findAll();
if (references.size() == 0) {
return;
}
if (references.size() == 1) {
ReferenceListPopupStep.openReference(references.iterator().next());
return;
}
JBPopupFactory popupFactory = JBPopupFactory.getInstance();
BaseListPopupStep popupStep = new ReferenceListPopupStep("Render this View from", references);
ListPopup popup = popupFactory.createListPopup(popupStep);
Project project = e.getProject();
if (project == null) {
popup.showInFocusCenter();
} else {
popup.showCenteredInCurrentWindow(project);
}
}
use of com.intellij.openapi.ui.popup.util.BaseListPopupStep 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.util.BaseListPopupStep 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());
}
use of com.intellij.openapi.ui.popup.util.BaseListPopupStep 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());
}
Aggregations