当前位置: 首页>>代码示例>>Java>>正文


Java InputValidator类代码示例

本文整理汇总了Java中com.intellij.openapi.ui.InputValidator的典型用法代码示例。如果您正苦于以下问题:Java InputValidator类的具体用法?Java InputValidator怎么用?Java InputValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InputValidator类属于com.intellij.openapi.ui包,在下文中一共展示了InputValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeDialog

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CreateResourceDirectoryAction.java

示例2: invokeDialog

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateTypedResourceFileAction.java

示例3: MyDialog

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
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));
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateMultiRootResourceFileAction.java

示例4: getRegexInputValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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;
        }
    };
}
 
开发者ID:dubreuia,项目名称:intellij-plugin-save-actions,代码行数:24,代码来源:FileMaskPanel.java

示例5: configure

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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));
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:41,代码来源:ProjectModule.java

示例6: actionPerformed

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AssignWeightAction.java

示例7: selectFolderDir

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:OverrideResourceAction.java

示例8: InputHostDialog

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
public InputHostDialog(Component parentComponent,
                       String message,
                       String title,
                       Icon icon,
                       String initialValue,
                       InputValidator validator) {
  super(parentComponent, message, title, icon, initialValue, validator);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:PluginHostsConfigurable.java

示例9: actionPerformed

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:chrimm,项目名称:cordovastudio,代码行数:37,代码来源:AssignWeightAction.java

示例10: setValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Override
public Builder setValidator(InputValidator validator) {
    myDialog.myInputValidator = validator;
    return this;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:6,代码来源:CustomCreateFileFromTemplateDialog.java

示例11: InputHostDialog

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
public InputHostDialog(Component parent, String message, String title, Icon icon, String initialValue, InputValidator validator) {
  super(parent, message, title, icon, initialValue, validator);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:PluginHostsConfigurable.java

示例12: setValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Override
public Builder setValidator(InputValidator validator) {
  myDialog.myInputValidator = validator;
  return this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:CreateFileFromTemplateDialog.java

示例13: createValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Nullable
protected InputValidator createValidator(@NotNull String subdirName) {
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:CreateResourceFileDialog.java

示例14: getValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
public InputValidator getValidator() {
  return myValidator;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CreateResourceFileDialog.java

示例15: createValidator

import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
protected InputValidator createValidator(Project project, PsiDirectory directory) {
  return new MyValidator(project, directory);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CreateTypedResourceFileAction.java


注:本文中的com.intellij.openapi.ui.InputValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。