diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DashboardRunnable.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DashboardRunnable.java index 3f2171542b..c08749a9b1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DashboardRunnable.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DashboardRunnable.java @@ -197,4 +197,11 @@ public class DashboardRunnable implements Runnable, Serializable public void add(DashboardPanel dashboardPanel) { dashboardPanels.add(dashboardPanel); } + + /** + * @return boolean + */ + public boolean isEmpty() { + return dashboardPanels == null || dashboardPanels.isEmpty() ? true : false; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index efaf2f109d..7de826db54 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -22,8 +22,11 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Serializable; import java.net.URL; +import java.util.Properties; 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.WPerformanceDetail; 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.panel.HeaderPanel; import org.adempiere.webui.panel.SidePanel; +import org.adempiere.webui.session.SessionContextListener; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.IServerPushCallback; import org.adempiere.webui.util.ServerPushTemplate; @@ -76,7 +80,7 @@ import org.zkoss.zul.Toolbarbutton; public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback { /** - * generated serial version ID + * generated serial version ID */ private static final long serialVersionUID = -8203958978173990301L; @@ -96,6 +100,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria private int noOfWorkflow; + private Tabpanel homeTab; + public DefaultDesktop() { super(); @@ -133,7 +139,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria w.setSplittable(true); w.setTitle("Menu"); w.setFlex(true); - w.addEventListener(Events.ON_OPEN, new EventListener() { + w.addEventListener(Events.ON_OPEN, new EventListener() { @Override public void onEvent(Event event) throws Exception { OpenEvent oe = (OpenEvent) event; @@ -153,15 +159,48 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria 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; } - private void createHomeTab() + private void renderHomeTab() { - Tabpanel homeTab = new Tabpanel(); - windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); + homeTab.getChildren().clear(); Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%"); @@ -196,6 +235,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria Panel panel = new Panel(); panel.setStyle("margin-bottom:10px"); panel.setTitle(dp.getName()); + panel.setMaximizable(true); String description = dp.getDescription(); if(description != null) @@ -249,6 +289,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID)); I_AD_Menu menu = dp.getAD_Menu(); btn.setLabel(menu.getName()); + btn.setAttribute("AD_Menu_ID", AD_Menu_ID); btn.addEventListener(Events.ON_CLICK, this); content.appendChild(btn); panelEmpty = false; @@ -275,7 +316,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria String goalDisplay = dp.getGoalDisplay(); MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - WGraph graph = new WGraph(goal, 55, false, true, + WGraph graph = new WGraph(goal, 55, false, true, !(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); content.appendChild(graph); @@ -318,9 +359,6 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria { logger.log(Level.WARNING, "Failed to create dashboard content", e); } - finally - { - } // //register as 0 @@ -329,11 +367,14 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria if (!portalLayout.getDesktop().isServerPushEnabled()) portalLayout.getDesktop().enableServerPush(true); - dashboardRunnable.refreshDashboard(); + if (!dashboardRunnable.isEmpty()) + { + dashboardRunnable.refreshDashboard(); - dashboardThread = new Thread(dashboardRunnable, "UpdateInfo"); - dashboardThread.setDaemon(true); - dashboardThread.start(); + dashboardThread = new Thread(dashboardRunnable, "UpdateInfo"); + dashboardThread.setDaemon(true); + dashboardThread.start(); + } } public void onEvent(Event event) @@ -347,16 +388,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria { ToolBarButton btn = (ToolBarButton) comp; - int menuId = 0; - try + if (btn.getAttribute("AD_Menu_ID") != null) { - menuId = Integer.valueOf(btn.getName()); + int menuId = (Integer)btn.getAttribute("AD_Menu_ID"); + if(menuId > 0) onMenuSelected(menuId); } - catch (Exception e) { - - } - - if(menuId > 0) onMenuSelected(menuId); } } } @@ -414,7 +450,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria + ", " + Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest + ", " + Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow); } - + private void autoHideMenu() { if (layout.getWest().isCollapsible() && !layout.getWest().isOpen()) { @@ -431,8 +467,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria } @Override - protected void preOpenNewTab() + protected void preOpenNewTab() { autoHideMenu(); - } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java index fc1c4e69ab..27a294fe76 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java @@ -20,8 +20,12 @@ import java.io.Serializable; import java.net.URL; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.Properties; 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.graph.WGraph; 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.HeaderPanel; import org.adempiere.webui.panel.SidePanel; +import org.adempiere.webui.session.SessionContextListener; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.IServerPushCallback; import org.adempiere.webui.util.ServerPushTemplate; @@ -97,6 +102,8 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria private int noOfWorkflow; + private Tabpanel homeTab; + public NavBar2Desktop() { super(); @@ -191,15 +198,48 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria 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; } - private void createHomeTab() + private void renderHomeTab() { - Tabpanel homeTab = new Tabpanel(); - windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); + homeTab.getChildren().clear(); Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java index 650f3f8af3..2fa446e6b3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java @@ -20,8 +20,12 @@ import java.io.Serializable; import java.net.URL; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.Properties; 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.graph.WGraph; 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.HeaderPanel; import org.adempiere.webui.panel.SidePanel; +import org.adempiere.webui.session.SessionContextListener; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.IServerPushCallback; import org.adempiere.webui.util.ServerPushTemplate; @@ -107,6 +112,8 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial private int noOfWorkflow; + private Tabpanel homeTab; + public NavBarDesktop() { super(); @@ -193,15 +200,48 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial 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; } - private void createHomeTab() + private void renderHomeTab() { - Tabpanel homeTab = new Tabpanel(); - windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); + homeTab.getChildren().clear(); Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%");