applyDialogFont(composite);
return composite;
}
private void doValidation() {
StatusInfo status = new StatusInfo();
String newName = fNameDialogField.getText();
String newPath = fPathDialogField.getText();
if (newPath.length() == 0) {
status.setError("Enter PEAR path.");
}
if (newName.length() == 0 && newPath.length() > 0) {
int lastIndex = WINDOWS ? newPath.lastIndexOf("\\") : newPath.lastIndexOf("/");
if (lastIndex > 0) {
newName = newPath.substring(lastIndex + 1).replace(' ', '_');
fNameDialogField.setText(newName);
}
}
if (newName.length() == 0) {
status.setError("Enter library name.");
} else {
if (!Pattern.matches("^[a-zA-Z0-9_]+$", newName)) {
status.setError("Name can only contain letters, numbers and underscores");
} else if (fExistingNames.contains(newName)) {
status.setError("An entry with the same name already exists");
}
}
updateStatus(status);
}