IDEMPIERE-3194:prepare data of perfomance gadget should do on thread
just work-around better complete implement IDEMPIERE-348.
This commit is contained in:
parent
123e2074c8
commit
79f3e4e8f4
|
@ -15,28 +15,22 @@ import org.zkoss.zul.Div;
|
||||||
import org.zkoss.zul.Label;
|
import org.zkoss.zul.Label;
|
||||||
|
|
||||||
public class WPAPanel extends Panel implements EventListener<Event>
|
public class WPAPanel extends Panel implements EventListener<Event>
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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
|
* Get Panel if User has Performance Goals
|
||||||
* @return panel pr null
|
* @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());
|
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
|
||||||
MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID);
|
MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID);
|
||||||
if (goals.length == 0)
|
return goals;
|
||||||
return null;
|
|
||||||
return new WPAPanel(goals, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -44,9 +38,12 @@ public class WPAPanel extends Panel implements EventListener<Event>
|
||||||
* @param goals
|
* @param goals
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
private WPAPanel (MGoal[] goals, Options options)
|
public WPAPanel ()
|
||||||
{
|
{
|
||||||
super ();
|
super ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoals (MGoal[] goals, Options options){
|
||||||
m_goals = goals;
|
m_goals = goals;
|
||||||
init(options);
|
init(options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.adempiere.webui.apps.graph;
|
package org.adempiere.webui.apps.graph;
|
||||||
|
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
|
import org.compiere.model.MGoal;
|
||||||
|
|
||||||
public class WViewPI extends ADForm {
|
public class WViewPI extends ADForm {
|
||||||
|
|
||||||
|
@ -13,8 +14,13 @@ public class WViewPI extends ADForm {
|
||||||
protected void initForm() {
|
protected void initForm() {
|
||||||
this.setSclass("window-view-pi");
|
this.setSclass("window-view-pi");
|
||||||
WPerformanceIndicator.Options options = new WPerformanceIndicator.Options();
|
WPerformanceIndicator.Options options = new WPerformanceIndicator.Options();
|
||||||
WPAPanel paPanel = WPAPanel.get(options);
|
|
||||||
if (paPanel != null)
|
WPAPanel paPanel = new WPAPanel();
|
||||||
appendChild(paPanel);
|
MGoal [] data = WPAPanel.loadGoal();
|
||||||
|
if (data != null && data.length > 0){
|
||||||
|
paPanel.setGoals (data, options);
|
||||||
|
appendChild(paPanel);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,14 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.dashboard;
|
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.WPAPanel;
|
||||||
|
import org.adempiere.webui.apps.graph.WPerformanceIndicator.Options;
|
||||||
import org.adempiere.webui.util.ServerPushTemplate;
|
import org.adempiere.webui.util.ServerPushTemplate;
|
||||||
|
import org.compiere.Adempiere;
|
||||||
|
import org.compiere.model.MGoal;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.au.out.AuScript;
|
import org.zkoss.zk.au.out.AuScript;
|
||||||
|
@ -37,27 +43,50 @@ public class DPPerformance extends DashboardPanel {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -8878665031716441912L;
|
private static final long serialVersionUID = -8878665031716441912L;
|
||||||
|
|
||||||
|
private WPAPanel paPanel;
|
||||||
|
|
||||||
public DPPerformance()
|
public DPPerformance()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
setSclass("performance-widget");
|
setSclass("performance-widget");
|
||||||
|
// have to add at least a child component, other it will be remove from DashboardController
|
||||||
WPAPanel paPanel = createPAPanel();
|
// and can't update when finish load data
|
||||||
if (paPanel != null)
|
paPanel = new WPAPanel();
|
||||||
{
|
appendChild(paPanel);
|
||||||
this.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() {
|
AEnv.executeAsyncDesktopTask(new Runnable() {
|
||||||
WPAPanel paPanel = WPAPanel.get();
|
@Override
|
||||||
return paPanel;
|
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) {
|
public void refresh(ServerPushTemplate template) {
|
||||||
super.refresh(template);
|
super.refresh(template);
|
||||||
if (Executions.getCurrent() != 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);
|
setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE);
|
||||||
Events.echoEvent("onPostRender", this, null);
|
Events.echoEvent("onPostRender", this, null);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +98,7 @@ public class DPPerformance extends DashboardPanel {
|
||||||
super.onPageAttached(newpage, oldpage);
|
super.onPageAttached(newpage, oldpage);
|
||||||
if (newpage != null) {
|
if (newpage != null) {
|
||||||
if (Executions.getCurrent() != 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);
|
setAttribute(ON_POST_RENDER_ATTR, Boolean.TRUE);
|
||||||
Events.echoEvent("onPostRender", this, null);
|
Events.echoEvent("onPostRender", this, null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue