本文整理汇总了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();
}
示例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;
}
示例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));
}
}
});
}
示例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;
}
};
}
示例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));
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例10: setValidator
import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Override
public Builder setValidator(InputValidator validator) {
myDialog.myInputValidator = validator;
return this;
}
示例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);
}
示例12: setValidator
import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Override
public Builder setValidator(InputValidator validator) {
myDialog.myInputValidator = validator;
return this;
}
示例13: createValidator
import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
@Nullable
protected InputValidator createValidator(@NotNull String subdirName) {
return null;
}
示例14: getValidator
import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
public InputValidator getValidator() {
return myValidator;
}
示例15: createValidator
import com.intellij.openapi.ui.InputValidator; //导入依赖的package包/类
protected InputValidator createValidator(Project project, PsiDirectory directory) {
return new MyValidator(project, directory);
}