Render user home page in background thread.
This commit is contained in:
parent
ba9cc04439
commit
14242ef8b6
|
@ -197,4 +197,11 @@ public class DashboardRunnable implements Runnable, Serializable
|
||||||
public void add(DashboardPanel dashboardPanel) {
|
public void add(DashboardPanel dashboardPanel) {
|
||||||
dashboardPanels.add(dashboardPanel);
|
dashboardPanels.add(dashboardPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return dashboardPanels == null || dashboardPanels.isEmpty() ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,11 @@ import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.ServerContext;
|
||||||
|
import org.adempiere.webui.apps.BusyDialog;
|
||||||
import org.adempiere.webui.apps.graph.WGraph;
|
import org.adempiere.webui.apps.graph.WGraph;
|
||||||
import org.adempiere.webui.apps.graph.WPerformanceDetail;
|
import org.adempiere.webui.apps.graph.WPerformanceDetail;
|
||||||
import org.adempiere.webui.component.Tabpanel;
|
import org.adempiere.webui.component.Tabpanel;
|
||||||
|
@ -34,6 +37,7 @@ import org.adempiere.webui.dashboard.DashboardRunnable;
|
||||||
import org.adempiere.webui.event.MenuListener;
|
import org.adempiere.webui.event.MenuListener;
|
||||||
import org.adempiere.webui.panel.HeaderPanel;
|
import org.adempiere.webui.panel.HeaderPanel;
|
||||||
import org.adempiere.webui.panel.SidePanel;
|
import org.adempiere.webui.panel.SidePanel;
|
||||||
|
import org.adempiere.webui.session.SessionContextListener;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.adempiere.webui.util.IServerPushCallback;
|
import org.adempiere.webui.util.IServerPushCallback;
|
||||||
import org.adempiere.webui.util.ServerPushTemplate;
|
import org.adempiere.webui.util.ServerPushTemplate;
|
||||||
|
@ -96,6 +100,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
|
|
||||||
private int noOfWorkflow;
|
private int noOfWorkflow;
|
||||||
|
|
||||||
|
private Tabpanel homeTab;
|
||||||
|
|
||||||
public DefaultDesktop()
|
public DefaultDesktop()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -153,15 +159,48 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
|
|
||||||
windowContainer.createPart(windowArea);
|
windowContainer.createPart(windowArea);
|
||||||
|
|
||||||
createHomeTab();
|
homeTab = new Tabpanel();
|
||||||
|
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||||
|
BusyDialog busyDialog = new BusyDialog();
|
||||||
|
busyDialog.setShadow(false);
|
||||||
|
homeTab.appendChild(busyDialog);
|
||||||
|
|
||||||
|
if (!layout.getDesktop().isServerPushEnabled())
|
||||||
|
{
|
||||||
|
layout.getDesktop().enableServerPush(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
|
||||||
|
IServerPushCallback callback = new IServerPushCallback() {
|
||||||
|
public void updateUI() {
|
||||||
|
Properties ctx = (Properties)layout.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||||
|
try {
|
||||||
|
ServerContext.setCurrentInstance(ctx);
|
||||||
|
renderHomeTab();
|
||||||
|
} finally {
|
||||||
|
ServerContext.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ServerPushTemplate template = new ServerPushTemplate(layout.getDesktop());
|
||||||
|
template.execute(callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHomeTab()
|
private void renderHomeTab()
|
||||||
{
|
{
|
||||||
Tabpanel homeTab = new Tabpanel();
|
homeTab.getChildren().clear();
|
||||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
|
||||||
|
|
||||||
Portallayout portalLayout = new Portallayout();
|
Portallayout portalLayout = new Portallayout();
|
||||||
portalLayout.setWidth("100%");
|
portalLayout.setWidth("100%");
|
||||||
|
@ -196,6 +235,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
Panel panel = new Panel();
|
Panel panel = new Panel();
|
||||||
panel.setStyle("margin-bottom:10px");
|
panel.setStyle("margin-bottom:10px");
|
||||||
panel.setTitle(dp.getName());
|
panel.setTitle(dp.getName());
|
||||||
|
panel.setMaximizable(true);
|
||||||
|
|
||||||
String description = dp.getDescription();
|
String description = dp.getDescription();
|
||||||
if(description != null)
|
if(description != null)
|
||||||
|
@ -249,6 +289,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
|
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
|
||||||
I_AD_Menu menu = dp.getAD_Menu();
|
I_AD_Menu menu = dp.getAD_Menu();
|
||||||
btn.setLabel(menu.getName());
|
btn.setLabel(menu.getName());
|
||||||
|
btn.setAttribute("AD_Menu_ID", AD_Menu_ID);
|
||||||
btn.addEventListener(Events.ON_CLICK, this);
|
btn.addEventListener(Events.ON_CLICK, this);
|
||||||
content.appendChild(btn);
|
content.appendChild(btn);
|
||||||
panelEmpty = false;
|
panelEmpty = false;
|
||||||
|
@ -318,9 +359,6 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
{
|
{
|
||||||
logger.log(Level.WARNING, "Failed to create dashboard content", e);
|
logger.log(Level.WARNING, "Failed to create dashboard content", e);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
|
|
||||||
//register as 0
|
//register as 0
|
||||||
|
@ -329,12 +367,15 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
if (!portalLayout.getDesktop().isServerPushEnabled())
|
if (!portalLayout.getDesktop().isServerPushEnabled())
|
||||||
portalLayout.getDesktop().enableServerPush(true);
|
portalLayout.getDesktop().enableServerPush(true);
|
||||||
|
|
||||||
|
if (!dashboardRunnable.isEmpty())
|
||||||
|
{
|
||||||
dashboardRunnable.refreshDashboard();
|
dashboardRunnable.refreshDashboard();
|
||||||
|
|
||||||
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
|
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
|
||||||
dashboardThread.setDaemon(true);
|
dashboardThread.setDaemon(true);
|
||||||
dashboardThread.start();
|
dashboardThread.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
|
@ -347,19 +388,14 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
{
|
{
|
||||||
ToolBarButton btn = (ToolBarButton) comp;
|
ToolBarButton btn = (ToolBarButton) comp;
|
||||||
|
|
||||||
int menuId = 0;
|
if (btn.getAttribute("AD_Menu_ID") != null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
menuId = Integer.valueOf(btn.getName());
|
int menuId = (Integer)btn.getAttribute("AD_Menu_ID");
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(menuId > 0) onMenuSelected(menuId);
|
if(menuId > 0) onMenuSelected(menuId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onServerPush(ServerPushTemplate template)
|
public void onServerPush(ServerPushTemplate template)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,8 +20,12 @@ import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.ServerContext;
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
import org.adempiere.webui.apps.BusyDialog;
|
||||||
import org.adempiere.webui.apps.ProcessDialog;
|
import org.adempiere.webui.apps.ProcessDialog;
|
||||||
import org.adempiere.webui.apps.graph.WGraph;
|
import org.adempiere.webui.apps.graph.WGraph;
|
||||||
import org.adempiere.webui.component.Accordion;
|
import org.adempiere.webui.component.Accordion;
|
||||||
|
@ -34,6 +38,7 @@ import org.adempiere.webui.event.MenuListener;
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
import org.adempiere.webui.panel.HeaderPanel;
|
import org.adempiere.webui.panel.HeaderPanel;
|
||||||
import org.adempiere.webui.panel.SidePanel;
|
import org.adempiere.webui.panel.SidePanel;
|
||||||
|
import org.adempiere.webui.session.SessionContextListener;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.adempiere.webui.util.IServerPushCallback;
|
import org.adempiere.webui.util.IServerPushCallback;
|
||||||
import org.adempiere.webui.util.ServerPushTemplate;
|
import org.adempiere.webui.util.ServerPushTemplate;
|
||||||
|
@ -97,6 +102,8 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
|
|
||||||
private int noOfWorkflow;
|
private int noOfWorkflow;
|
||||||
|
|
||||||
|
private Tabpanel homeTab;
|
||||||
|
|
||||||
public NavBar2Desktop()
|
public NavBar2Desktop()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -191,15 +198,48 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
|
|
||||||
windowContainer.createPart(windowArea);
|
windowContainer.createPart(windowArea);
|
||||||
|
|
||||||
createHomeTab();
|
homeTab = new Tabpanel();
|
||||||
|
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||||
|
BusyDialog busyDialog = new BusyDialog();
|
||||||
|
busyDialog.setShadow(false);
|
||||||
|
homeTab.appendChild(busyDialog);
|
||||||
|
|
||||||
|
if (!layout.getDesktop().isServerPushEnabled())
|
||||||
|
{
|
||||||
|
layout.getDesktop().enableServerPush(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
|
||||||
|
IServerPushCallback callback = new IServerPushCallback() {
|
||||||
|
public void updateUI() {
|
||||||
|
Properties ctx = (Properties)layout.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||||
|
try {
|
||||||
|
ServerContext.setCurrentInstance(ctx);
|
||||||
|
renderHomeTab();
|
||||||
|
} finally {
|
||||||
|
ServerContext.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ServerPushTemplate template = new ServerPushTemplate(layout.getDesktop());
|
||||||
|
template.execute(callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHomeTab()
|
private void renderHomeTab()
|
||||||
{
|
{
|
||||||
Tabpanel homeTab = new Tabpanel();
|
homeTab.getChildren().clear();
|
||||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
|
||||||
|
|
||||||
Portallayout portalLayout = new Portallayout();
|
Portallayout portalLayout = new Portallayout();
|
||||||
portalLayout.setWidth("100%");
|
portalLayout.setWidth("100%");
|
||||||
|
|
|
@ -20,8 +20,12 @@ import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.ServerContext;
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
import org.adempiere.webui.apps.BusyDialog;
|
||||||
import org.adempiere.webui.apps.ProcessDialog;
|
import org.adempiere.webui.apps.ProcessDialog;
|
||||||
import org.adempiere.webui.apps.graph.WGraph;
|
import org.adempiere.webui.apps.graph.WGraph;
|
||||||
import org.adempiere.webui.component.Accordion;
|
import org.adempiere.webui.component.Accordion;
|
||||||
|
@ -35,6 +39,7 @@ import org.adempiere.webui.event.MenuListener;
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
import org.adempiere.webui.panel.HeaderPanel;
|
import org.adempiere.webui.panel.HeaderPanel;
|
||||||
import org.adempiere.webui.panel.SidePanel;
|
import org.adempiere.webui.panel.SidePanel;
|
||||||
|
import org.adempiere.webui.session.SessionContextListener;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.adempiere.webui.util.IServerPushCallback;
|
import org.adempiere.webui.util.IServerPushCallback;
|
||||||
import org.adempiere.webui.util.ServerPushTemplate;
|
import org.adempiere.webui.util.ServerPushTemplate;
|
||||||
|
@ -107,6 +112,8 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
|
||||||
|
|
||||||
private int noOfWorkflow;
|
private int noOfWorkflow;
|
||||||
|
|
||||||
|
private Tabpanel homeTab;
|
||||||
|
|
||||||
public NavBarDesktop()
|
public NavBarDesktop()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -193,15 +200,48 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
|
||||||
|
|
||||||
windowContainer.createPart(windowArea);
|
windowContainer.createPart(windowArea);
|
||||||
|
|
||||||
createHomeTab();
|
homeTab = new Tabpanel();
|
||||||
|
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||||
|
BusyDialog busyDialog = new BusyDialog();
|
||||||
|
busyDialog.setShadow(false);
|
||||||
|
homeTab.appendChild(busyDialog);
|
||||||
|
|
||||||
|
if (!layout.getDesktop().isServerPushEnabled())
|
||||||
|
{
|
||||||
|
layout.getDesktop().enableServerPush(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
|
||||||
|
IServerPushCallback callback = new IServerPushCallback() {
|
||||||
|
public void updateUI() {
|
||||||
|
Properties ctx = (Properties)layout.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
|
||||||
|
try {
|
||||||
|
ServerContext.setCurrentInstance(ctx);
|
||||||
|
renderHomeTab();
|
||||||
|
} finally {
|
||||||
|
ServerContext.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ServerPushTemplate template = new ServerPushTemplate(layout.getDesktop());
|
||||||
|
template.execute(callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHomeTab()
|
private void renderHomeTab()
|
||||||
{
|
{
|
||||||
Tabpanel homeTab = new Tabpanel();
|
homeTab.getChildren().clear();
|
||||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
|
||||||
|
|
||||||
Portallayout portalLayout = new Portallayout();
|
Portallayout portalLayout = new Portallayout();
|
||||||
portalLayout.setWidth("100%");
|
portalLayout.setWidth("100%");
|
||||||
|
|
Loading…
Reference in New Issue