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
This commit is contained in:
Jacobo Aragunde Pérez 2010-09-08 19:59:26 +02:00 committed by Farruco Sanjurjo
parent edf67c3fea
commit 09e62a9d2d
2 changed files with 35 additions and 5 deletions

View file

@ -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;

View file

@ -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<TaskElement> doubleClickCommand,
IPredicate predicate) {
PlannerConfiguration<TaskElement> configuration = createConfiguration(predicate);
configuration.setExpandPlanningViewCharts(configurationDAO
.getConfiguration().isExpandCompanyPlanningViewCharts());
final PlannerConfiguration<TaskElement> 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<Void>() {
@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();