Example usage for com.intellij.openapi.ui ValidationInfo ValidationInfo

List of usage examples for com.intellij.openapi.ui ValidationInfo ValidationInfo

Introduction

In this page you can find the example usage for com.intellij.openapi.ui ValidationInfo ValidationInfo.

Prototype

public ValidationInfo(@NotNull String message, @Nullable JComponent component) 

Source Link

Document

Creates a validation error message associated with a specific component.

Usage

From source file:com.aijia.plugin.gradle.GradleRunTaskDialog.java

License:Apache License

@Nullable
@Override//from   w ww  .java  2s  .  co  m
protected ValidationInfo doValidate() {
    if (myProjectPathField.getText().trim().isEmpty()) {
        return new ValidationInfo("Working directory is empty", myProjectPathField);
    }

    return null;
}

From source file:com.android.tools.idea.actions.CreateFileFromTemplateDialog.java

License:Apache License

@Nullable
@Override//from   ww w .  j  av a 2s  .c  o m
protected ValidationInfo doValidate() {
    if (myInputValidator != null) {
        String nameText = myNameField.getText();
        String superclassAsString = mySuperclassField.getText();
        String packageText = myPackageField.getText();
        if (!myInputValidator.checkInput(nameText)) {
            String errorText = LangBundle.message("incorrect.name");
            String message = myInputValidator.getErrorText(nameText);
            if (message != null) {
                errorText = message;
            }

            return new ValidationInfo(errorText, myNameField);
        }

        if (!superclassAsString.isEmpty()) {
            Type superclassAsType = Type.newType(superclassAsString, myProject);
            if (mySuperclassField.isVisible() && (!superclassAsType.canUseAsClass()
                    || !myInputValidator.checkSuperclass(superclassAsString))) {
                return new ValidationInfo(myInputValidator.getSuperclassErrorText(superclassAsString),
                        mySuperclassField);
            }
        }

        for (String interfaceAsString : Splitter.on(',').trimResults().omitEmptyStrings()
                .split(getInterfaces())) {
            Type interfaceAsType = Type.newType(interfaceAsString, myProject);
            if (!interfaceAsType.canUseAsInterface() || !myInputValidator.checkInterface(interfaceAsString)) {
                return new ValidationInfo(myInputValidator.getInterfacesErrorText(interfaceAsString),
                        myInterfacesField);
            }
        }

        if (!myInputValidator.checkPackage(packageText)) {
            return new ValidationInfo(myInputValidator.getPackageErrorText(packageText), myPackageField);
        }
    }
    return super.doValidate();
}

From source file:com.android.tools.idea.ddms.hprof.ConvertHprofDialog.java

License:Apache License

@Nullable
@Override/* w w w . ja v a 2s .c om*/
protected ValidationInfo doValidate() {
    String path = myPathTextFieldWithButton.getText().trim();
    JTextField textField = myPathTextFieldWithButton.getTextField();

    if (path.isEmpty()) {
        return new ValidationInfo("Destination should not be empty", textField);
    }

    File f = new File(path);
    if (!f.isAbsolute()) {
        return new ValidationInfo("Destination path must be absolute.", textField);
    }

    if (f.getParentFile() == null || !f.getParentFile().isDirectory()) {
        return new ValidationInfo("Invalid path", textField);
    }

    return null;
}

From source file:com.android.tools.idea.ddms.screenrecord.ScreenRecorderOptionsDialog.java

License:Apache License

@Nullable
private static ValidationInfo validateIntegerMultipleOf(JTextField textField, int multiple,
        String errorMessage) {/*from  ww w  .j  a va  2  s  .c  o  m*/
    String s = getText(textField);
    if (s.isEmpty()) {
        return null;
    }

    int x;
    try {
        x = Integer.parseInt(s);
    } catch (NumberFormatException e) {
        return new ValidationInfo(errorMessage, textField);
    }

    return (x % multiple > 0) ? new ValidationInfo("Must be a multiple of " + multiple, textField) : null;
}

From source file:com.android.tools.idea.editors.strings.NewStringKeyDialog.java

License:Apache License

@Nullable
@Override// w w w  . ja  v a2s  .c o  m
protected ValidationInfo doValidate() {
    if (myKeyField.getText().isEmpty()) {
        return new ValidationInfo("Key cannot be empty", myKeyField);
    }

    String key = myKeyField.getText().trim();
    String error = myResourceNameValidator.getErrorText(key);
    if (error != null) {
        return new ValidationInfo(error, myKeyField);
    }

    if (myDefaultValueField.getText().isEmpty()) {
        return new ValidationInfo("Default Value cannot be empty", myDefaultValueField);
    }

    return null;
}

From source file:com.android.tools.idea.editors.theme.NewStyleDialog.java

License:Apache License

@Nullable
@Override//from   w  w  w  .  j a  v  a  2  s  .co m
protected ValidationInfo doValidate() {
    String newStyleName = myStyleNameTextField.getText();
    if (Strings.isNullOrEmpty(newStyleName)) {
        return new ValidationInfo(myEmptyStyleValidationText, myStyleNameTextField);
    }

    if (!myResourceNameValidator.checkInput(newStyleName)) {
        // If checkInput is false, getErrorText will be not null.
        //noinspection ConstantConditions
        return new ValidationInfo(myResourceNameValidator.getErrorText(newStyleName), myStyleNameTextField);
    }

    return super.doValidate();
}

From source file:com.android.tools.idea.fd.actions.InstantRunFeedbackDialog.java

License:Apache License

@Nullable
@Override//from w w  w.j a  va2 s . co m
protected ValidationInfo doValidate() {
    String issueReport = getIssueReport();
    if (issueReport.isEmpty()) {
        return new ValidationInfo("Please describe the issue", myIssueTextArea);
    }
    return super.doValidate();
}

From source file:com.android.tools.idea.gradle.actions.LinkExternalCppProjectDialog.java

License:Apache License

@Nullable
@Override//from  w  w w.  j a v a2 s .com
protected ValidationInfo doValidate() {
    String projectPath = toSystemIndependentName(myProjectPathTextField.getText().trim());
    if (Strings.isNullOrEmpty(projectPath)) {
        getOKAction().setEnabled(false);
        setProjectPathResultLabelVisible(false);
        return null;
    }

    String errorMessage = validateProjectFilePath(new File(projectPath));
    if (errorMessage != null) {
        setProjectPathResultLabelVisible(false);
        return new ValidationInfo(errorMessage, myProjectPathTextField.getTextField());
    }
    String relativePath = getPathRelativeToModuleDir(myModule, projectPath);
    assert relativePath != null;

    myProjectPathResultLabel.setText(
            "<html>Path to be saved into the build.gradle file:<br><b>\"" + relativePath + "\"</b></html>");

    getOKAction().setEnabled(true);
    setProjectPathResultLabelVisible(true);

    return null;
}

From source file:com.android.tools.idea.gradle.project.ChooseGradleHomeDialog.java

License:Apache License

@NotNull
private ValidationInfo newPathIsInvalidInfo(@NotNull String msg) {
    storeErrorMessage(msg);
    return new ValidationInfo(msg, myGradleHomePathField.getTextField());
}

From source file:com.android.tools.idea.gradle.project.subset.ModulesToImportDialog.java

License:Apache License

@Override
@Nullable/*from   w  w w  . j av  a2  s. c  o  m*/
protected ValidationInfo doValidate() {
    int selectionCount = getModulesTable().getModel().selectedRowCount;
    if (selectionCount <= 0) {
        return new ValidationInfo("Please select at least one Module", myModulesTable);
    }
    if (myMaxSelectionCount > 0 && selectionCount > myMaxSelectionCount) {
        String message = "Please select only " + myMaxSelectionCount + " module";
        if (myMaxSelectionCount > 1) {
            message += "s";
        }
        message += ".";
        return new ValidationInfo(message, myModulesTable);
    }
    return null;
}