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 android by JetBrains.
the class CreateXmlResourceDialog method checkIfResourceAlreadyExists.
@Nullable
public static ValidationInfo checkIfResourceAlreadyExists(@NotNull Project project, @NotNull VirtualFile resourceDir, @NotNull String resourceName, @NotNull ResourceType resourceType, @NotNull List<String> dirNames, @NotNull String fileName) {
if (resourceName.length() == 0 || dirNames.size() == 0 || fileName.length() == 0) {
return null;
}
for (String directoryName : dirNames) {
final VirtualFile resourceSubdir = resourceDir.findChild(directoryName);
if (resourceSubdir == null) {
continue;
}
final VirtualFile resFile = resourceSubdir.findChild(fileName);
if (resFile == null) {
continue;
}
if (resFile.getFileType() != StdFileTypes.XML) {
return new ValidationInfo("File " + FileUtil.toSystemDependentName(resFile.getPath()) + " is not XML file");
}
final Resources resources = AndroidUtils.loadDomElement(project, resFile, Resources.class);
if (resources == null) {
return new ValidationInfo(AndroidBundle.message("not.resource.file.error", FileUtil.toSystemDependentName(resFile.getPath())));
}
for (ResourceElement element : AndroidResourceUtil.getValueResourcesFromElement(resourceType, resources)) {
if (resourceName.equals(element.getName().getValue())) {
return new ValidationInfo("resource '" + resourceName + "' already exists in " + FileUtil.toSystemDependentName(resFile.getPath()));
}
}
}
return null;
}
use of com.intellij.openapi.ui.ValidationInfo in project android by JetBrains.
the class ExtractStyleDialog method doValidate.
@Override
protected ValidationInfo doValidate() {
final String styleName = getStyleName();
if (styleName.length() == 0) {
return new ValidationInfo("specify style name", myStyleNameField);
}
if (!AndroidResourceUtil.isCorrectAndroidResourceName(styleName)) {
return new ValidationInfo("incorrect style name", myStyleNameField);
}
final Module module = getChosenModule();
if (module == null) {
return new ValidationInfo("specify module", myModuleCombo);
}
VirtualFile resourceDir = getResourceDirectory();
if (resourceDir == null) {
return new ValidationInfo("specify a module with resources", myModuleCombo);
}
return CreateXmlResourceDialog.checkIfResourceAlreadyExists(module.getProject(), resourceDir, getStyleName(), ResourceType.STYLE, myDirNames, myFileName);
}
Aggregations