use of org.compiere.util.Language in project adempiere by adempiere.
the class VCollectDetail method loadCheckPanel.
/**
* Load Check Panel
* @return void
*/
private void loadCheckPanel() {
// Instance Panel
checkPanel = new CPanel(layout);
// For Check No
String m_CheckNo = Msg.translate(ctx, "CheckNo");
fieldCheckNo = new POSTextField(m_CheckNo, keyboard);
fieldCheckNo.setPlaceholder(m_CheckNo);
fieldCheckNo.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
fieldCheckNo.setFont(font);
fieldCheckNo.addKeyListener(this);
fieldCheckNo.addActionListener(this);
// For Check Route No
String m_RoutingNo = Msg.translate(ctx, "RoutingNo");
fieldCheckRoutingNo = new POSTextField(m_RoutingNo, keyboard);
fieldCheckRoutingNo.setPlaceholder(m_RoutingNo);
fieldCheckRoutingNo.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
fieldCheckRoutingNo.setFont(font);
fieldCheckRoutingNo.addKeyListener(this);
fieldCheckRoutingNo.addActionListener(this);
// For Check Date
String languageName = Env.getAD_Language(ctx);
Language language = Language.getLanguage(languageName);
Language.setLoginLanguage(language);
// Locale
Locale locale = language.getLocale();
Locale.setDefault(locale);
fieldCheckDate = new VDate(DisplayType.Date);
fieldCheckDate.setFormat();
fieldCheckDate.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
fieldCheckDate.setFont(font);
fieldCheckDate.addActionListener(this);
// Add To Panel
checkPanel.add(fieldCheckRoutingNo, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
checkPanel.add(fieldCheckNo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
checkPanel.add(fieldCheckDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
// Default visible false
checkPanel.setVisible(false);
}
use of org.compiere.util.Language in project adempiere by adempiere.
the class VTreeBOM method preInit.
// init
/**
* Fill Tree Combo
*/
private void preInit() throws Exception {
Properties ctx = getCtx();
// Base Language
Language language = Language.getLoginLanguage();
MLookup m_fieldProduct = MLookupFactory.get(ctx, m_WindowNo, MColumn.getColumn_ID(MProduct.Table_Name, "M_Product_ID"), DisplayType.Search, language, MProduct.COLUMNNAME_M_Product_ID, 0, false, " M_Product.IsSummary = 'N'");
fieldProduct = new VLookup("M_Product_ID", false, false, true, m_fieldProduct) {
private static final long serialVersionUID = 1L;
public void setValue(Object value) {
super.setValue(value);
action_loadBOM();
}
};
implosion.addActionListener(this);
splitPane.add(dataPane, JSplitPane.RIGHT);
splitPane.add(treePane, JSplitPane.LEFT);
}
use of org.compiere.util.Language in project adempiere by adempiere.
the class HRPayPrint method loadPaymentRule.
// loadPaySelectInfo
/**
* Bank changed - load PaymentRule
*/
public ArrayList<ValueNamePair> loadPaymentRule(int C_PaySelection_ID) {
ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
// load PaymentRule for Bank
// MLookupInfo.getAD_Reference_ID("All_Payment Rule");
int AD_Reference_ID = 195;
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY")) + " AND " + info.KeyColumn + " IN (SELECT PaymentRule FROM HR_PaySelectionCheck WHERE HR_PaySelection_ID=?) " + info.Query.substring(info.Query.indexOf(" ORDER BY"));
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
//
while (rs.next()) {
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
data.add(pp);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
if (data.size() == 0)
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
return data;
}
use of org.compiere.util.Language in project adempiere by adempiere.
the class LoginPanel method validateLogin.
/**
* validates user name and password when logging in
*
**/
public void validateLogin() {
Login login = new Login(ctx);
String userId = txtUserId.getValue();
String userPassword = txtPassword.getValue();
//check is token
String token = (String) txtPassword.getAttribute("user.token.hash");
if (token != null && token.equals(userPassword)) {
userPassword = "";
int AD_Session_ID = (Integer) txtPassword.getAttribute("user.token.sid");
MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
if (session.get_ID() == AD_Session_ID) {
MUser user = MUser.get(Env.getCtx(), session.getCreatedBy());
if (BrowserToken.validateToken(session, user, token)) {
userPassword = user.getPassword();
}
}
}
KeyNamePair[] rolesKNPairs = login.getRoles(userId, userPassword);
if (rolesKNPairs == null || rolesKNPairs.length == 0)
throw new WrongValueException("User Id or Password invalid!!!");
else {
String langName = null;
if (lstLanguage.getSelectedItem() != null)
langName = (String) lstLanguage.getSelectedItem().getLabel();
else
langName = Language.getBaseLanguage().getName();
Language language = findLanguage(langName);
wndLogin.loginOk(userId, userPassword);
// Elaine 2009/02/06
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName());
Locales.setThreadLocal(language.getLocale());
String timeoutText = getUpdateTimeoutTextScript();
if (!Strings.isEmpty(timeoutText))
Clients.response("zkLocaleJavaScript2", new AuScript(null, timeoutText));
}
// This temporary validation code is added to check the reported bug
// [ adempiere-ZK Web Client-2832968 ] User context lost?
// https://sourceforge.net/tracker/?func=detail&atid=955896&aid=2832968&group_id=176962
// it's harmless, if there is no bug then this must never fail
Session currSess = Executions.getCurrent().getDesktop().getSession();
currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
// End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?
Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
/* Check DB version */
String version = DB.getSQLValueString(null, "SELECT Version FROM AD_System");
// Identical DB version
if (!Adempiere.DB_VERSION.equals(version)) {
String AD_Message = "DatabaseVersionError";
// Code assumes Database version {0}, but Database has Version {1}.
// complete message
String msg = Msg.getMsg(ctx, AD_Message);
msg = MessageFormat.format(msg, new Object[] { Adempiere.DB_VERSION, version });
throw new ApplicationException(msg);
}
}
use of org.compiere.util.Language in project adempiere by adempiere.
the class RolePanel method initComponents.
@SuppressWarnings("unchecked")
private void initComponents() {
Language language = Env.getLanguage(m_ctx);
ResourceBundle res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
lblRole = new Label();
lblRole.setId("lblRole");
lblRole.setValue(res.getString("Role"));
lblClient = new Label();
lblClient.setId("lblClient");
lblClient.setValue(res.getString("Client"));
lblOrganisation = new Label();
lblOrganisation.setId("lblOrganisation");
lblOrganisation.setValue(res.getString("Organization"));
lblWarehouse = new Label();
lblWarehouse.setId("lblWarehouse");
lblWarehouse.setValue(res.getString("Warehouse"));
lstRole = new Combobox();
lstRole.setAutocomplete(true);
lstRole.setAutodrop(true);
lstRole.setId("lstRole");
lstRole.addEventListener(Events.ON_SELECT, this);
lstClient = new Combobox();
lstClient.setAutocomplete(true);
lstClient.setAutodrop(true);
lstClient.setId("lstClient");
lstClient.addEventListener(Events.ON_SELECT, this);
lstOrganisation = new Combobox();
lstOrganisation.setAutocomplete(true);
lstOrganisation.setAutodrop(true);
lstOrganisation.setId("lstOrganisation");
lstOrganisation.addEventListener(Events.ON_SELECT, this);
lstWarehouse = new Combobox();
lstWarehouse.setAutocomplete(true);
lstWarehouse.setAutodrop(true);
lstWarehouse.setId("lstWarehouse");
lstWarehouse.addEventListener(Events.ON_SELECT, this);
btnOk = new Button();
btnOk.setId("btnOk");
btnOk.setLabel("Ok");
btnOk.addEventListener("onClick", this);
btnCancel = new Button();
btnCancel.setId("btnCancel");
btnCancel.setLabel("Cancel");
btnCancel.addEventListener("onClick", this);
// initial role - Elaine 2009/02/06
UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
String initDefault = userPreference.getProperty(UserPreference.P_ROLE);
for (int i = 0; i < rolesKNPairs.length; i++) {
ComboItem ci = new ComboItem(rolesKNPairs[i].getName(), rolesKNPairs[i].getID());
lstRole.appendChild(ci);
if (rolesKNPairs[i].getID().equals(initDefault))
lstRole.setSelectedItem(ci);
}
if (lstRole.getSelectedIndex() == -1 && lstRole.getItemCount() > 0)
lstRole.setSelectedIndex(0);
// If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
if (lstRole.getItemCount() == 1 && !MSysConfig.getBooleanValue("ALogin_ShowOneRole", true)) {
lstRole.setSelectedIndex(0);
lblRole.setVisible(false);
lstRole.setVisible(false);
} else {
lblRole.setVisible(true);
lstRole.setVisible(true);
}
updateClientList();
}
Aggregations