IDEMPIERE-724 Zk: Make iDempiere theme more easily customizable. Refactoring to allow theme to change the appearance of ChangePasswordPanel and ResetPasswordPanel.

This commit is contained in:
Heng Sin Low 2013-05-02 17:31:27 +08:00
parent 329d7afaef
commit 04e5c02920
2 changed files with 50 additions and 40 deletions

View File

@ -61,28 +61,28 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
private static CLogger logger = CLogger.getCLogger(ChangePasswordPanel.class); private static CLogger logger = CLogger.getCLogger(ChangePasswordPanel.class);
private LoginWindow wndLogin; protected LoginWindow wndLogin;
/** Context */ /** Context */
private Properties m_ctx; protected Properties m_ctx;
/** Username */ /** Username */
private String m_userName; protected String m_userName;
/** Password */ /** Password */
private String m_userPassword; protected String m_userPassword;
private KeyNamePair[] m_clientKNPairs; protected KeyNamePair[] m_clientKNPairs;
private boolean m_show = true; protected boolean m_show = true;
private Label lblOldPassword; protected Label lblOldPassword;
private Label lblNewPassword; protected Label lblNewPassword;
private Label lblRetypeNewPassword; protected Label lblRetypeNewPassword;
private Label lblSecurityQuestion; protected Label lblSecurityQuestion;
private Label lblAnswer; protected Label lblAnswer;
private Combobox lstSecurityQuestion; protected Combobox lstSecurityQuestion;
private Textbox txtOldPassword; protected Textbox txtOldPassword;
private Textbox txtNewPassword; protected Textbox txtNewPassword;
private Textbox txtRetypeNewPassword; protected Textbox txtRetypeNewPassword;
private Textbox txtAnswer; protected Textbox txtAnswer;
public ChangePasswordPanel(Properties ctx, LoginWindow loginWindow, String userName, String userPassword, boolean show, KeyNamePair[] clientsKNPairs) public ChangePasswordPanel(Properties ctx, LoginWindow loginWindow, String userName, String userPassword, boolean show, KeyNamePair[] clientsKNPairs)
{ {
@ -96,11 +96,16 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
initComponents(); initComponents();
init(); init();
this.setId("changePasswordPanel"); this.setId("changePasswordPanel");
this.setSclass("login-box");
} }
private void init() private void init()
{ {
Div div = new Div(); createUI();
}
protected void createUI() {
Div div = new Div();
div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS); div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS);
Label label = new Label(Msg.getMsg(m_ctx, "ChangePassword")); Label label = new Label(Msg.getMsg(m_ctx, "ChangePassword"));
label.setSclass(ITheme.LOGIN_BOX_HEADER_TXT_CLASS); label.setSclass(ITheme.LOGIN_BOX_HEADER_TXT_CLASS);
@ -195,7 +200,7 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
pnlButtons.getButton(ConfirmPanel.A_CANCEL).setSclass(ITheme.LOGIN_BUTTON_CLASS); pnlButtons.getButton(ConfirmPanel.A_CANCEL).setSclass(ITheme.LOGIN_BUTTON_CLASS);
div.appendChild(pnlButtons); div.appendChild(pnlButtons);
this.appendChild(div); this.appendChild(div);
} }
private void initComponents() private void initComponents()
{ {

View File

@ -69,32 +69,32 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
private static CLogger logger = CLogger.getCLogger(ResetPasswordPanel.class); private static CLogger logger = CLogger.getCLogger(ResetPasswordPanel.class);
private static final int MAX_RESET_PASSWORD_TRIES = 3; protected static final int MAX_RESET_PASSWORD_TRIES = 3;
protected static final int NO_OF_SECURITY_QUESTION = 5; protected static final int NO_OF_SECURITY_QUESTION = 5;
protected static final String SECURITY_QUESTION_PREFIX = "SecurityQuestion_"; protected static final String SECURITY_QUESTION_PREFIX = "SecurityQuestion_";
private static final String RESET_PASSWORD_MAIL_TEXT_NAME = "Reset Password"; protected static final String RESET_PASSWORD_MAIL_TEXT_NAME = "Reset Password";
private LoginWindow wndLogin; protected LoginWindow wndLogin;
/** Context */ /** Context */
private Properties m_ctx; protected Properties m_ctx;
/** Username */ /** Username */
private String m_userName; protected String m_userName;
/** No Security Question */ /** No Security Question */
private boolean m_noSecurityQuestion; protected boolean m_noSecurityQuestion;
/** Tries Counter */ /** Tries Counter */
private int counter; protected int counter;
/** EMail Login preference */ /** EMail Login preference */
boolean m_email_login = false; protected boolean m_email_login = false;
private Label lblSecurityQuestion; protected Label lblSecurityQuestion;
private Label lblAnswer; protected Label lblAnswer;
private Label lblUserId; protected Label lblUserId;
private Label lblEmail; protected Label lblEmail;
private Textbox txtSecurityQuestion; protected Textbox txtSecurityQuestion;
private Textbox txtAnswer; protected Textbox txtAnswer;
private Textbox txtUserId; protected Textbox txtUserId;
private Textbox txtEmail; protected Textbox txtEmail;
public ResetPasswordPanel(Properties ctx, LoginWindow loginWindow, String userName, boolean noSecurityQuestion) public ResetPasswordPanel(Properties ctx, LoginWindow loginWindow, String userName, boolean noSecurityQuestion)
{ {
@ -107,13 +107,18 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
initComponents(); initComponents();
init(); init();
this.setId("resetPasswordPanel"); this.setId("resetPasswordPanel");
this.setSclass("login-box");
loadData(); loadData();
} }
private void init() private void init()
{ {
Div div = new Div(); createUI();
}
protected void createUI() {
Div div = new Div();
div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS); div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS);
Label label = new Label(Msg.getMsg(m_ctx, "ForgotMyPassword")); Label label = new Label(Msg.getMsg(m_ctx, "ForgotMyPassword"));
label.setSclass(ITheme.LOGIN_BOX_HEADER_TXT_CLASS); label.setSclass(ITheme.LOGIN_BOX_HEADER_TXT_CLASS);
@ -207,7 +212,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
pnlButtons.getButton(ConfirmPanel.A_CANCEL).setSclass(ITheme.LOGIN_BUTTON_CLASS); pnlButtons.getButton(ConfirmPanel.A_CANCEL).setSclass(ITheme.LOGIN_BUTTON_CLASS);
div.appendChild(pnlButtons); div.appendChild(pnlButtons);
this.appendChild(div); this.appendChild(div);
} }
private void initComponents() private void initComponents()
{ {
@ -270,7 +275,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
} }
} }
private void loadSecurityQuestion() protected void loadSecurityQuestion()
{ {
String email = txtEmail.getValue(); String email = txtEmail.getValue();
String userid = txtUserId.getValue(); String userid = txtUserId.getValue();
@ -321,7 +326,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
} }
} }
private void validateEmail() protected void validateEmail()
{ {
String email = txtEmail.getValue(); String email = txtEmail.getValue();
String userid = txtUserId.getValue(); String userid = txtUserId.getValue();
@ -351,7 +356,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
loadSecurityQuestion(); loadSecurityQuestion();
} }
private void validateResetPassword() protected void validateResetPassword()
{ {
String email = txtEmail.getValue(); String email = txtEmail.getValue();
String userid = txtUserId.getValue(); String userid = txtUserId.getValue();
@ -485,7 +490,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
} }
} }
private boolean sendEmail(MUser to, String newPassword) protected boolean sendEmail(MUser to, String newPassword)
{ {
MClient client = MClient.get(m_ctx, to.getAD_Client_ID()); MClient client = MClient.get(m_ctx, to.getAD_Client_ID());