Java 类com.intellij.openapi.ui.InputValidator 实例源码

项目:intellij-ce-playground    文件:CreateResourceDirectoryAction.java   
@NotNull
public PsiElement[] invokeDialog(@NotNull final Project project, @NotNull final PsiDirectory directory) {
  final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project, myResourceFolderType, directory,
                                                                                 AndroidPsiUtils.getModuleSafely(directory)) {
    @Override
    protected InputValidator createValidator() {
      return CreateResourceDirectoryAction.this.createValidator(project, directory);
    }
  };
  dialog.setTitle(AndroidBundle.message("new.resource.dir.dialog.title"));
  dialog.show();
  final InputValidator validator = dialog.getValidator();
  if (validator == null) {
    return PsiElement.EMPTY_ARRAY;
  }
  return ((MyInputValidator)validator).getCreatedElements();
}
项目:intellij-ce-playground    文件:CreateTypedResourceFileAction.java   
@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
  final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
  if (view != null) {
    // If you're in the Android View, we want to ask you not just the filename but also let you
    // create other resource folder configurations
    AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
    if (pane instanceof AndroidProjectViewPane) {
      return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
    }

    final PsiDirectory directory = view.getOrChooseDirectory();
    if (directory != null) {
      InputValidator validator = createValidator(project, directory);
      Messages.showInputDialog(project, AndroidBundle.message("new.file.dialog.text"),
                               AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName),
                               Messages.getQuestionIcon(), "", validator);
    }
  }
  return PsiElement.EMPTY_ARRAY;
}
项目:intellij-ce-playground    文件:CreateMultiRootResourceFileAction.java   
protected MyDialog(@NotNull AndroidFacet facet, @Nullable InputValidator validator) {
  super(facet.getModule().getProject());
  myValidator = validator;
  setTitle(AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName));
  final List<String> tagNames = getSortedAllowedTagNames(facet);
  myRootElementField = new TextFieldWithAutoCompletion<String>(
    facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true, null);
  myRootElementField.setText(myDefaultRootTag);
  myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
  myRootElementLabel.setLabelFor(myRootElementField);
  init();

  myFileNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      final String text = myFileNameField.getText().trim();
      if (myValidator instanceof InputValidatorEx) {
        setErrorText(((InputValidatorEx) myValidator).getErrorText(text));
      }
    }
  });
}
项目:intellij-plugin-save-actions    文件:FileMaskPanel.java   
@NotNull
private InputValidator getRegexInputValidator() {
    return new InputValidator() {
        @Override
        public boolean checkInput(String string) {
            try {
                if (string == null || string.trim().isEmpty()) {
                    //do not allow null or blank entries
                    return false;
                }
                Pattern.compile(string);
                return true;
            } catch (PatternSyntaxException e) {
                return false;
            }
        }

        @Override
        public boolean canClose(String s) {
            return true;
        }
    };
}
项目:json2java4idea    文件:ProjectModule.java   
@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));
}
项目:intellij-ce-playground    文件:AssignWeightAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final List<? extends RadViewComponent> targets = mySelectedChildren;
  if (targets.isEmpty()) {
    return;
  }
  String currentWeight = targets.get(0).getTag().getAttributeValue(ATTR_LAYOUT_WEIGHT, ANDROID_URI);
  if (currentWeight == null || currentWeight.isEmpty()) {
    currentWeight = "0.0";
  }

  String title = getTemplatePresentation().getDescription();
  InputValidator validator = null; // TODO: Number validation!
  final String weight = Messages.showInputDialog(myDesigner, "Enter Weight Value:", title, null, currentWeight, validator);
  if (weight != null) {

    myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
      @Override
      public void run() throws Exception {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            if (weight.isEmpty()) {
              // Remove attributes
              ClearWeightsAction.clearWeights(myLayout, targets);
            } else {
              for (RadViewComponent target : targets) {
                target.getTag().setAttribute(ATTR_LAYOUT_WEIGHT, ANDROID_URI, weight);
              }
            }
          }
        });
      }
    }, getTemplatePresentation().getDescription(), true);
  }
}
项目:intellij-ce-playground    文件:OverrideResourceAction.java   
@Nullable
public static PsiDirectory selectFolderDir(final Project project, VirtualFile res, ResourceFolderType folderType) {
  final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(res);
  if (directory == null) {
    return null;
  }
  if (ApplicationManager.getApplication().isUnitTestMode() && ourTargetFolderName != null) {
    PsiDirectory subDirectory = directory.findSubdirectory(ourTargetFolderName);
    if (subDirectory != null) {
      return subDirectory;
    }
    return directory.createSubdirectory(ourTargetFolderName);
  }
  final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project, folderType, directory, null) {
    @Override
    protected InputValidator createValidator() {
      return new ResourceDirectorySelector(project, directory);
    }
  };
  dialog.setTitle("Select Resource Directory");
  dialog.show();
  final InputValidator validator = dialog.getValidator();
  if (validator != null) {
    PsiElement[] createdElements = ((ResourceDirectorySelector)validator).getCreatedElements();
    if (createdElements != null && createdElements.length > 0) {
      return (PsiDirectory)createdElements[0];
    }
  }

  return null;
}
项目:tools-idea    文件:PluginHostsConfigurable.java   
public InputHostDialog(Component parentComponent,
                       String message,
                       String title,
                       Icon icon,
                       String initialValue,
                       InputValidator validator) {
  super(parentComponent, message, title, icon, initialValue, validator);
}
项目:cordovastudio    文件:AssignWeightAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    final List<? extends RadViewComponent> targets = mySelectedChildren;
    if (targets.isEmpty()) {
        return;
    }
    String currentWeight = targets.get(0).getTag().getAttributeValue(ATTR_LAYOUT_WEIGHT, CORDOVASTUDIO_URI);
    if (currentWeight == null || currentWeight.isEmpty()) {
        currentWeight = "0.0";
    }

    String title = getTemplatePresentation().getDescription();
    InputValidator validator = null; // TODO: Number validation!
    final String weight = Messages.showInputDialog(myDesigner, "Enter Weight Value:", title, null, currentWeight, validator);
    if (weight != null) {

        myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
            @Override
            public void run() throws Exception {
                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    @Override
                    public void run() {
                        if (weight.isEmpty()) {
                            // Remove attributes
                            ClearWeightsAction.clearWeights(myLayout, targets);
                        } else {
                            for (RadViewComponent target : targets) {
                                target.getTag().setAttribute(ATTR_LAYOUT_WEIGHT, CORDOVASTUDIO_URI, weight);
                            }
                        }
                    }
                });
            }
        }, getTemplatePresentation().getDescription(), true);
    }
}
项目:GravSupport    文件:CustomCreateFileFromTemplateDialog.java   
@Override
public Builder setValidator(InputValidator validator) {
    myDialog.myInputValidator = validator;
    return this;
}
项目:intellij-ce-playground    文件:PluginHostsConfigurable.java   
public InputHostDialog(Component parent, String message, String title, Icon icon, String initialValue, InputValidator validator) {
  super(parent, message, title, icon, initialValue, validator);
}
项目:intellij-ce-playground    文件:CreateFileFromTemplateDialog.java   
@Override
public Builder setValidator(InputValidator validator) {
  myDialog.myInputValidator = validator;
  return this;
}
项目:intellij-ce-playground    文件:CreateResourceFileDialog.java   
@Nullable
protected InputValidator createValidator(@NotNull String subdirName) {
  return null;
}
项目:intellij-ce-playground    文件:CreateResourceFileDialog.java   
public InputValidator getValidator() {
  return myValidator;
}
项目:intellij-ce-playground    文件:CreateTypedResourceFileAction.java   
protected InputValidator createValidator(Project project, PsiDirectory directory) {
  return new MyValidator(project, directory);
}
项目:intellij-ce-playground    文件:CreateResourceDirectoryDialog.java   
public InputValidator getValidator() {
  return myValidator;
}
项目:defrac-plugin-intellij    文件:MultiPlatformCreateDialog.java   
public void setValidator(@Nullable final InputValidator value) {
  inputValidator = value;
}
项目:tools-idea    文件:CreateFileFromTemplateDialog.java   
@Override
public Builder setValidator(InputValidator validator) {
  myDialog.myInputValidator = validator;
  return this;
}
项目:consulo    文件:CreateFileFromTemplateDialog.java   
@Override
public Builder setValidator(InputValidator validator) {
  myDialog.myInputValidator = validator;
  return this;
}
项目:GravSupport    文件:CustomCreateFileFromTemplateDialog.java   
Builder setValidator(InputValidator validator);
项目:intellij-ce-playground    文件:CreateFileFromTemplateDialog.java   
Builder setValidator(InputValidator validator);
项目:intellij-ce-playground    文件:CreateResourceDirectoryDialog.java   
protected abstract InputValidator createValidator();
项目:tools-idea    文件:CreateFileFromTemplateDialog.java   
Builder setValidator(InputValidator validator);
项目:consulo    文件:CreateFileFromTemplateDialog.java   
Builder setValidator(InputValidator validator);