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 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 *
|
* 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 *
|
* 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 *
|
* 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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.adempiere.webui.desktop.IDesktop;
|
import org.adempiere.webui.desktop.IDesktop;
|
||||||
import org.adempiere.webui.session.ServerContext;
|
import org.adempiere.webui.session.ServerContext;
|
||||||
|
|
@ -22,10 +23,11 @@ import org.adempiere.webui.session.SessionContextListener;
|
||||||
import org.adempiere.webui.util.ServerPushTemplate;
|
import org.adempiere.webui.util.ServerPushTemplate;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.zkoss.util.Locales;
|
||||||
import org.zkoss.zk.ui.Desktop;
|
import org.zkoss.zk.ui.Desktop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,51 +36,54 @@ public class DashboardRunnable implements Runnable {
|
||||||
private boolean stop = false;
|
private boolean stop = false;
|
||||||
private List<DashboardPanel> dashboardPanels;
|
private List<DashboardPanel> dashboardPanels;
|
||||||
private IDesktop appDesktop;
|
private IDesktop appDesktop;
|
||||||
|
private Locale locale;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final CLogger logger = CLogger.getCLogger(DashboardRunnable.class);
|
private static final CLogger logger = CLogger.getCLogger(DashboardRunnable.class);
|
||||||
|
|
||||||
private final static String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL";
|
private final static String ZK_DASHBOARD_REFRESH_INTERVAL = "ZK_DASHBOARD_REFRESH_INTERVAL";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param desktop zk desktop interface
|
* @param desktop zk desktop interface
|
||||||
* @param appDesktop adempiere desktop interface
|
* @param appDesktop adempiere desktop interface
|
||||||
*/
|
*/
|
||||||
public DashboardRunnable(Desktop desktop, IDesktop appDesktop) {
|
public DashboardRunnable(Desktop desktop, IDesktop appDesktop) {
|
||||||
this.desktop = desktop;
|
this.desktop = desktop;
|
||||||
this.appDesktop = appDesktop;
|
this.appDesktop = appDesktop;
|
||||||
|
|
||||||
dashboardPanels = new ArrayList<DashboardPanel>();
|
dashboardPanels = new ArrayList<DashboardPanel>();
|
||||||
|
locale = Locales.getCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
// default Update every one minutes
|
// default Update every one minutes
|
||||||
int interval = MSysConfig.getIntValue(ZK_DASHBOARD_REFRESH_INTERVAL, 60000);
|
int interval = MSysConfig.getIntValue(ZK_DASHBOARD_REFRESH_INTERVAL, 60000);
|
||||||
while(!stop) {
|
while(!stop) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(interval);
|
Thread.sleep(interval);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
if (stop) break;
|
if (stop) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desktop.isAlive()) {
|
if (desktop.isAlive()) {
|
||||||
refreshDashboard();
|
Locales.setThreadLocal(locale);
|
||||||
|
refreshDashboard();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh dashboard content
|
* Refresh dashboard content
|
||||||
*/
|
*/
|
||||||
public void refreshDashboard()
|
public void refreshDashboard()
|
||||||
{
|
{
|
||||||
|
|
||||||
ServerPushTemplate template = new ServerPushTemplate(desktop);
|
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
|
//make sure context is correct
|
||||||
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||||
|
|
@ -88,14 +93,14 @@ public class DashboardRunnable implements Runnable {
|
||||||
}
|
}
|
||||||
dashboardPanels.get(i).refresh(template);
|
dashboardPanels.get(i).refresh(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
//make sure context is correct
|
//make sure context is correct
|
||||||
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
ServerContext ctx = (ServerContext)template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||||
if (ctx != null && ServerContext.getCurrentInstance() != ctx)
|
if (ctx != null && ServerContext.getCurrentInstance() != ctx)
|
||||||
{
|
{
|
||||||
ServerContext.setCurrentInstance(ctx);
|
ServerContext.setCurrentInstance(ctx);
|
||||||
}
|
}
|
||||||
appDesktop.onServerPush(template);
|
appDesktop.onServerPush(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue