}
private void composeProfile() {
// compose profile tab
sectionGeneral = new StyledFlowPanel("section");
buttonEditG = new TooltipPushButton(new Image(OswClient.getInstance()
.getPreference("theme_folder")
+ "assets/i-edit.png"), uiText.EditProfile());
buttonEditG.addStyleName("sectionedit");
StyledLabel titleG = new StyledLabel("grouplabel", uiText.General());
sectionGeneral.add(buttonEditG);
sectionGeneral.add(titleG);
this.profile.add(sectionGeneral);
// Editor version of general information
generalEdit = new FlexTable();
generalEdit.addStyleName("edit");
final AvatarUploadField avatarF = new AvatarUploadField();
addWidgetRow(generalEdit, uiText.Avatar(), avatarF);
avatarD.setMaxSize(80, 80);
final StyledTextBox displaynameF = new StyledTextBox("", "", "250px");
addWidgetRow(generalEdit, uiText.DisplayName(), displaynameF);
final NameEditField nameF = new NameEditField();
addWidgetRow(generalEdit, uiText.FullName(), nameF);
final DateField birthdayF = new DateField();
addWidgetRow(generalEdit, uiText.Birthday(), birthdayF);
addWidgetRow(generalEdit, uiText.Gender(), genderF);
final StyledTextBox bioF = new StyledTextBox("", "", "250px");
addWidgetRow(generalEdit, uiText.Bio(), bioF);
final StyledTextBox emailF = new StyledTextBox("", "", "250px");
addWidgetRow(generalEdit, uiText.Email(), emailF);
final StyledTextBox telF = new StyledTextBox("", "", "250px");
addWidgetRow(generalEdit, uiText.Telephone(), telF);
final StyledTextBox urlF = new StyledTextBox("", "", "250px");
addWidgetRow(generalEdit, uiText.Website(), urlF);
// Text only version of general information
general = new FlexTable();
sectionGeneral.add(general);
// make sure the model is not empty when there is no profile available
if (model != null) {
if (model.hasField(PhotoField.NAME)) {
String avatar = model.getPhotoUri();
// the field
avatarF.setAvatar(avatar);
// for display
avatarD.setUrl(avatar);
if (avatar != null && avatar.length() > 0)
addWidgetRow(general, uiText.Avatar(), avatarD);
}
if (model.hasField(FullNameField.NAME)) {
String displayname = model.getFullName();
displaynameF.setText(displayname);
if (displayname != null && displayname.length() > 0)
addHTMLLabelRow(general, uiText.DisplayName(), displayname);
}
if (model.hasField(NameField.NAME)) {
// the full string
String name = model.getName();
// get the separate pieces for editing
DefaultNameField nameField = new DefaultNameField();
nameField = (DefaultNameField) model.getField(NameField.NAME);
nameF.setName(nameField.getGiven(), nameField.getSurname());
if (name != null && name.length() > 0)
addHTMLLabelRow(general, uiText.FullName(), name);
}
if (model.hasField(BirthdayField.NAME)) {
Date birthday = model.getBirthday();
if (birthday != null) {
DateTimeFormat dtf = DateTimeFormat.getFormat("d MMMM yyyy");
String bday = dtf.format(birthday);
birthdayF.setDate(birthday);
if (birthday != null ) addHTMLLabelRow(general, uiText.Birthday(), bday);
}
}
if (model.hasField(GenderField.NAME)) {
GenderField.Type gender = model.getGender();
// get the gender value
DefaultGenderField genderField = new DefaultGenderField();
genderField = (DefaultGenderField) model.getField(GenderField.NAME);
genderF.setGender(gender);
if (gender != null)
addHTMLLabelRow(general, uiText.Gender(), genderF.getGenderText());
}
if (model.hasField(NoteField.NAME)) {
String bio = model.getNote();
bioF.setText(bio);
if (bio != null && bio.length() > 0)
addHTMLLabelRow(general, uiText.Bio(), model.getField("note")
.getValue());
}
if (model.hasField(EmailField.NAME)) {
String email = model.getEmail();
emailF.setText(email);
if (email != null && email.length() > 0)
addHTMLLabelRow(general, uiText.Email(), email);
}
if (model.hasField(TelField.NAME)) {
String tel = model.getTel();
telF.setText(tel);
if (tel != null && tel.length() > 0)
addHTMLLabelRow(general, uiText.Telephone(), tel);
}
if (model.hasField(URLField.NAME)) {
String url = model.getUrl();
urlF.setText(url);
if (url != null && url.length() > 0)
addHTMLLabelRow(general, uiText.Website(), url);
}
// if there are no fields
if (model.getFields().size() == 0) {
showEditProfile();
}
}
StyledFlowPanel confirmG = new StyledFlowPanel("confirm");
Button buttonSaveG = new Button(uiText.Save());
Button buttonCancelG = new Button(uiText.Cancel());
confirmG.add(buttonSaveG);
confirmG.add(buttonCancelG);
addWidgetRow(generalEdit, "", confirmG);
// handlers
buttonEditG.addClickHandler(new ClickHandler() {