use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class AbstractComboBoxAction method createComboBoxButton.
@Override
protected ComboBoxButton createComboBoxButton(Presentation presentation) {
if (myShowDisabledActions) {
return new ComboBoxButton(presentation) {
@Override
protected JBPopup createPopup(Runnable onDispose) {
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, createPopupActionGroup(this), getDataContext(), true, onDispose, getMaxRows());
popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
return popup;
}
};
}
return super.createComboBoxButton(presentation);
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class FormSpellCheckingInspection method checkStringDescriptor.
@Override
protected void checkStringDescriptor(Module module, final IComponent component, final IProperty prop, final StringDescriptor descriptor, final FormErrorCollector collector) {
final String value = descriptor.getResolvedValue();
if (value == null) {
return;
}
final SpellCheckerManager manager = SpellCheckerManager.getInstance(module.getProject());
PlainTextSplitter.getInstance().split(value, TextRange.allOf(value), textRange -> {
final String word = textRange.substring(value);
if (manager.hasProblem(word)) {
final List<String> suggestions = manager.getSuggestions(word);
if (!suggestions.isEmpty() && prop instanceof IntroStringProperty) {
EditorQuickFixProvider changeToProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(final GuiEditor editor, final RadComponent component1) {
return new PopupQuickFix<String>(editor, "Change to...", component1) {
@Override
public void run() {
ListPopup popup = JBPopupFactory.getInstance().createListPopup(getPopupStep());
popup.showUnderneathOf(component1.getDelegee());
}
@Override
public ListPopupStep<String> getPopupStep() {
return new BaseListPopupStep<String>("Select Replacement", suggestions) {
@Override
public PopupStep onChosen(String selectedValue, boolean finalChoice) {
FormInspectionUtil.updateStringPropertyValue(editor, component1, (IntroStringProperty) prop, descriptor, selectedValue);
return FINAL_CHOICE;
}
};
}
};
}
};
EditorQuickFixProvider acceptProvider = new EditorQuickFixProvider() {
@Override
public QuickFix createQuickFix(final GuiEditor editor, RadComponent component1) {
return new QuickFix(editor, "Save '" + word + "' to dictionary", component1) {
@Override
public void run() {
manager.acceptWordAsCorrect(word, editor.getProject());
}
};
}
};
collector.addError(getID(), component, prop, "Typo in word '" + word + "'", changeToProvider, acceptProvider);
} else {
collector.addError(getID(), component, prop, "Typo in word '" + word + "'");
}
}
});
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class MorphAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = selectedValue -> {
Runnable runnable = () -> {
for (RadComponent c : selection) {
if (!morphComponent(editor, c, selectedValue))
break;
}
editor.refreshAndSave(true);
};
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
});
return true;
};
PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
step.hideNonAtomic();
if (selection.size() == 1) {
step.hideComponentClass(selection.get(0).getComponentClassName());
}
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class CreateListenerAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
final DefaultActionGroup actionGroup = prepareActionGroup(selection);
final JComponent selectedComponent = selection.get(0).getDelegee();
final DataContext context = DataManager.getInstance().getDataContext(selectedComponent);
final JBPopupFactory factory = JBPopupFactory.getInstance();
final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("create.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
FormEditingUtil.showPopupUnderComponent(popup, selection.get(0));
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class ModuleChooserUtil method selectModule.
public static void selectModule(@NotNull Project project, final Collection<Module> suitableModules, final Function<Module, String> versionProvider, final Consumer<Module> callback, @Nullable DataContext context) {
final List<Module> modules = new ArrayList<>();
final Map<Module, String> versions = new HashMap<>();
for (Module module : suitableModules) {
modules.add(module);
versions.put(module, versionProvider.fun(module));
}
if (modules.size() == 1) {
callback.consume(modules.get(0));
return;
}
Collections.sort(modules, ModulesAlphaComparator.INSTANCE);
BaseListPopupStep<Module> step = new BaseListPopupStep<Module>("Which module to use classpath of?", modules, PlatformIcons.CONTENT_ROOT_ICON_CLOSED) {
@NotNull
@Override
public String getTextFor(Module value) {
return String.format("%s (%s)", value.getName(), versions.get(value));
}
@Override
public String getIndexedString(Module value) {
return value.getName();
}
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@Override
public PopupStep onChosen(Module selectedValue, boolean finalChoice) {
PropertiesComponent.getInstance(selectedValue.getProject()).setValue(GROOVY_LAST_MODULE, selectedValue.getName());
callback.consume(selectedValue);
return null;
}
};
final String lastModuleName = PropertiesComponent.getInstance(project).getValue(GROOVY_LAST_MODULE);
if (lastModuleName != null) {
int defaultOption = ContainerUtil.indexOf(modules, new Condition<Module>() {
@Override
public boolean value(Module module) {
return module.getName().equals(lastModuleName);
}
});
if (defaultOption >= 0) {
step.setDefaultOptionIndex(defaultOption);
}
}
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
if (context == null) {
listPopup.showCenteredInCurrentWindow(project);
} else {
listPopup.showInBestPositionFor(context);
}
}
Aggregations