BF[2723605] date fields shown only in English format ("mm/dd/yyyy")
This commit is contained in:
parent
648979a759
commit
c020c9808c
|
@ -23,6 +23,7 @@ import java.util.Properties;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.desktop.DefaultDesktop;
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -51,7 +52,7 @@ import org.zkoss.zul.Window;
|
|||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Feb 25, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
*
|
||||
*
|
||||
* @author hengsin
|
||||
*/
|
||||
public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||
|
@ -69,19 +70,19 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
private ClientInfo clientInfo;
|
||||
|
||||
private String langSession;
|
||||
|
||||
|
||||
private UserPreference userPreference;
|
||||
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(AdempiereWebUI.class);
|
||||
|
||||
public AdempiereWebUI()
|
||||
{
|
||||
this.addEventListener(Events.ON_CLIENT_INFO, this);
|
||||
this.setVisible(false);
|
||||
|
||||
this.setVisible(false);
|
||||
|
||||
userPreference = new UserPreference();
|
||||
}
|
||||
|
||||
|
||||
public void onCreate()
|
||||
{
|
||||
this.getPage().setTitle(APP_NAME);
|
||||
|
@ -97,7 +98,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
else
|
||||
{
|
||||
loginCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onOk()
|
||||
|
@ -113,48 +114,63 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
*/
|
||||
public void loginCompleted()
|
||||
{
|
||||
if (loginDesktop != null)
|
||||
if (loginDesktop != null)
|
||||
{
|
||||
loginDesktop.detach();
|
||||
loginDesktop = null;
|
||||
}
|
||||
|
||||
|
||||
Properties ctx = Env.getCtx();
|
||||
String langLogin = Env.getContext(ctx, Env.LANGUAGE);
|
||||
if (langLogin == null || langLogin.length() <= 0) {
|
||||
if (langLogin == null || langLogin.length() <= 0)
|
||||
{
|
||||
langLogin = langSession;
|
||||
Env.setContext(ctx, Env.LANGUAGE, langSession);
|
||||
}
|
||||
|
||||
|
||||
// Validate language
|
||||
Language language = Language.getLanguage(langLogin);
|
||||
String locale = Env.getContext(ctx, AEnv.LOCALE);
|
||||
if (locale != null && locale.length() > 0 && !language.getLocale().toString().equals(locale))
|
||||
{
|
||||
String adLanguage = language.getAD_Language();
|
||||
Language tmp = Language.getLanguage(locale);
|
||||
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
|
||||
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
Language tmp = language;
|
||||
language = new Language(tmp.getName(), tmp.getAD_Language(), tmp.getLocale(), tmp.isDecimalPoint(),
|
||||
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||
}
|
||||
Env.verifyLanguage(ctx, language);
|
||||
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language()); //Bug
|
||||
|
||||
|
||||
// Create adempiere Session - user id in ctx
|
||||
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
||||
HttpSession httpSess = (HttpSession) currSess.getNativeSession();
|
||||
|
||||
MSession.get (ctx, currSess.getRemoteAddr(),
|
||||
MSession.get (ctx, currSess.getRemoteAddr(),
|
||||
currSess.getRemoteHost(), httpSess.getId() );
|
||||
|
||||
//enable full interface, relook into this when doing preference
|
||||
|
||||
//enable full interface, relook into this when doing preference
|
||||
Env.setContext(ctx, "#ShowTrl", true);
|
||||
Env.setContext(ctx, "#ShowAcct", true);
|
||||
Env.setContext(ctx, "#ShowAdvanced", true);
|
||||
|
||||
|
||||
String autoCommit = userPreference.getProperty(UserPreference.P_AUTO_COMMIT);
|
||||
Env.setAutoCommit(ctx, "true".equalsIgnoreCase(autoCommit) || "y".equalsIgnoreCase(autoCommit));
|
||||
|
||||
|
||||
IDesktop d = (IDesktop) currSess.getAttribute("application.desktop");
|
||||
if (d != null && d instanceof IDesktop)
|
||||
if (d != null && d instanceof IDesktop)
|
||||
{
|
||||
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
||||
if (eco != null) {
|
||||
//try restore
|
||||
try {
|
||||
appDesktop = (IDesktop) d;
|
||||
|
||||
|
||||
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
||||
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||
Visualizer vi = ctrl.getVisualizer();
|
||||
|
@ -163,7 +179,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
try {
|
||||
ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||
ctrl.setVisualizer(vi);
|
||||
|
||||
|
||||
//detach root component from old page
|
||||
Page page = appDesktop.getComponent().getPage();
|
||||
Collection<?> collection = page.getRoots();
|
||||
|
@ -182,24 +198,24 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
eco.cleanup();
|
||||
current.carryOver();
|
||||
}
|
||||
|
||||
|
||||
if (appDesktop != null) {
|
||||
//re-attach root components
|
||||
for (Component component : rootComponents) {
|
||||
component.setPage(this.getPage());
|
||||
}
|
||||
appDesktop.setPage(this.getPage());
|
||||
appDesktop.setPage(this.getPage());
|
||||
currSess.setAttribute("execution.carryover", current);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
//restore fail
|
||||
appDesktop = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (appDesktop == null)
|
||||
|
||||
if (appDesktop == null)
|
||||
{
|
||||
//create new desktop
|
||||
createDesktop();
|
||||
|
@ -211,22 +227,22 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
}
|
||||
}
|
||||
|
||||
private void createDesktop()
|
||||
private void createDesktop()
|
||||
{
|
||||
appDesktop = null;
|
||||
String className = MSysConfig.getValue(IDesktop.CLASS_NAME_KEY);
|
||||
if ( className != null && className.trim().length() > 0)
|
||||
if ( className != null && className.trim().length() > 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
Class<?> clazz = this.getClass().getClassLoader().loadClass(className);
|
||||
appDesktop = (IDesktop) clazz.newInstance();
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
logger.warning("Failed to instantiate desktop. Class=" + className);
|
||||
}
|
||||
}
|
||||
}
|
||||
//fallback to default
|
||||
if (appDesktop == null)
|
||||
appDesktop = new DefaultDesktop();
|
||||
|
@ -238,12 +254,12 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
public void logout()
|
||||
{
|
||||
appDesktop.logout();
|
||||
|
||||
|
||||
MSession mSession = MSession.get(Env.getCtx(), false);
|
||||
if (mSession != null) {
|
||||
mSession.logout();
|
||||
}
|
||||
|
||||
|
||||
SessionManager.clearSession();
|
||||
super.getChildren().clear();
|
||||
Page page = this.getPage();
|
||||
|
@ -258,7 +274,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
{
|
||||
return appDesktop;
|
||||
}
|
||||
|
||||
|
||||
public void onEvent(Event event) {
|
||||
if (event instanceof ClientInfoEvent) {
|
||||
ClientInfoEvent c = (ClientInfoEvent)event;
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.sql.SQLException;
|
|||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
@ -49,6 +50,7 @@ import org.compiere.util.CLogger;
|
|||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Language;
|
||||
import org.zkoss.web.servlet.Servlets;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Execution;
|
||||
|
@ -62,7 +64,7 @@ import com.lowagie.text.pdf.PdfReader;
|
|||
import com.lowagie.text.pdf.PdfWriter;
|
||||
|
||||
/**
|
||||
* Windows Application Environment and utilities
|
||||
* ZK Application Environment and utilities
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
|
@ -71,6 +73,8 @@ import com.lowagie.text.pdf.PdfWriter;
|
|||
*/
|
||||
public final class AEnv
|
||||
{
|
||||
public static final String LOCALE = "#Locale";
|
||||
|
||||
/**
|
||||
* Show in the center of the screen.
|
||||
* (pack, set location and set visibility)
|
||||
|
@ -94,7 +98,7 @@ public final class AEnv
|
|||
* Show in the center of the screen.
|
||||
* (pack, set location and set visibility)
|
||||
* @param window Window to position
|
||||
* @param position
|
||||
* @param position
|
||||
*/
|
||||
public static void showScreen(Window window, String position)
|
||||
{
|
||||
|
@ -172,7 +176,7 @@ public final class AEnv
|
|||
AD_Window_ID = PO_Window_ID;
|
||||
}
|
||||
|
||||
log.config(TableName + " - Record_ID=" + Record_ID + " (IsSOTrx=" + isSOTrx + ")");
|
||||
log.config(TableName + " - Record_ID=" + Record_ID + " (IsSOTrx=" + isSOTrx + ")");
|
||||
zoom(AD_Window_ID, MQuery.getEqualQuery(TableName + "_ID", Record_ID));
|
||||
} // zoom
|
||||
|
||||
|
@ -204,10 +208,10 @@ public final class AEnv
|
|||
int AD_Window_ID = DB.getSQLValue(null, "SELECT AD_Window_ID FROM AD_Window WHERE Name = 'Workflow Process'");
|
||||
s_workflow_Window_ID = AD_Window_ID;
|
||||
}
|
||||
|
||||
|
||||
if (s_workflow_Window_ID <= 0)
|
||||
return;
|
||||
|
||||
|
||||
MQuery query = new MQuery();
|
||||
query.addRestriction("AD_Table_ID", MQuery.EQUAL, AD_Table_ID);
|
||||
query.addRestriction("Record_ID", MQuery.EQUAL, Record_ID);
|
||||
|
@ -259,11 +263,11 @@ public final class AEnv
|
|||
GridWindowVO mWindowVO = null;
|
||||
String locale = Env.getLanguage(Env.getCtx()).getLocale().toString();
|
||||
if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache
|
||||
{
|
||||
{
|
||||
synchronized (windowCache)
|
||||
{
|
||||
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
||||
if (cache != null)
|
||||
if (cache != null)
|
||||
{
|
||||
mWindowVO = cache.get(AD_Window_ID);
|
||||
if (mWindowVO != null)
|
||||
|
@ -274,7 +278,7 @@ public final class AEnv
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create Window Model on Client
|
||||
if (mWindowVO == null)
|
||||
{
|
||||
|
@ -285,14 +289,14 @@ public final class AEnv
|
|||
synchronized (windowCache)
|
||||
{
|
||||
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
||||
if (cache == null)
|
||||
if (cache == null)
|
||||
{
|
||||
cache = new CCache<Integer, GridWindowVO>("AD_Window", 10);
|
||||
windowCache.put(locale, cache);
|
||||
}
|
||||
cache.put(AD_Window_ID, mWindowVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // from Client
|
||||
if (mWindowVO == null)
|
||||
return null;
|
||||
|
@ -583,16 +587,16 @@ public final class AEnv
|
|||
}
|
||||
return uri;
|
||||
} // getImageIcon
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isFirefox2() {
|
||||
Execution execution = Executions.getCurrent();
|
||||
if (execution == null)
|
||||
return false;
|
||||
|
||||
|
||||
Object n = execution.getNativeRequest();
|
||||
if (n instanceof ServletRequest) {
|
||||
String userAgent = Servlets.getUserAgent((ServletRequest) n);
|
||||
|
@ -601,9 +605,9 @@ public final class AEnv
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param parent
|
||||
* @param child
|
||||
* @return boolean
|
||||
|
@ -611,19 +615,19 @@ public final class AEnv
|
|||
public static boolean contains(Component parent, Component child) {
|
||||
if (child == parent)
|
||||
return true;
|
||||
|
||||
|
||||
Component c = child.getParent();
|
||||
while (c != null) {
|
||||
if (c == parent)
|
||||
return true;
|
||||
c = c.getParent();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param pdfList
|
||||
* @param outFile
|
||||
* @throws IOException
|
||||
|
@ -633,13 +637,13 @@ public final class AEnv
|
|||
public static void mergePdf(List<File> pdfList, File outFile) throws IOException,
|
||||
DocumentException, FileNotFoundException {
|
||||
Document document = null;
|
||||
PdfWriter copy = null;
|
||||
for (File f : pdfList)
|
||||
PdfWriter copy = null;
|
||||
for (File f : pdfList)
|
||||
{
|
||||
PdfReader reader = new PdfReader(f.getAbsolutePath());
|
||||
if (document == null)
|
||||
{
|
||||
document = new Document(reader.getPageSizeWithRotation(1));
|
||||
document = new Document(reader.getPageSizeWithRotation(1));
|
||||
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
|
||||
document.open();
|
||||
}
|
||||
|
@ -653,7 +657,7 @@ public final class AEnv
|
|||
}
|
||||
document.close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get window title
|
||||
* @param ctx context
|
||||
|
@ -680,4 +684,42 @@ public final class AEnv
|
|||
}
|
||||
return sb.toString();
|
||||
} // getHeader
|
||||
|
||||
/**
|
||||
* @param ctx
|
||||
* @return Language
|
||||
*/
|
||||
public static Language getLanguage(Properties ctx) {
|
||||
Locale locale = getLocale(ctx);
|
||||
Language language = Env.getLanguage(ctx);
|
||||
if (!language.getLocale().equals(locale)) {
|
||||
Language tmp = Language.getLanguage(locale.toString());
|
||||
String adLanguage = language.getAD_Language();
|
||||
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
|
||||
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx
|
||||
* @return Locale
|
||||
*/
|
||||
public static Locale getLocale(Properties ctx) {
|
||||
String value = Env.getContext(ctx, AEnv.LOCALE);
|
||||
Locale locale = null;
|
||||
if (value != null && value.length() > 0)
|
||||
{
|
||||
String[] components = value.split("\\_");
|
||||
String language = components.length > 0 ? components[0] : "";
|
||||
String country = components.length > 1 ? components[1] : "";
|
||||
locale = new Locale(language, country);
|
||||
}
|
||||
else
|
||||
{
|
||||
locale = Env.getLanguage(ctx).getLocale();
|
||||
}
|
||||
|
||||
return locale;
|
||||
}
|
||||
} // AEnv
|
||||
|
|
|
@ -20,16 +20,18 @@ package org.adempiere.webui.editor;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Datebox;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Mar 12, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
|
@ -39,16 +41,16 @@ public class WDateEditor extends WEditor
|
|||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
||||
@SuppressWarnings("unused")
|
||||
private static final CLogger logger;
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
logger = CLogger.getCLogger(WDateEditor.class);
|
||||
}
|
||||
|
||||
|
||||
private Timestamp oldValue = new Timestamp(0);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param gridField
|
||||
*/
|
||||
public WDateEditor(GridField gridField)
|
||||
|
@ -56,11 +58,11 @@ public class WDateEditor extends WEditor
|
|||
super(new Datebox(), gridField);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for use if a grid field is unavailable
|
||||
*
|
||||
*
|
||||
* @param label
|
||||
* column name (not displayed)
|
||||
* @param description
|
||||
|
@ -78,14 +80,14 @@ public class WDateEditor extends WEditor
|
|||
setColumnName("Date");
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public WDateEditor()
|
||||
{
|
||||
this("Date", "Date", false, false, true);
|
||||
this("Date", "Date", false, false, true);
|
||||
} // VDate
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param columnName
|
||||
* @param mandatory
|
||||
* @param readonly
|
||||
|
@ -97,24 +99,24 @@ public class WDateEditor extends WEditor
|
|||
{
|
||||
super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
|
||||
}
|
||||
|
||||
private void init()
|
||||
|
||||
private void init()
|
||||
{
|
||||
getComponent().setFormat(DisplayType.getDateFormat().toPattern());
|
||||
getComponent().setFormat(DisplayType.getDateFormat(AEnv.getLanguage(Env.getCtx())).toPattern());
|
||||
}
|
||||
|
||||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||
{
|
||||
Date date = getComponent().getValue();
|
||||
Timestamp newValue = null;
|
||||
|
||||
|
||||
if (date != null)
|
||||
{
|
||||
newValue = new Timestamp(date.getTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||
super.fireValueChange(changeEvent);
|
||||
oldValue = newValue;
|
||||
|
@ -162,9 +164,9 @@ public class WDateEditor extends WEditor
|
|||
getComponent().setValue((Timestamp)value);
|
||||
oldValue = (Timestamp)value;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
getComponent().setText(value.toString());
|
||||
} catch (Exception e) {}
|
||||
|
@ -174,7 +176,7 @@ public class WDateEditor extends WEditor
|
|||
oldValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Datebox getComponent() {
|
||||
return (Datebox) component;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.math.BigDecimal;
|
|||
import java.text.DecimalFormat;
|
||||
|
||||
import org.adempiere.webui.ValuePreference;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.NumberBox;
|
||||
import org.adempiere.webui.event.ContextMenuEvent;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
|
@ -36,28 +37,28 @@ import org.zkoss.zk.ui.event.Events;
|
|||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Mar 11, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
*
|
||||
*
|
||||
* @author Low Heng Sin
|
||||
*/
|
||||
public class WNumberEditor extends WEditor
|
||||
{
|
||||
public static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
||||
|
||||
|
||||
public static final int MAX_DISPLAY_LENGTH = 20;
|
||||
|
||||
private BigDecimal oldValue;
|
||||
|
||||
|
||||
private boolean mandatory = false;
|
||||
|
||||
private int displayType;
|
||||
|
||||
public WNumberEditor()
|
||||
|
||||
public WNumberEditor()
|
||||
{
|
||||
this("Number", false, false, true, DisplayType.Number, "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param gridField
|
||||
*/
|
||||
public WNumberEditor(GridField gridField)
|
||||
|
@ -67,9 +68,9 @@ public class WNumberEditor extends WEditor
|
|||
this.displayType = gridField.getDisplayType();
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param gridField
|
||||
* @param integral
|
||||
*/
|
||||
|
@ -81,7 +82,7 @@ public class WNumberEditor extends WEditor
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param columnName
|
||||
* @param mandatory
|
||||
* @param readonly
|
||||
|
@ -90,9 +91,9 @@ public class WNumberEditor extends WEditor
|
|||
* @param title
|
||||
*/
|
||||
public WNumberEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
||||
int displayType, String title)
|
||||
int displayType, String title)
|
||||
{
|
||||
super(new NumberBox(displayType == DisplayType.Integer), columnName, title, null, mandatory,
|
||||
super(new NumberBox(displayType == DisplayType.Integer), columnName, title, null, mandatory,
|
||||
readonly, updateable);
|
||||
this.displayType = displayType;
|
||||
init();
|
||||
|
@ -103,14 +104,14 @@ public class WNumberEditor extends WEditor
|
|||
if (gridField != null)
|
||||
{
|
||||
getComponent().setTooltiptext(gridField.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!DisplayType.isNumeric(displayType))
|
||||
displayType = DisplayType.Number;
|
||||
DecimalFormat format = DisplayType.getNumberFormat(displayType, Env.getLanguage(Env.getCtx()));
|
||||
DecimalFormat format = DisplayType.getNumberFormat(displayType, AEnv.getLanguage(Env.getCtx()));
|
||||
getComponent().getDecimalbox().setFormat(format.toPattern());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event handler
|
||||
* @param event
|
||||
|
@ -125,7 +126,7 @@ public class WNumberEditor extends WEditor
|
|||
oldValue = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NumberBox getComponent() {
|
||||
return (NumberBox) component;
|
||||
|
@ -167,29 +168,29 @@ public class WNumberEditor extends WEditor
|
|||
|
||||
@Override
|
||||
public void setValue(Object value)
|
||||
{
|
||||
{
|
||||
if (value == null)
|
||||
oldValue = null;
|
||||
else if (value instanceof BigDecimal)
|
||||
oldValue = (BigDecimal) value;
|
||||
else if (value instanceof Number)
|
||||
oldValue = new BigDecimal(((Number)value).doubleValue());
|
||||
else
|
||||
else
|
||||
oldValue = new BigDecimal(value.toString());
|
||||
getComponent().setValue(oldValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getEvents()
|
||||
{
|
||||
return LISTENER_EVENTS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle context menu events
|
||||
* Handle context menu events
|
||||
* @param evt
|
||||
*/
|
||||
public void onMenu(ContextMenuEvent evt)
|
||||
public void onMenu(ContextMenuEvent evt)
|
||||
{
|
||||
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()) && gridField != null)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.adempiere.webui.panel;
|
|||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.Label;
|
||||
|
@ -35,6 +36,7 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Login;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.au.out.AuFocus;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
|
@ -57,7 +59,7 @@ import org.zkoss.zul.Listitem;
|
|||
public class LoginPanel extends Window implements EventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private static final String RESOURCE = "org.compiere.apps.ALoginRes";
|
||||
private ResourceBundle res = ResourceBundle.getBundle(RESOURCE);
|
||||
|
||||
|
@ -79,7 +81,7 @@ public class LoginPanel extends Window implements EventListener
|
|||
initComponents();
|
||||
init();
|
||||
this.setId("loginPanel");
|
||||
|
||||
|
||||
AuFocus auf = new AuFocus(txtUserId);
|
||||
Clients.response(auf);
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ public class LoginPanel extends Window implements EventListener
|
|||
logo.setSpans("2");
|
||||
Image image = new Image();
|
||||
image.setSrc("images/logo.png");
|
||||
logo.appendChild(image);
|
||||
logo.appendChild(image);
|
||||
Row rowUser = new Row();
|
||||
rowUser.setId("rowUser");
|
||||
Row rowPassword = new Row();
|
||||
|
@ -160,7 +162,7 @@ public class LoginPanel extends Window implements EventListener
|
|||
lstLanguage.setMold("select");
|
||||
lstLanguage.addEventListener(Events.ON_SELECT, this);
|
||||
lstLanguage.setWidth("220px");
|
||||
|
||||
|
||||
// Update Language List
|
||||
lstLanguage.getItems().clear();
|
||||
String[] availableLanguages = Language.getNames();
|
||||
|
@ -215,18 +217,26 @@ public class LoginPanel extends Window implements EventListener
|
|||
}
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
private void languageChanged(String langName)
|
||||
{
|
||||
Language language = Language.getLanguage(langName);
|
||||
Env.verifyLanguage(ctx, language);
|
||||
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language());
|
||||
|
||||
Language language = findLanguage(langName);
|
||||
|
||||
res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
|
||||
lblUserId.setValue(res.getString("User"));
|
||||
lblPassword.setValue(res.getString("Password"));
|
||||
lblLanguage.setValue(res.getString("Language"));
|
||||
}
|
||||
|
||||
private Language findLanguage(String langName) {
|
||||
Language tmp = Language.getLanguage(langName);
|
||||
Language language = new Language(tmp.getName(), tmp.getAD_Language(), tmp.getLocale(), tmp.isDecimalPoint(),
|
||||
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||
Env.verifyLanguage(ctx, language);
|
||||
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language());
|
||||
Env.setContext(ctx, AEnv.LOCALE, language.getLocale().toString());
|
||||
return language;
|
||||
}
|
||||
/**
|
||||
* validates user name and password when logging in
|
||||
*
|
||||
|
@ -247,11 +257,12 @@ public class LoginPanel extends Window implements EventListener
|
|||
langName = (String) lstLanguage.getSelectedItem().getLabel();
|
||||
else
|
||||
langName = Language.getBaseLanguage().getName();
|
||||
Language language = Language.getLanguage(langName);
|
||||
Env.verifyLanguage(ctx, language);
|
||||
wndLogin.loginOk(userId, userPassword);
|
||||
|
||||
Language language = findLanguage(langName);
|
||||
wndLogin.loginOk(userId, userPassword);
|
||||
|
||||
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06
|
||||
|
||||
Locales.setThreadLocal(language.getLocale());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.adempiere.webui.session;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
@ -31,7 +32,7 @@ import org.zkoss.zk.ui.util.ExecutionCleanup;
|
|||
import org.zkoss.zk.ui.util.ExecutionInit;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Feb 25, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
|
@ -44,17 +45,17 @@ public class SessionContextListener implements ExecutionInit,
|
|||
/**
|
||||
* @param exec
|
||||
* @param parent
|
||||
*
|
||||
*
|
||||
* @see ExecutionInit#init(Execution, Execution)
|
||||
*/
|
||||
public void init(Execution exec, Execution parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
{
|
||||
ServerContext ctx = (ServerContext)exec.getDesktop().getSession().getAttribute(SESSION_CTX);
|
||||
if (ctx == null)
|
||||
{
|
||||
ctx = ServerContext.newInstance();
|
||||
ctx = ServerContext.newInstance();
|
||||
exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx);
|
||||
}
|
||||
else
|
||||
|
@ -62,7 +63,7 @@ public class SessionContextListener implements ExecutionInit,
|
|||
ServerContext.setCurrentInstance(ctx);
|
||||
}
|
||||
exec.setAttribute(SESSION_CTX, ctx);
|
||||
|
||||
|
||||
//set locale
|
||||
Locales.setThreadLocal(Env.getLanguage(ctx).getLocale());
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ public class SessionContextListener implements ExecutionInit,
|
|||
* @param exec
|
||||
* @param parent
|
||||
* @param errs
|
||||
* @see ExecutionCleanup#cleanup(Execution, Execution, List)
|
||||
* @see ExecutionCleanup#cleanup(Execution, Execution, List)
|
||||
*/
|
||||
public void cleanup(Execution exec, Execution parent, List errs)
|
||||
{
|
||||
|
@ -80,7 +81,7 @@ public class SessionContextListener implements ExecutionInit,
|
|||
{
|
||||
exec.removeAttribute(SESSION_CTX);
|
||||
ServerContext.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,11 +103,11 @@ public class SessionContextListener implements ExecutionInit,
|
|||
ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute(
|
||||
SESSION_CTX);
|
||||
ServerContext.setCurrentInstance(ctx);
|
||||
|
||||
|
||||
// set locale
|
||||
Locales.setThreadLocal(Env.getLanguage(ctx).getLocale());
|
||||
|
||||
return true;
|
||||
Locales.setThreadLocal(AEnv.getLocale(ctx));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,5 +139,5 @@ public class SessionContextListener implements ExecutionInit,
|
|||
public void abortResume(Component comp, Event evt)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue