name = addresses[index].getAddr();
}
// Create the edit field, associate the address to the field
// and add it to the screen and collection of fields.
final EditField headerField =
new EditField(HEADER_NAMES[key], name,
TextField.DEFAULT_MAXCHARS, editableStyle);
headerField.setCookie(addresses[index]);
addTextFieldToTableAndScreen(headerField, HEADER_KEYS[key]);
}
} catch (final MessagingException e) {
BlackBerryMailDemo
.errorDialog("Error: could not retrieve message header.");
close();
}
}
// Display the 'Sent' date if it is available
final Date sent = _message.getSentDate();
if (sent != null) {
final EditField sentDate =
new EditField("Sent: ", Util.getDateAsString(sent),
TextField.DEFAULT_MAXCHARS, Field.READONLY
| Field.NON_FOCUSABLE);
// Change the label to "Saved: " if the message hasn't been sent yet
if (_message.getStatus() == Message.Status.TX_COMPOSING) {
sentDate.setLabel("Saved: ");
}
add(sentDate);
}
// Display the 'Received' date if the message was an inbound message
final Date recieved = _message.getSentDate();
if (_message.isInbound() && recieved != null) {
final EditField sentDate =
new EditField("Recieved: ", Util.getDateAsString(recieved),
TextField.DEFAULT_MAXCHARS, Field.READONLY
| Field.NON_FOCUSABLE);
add(sentDate);
}
// If the message was received, retrieve and display who sent the
// message
if (_message.isInbound()) {
try {
final Address from = _message.getFrom();
String name = from.getName();
if (name == null || name.length() == 0) {
name = from.getAddr();
}
final EditField fromField =
new EditField("From: ", name,
TextField.DEFAULT_MAXCHARS, editableStyle);
fromField.setCookie(from);
add(fromField);
} catch (final MessagingException e) {
BlackBerryMailDemo
.errorDialog("Error: could not retrieve message sender.");
close();
}
}
// Display the subject field
String subject = _message.getSubject();
if (subject == null) {
subject = NO_SUBJECT;
}
final EditField subjectField =
new EditField("Subject: ", subject, TextField.DEFAULT_MAXCHARS,
editableStyle);
addTextFieldToTableAndScreen(subjectField, SUBJECT);
}