device = null;
fallbackDevice = null;
updateValues();
// Default status is valid.
ValidationStatus status = VALID_STATUS;
String supplementaryArgs[] = {
DevicesMessages.getString(RESOURCE_PREFIX + "newDevice.text")
};
validationMessageBuilder.setSupplementaryFormatArgs(supplementaryArgs);
status = DEVICE_NAME_VALIDATOR.validate(getDevice(),
validationMessageBuilder);
// Ensure the fallback device has been selected.
if ((status.getSeverity() == Status.OK) &&
deviceFallbackTree.getSelectionCount() <= 0) {
String message = DevicesMessages.getString(RESOURCE_PREFIX +
"error.fallbackDeviceIsMandatory");
status = new ValidationStatus(4, message);
}
// If the status is OK then check to see if we have any duplicate names.
if (status.getSeverity() == Status.OK) {
visitor.reset();
walker.visit(root, visitor);
if (visitor.isDuplicate()) {
String message = DevicesMessages.getString(RESOURCE_PREFIX +
"error.duplicateDeviceName");
String args[] = {
getDevice()
};
MessageFormat format = new MessageFormat(message);
message = format.format(args);
status = new ValidationStatus(Status.ERROR, message);
}
}
if (status.getSeverity() == Status.ERROR) {
setErrorMessage(status.getMessage());
} else if (status.getSeverity() == Status.WARNING) {
setErrorMessage(null);
setMessage(status.getMessage());
} else {
setErrorMessage(null);
if(context.isAdminProject()) {
setMessage(DevicesMessages.getString(RESOURCE_PREFIX +
"info.admin"));
} else {
setMessage(DevicesMessages.getString(RESOURCE_PREFIX +
"info.custom"));
}
}
valid = status.getSeverity() == Status.OK;
return valid;
}