editProfileTable.getFlexCellFormatter().setHeight(6, 0, "25px");
editProfileTable.getFlexCellFormatter().setHeight(7, 0, "50px");
editProfileFormPanel.add(editProfileTable);
final UserId userId = Application.get().getUserId();
final TextBox userNameTextBox = new TextBox();
userNameTextBox.setWidth("250px");
userNameTextBox.setEnabled(false);
Label userNameLabel = new Label("User name:");
userNameLabel.setStyleName("label");
editProfileTable.setWidget(2, 0, userNameLabel);
editProfileTable.setWidget(2, 1, userNameTextBox);
if (!userId.isGuest()) {
userNameTextBox.setText(userId.getUserName());
}
final HTML changePasswordHTML = new HTML(
" <b><span style='font-size:100%;text-decoration:underline;'>Click here to change your password</span></b>");
changePasswordHTML.setStyleName("links-blue");
//if else https
// addChangePasswordHTMLClickHandler(changePasswordHTML);
editProfileTable.setWidget(3, 1, changePasswordHTML);
final TextBox userEmailTextBox = new TextBox();
userEmailTextBox.setWidth("250px");
Label emailIdLabel = new Label("Email:");
emailIdLabel.setStyleName("label");
editProfileTable.setWidget(4, 0, emailIdLabel);
editProfileTable.setWidget(4, 1, userEmailTextBox);
Label ontologyNotificationIdLabel = new Label("Notify me of ont. changes:");
ontologyNotificationIdLabel.setStyleName("label");
final ListBox ontologyNotificationListBox = new ListBox(false);
ontologyNotificationListBox.setWidth("250px");
ontologyNotificationListBox.addItem(NotificationInterval.NEVER.getValue());
ontologyNotificationListBox.addItem(NotificationInterval.IMMEDIATELY.getValue());
ontologyNotificationListBox.addItem(NotificationInterval.HOURLY.getValue());
ontologyNotificationListBox.addItem(NotificationInterval.DAILY.getValue());
ontologyNotificationListBox.setSelectedIndex(1);
editProfileTable.setWidget(5, 0, ontologyNotificationIdLabel);
editProfileTable.setWidget(5, 1, ontologyNotificationListBox);
Label commentsNotificationIdLabel = new Label("Notify me of discussions:");
commentsNotificationIdLabel.setStyleName("label");
final ListBox commentsNotificationListBox = new ListBox(false);
commentsNotificationListBox .setWidth("250px");
commentsNotificationListBox.addItem(NotificationInterval.NEVER.getValue());
commentsNotificationListBox.addItem(NotificationInterval.IMMEDIATELY.getValue());
commentsNotificationListBox.addItem(NotificationInterval.HOURLY.getValue());
commentsNotificationListBox.addItem(NotificationInterval.DAILY.getValue());
commentsNotificationListBox.setSelectedIndex(1);
editProfileTable.setWidget(6, 0, commentsNotificationIdLabel );
editProfileTable.setWidget(6, 1, commentsNotificationListBox );
Button okButton = new Button("Ok", new OkButtonListenerAdapter(win, userEmailTextBox, userNameTextBox, commentsNotificationListBox, ontologyNotificationListBox));
Button cancelButton = new Button("Cancel", new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
win.close();
}
});
HorizontalPanel buttonPanel = new HorizontalPanel();
buttonPanel.setSpacing(20);
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
editProfileTable.setWidget(7, 1, buttonPanel);
editProfileTable.getFlexCellFormatter()
.setAlignment(7, 1, HasAlignment.ALIGN_CENTER, HasAlignment.ALIGN_MIDDLE);
FlexTable topEditProfileTable = new FlexTable();
topEditProfileTable.setWidget(0, 0, editProfileFormPanel);
topEditProfileTable.getFlexCellFormatter().setAlignment(0, 0, HasAlignment.ALIGN_CENTER,
HasAlignment.ALIGN_MIDDLE);
Panel panel = new Panel();
panel.setBorder(false);
panel.setPaddings(15);
panel.setCls("loginpanel");
panel.setLayout(new FitLayout());
win.setLayout(new FitLayout());
panel.add(topEditProfileTable, new AnchorLayoutData("-100 30%"));
win.setTitle("Edit Profile");
win.setClosable(true);
win.setWidth(408);
win.setHeight(400);
win.setClosable(true);
win.setPaddings(7);
win.setCloseAction(Window.HIDE);
win.add(panel);
if (!userId.isGuest()) {
win.show();
win.getEl().mask("Retrieving user email...");
AdminServiceManager.getInstance().getUserEmail(userId, new RetrieveUserEmailHandler(win, userEmailTextBox));
NotificationServiceManager.getInstance().getNotificationDelay(userId, new AsyncCallback<Map<NotificationType, NotificationInterval>>() {
public void onSuccess(Map<NotificationType, NotificationInterval> notificationPreferences) {
win.getEl().unmask();
for (NotificationType type : notificationPreferences.keySet()) {
if (type.equals(NotificationType.ONTOLOGY)){
int i = 0;
while (i < ontologyNotificationListBox.getItemCount()){
final String s = ontologyNotificationListBox.getItemText(i);
if (notificationPreferences.get(type).getValue().equals(s)){
ontologyNotificationListBox.setItemSelected(i, true);
}
i ++;
}
}
if (type.equals(NotificationType.COMMENT)){
int i = 0;
while (i < commentsNotificationListBox.getItemCount()){
final String s = commentsNotificationListBox.getItemText(i);
if (notificationPreferences.get(type).getValue().equals(s)){
commentsNotificationListBox.setItemSelected(i, true);
}
i ++;
}
}
}
}
public void onFailure(Throwable caught) {
GWT.log("Error at Getting User Notification Preferences:", caught);
win.getEl().unmask();
MessageBox.alert("failed. Please try again. Message: " + caught.getMessage());
win.close();
}
});
// final FlexTable editProfTable = editProfileTable;
OpenIdServiceManager.getInstance().getUsersOpenId(userId.getUserName(), new GetUsersOpenIdHandler(win, editProfileTable));
} else {
MessageBox.alert("Error at Getting User Name, Please try again");
}
}