Search in sources :

Example 11 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.

the class AzureNewDockerHostStep method validateDockerHostName.

private ValidationInfo validateDockerHostName(boolean shakeOnError) {
    // Docker virtual machine name
    String hostName = dockerHostNameTextField.getText();
    if (hostName == null || hostName.isEmpty() || !AzureDockerValidationUtils.validateDockerHostName(hostName)) {
        ValidationInfo info = AzureDockerUIResources.validateComponent("Missing virtual machine name", rootConfigureContainerPanel, dockerHostNameTextField, dockerHostNameLabel);
        setDialogButtonsState(false);
        if (shakeOnError) {
            model.DialogShaker(info);
        }
        return info;
    }
    newHost.name = hostName;
    newHost.hostVM.name = hostName;
    newHost.certVault.hostName = hostName;
    newHost.hostVM.publicIpName = hostName + "-pip";
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo)

Example 12 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerWizardModel method doValidate.

public ValidationInfo doValidate() {
    ValidationInfo validationInfo = selectDockerHostForm.doValidate();
    if (validationInfo != null) {
        finishedOK = false;
        return validationInfo;
    }
    validationInfo = configureDockerContainerForm.doValidate();
    if (validationInfo != null) {
        finishedOK = false;
        return validationInfo;
    }
    if (!dockerImageDescription.hasNewDockerHost && dockerImageDescription.host.state != DockerHost.DockerHostVMState.RUNNING && !DefaultLoader.getUIHelper().showConfirmation(String.format("The selected Docker host %s state is %s and publishing could fail.\n\n Do you want to continue?", dockerImageDescription.host.name, dockerImageDescription.host.state), "Docker Host Not in Running State", new String[] { "Yes", "No" }, null)) {
        ValidationInfo info = new ValidationInfo("Invalid Docker host selection", selectDockerHostForm.getPreferredFocusedComponent());
        finishedOK = false;
        return info;
    }
    finishedOK = true;
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo)

Example 13 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.

the class AzureNewDockerHostStep method validateDockerSubscription.

private ValidationInfo validateDockerSubscription(boolean shakeOnError) {
    // Subscription
    AzureDockerSubscription currentSubscription = (AzureDockerSubscription) dockerSubscriptionComboBox.getSelectedItem();
    if (currentSubscription == null || currentSubscription.id == null || currentSubscription.id.isEmpty()) {
        ValidationInfo info = AzureDockerUIResources.validateComponent("Subscription not found", rootConfigureContainerPanel, dockerSubscriptionComboBox, null);
        setDialogButtonsState(false);
        if (shakeOnError) {
            model.DialogShaker(info);
        }
        return info;
    }
    newHost.sid = currentSubscription.id;
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo)

Example 14 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.

the class AzureNewDockerHostStep method validateDockerLocation.

private ValidationInfo validateDockerLocation(boolean shakeOnError) {
    // Location/region
    String region = (String) dockerLocationComboBox.getSelectedItem();
    if (preferredLocation == null || region == null || region.isEmpty()) {
        ValidationInfo info = AzureDockerUIResources.validateComponent("Location not found", rootConfigureContainerPanel, dockerLocationComboBox, null);
        setDialogButtonsState(false);
        if (shakeOnError) {
            model.DialogShaker(info);
        }
        return info;
    }
    newHost.hostVM.region = preferredLocation;
    newHost.hostVM.dnsName = String.format("%s.%s.cloudapp.azure.com", newHost.hostVM.name, newHost.hostVM.region);
    newHost.apiUrl = newHost.hostVM.dnsName;
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo)

Example 15 with ValidationInfo

use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.

the class NewCertificateDialog method doValidate.

@Nullable
protected ValidationInfo doValidate() {
    if (txtPwd.getPassword().length == 0) {
        return new ValidationInfo(message("newCertDlgPwNul"), txtPwd);
    } else if (txtConfirmPwd.getPassword().length == 0) {
        return new ValidationInfo(message("newCertDlgPwNul"), txtPwd);
    }
    Pattern pattern = Pattern.compile("^\\S+$");
    Matcher match = pattern.matcher(String.valueOf(txtPwd.getPassword()));
    if (!match.find()) {
        return new ValidationInfo(message("newCertDlgPwNtCor"), txtPwd);
    }
    match = pattern.matcher(String.valueOf(txtConfirmPwd.getPassword()));
    if (!match.find()) {
        return new ValidationInfo(message("newCertDlgPwNtCor"), txtPwd);
    }
    if (!Arrays.equals(txtPwd.getPassword(), txtConfirmPwd.getPassword())) {
        return new ValidationInfo(message("newCerDlgPwNtMsg"));
    }
    if (txtCNName.getText().isEmpty()) {
        return new ValidationInfo(message("newCertDlgCNNull"), txtCNName);
    }
    if (txtCertFile.getText().isEmpty()) {
        return new ValidationInfo(message("newCertDlgCerNul"), txtCertFile);
    }
    if (txtPFXFile.getText().isEmpty()) {
        return new ValidationInfo(message("newCertDlgPFXNull"), txtPFXFile);
    }
    String certFilePath = txtCertFile.getText();
    String pfxFilePath = txtPFXFile.getText();
    if (certFilePath.lastIndexOf(File.separator) == -1 || pfxFilePath.lastIndexOf(File.separator) == -1) {
        return new ValidationInfo(message("newCerDlgInvldPth"));
    }
    if ((!certFilePath.endsWith(".cer")) || (!pfxFilePath.endsWith(".pfx"))) {
        return new ValidationInfo(message("newCerDlgInvdFlExt"));
    }
    String certFolder = certFilePath.substring(0, certFilePath.lastIndexOf(File.separator));
    String pfxFolder = pfxFilePath.substring(0, pfxFilePath.lastIndexOf(File.separator));
    File certFile = new File(certFolder);
    File pfxFile = new File(pfxFolder);
    if (!(certFile.exists() && pfxFile.exists())) {
        return new ValidationInfo(message("newCerDlgInvldPth"));
    }
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ValidationInfo (com.intellij.openapi.ui.ValidationInfo)53 Nullable (org.jetbrains.annotations.Nullable)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 File (java.io.File)7 Module (com.intellij.openapi.module.Module)3 Pattern (java.util.regex.Pattern)3 DocumentEvent (javax.swing.event.DocumentEvent)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 ActionButton (com.intellij.openapi.actionSystem.impl.ActionButton)2 Project (com.intellij.openapi.project.Project)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)2 ResourceRepository (com.android.ide.common.resources.ResourceRepository)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 Configuration (com.android.tools.idea.gradle.structure.dependencies.android.Configuration)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)1 PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)1 PsBuildType (com.android.tools.idea.gradle.structure.model.android.PsBuildType)1 PsLibraryAndroidDependency (com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency)1 FilterData (com.android.tools.idea.logcat.PersistentAndroidLogFilters.FilterData)1