com.intellij.openapi.ui.InputValidator Java Examples
The following examples show how to use
com.intellij.openapi.ui.InputValidator.
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: IdeaMessages.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static String showInputDialog(@Nullable Project project, Component parentComponent, String message, String title, @Nullable Icon icon, @Nullable String initialValue, @Nullable InputValidator validator, @Nullable TextRange selection) { InputDialog dialog = new InputDialog(project, message, title, icon, initialValue, validator, new String[]{com.intellij.openapi.ui.Messages.OK_BUTTON}, 0);// Fix support with WebStorm 173(2017.3) JTextComponent field = dialog.getTextField(); if (selection != null) { field.select(selection.getStartOffset(), selection.getEndOffset()); field.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, true); } dialog.show(); return dialog.getInputString(); }
Example #2
Source File: EditJsAppPathAction.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Edit given project's js project work directory * @param project */ public static void doEditJsProjectPath(Project project) { String path = IdeaMessages.showInputDialog(project, "Specify js project working directory rather than root directory, eg ./jsapp\nThe value is stored in file .idea/.rnconsole", "Input Js Working Directory", PluginIcons.EditFolder, RNPathUtil.getRNProjectRawRootPathFromConfig(project), new InputValidator() { @Override public boolean checkInput(String text) { boolean notEmpty = Utils.notEmpty(text); if(!notEmpty) return false; try { File f = new File(project.getBasePath(), text); return (f.isDirectory() && f.exists()); } catch (Exception e) { e.printStackTrace(); return false; } } @Override public boolean canClose(String s) { return true; } }); if(Utils.notEmpty(path)) RNPathUtil.saveRNProjectRootPathToConfig(project, path); }
Example #3
Source File: ProjectModule.java From json2java4idea with Apache License 2.0 | 5 votes |
@Override public void configure(@Nonnull Binder binder) { binder.bind(Project.class) .toInstance(project); // Binding InputValidator related classes binder.bind(InputValidator.class) .annotatedWith(Name.NAME_VALIDATOR.annotation()) .to(NameValidator.class); binder.bind(InputValidator.class) .annotatedWith(Name.JSON_VALIDATOR.annotation()) .to(JsonValidator.class); binder.bind(InputValidator.class) .annotatedWith(Name.CLASS_PREFIX_VALIDATOR.annotation()) .to(ClassPrefixValidator.class); binder.bind(InputValidator.class) .annotatedWith(Name.CLASS_SUFFIX_VALIDATOR.annotation()) .to(ClassSuffixValidator.class); // Binding NamePolicy classes binder.bind(NamePolicy.class) .annotatedWith(Name.CLASS_NAME_POLICY.annotation()) .to(ClassNamePolicy.class); binder.bind(NamePolicy.class) .annotatedWith(Name.FIELD_NAME_POLICY.annotation()) .to(FieldNamePolicy.class); binder.bind(NamePolicy.class) .annotatedWith(Name.METHOD_NAME_POLICY.annotation()) .to(MethodNamePolicy.class); binder.bind(NamePolicy.class) .annotatedWith(Name.PARAMETER_NAME_POLICY.annotation()) .to(ParameterNamePolicy.class); // Binding other classes binder.bind(Json2JavaBundle.class) .toInstance(Json2JavaBundle.getInstance()); // Installation factory modules binder.install(new FactoryModuleBuilder().build(CommandActionFactory.class)); }
Example #4
Source File: SafeDialogUtils.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Synchronously shows an input dialog. This method must not be called from a write safe context * as it needs to be executed synchronously and AWT actions are not allowed from a write safe * context. * * @param project the project used as a reference to generate and position the dialog * @param message the text displayed as the message of the dialog * @param initialValue the initial value contained in the text field of the input dialog * @param title the text displayed as the title of the dialog * @param selection the input range that is selected by default * @return the <code>String</code> entered by the user or <code>null</code> if the dialog did not * finish with the exit code 0 (it was not closed by pressing the "OK" button) * @throws IllegalAWTContextException if the calling thread is currently inside a write safe * context * @see Messages.InputDialog#getInputString() * @see com.intellij.openapi.ui.DialogWrapper#OK_EXIT_CODE */ public static String showInputDialog( Project project, final String message, final String initialValue, final String title, InputValidator inputValidator, TextRange selection) throws IllegalAWTContextException { if (application.isWriteAccessAllowed()) { throw new IllegalAWTContextException("AWT events are not allowed " + "inside write actions."); } log.info("Showing input dialog: " + title + " - " + message + " - " + initialValue); return EDTExecutor.invokeAndWait( (Computable<String>) () -> Messages.showInputDialog( project, message, title, Messages.getQuestionIcon(), initialValue, inputValidator, selection), ModalityState.defaultModalityState()); }
Example #5
Source File: IdeaMessages.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nullable public static String showInputDialog(@Nullable Project project, @Nls String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon, @Nullable String initialValue, @Nullable InputValidator validator) { return IdeaMessages.showInputDialog(project, (Component)null, message, title, icon, initialValue, validator, (TextRange)null); }
Example #6
Source File: CreateFileFromTemplateDialog.java From consulo with Apache License 2.0 | 4 votes |
@Override public Builder setValidator(@Nonnull InputValidator validator) { myDialog.myInputValidator = validator; return this; }
Example #7
Source File: CreateFileFromTemplateDialog.java From consulo with Apache License 2.0 | 4 votes |
@Override public Builder setValidator(InputValidator validator) { myInputValidator = validator; return this; }
Example #8
Source File: CreateFileFromTemplateDialog.java From consulo with Apache License 2.0 | votes |
Builder setValidator(InputValidator validator);