From 09e62a9d2d5f38551acbef9082e574ddcda12b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Wed, 8 Sep 2010 19:59:26 +0200 Subject: [PATCH] Delay the construction and data retrieval for the charts below the company view until they are actually shown. The charts have also been configured to be hidden by default, to boost the load of the initial screen. FEA: ItEr60S17CambiosPantallaVistaEmpresa --- .../common/entities/Configuration.java | 2 +- .../planner/company/CompanyPlanningModel.java | 38 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/common/entities/Configuration.java b/navalplanner-business/src/main/java/org/navalplanner/business/common/entities/Configuration.java index 6efaca980..72e7a978d 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/common/entities/Configuration.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/common/entities/Configuration.java @@ -55,7 +55,7 @@ public class Configuration extends BaseEntity { private Boolean generateCodeForUnitTypes = false; - private Boolean expandCompanyPlanningViewCharts = true; + private Boolean expandCompanyPlanningViewCharts = false; private Boolean expandOrderPlanningViewCharts = true; diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/company/CompanyPlanningModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/company/CompanyPlanningModel.java index c29cb2428..b81c14de9 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/company/CompanyPlanningModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/company/CompanyPlanningModel.java @@ -105,6 +105,7 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zkex.zul.api.South; import org.zkoss.zul.Button; import org.zkoss.zul.Checkbox; import org.zkoss.zul.Datebox; @@ -225,11 +226,12 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel { ICommandOnTask doubleClickCommand, IPredicate predicate) { - PlannerConfiguration configuration = createConfiguration(predicate); - configuration.setExpandPlanningViewCharts(configurationDAO - .getConfiguration().isExpandCompanyPlanningViewCharts()); + final PlannerConfiguration configuration = createConfiguration(predicate); + boolean expandPlanningViewChart = configurationDAO. + getConfiguration().isExpandCompanyPlanningViewCharts(); + configuration.setExpandPlanningViewCharts(expandPlanningViewChart); - Tabbox chartComponent = new Tabbox(); + final Tabbox chartComponent = new Tabbox(); chartComponent.setOrient("vertical"); chartComponent.setHeight("200px"); appendTabs(chartComponent); @@ -303,6 +305,34 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel { configuration.setSecondLevelModificators(new BankHolidaysMarker()); planner.setConfiguration(configuration); + + if(expandPlanningViewChart) { + //if the chart is expanded, we load the data now + setupChartAndItsContent(planner, chartComponent); + } + else { + //if the chart is not expanded, we load the data later with a listener + ((South) planner.getFellow("graphics")).addEventListener("onOpen", + new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + transactionService + .runOnReadOnlyTransaction(new IOnTransaction() { + @Override + public Void execute() { + setupChartAndItsContent(planner, chartComponent); + return null; + } + }); + //data is loaded only once, then we remove the listener + event.getTarget().removeEventListener("onOpen", this); + } + }); + } + } + + private void setupChartAndItsContent(Planner planner, + Tabbox chartComponent) { Timeplot chartLoadTimeplot = createEmptyTimeplot(); Timeplot chartEarnedValueTimeplot = createEmptyTimeplot(); CompanyEarnedValueChartFiller earnedValueChartFiller = new CompanyEarnedValueChartFiller();