diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java index c31a00ece7..763b86aa63 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java @@ -15,28 +15,22 @@ import org.zkoss.zul.Div; import org.zkoss.zul.Label; public class WPAPanel extends Panel implements EventListener -{ +{ + /** * */ - private static final long serialVersionUID = -6491684272848160726L; + private static final long serialVersionUID = -6367672112341229048L; - public static WPAPanel get() - { - return get((WPerformanceIndicator.Options)null); - } - /** * Get Panel if User has Performance Goals * @return panel pr null */ - public static WPAPanel get(WPerformanceIndicator.Options options) + public static MGoal[] loadGoal() { int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID); - if (goals.length == 0) - return null; - return new WPAPanel(goals, options); + return goals; } /************************************************************************** @@ -44,9 +38,12 @@ public class WPAPanel extends Panel implements EventListener * @param goals * @param options */ - private WPAPanel (MGoal[] goals, Options options) + public WPAPanel () { super (); + } + + public void setGoals (MGoal[] goals, Options options){ m_goals = goals; init(options); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WViewPI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WViewPI.java index ba8f7386db..465ba35395 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WViewPI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WViewPI.java @@ -1,6 +1,7 @@ package org.adempiere.webui.apps.graph; import org.adempiere.webui.panel.ADForm; +import org.compiere.model.MGoal; public class WViewPI extends ADForm { @@ -13,8 +14,13 @@ public class WViewPI extends ADForm { protected void initForm() { this.setSclass("window-view-pi"); WPerformanceIndicator.Options options = new WPerformanceIndicator.Options(); - WPAPanel paPanel = WPAPanel.get(options); - if (paPanel != null) - appendChild(paPanel); + + WPAPanel paPanel = new WPAPanel(); + MGoal [] data = WPAPanel.loadGoal(); + if (data != null && data.length > 0){ + paPanel.setGoals (data, options); + appendChild(paPanel); + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java index c5f1b41d2f..48b4a2cc2b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPPerformance.java @@ -13,8 +13,14 @@ *****************************************************************************/ package org.adempiere.webui.dashboard; +import org.adempiere.util.ContextRunnable; +import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.apps.DesktopRunnable; import org.adempiere.webui.apps.graph.WPAPanel; +import org.adempiere.webui.apps.graph.WPerformanceIndicator.Options; import org.adempiere.webui.util.ServerPushTemplate; +import org.compiere.Adempiere; +import org.compiere.model.MGoal; import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.zkoss.zk.au.out.AuScript; @@ -37,27 +43,50 @@ public class DPPerformance extends DashboardPanel { */ private static final long serialVersionUID = -8878665031716441912L; + private WPAPanel paPanel; + public DPPerformance() { super(); setSclass("performance-widget"); - - WPAPanel paPanel = createPAPanel(); - if (paPanel != null) - { - this.appendChild(paPanel); - } + // have to add at least a child component, other it will be remove from DashboardController + // and can't update when finish load data + paPanel = new WPAPanel(); + appendChild(paPanel); + Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new LoadPerfomanceData(this), Executions.getCurrent().getDesktop())); } + + static class LoadPerfomanceData extends ContextRunnable{ + private DPPerformance parentCtr; + public LoadPerfomanceData (DPPerformance parentCtr){ + this.parentCtr = parentCtr; + } + + @Override + protected void doRun() { + MGoal [] performanceData = WPAPanel.loadGoal(); - protected WPAPanel createPAPanel() { - WPAPanel paPanel = WPAPanel.get(); - return paPanel; + AEnv.executeAsyncDesktopTask(new Runnable() { + @Override + public void run() { + if (performanceData != null && performanceData.length > 0){ + parentCtr.paPanel.setGoals(performanceData, (Options)null); + if (parentCtr.getAttribute(ON_POST_RENDER_ATTR) == null) { + parentCtr.setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE); + Events.echoEvent("onPostRender", parentCtr, null); + } + } + } + }); + + } + } public void refresh(ServerPushTemplate template) { super.refresh(template); if (Executions.getCurrent() != null) { - if (this.getAttribute(ON_POST_RENDER_ATTR) == null) { + if (this.getAttribute(ON_POST_RENDER_ATTR) == null && paPanel.getChildren().size() > 0) { setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE); Events.echoEvent("onPostRender", this, null); } @@ -69,7 +98,7 @@ public class DPPerformance extends DashboardPanel { super.onPageAttached(newpage, oldpage); if (newpage != null) { if (Executions.getCurrent() != null) { - if (this.getAttribute(ON_POST_RENDER_ATTR) == null) { + if (this.getAttribute(ON_POST_RENDER_ATTR) == null && paPanel.getChildren().size() > 0) { setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE); Events.echoEvent("onPostRender", this, null); }