From acc94293e6a3a91f0ef8553fd1a190f96e0be980 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 e42046604..5940ee20a 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 = true; - 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 562930da7..1cc9120d1 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 @@ -107,6 +107,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();