From edab490939a79a7383ca90aeff1bbd60bb19836c Mon Sep 17 00:00:00 2001 From: Nacho Barrientos Date: Mon, 14 Nov 2011 17:43:05 +0100 Subject: [PATCH] Add a new empty tab to the UI. FEA: ItEr75S27PerProjectDashboard --- .../web/dashboard/DashboardController.java | 62 ++++++++++ .../web/planner/order/IOrderPlanningGate.java | 2 + .../web/planner/tabs/DashboardTabCreator.java | 115 ++++++++++++++++++ .../tabs/MultipleTabsPlannerController.java | 46 ++++++- .../main/webapp/common/css/libreplan_zk.css | 4 + .../webapp/dashboard/_dashboardfororder.zul | 34 ++++++ 6 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java create mode 100644 libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/DashboardTabCreator.java create mode 100644 libreplan-webapp/src/main/webapp/dashboard/_dashboardfororder.zul diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java new file mode 100644 index 000000000..9bc55bba7 --- /dev/null +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java @@ -0,0 +1,62 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.web.dashboard; + +import org.libreplan.business.orders.entities.Order; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zul.Label; + +/** + * Controller for global resourceload view + * @author Óscar González Fernández + * @author Nacho Barrientos + */ +@Component +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class DashboardController extends GenericForwardComposer { + + //@Autowired + //private IResourceLoadModel resourceLoadModel; + + private Label testlabel; + + private org.zkoss.zk.ui.Component parent; + + private Order order; + + public DashboardController() { + } + + @Override + public void doAfterCompose(org.zkoss.zk.ui.Component comp) throws Exception { + super.doAfterCompose(comp); + this.parent = comp; + this.testlabel.setValue("hello world"); + } + + public void setCurrentOrder(Order order) { + this.order = order; + } +} diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/IOrderPlanningGate.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/IOrderPlanningGate.java index 2d136505b..dd8372e3d 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/IOrderPlanningGate.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/IOrderPlanningGate.java @@ -38,4 +38,6 @@ public interface IOrderPlanningGate { void goToOrderDetails(Order order); + void goToDashboard(Order order); + } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/DashboardTabCreator.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/DashboardTabCreator.java new file mode 100644 index 000000000..a20551b67 --- /dev/null +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/DashboardTabCreator.java @@ -0,0 +1,115 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.libreplan.web.planner.tabs; + +import static org.libreplan.web.I18nHelper._; +import static org.libreplan.web.planner.tabs.MultipleTabsPlannerController.BREADCRUMBS_SEPARATOR; +import static org.libreplan.web.planner.tabs.MultipleTabsPlannerController.getSchedulingLabel; + +import java.util.HashMap; +import java.util.Map; + +import org.libreplan.business.orders.entities.Order; +import org.libreplan.web.dashboard.DashboardController; +import org.libreplan.web.planner.order.IOrderPlanningGate; +import org.libreplan.web.planner.order.OrderPlanningController; +import org.libreplan.web.planner.tabs.CreatedOnDemandTab.IComponentCreator; +import org.zkoss.ganttz.extensions.ITab; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zul.Image; +import org.zkoss.zul.Label; + +/** + * @author Óscar González Fernández + * @author Nacho Barrientos + * + */ +public class DashboardTabCreator { + + private final IOrderPlanningGate orderPlanningGate; + + public static ITab create(Mode mode, + DashboardController dashboardController, + OrderPlanningController orderPlanningController, + Component breadcrumbs, + IOrderPlanningGate orderPlanningGate) { + return new DashboardTabCreator(mode, dashboardController, + orderPlanningController, orderPlanningGate, + breadcrumbs) + .build(); + } + + private final Mode mode; + private final DashboardController dashboardController; + private final OrderPlanningController orderPlanningController; + private final Component breadcrumbs; + + private DashboardTabCreator(Mode mode, + DashboardController dashboardController, + OrderPlanningController orderPlanningController, + IOrderPlanningGate orderPlanningGate, + Component breadcrumbs) { + this.mode = mode; + this.dashboardController = dashboardController; + this.orderPlanningController = orderPlanningController; + this.orderPlanningGate = orderPlanningGate; + this.breadcrumbs = breadcrumbs; + } + + private ITab build() { + return TabOnModeType.forMode(mode) + .forType(ModeType.GLOBAL, createDashboardTab()) + .forType(ModeType.ORDER, createDashboardTab()) + .create(); + } + + private ITab createDashboardTab() { + IComponentCreator componentCreator = new IComponentCreator() { + + @Override + public org.zkoss.zk.ui.Component create( + org.zkoss.zk.ui.Component parent) { + Map arguments = new HashMap(); + arguments.put("dashboardController", dashboardController); + return Executions.createComponents( + "/dashboard/_dashboardfororder.zul", parent, + arguments); + } + + }; + return new CreatedOnDemandTab(_("Order Dashboard"), "order-dashboard", + componentCreator) { + + @Override + protected void afterShowAction() { + Order order = orderPlanningController.getOrder(); + dashboardController.setCurrentOrder(order); + breadcrumbs.getChildren().clear(); + breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR)); + breadcrumbs.appendChild(new Label(getSchedulingLabel())); + breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR)); + breadcrumbs.appendChild(new Label(_("Order Dashboard"))); + breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR)); + Order currentOrder = mode.getOrder(); + breadcrumbs.appendChild(new Label(currentOrder.getName())); + } + }; + } +} diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java index 4f6733851..bc6deebbc 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java @@ -36,6 +36,7 @@ import org.libreplan.business.templates.entities.OrderTemplate; import org.libreplan.business.users.entities.UserRole; import org.libreplan.web.common.entrypoints.EntryPointsHandler; import org.libreplan.web.common.entrypoints.URLHandlerRegistry; +import org.libreplan.web.dashboard.DashboardController; import org.libreplan.web.limitingresources.LimitingResourcesController; import org.libreplan.web.montecarlo.MonteCarloController; import org.libreplan.web.orders.OrderCRUDController; @@ -159,6 +160,8 @@ public class MultipleTabsPlannerController implements Composer, private ITab advancedAllocationTab; + private ITab dashboardTab; + private TabSwitcher tabsSwitcher; @Autowired @@ -179,6 +182,9 @@ public class MultipleTabsPlannerController implements Composer, @Autowired private LimitingResourcesController limitingResourcesControllerGlobal; + @Autowired + private DashboardController dashboardController; + private org.zkoss.zk.ui.Component breadcrumbs; @Autowired @@ -227,6 +233,11 @@ public class MultipleTabsPlannerController implements Composer, .show(planningTab, changeModeTo(order)); } + @Override + public void goToDashboard(Order order) { + // do nothing + } + }, breadcrumbs); limitingResourcesTab = LimitingResourcesTabCreator.create(mode, @@ -253,8 +264,40 @@ public class MultipleTabsPlannerController implements Composer, // do nothing } + @Override + public void goToDashboard(Order order) { + // do nothing + } + }, parameters); + dashboardTab = DashboardTabCreator.create(mode, dashboardController, orderPlanningController, + breadcrumbs, new IOrderPlanningGate() { + + @Override + public void goToScheduleOf(Order order) { + getTabsRegistry() + .show(planningTab, changeModeTo(order)); + } + + @Override + public void goToOrderDetails(Order order) { + getTabsRegistry().show(ordersTab, changeModeTo(order)); + } + + @Override + public void goToTaskResourceAllocation(Order order, + TaskElement task) { + // do nothing + } + + @Override + public void goToDashboard(Order order) { + // do nothing + } + + }); + final boolean isMontecarloVisible = isMonteCarloVisible(); if (isMontecarloVisible) { monteCarloTab = MonteCarloTabCreator.create(mode, @@ -273,7 +316,8 @@ public class MultipleTabsPlannerController implements Composer, .add(tabWithNameReloading(ordersTab, typeChanged)) .add(tabWithNameReloading(resourceLoadTab, typeChanged)) .add(tabWithNameReloading(limitingResourcesTab, typeChanged)) - .add(visibleOnlyAtOrderMode(advancedAllocationTab)); + .add(visibleOnlyAtOrderMode(advancedAllocationTab)) + .add(visibleOnlyAtOrderMode(dashboardTab)); if (isMontecarloVisible) { tabsConfiguration.add(visibleOnlyAtOrderMode(monteCarloTab)); diff --git a/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css b/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css index e82d33338..a8fc480aa 100644 --- a/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css +++ b/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css @@ -1046,6 +1046,10 @@ span.perspective, span.perspective-active { .perspective-active.montecarlo-simulation .z-button-cm { background-image: url(../img/ico_montecarlo-simulation.png); } +.perspective.order-dashboard .z-button-cm, +.perspective-active.order-dashboard .z-button-cm { + background-image: url(../img/ico_order-data.png); +} .perspectives-column { diff --git a/libreplan-webapp/src/main/webapp/dashboard/_dashboardfororder.zul b/libreplan-webapp/src/main/webapp/dashboard/_dashboardfororder.zul new file mode 100644 index 000000000..81ace357c --- /dev/null +++ b/libreplan-webapp/src/main/webapp/dashboard/_dashboardfororder.zul @@ -0,0 +1,34 @@ + + + + + + +
+ + + +
+ +
\ No newline at end of file