use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class SurroundWithTemplateHandler method invoke.
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!EditorModificationUtil.checkModificationAllowed(editor))
return;
DefaultActionGroup group = createActionGroup(project, editor, file);
if (group == null)
return;
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(CodeInsightBundle.message("templates.select.template.chooser.title"), group, DataManager.getInstance().getDataContext(editor.getContentComponent()), JBPopupFactory.ActionSelectionAid.MNEMONICS, false);
popup.showInBestPositionFor(editor);
}
use of com.intellij.openapi.ui.popup.ListPopup 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.ListPopup in project intellij-community by JetBrains.
the class ProjectStartupConfigurable method createNewWrapper.
private ChooseRunConfigurationPopup.ItemWrapper<Void> createNewWrapper(final AnActionButton button) {
return new ChooseRunConfigurationPopup.ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return IconUtil.getAddIcon();
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ExecutionBundle.message("add.new.run.configuration.acrtion.name"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
final ConfigurationType[] factories = runManager.getConfigurationFactories();
final Condition<ConfigurationType> filter = new Condition<ConfigurationType>() {
private final RunnerRegistry myRegistry = RunnerRegistry.getInstance();
@Override
public boolean value(ConfigurationType configurationType) {
ConfigurationFactory factory;
return !UnknownConfigurationType.INSTANCE.equals(configurationType) && ((factory = runManager.getFactory(configurationType.getId(), null)) != null) && myRegistry.getRunner(executor.getId(), runManager.getConfigurationTemplate(factory).getConfiguration()) != null;
}
};
final List<ConfigurationType> factoriesList = ContainerUtil.filter(Arrays.asList(factories), filter);
final ListPopup popup = NewRunConfigurationPopup.createAddPopup(factoriesList, "", factory -> ApplicationManager.getApplication().invokeLater(() -> {
final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project, factory);
if (dialog.showAndGet()) {
ApplicationManager.getApplication().invokeLater(() -> {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
addConfiguration(configuration);
}
}, ModalityState.any(), project.getDisposed());
}
}, ModalityState.any(), project.getDisposed()), null, EmptyRunnable.getInstance(), false);
showPopup(button, popup);
}
@Override
public boolean available(Executor executor) {
return true;
}
};
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class ShowAddPackagingElementPopupAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DefaultActionGroup group = new DefaultActionGroup();
for (PackagingElementType type : PackagingElementFactory.getInstance().getAllElementTypes()) {
group.add(new AddNewPackagingElementAction((PackagingElementType<?>) type, myArtifactEditor));
}
final DataContext dataContext = e.getDataContext();
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Add", group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
popup.showInBestPositionFor(dataContext);
}
use of com.intellij.openapi.ui.popup.ListPopup 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);
}
}
Aggregations