in plugin/src/com/microsoft/alm/plugin/idea/common/ui/checkout/CheckoutPageModelImpl.java [206:261]
public ModelValidationInfo validate() {
ModelValidationInfo result = super.validate();
if (result == ModelValidationInfo.NO_ERRORS) {
final String parentDirectory = getParentDirectory();
if (parentDirectory == null || parentDirectory.isEmpty()) {
return ModelValidationInfo.createWithResource(PROP_PARENT_DIR,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_PARENT_DIR_EMPTY);
}
final File parentDirectoryOnDisk = new File(parentDirectory);
if (!parentDirectoryOnDisk.exists()) {
return ModelValidationInfo.createWithResource(PROP_PARENT_DIR,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_PARENT_DIR_NOT_FOUND);
}
// We test this method and so we need to check to see if we are in IntelliJ before using VirtualFileManager
// ApplicationManager is null if we are not in IntelliJ
if (ApplicationManager.getApplication() != null) {
final VirtualFile destinationParent = LocalFileSystem.getInstance().findFileByPath(parentDirectory);
if (destinationParent == null) {
return ModelValidationInfo.createWithResource(PROP_PARENT_DIR,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_PARENT_DIR_NOT_FOUND);
}
}
if (getSelectedContext() == null) {
return ModelValidationInfo.createWithResource(PROP_REPO_TABLE,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_REPO_NOT_SELECTED);
}
final String directoryName = getDirectoryName();
if (directoryName == null || directoryName.isEmpty()) {
return ModelValidationInfo.createWithResource(PROP_DIRECTORY_NAME,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_DIR_NAME_EMPTY);
}
final File destDirectoryOnDisk = new File(parentDirectory, directoryName);
//verify the destination directory does not exist
if (destDirectoryOnDisk.exists() && destDirectoryOnDisk.isDirectory()) {
return ModelValidationInfo.createWithResource(PROP_DIRECTORY_NAME,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_DESTINATION_EXISTS, directoryName);
}
//verify destination directory parent exists, we can reach this condition if user specifies a path for directory name
if (destDirectoryOnDisk.getParentFile() == null || !destDirectoryOnDisk.getParentFile().exists()) {
return ModelValidationInfo.createWithResource(PROP_DIRECTORY_NAME,
TfPluginBundle.KEY_CHECKOUT_DIALOG_ERRORS_DIR_NAME_INVALID,
directoryName, destDirectoryOnDisk.getParent());
}
} else {
return result;
}
return ModelValidationInfo.NO_ERRORS;
}