LoginPanel should display only supported language.
This commit is contained in:
parent
a757a02378
commit
916fef8565
|
@ -24,6 +24,7 @@
|
||||||
package org.adempiere.webui.panel;
|
package org.adempiere.webui.panel;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
@ -85,9 +86,9 @@ import org.zkoss.zul.Image;
|
||||||
* @date July 18, 2007
|
* @date July 18, 2007
|
||||||
*/
|
*/
|
||||||
public class LoginPanel extends Window implements EventListener
|
public class LoginPanel extends Window implements EventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3992171368813030624L;
|
private static final long serialVersionUID = 3992171368813030624L;
|
||||||
private static final String RESOURCE = "org.compiere.apps.ALoginRes";
|
private static final String RESOURCE = "org.compiere.apps.ALoginRes";
|
||||||
|
@ -114,7 +115,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
|
|
||||||
AuFocus auf = new AuFocus(txtUserId);
|
AuFocus auf = new AuFocus(txtUserId);
|
||||||
Clients.response(auf);
|
Clients.response(auf);
|
||||||
|
|
||||||
BrowserToken.load(this.getUuid());
|
BrowserToken.load(this.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +195,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
td.appendChild(chkRememberMe);
|
td.appendChild(chkRememberMe);
|
||||||
}
|
}
|
||||||
|
|
||||||
div = new Div();
|
div = new Div();
|
||||||
div.setSclass(ITheme.LOGIN_BOX_FOOTER_CLASS);
|
div.setSclass(ITheme.LOGIN_BOX_FOOTER_CLASS);
|
||||||
ConfirmPanel pnlButtons = new ConfirmPanel(false);
|
ConfirmPanel pnlButtons = new ConfirmPanel(false);
|
||||||
|
@ -204,13 +205,13 @@ public class LoginPanel extends Window implements EventListener
|
||||||
pnlButtons.getButton(ConfirmPanel.A_OK).setSclass(ITheme.LOGIN_BUTTON_CLASS);
|
pnlButtons.getButton(ConfirmPanel.A_OK).setSclass(ITheme.LOGIN_BUTTON_CLASS);
|
||||||
div.appendChild(pnlButtons);
|
div.appendChild(pnlButtons);
|
||||||
this.appendChild(div);
|
this.appendChild(div);
|
||||||
|
|
||||||
this.addEventListener(TokenEvent.ON_USER_TOKEN, new EventListener() {
|
this.addEventListener(TokenEvent.ON_USER_TOKEN, new EventListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
String[] data = (String[]) event.getData();
|
String[] data = (String[]) event.getData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int AD_Session_ID = Integer.parseInt(data[0]);
|
int AD_Session_ID = Integer.parseInt(data[0]);
|
||||||
MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
|
MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
|
||||||
|
@ -282,8 +283,13 @@ public class LoginPanel extends Window implements EventListener
|
||||||
// Update Language List
|
// Update Language List
|
||||||
lstLanguage.getItems().clear();
|
lstLanguage.getItems().clear();
|
||||||
String[] availableLanguages = Language.getNames();
|
String[] availableLanguages = Language.getNames();
|
||||||
|
ArrayList<String> supported = Env.getSupportedLanguages();
|
||||||
for (String langName : availableLanguages) {
|
for (String langName : availableLanguages) {
|
||||||
Language language = Language.getLanguage(langName);
|
Language language = Language.getLanguage(langName);
|
||||||
|
if (!language.isBaseLanguage()) {
|
||||||
|
if (!supported.contains(language.getAD_Language()))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
lstLanguage.appendItem(langName, language.getAD_Language());
|
lstLanguage.appendItem(langName, language.getAD_Language());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +367,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
Locale loc = language.getLocale();
|
Locale loc = language.getLocale();
|
||||||
Locale.setDefault(loc);
|
Locale.setDefault(loc);
|
||||||
res = ResourceBundle.getBundle(RESOURCE, loc);
|
res = ResourceBundle.getBundle(RESOURCE, loc);
|
||||||
|
|
||||||
lblUserId.setValue(res.getString("User"));
|
lblUserId.setValue(res.getString("User"));
|
||||||
lblPassword.setValue(res.getString("Password"));
|
lblPassword.setValue(res.getString("Password"));
|
||||||
lblLanguage.setValue(res.getString("Language"));
|
lblLanguage.setValue(res.getString("Language"));
|
||||||
|
@ -386,7 +392,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
Login login = new Login(ctx);
|
Login login = new Login(ctx);
|
||||||
String userId = txtUserId.getValue();
|
String userId = txtUserId.getValue();
|
||||||
String userPassword = txtPassword.getValue();
|
String userPassword = txtPassword.getValue();
|
||||||
|
|
||||||
//check is token
|
//check is token
|
||||||
String token = (String) txtPassword.getAttribute("user.token.hash");
|
String token = (String) txtPassword.getAttribute("user.token.hash");
|
||||||
if (token != null && token.equals(userPassword))
|
if (token != null && token.equals(userPassword))
|
||||||
|
@ -403,7 +409,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyNamePair rolesKNPairs[] = login.getRoles(userId, userPassword);
|
KeyNamePair rolesKNPairs[] = login.getRoles(userId, userPassword);
|
||||||
if(rolesKNPairs == null || rolesKNPairs.length == 0)
|
if(rolesKNPairs == null || rolesKNPairs.length == 0)
|
||||||
throw new WrongValueException("User Id or Password invalid!!!");
|
throw new WrongValueException("User Id or Password invalid!!!");
|
||||||
|
@ -435,7 +441,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
||||||
currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
|
currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
|
||||||
// End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?
|
// End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?
|
||||||
|
|
||||||
Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
|
Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
|
||||||
|
|
||||||
/* Check DB version */
|
/* Check DB version */
|
||||||
|
|
Loading…
Reference in New Issue