com.intellij.openapi.ui.InputValidatorEx Java Examples
The following examples show how to use
com.intellij.openapi.ui.InputValidatorEx.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateDirectoryOrPackageAction.java From consulo with Apache License 2.0 | 6 votes |
private JBPopup createLightWeightPopup(CreateDirectoryOrPackageHandler validator, String title, Consumer<PsiElement> consumer) { NewItemSimplePopupPanel contentPanel = new NewItemSimplePopupPanel(); TextBox nameField = contentPanel.getTextField(); JBPopup popup = NewItemPopupUtil.createNewItemPopup(title, contentPanel, (JComponent)TargetAWT.to(nameField)); contentPanel.addValidator(value -> { if (!validator.checkInput(value)) { String message = InputValidatorEx.getErrorText(validator, value, LangBundle.message("incorrect.name")); return new ValidableComponent.ValidationInfo(message); } return null; }); contentPanel.setApplyAction(event -> { String name = nameField.getValue(); validator.canClose(name); popup.closeOk(event); consumer.accept(validator.getCreatedElement()); }); return popup; }