Add a new empty tab to the UI.

FEA: ItEr75S27PerProjectDashboard
This commit is contained in:
Nacho Barrientos 2011-11-14 17:43:05 +01:00 committed by Manuel Rego Casasnovas
parent 23d134ca22
commit edab490939
6 changed files with 262 additions and 1 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <ogonzalez@igalia.com>
* @author Nacho Barrientos <nacho@igalia.com>
*/
@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;
}
}

View file

@ -38,4 +38,6 @@ public interface IOrderPlanningGate {
void goToOrderDetails(Order order);
void goToDashboard(Order order);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <ogonzalez@igalia.com>
* @author Nacho Barrientos <nacho@igalia.com>
*
*/
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<String, Object> arguments = new HashMap<String, Object>();
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()));
}
};
}
}

View file

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

View file

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

View file

@ -0,0 +1,34 @@
<!--
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 <http://www.gnu.org/licenses/>.
-->
<zk>
<zscript><![CDATA[
dashboardController = arg.get("dashboardController");
]]>
</zscript>
<div self="@{define(content)}" >
<window apply="${dashboardController}">
<label id="testlabel"/>
</window>
</div>
</zk>