private static final long serialVersionUID = -7782013424757219975L;
public void buttonClick(ClickEvent event) {
String val = (String) field.getValue();
currentPage.user.setPhoneNumber(val);
DAOFactory df = DAOFactory.getInstance();
try {
df.getUserDAO().updateUser(user);
} catch (UserNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
me.getApplication().getMainWindow().removeWindow(editWindow);
me.getApplication().getMainWindow().setContent(new UserPageUI(user));
}
});
editWindow.addComponent(saveButton);
me.getApplication().getMainWindow().addWindow(editWindow);
}
});
userPanel.addComponent(phoneLayout);
HorizontalLayout emailLayout = new HorizontalLayout();
emailLayout.addComponent(preEmailLabel);
emailLayout.setSpacing(true);
emailLayout.addComponent(emailLabel);
emailLayout.addComponent(emailEditButton);
emailEditButton.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -2533599378971644874L;
public void buttonClick(ClickEvent event) {
final Window editWindow = new Window("Edit");
final TextField field = new TextField((String)preEmailLabel.getValue());
field.setValue(emailLabel.getValue());
editWindow.addComponent(field);
Button saveButton = new Button("save");
editWindow.setImmediate(true);
saveButton.setImmediate(true);
saveButton.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = 5200647238632086761L;
public void buttonClick(ClickEvent event) {
String val = (String) field.getValue();
currentPage.user.setEmail(val);
DAOFactory df = DAOFactory.getInstance();
try {
df.getUserDAO().updateUser(user);
} catch (UserNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
me.getApplication().getMainWindow().removeWindow(editWindow);
me.getApplication().getMainWindow().setContent(new UserPageUI(user));
}
});
editWindow.addComponent(saveButton);
me.getApplication().getMainWindow().addWindow(editWindow);
}
});
userPanel.addComponent(emailLayout);
passwordButton.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -3646155806867417299L;
public void buttonClick(ClickEvent event) {
final Window editWindow = new Window("Edit");
final PasswordField oldField = new PasswordField("Old Password");
final PasswordField newField = new PasswordField("New Password");
editWindow.addComponent(oldField);
editWindow.addComponent(newField);
Button saveButton = new Button("save");
editWindow.setImmediate(true);
saveButton.setImmediate(true);
saveButton.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -4933483940137908277L;
public void buttonClick(ClickEvent event) {
String val1 = (String) oldField.getValue();
String val2 = (String) newField.getValue();
if (Arrays.equals(Hash.hashString(val1), user.getPassword())) {
currentPage.user.setPassword(Hash.hashString(val2));
} else {
currentPage.me.getApplication().getMainWindow().showNotification("Old password doesn't match");
return;
}
DAOFactory df = DAOFactory.getInstance();
try {
df.getUserDAO().updateUser(user);
} catch (UserNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
me.getApplication().getMainWindow()