use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.
the class AzureDockerUIResources method validateComponent.
public static ValidationInfo validateComponent(String msgErr, JPanel panel, JComponent component, JComponent componentLabel) {
panel.requestFocus();
component.requestFocus();
if (componentLabel != null) {
componentLabel.setVisible(true);
}
panel.repaint();
ValidationInfo info = new ValidationInfo(msgErr, component);
return info;
}
use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.
the class AzureDockerHostUpdateLoginPanel method doValidate.
public ValidationInfo doValidate(boolean shakeOnError) {
// User name
String vmUsername = dockerHostUsernameTextField.getText();
if (vmUsername == null || vmUsername.isEmpty() || (dockerHostSecondPwdField.isVisible() && !AzureDockerValidationUtils.validateDockerHostUserName(vmUsername))) {
ValidationInfo info = AzureDockerUIResources.validateComponent("Missing username", mainPanel, dockerHostUsernameTextField, dockerHostUsernameLabel);
if (shakeOnError) {
DialogShaker(info);
}
return info;
}
editableHost.updatedDockerHost.certVault.vmUsername = vmUsername;
// Password login
String vmPwd1 = new String(dockerHostFirstPwdField.getPassword());
String vmPwd2 = new String(dockerHostSecondPwdField.getPassword());
if (((dockerHostKeepSshRadioButton.isSelected() && editableHost.originalDockerHost.hasSSHLogIn) || dockerHostFirstPwdField.getPassword().length > 0 || dockerHostSecondPwdField.getPassword().length > 0) && (vmPwd1.isEmpty() || vmPwd2.isEmpty() || !vmPwd1.equals(vmPwd2) || (dockerHostSecondPwdField.isVisible() && !AzureDockerValidationUtils.validateDockerHostPassword(vmPwd1)))) {
ValidationInfo info = AzureDockerUIResources.validateComponent("Incorrect password", mainPanel, dockerHostFirstPwdField, dockerHostFirstPwdLabel);
if (shakeOnError) {
DialogShaker(info);
}
return info;
}
if (dockerHostFirstPwdField.getPassword().length > 0) {
editableHost.updatedDockerHost.certVault.vmPwd = new String(dockerHostFirstPwdField.getPassword());
editableHost.updatedDockerHost.hasPwdLogIn = true;
} else {
editableHost.updatedDockerHost.certVault.vmPwd = null;
editableHost.updatedDockerHost.hasPwdLogIn = false;
}
// Keep current SSH keys
if (dockerHostKeepSshRadioButton.isSelected() && editableHost.originalDockerHost.hasSSHLogIn) {
AzureDockerCertVaultOps.copyVaultSshKeys(editableHost.updatedDockerHost.certVault, editableHost.originalDockerHost.certVault);
editableHost.updatedDockerHost.hasSSHLogIn = editableHost.originalDockerHost.hasSSHLogIn;
}
// SSH key auto generated
if (dockerHostAutoSshRadioButton.isSelected()) {
AzureDockerCertVault certVault = AzureDockerCertVaultOps.generateSSHKeys(null, "SSH keys for " + editableHost.updatedDockerHost.name);
AzureDockerCertVaultOps.copyVaultSshKeys(editableHost.updatedDockerHost.certVault, certVault);
editableHost.updatedDockerHost.hasSSHLogIn = true;
}
// SSH key imported from local file directory
if (dockerHostImportSshRadioButton.isSelected()) {
if (dockerHostImportSSHBrowseTextField.getText() == null || dockerHostImportSSHBrowseTextField.getText().isEmpty() || !AzureDockerValidationUtils.validateDockerHostSshDirectory(dockerHostImportSSHBrowseTextField.getText())) {
ValidationInfo info = AzureDockerUIResources.validateComponent("SSH key files were not found in the selected directory", mainPanel, dockerHostImportSSHBrowseTextField, dockerHostImportSSHBrowseLabel);
if (shakeOnError) {
DialogShaker(info);
}
return info;
} else {
AzureDockerCertVault certVault = AzureDockerCertVaultOps.getSSHKeysFromLocalFile(dockerHostImportSSHBrowseTextField.getText());
AzureDockerCertVaultOps.copyVaultSshKeys(editableHost.updatedDockerHost.certVault, certVault);
editableHost.updatedDockerHost.hasSSHLogIn = true;
}
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
int selectedRow = table.getSelectedRow();
if (selectedRow < 0) {
return new ValidationInfo("Please select an App Service to deploy to", table);
}
DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
WebAppDetails wad = webAppWebAppDetailsMap.get(tableModel.getValueAt(selectedRow, 0));
if (wad.webApp.javaVersion() == JavaVersion.OFF) {
return new ValidationInfo("Please select java based App Service", table);
}
return super.doValidate();
}
use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.
the class AppServiceChangeSettingsDialog method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
model.collectData();
ValidationInfo res = validateJdkTab();
if (res != null)
return res;
return super.superDoValidate();
}
use of com.intellij.openapi.ui.ValidationInfo in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
model.collectData();
String webappName = model.webAppName;
if (webappName.length() > 60 || !webappName.matches("^[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]$")) {
StringBuilder builder = new StringBuilder();
builder.append("The name can contain letters, numbers and hyphens but the first and last characters must be a letter or number. ");
builder.append("The length can be between 2 and 60 characters. ");
return new ValidationInfo(builder.toString(), textFieldWebappName);
} else {
for (List<WebApp> wal : AzureModel.getInstance().getResourceGroupToWebAppMap().values()) {
for (WebApp wa : wal) {
if (wa.name().toLowerCase().equals(webappName.toLowerCase())) {
return new ValidationInfo("The name is already taken", textFieldWebappName);
}
}
}
}
if (model.subscriptionDetail == null) {
return new ValidationInfo("Select a valid subscription.", comboBoxSubscription);
}
if (model.isAppServicePlanCreateNew) {
if (model.appServicePlanNameCreateNew.isEmpty()) {
return new ValidationInfo("Enter a valid App Service Plan name.", textFieldAppServicePlanName);
} else {
if (!model.appServicePlanNameCreateNew.matches("^[A-Za-z0-9-]*[A-Za-z0-9-]$")) {
return new ValidationInfo("App Service Plan name can only include alphanumeric characters and hyphens.", textFieldAppServicePlanName);
}
// App service plan name must be unuque in each subscription
SubscriptionDetail sd = model.subscriptionDetail;
List<ResourceGroup> rgl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().get(sd);
for (ResourceGroup rg : rgl) {
List<AppServicePlan> aspl = AzureModel.getInstance().getResourceGroupToAppServicePlanMap().get(rg);
for (AppServicePlan asp : aspl) {
if (asp.name().toLowerCase().equals(model.appServicePlanNameCreateNew.toLowerCase())) {
return new ValidationInfo("App service plan name must be unuque in each subscription.", textFieldAppServicePlanName);
}
}
}
}
if (model.appServicePlanLocationCreateNew == null) {
return new ValidationInfo("Select a valid App Service Plan Location.", comboBoxAppServicePlanLocation);
}
if (model.appServicePricingTierCreateNew == null) {
return new ValidationInfo("Select a valid App Service Plan PricingTier.", comboBoxAppServicePlanPricingTier);
}
} else {
if (model.appServicePlan == null) {
return new ValidationInfo("Select a valid App Service Plan.", comboBoxResourceGroup);
}
}
if (model.isResourceGroupCreateNew) {
if (model.resourceGroupNameCreateNew.isEmpty()) {
return new ValidationInfo("Enter a valid resource group name", textFieldResourceGroupName);
} else {
if (!model.resourceGroupNameCreateNew.matches("^[A-Za-z0-9-_()\\.]*[A-Za-z0-9-_()]$")) {
return new ValidationInfo("Resounce group name can only include alphanumeric characters, periods, underscores, hyphens, and parenthesis and can't end in a period.", textFieldResourceGroupName);
}
for (List<ResourceGroup> rgl : AzureModel.getInstance().getSubscriptionToResourceGroupMap().values()) {
for (ResourceGroup rg : rgl) {
if (rg.name().toLowerCase().equals(model.resourceGroupNameCreateNew.toLowerCase())) {
return new ValidationInfo("The name is already taken", textFieldResourceGroupName);
}
}
}
}
} else {
if (model.resourceGroup == null) {
return new ValidationInfo("Select a valid resource group.", comboBoxResourceGroup);
}
}
ValidationInfo res = validateJdkTab();
if (res != null)
return res;
return super.doValidate();
}
Aggregations