BF [2750447] Translations on Home tab
- ensure locale is correct for auto refresh background thread.
This commit is contained in:
parent
f900f53231
commit
7412778942
|
@ -1,6 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -15,6 +15,7 @@ package org.adempiere.webui.dashboard;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.adempiere.webui.session.ServerContext;
|
||||
|
@ -22,10 +23,11 @@ import org.adempiere.webui.session.SessionContextListener;
|
|||
import org.adempiere.webui.util.ServerPushTemplate;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
|
@ -34,51 +36,54 @@ public class DashboardRunnable implements Runnable {
|
|||
private boolean stop = false;
|
||||
private List<DashboardPanel> dashboardPanels;
|
||||
private IDesktop appDesktop;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final CLogger logger = CLogger.getCLogger(DashboardRunnable.class);
|
||||
|
||||
|
||||
private final static String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL";
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param desktop zk desktop interface
|
||||
* @param appDesktop adempiere desktop interface
|
||||
*/
|
||||
public DashboardRunnable(Desktop desktop, IDesktop appDesktop) {
|
||||
this.desktop = desktop;
|
||||
this.appDesktop = appDesktop;
|
||||
|
||||
|
||||
dashboardPanels = new ArrayList<DashboardPanel>();
|
||||
locale = Locales.getCurrent();
|
||||
}
|
||||
|
||||
public void run()
|
||||
|
||||
public void run()
|
||||
{
|
||||
// default Update every one minutes
|
||||
int interval = MSysConfig.getIntValue(ZK_DASHBOARD_REFRESH_INTERVAL, 60000);
|
||||
while(!stop) {
|
||||
try {
|
||||
Thread.sleep(interval);
|
||||
Thread.sleep(interval);
|
||||
} catch (InterruptedException e1) {
|
||||
if (stop) break;
|
||||
}
|
||||
|
||||
|
||||
if (desktop.isAlive()) {
|
||||
refreshDashboard();
|
||||
Locales.setThreadLocal(locale);
|
||||
refreshDashboard();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refresh dashboard content
|
||||
*/
|
||||
public void refreshDashboard()
|
||||
{
|
||||
|
||||
|
||||
ServerPushTemplate template = new ServerPushTemplate(desktop);
|
||||
for(int i = 0; i < dashboardPanels.size(); i++)
|
||||
for(int i = 0; i < dashboardPanels.size(); i++)
|
||||
{
|
||||
//make sure context is correct
|
||||
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||
|
@ -88,14 +93,14 @@ public class DashboardRunnable implements Runnable {
|
|||
}
|
||||
dashboardPanels.get(i).refresh(template);
|
||||
}
|
||||
|
||||
|
||||
//make sure context is correct
|
||||
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||
if (ctx != null && ServerContext.getCurrentInstance() != ctx)
|
||||
{
|
||||
ServerContext.setCurrentInstance(ctx);
|
||||
}
|
||||
appDesktop.onServerPush(template);
|
||||
appDesktop.onServerPush(template);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
|
Loading…
Reference in New Issue