Add new money cost bar at this moment using value, icon and color of reported hours

FEA: ItEr76S17MoneyCostMonitoringSystem
This commit is contained in:
Manuel Rego Casasnovas 2012-03-16 11:51:32 +01:00
parent b3eec587da
commit abb5851afb
15 changed files with 204 additions and 12 deletions

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -227,6 +227,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
}
result.setShowingReportedHours(planner.showReportedHoursRightNow());
result.setShowingMoneyCostBar(planner.showMoneyCostBarRightNow());
result.setShowingAdvances(planner.showAdvancesRightNow());
mapper.register(position, result, data);
@ -465,6 +466,20 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
}
}
@Override
public void showMoneyCostBar() {
for (Task task : diagramGraph.getTasks()) {
task.setShowingMoneyCostBar(true);
}
}
@Override
public void hideMoneyCostBar() {
for (Task task : diagramGraph.getTasks()) {
task.setShowingMoneyCostBar(false);
}
}
@Override
public void reloadCharts() {
configuration.reloadCharts();

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -120,6 +120,15 @@ public class Planner extends HtmlMacroComponent {
return toLowercaseSet(values).contains("all");
}
public static boolean guessShowMoneyCostBarByDefault(
Map<String, String[]> queryURLParameters) {
String[] values = queryURLParameters.get("moneyCostBar");
if (values == null) {
return false;
}
return toLowercaseSet(values).contains("all");
}
private static Set<String> toLowercaseSet(String[] values) {
Set<String> result = new HashSet<String>();
for (String each : values) {
@ -156,6 +165,8 @@ public class Planner extends HtmlMacroComponent {
private boolean isShowingReportedHours = false;
private boolean isShowingMoneyCostBar = false;
private boolean isShowingResources = false;
private boolean isExpandAll = false;
@ -571,12 +582,22 @@ public class Planner extends HtmlMacroComponent {
}
};
private IGraphChangeListener showMoneyCostBarOnChange = new IGraphChangeListener() {
@Override
public void execute() {
context.showMoneyCostBar();
}
};
private boolean containersExpandedByDefault = false;
private boolean shownAdvanceByDefault = false;
private boolean shownReportedHoursByDefault = false;
private boolean shownMoneyCostBarByDefault = false;
private FilterAndParentExpandedPredicates predicate;
private boolean visibleChart;
@ -645,6 +666,26 @@ public class Planner extends HtmlMacroComponent {
}
}
public void showMoneyCostBar() {
Button showMoneyCostBarButton = (Button) getFellow("showMoneyCostBar");
if (disabilityConfiguration.isMoneyCostBarEnabled()) {
if (isShowingMoneyCostBar) {
context.hideMoneyCostBar();
diagramGraph
.removePostGraphChangeListener(showMoneyCostBarOnChange);
showMoneyCostBarButton.setSclass("planner-command");
showMoneyCostBarButton.setTooltiptext(_("Show money cost bar"));
} else {
context.showMoneyCostBar();
diagramGraph
.addPostGraphChangeListener(showMoneyCostBarOnChange);
showMoneyCostBarButton.setSclass("planner-command clicked");
showMoneyCostBarButton.setTooltiptext(_("Hide money cost bar"));
}
isShowingMoneyCostBar = !isShowingMoneyCostBar;
}
}
public void showAllLabels() {
Button showAllLabelsButton = (Button) getFellow("showAllLabels");
if (isShowingLabels) {
@ -732,6 +773,19 @@ public class Planner extends HtmlMacroComponent {
return (areShownReportedHoursByDefault() || isShowingReportedHours);
}
public void setAreShownMoneyCostBarByDefault(
boolean shownMoneyCostBarByDefault) {
this.shownMoneyCostBarByDefault = shownMoneyCostBarByDefault;
}
public boolean areShownMoneyCostBarByDefault() {
return shownMoneyCostBarByDefault;
}
public boolean showMoneyCostBarRightNow() {
return (areShownMoneyCostBarByDefault() || isShowingMoneyCostBar);
}
public void expandAll() {
Button expandAllButton = (Button) getFellow("expandAll");
if (disabilityConfiguration.isExpandAllEnabled()) {

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -58,6 +58,7 @@ import org.zkoss.zul.Div;
* Graphical component which represents a {@link Task}.
*
* @author Javier Morán Rúa <jmoran@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public class TaskComponent extends Div implements AfterCompose {
@ -76,6 +77,8 @@ public class TaskComponent extends Div implements AfterCompose {
private PropertyChangeListener showingReportedHoursPropertyListener;
private PropertyChangeListener showingMoneyCostBarPropertyListener;
public static TaskComponent asTaskComponent(Task task,
IDisabilityConfiguration disabilityConfiguration,
boolean isTopLevel) {
@ -276,6 +279,20 @@ public class TaskComponent extends Div implements AfterCompose {
this.task
.addReportedHoursPropertyChangeListener(showingReportedHoursPropertyListener);
if (showingMoneyCostBarPropertyListener == null) {
showingMoneyCostBarPropertyListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (isInPage() && !(task instanceof Milestone)) {
updateCompletionMoneyCostBar();
}
}
};
}
this.task
.addMoneyCostBarPropertyChangeListener(showingMoneyCostBarPropertyListener);
if (criticalPathPropertyListener == null) {
criticalPathPropertyListener = new PropertyChangeListener() {
@ -483,6 +500,7 @@ public class TaskComponent extends Div implements AfterCompose {
return;
}
updateCompletionReportedHours();
updateCompletionMoneyCostBar();
updateCompletionAdvance();
}
@ -499,6 +517,20 @@ public class TaskComponent extends Div implements AfterCompose {
}
}
public void updateCompletionMoneyCostBar() {
if (task.isShowingMoneyCostBar()) {
int startPixels = this.task.getBeginDate().toPixels(getMapper());
// TODO change method, for the moment using getHoursAdvanceEndDate()
String widthMoneyCostBar = pixelsFromStartUntil(
startPixels, this.task.getHoursAdvanceEndDate()) + "px";
response(null, new AuInvoke(this, "resizeCompletionMoneyCostBar",
widthMoneyCostBar));
} else {
response(null, new AuInvoke(this, "resizeCompletionMoneyCostBar",
"0px"));
}
}
private void updateCompletionAdvance() {
if (task.isShowingAdvances()) {
int startPixels = this.task.getBeginDate().toPixels(getMapper());

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -22,7 +22,7 @@ package org.zkoss.ganttz.adapters;
/**
* @author Óscar González Fernández <ogonzalez@igalia.com>
*
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public interface IDisabilityConfiguration {
@ -40,6 +40,8 @@ public interface IDisabilityConfiguration {
public boolean isReportedHoursEnabled();
public boolean isMoneyCostBarEnabled();
public boolean isExpandAllEnabled();
public boolean isFlattenTreeEnabled();

View file

@ -148,6 +148,8 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
private boolean reportedHoursEnabled = true;
private boolean moneyCostBarEnabled = true;
private boolean expandAllEnabled = true;
private boolean flattenTreeEnabled = true;
@ -345,6 +347,15 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
return reportedHoursEnabled;
}
public void setMoneyCostBarEnabled(boolean moneyCostBarEnabled) {
this.moneyCostBarEnabled = moneyCostBarEnabled;
}
@Override
public boolean isMoneyCostBarEnabled() {
return moneyCostBarEnabled;
}
public void setExpandAllEnabled(boolean expandAllEnabled) {
this.expandAllEnabled = expandAllEnabled;
}

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -32,7 +32,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.Validate;
import org.joda.time.Duration;
import org.joda.time.LocalDate;
@ -48,7 +47,9 @@ import org.zkoss.ganttz.util.WeakReferencedListeners.Mode;
/**
* This class contains the information of a task. It can be modified and
* notifies of the changes to the interested parties. <br/>
*
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public abstract class Task implements ITaskFundamentalProperties {
@ -73,6 +74,9 @@ public abstract class Task implements ITaskFundamentalProperties {
private PropertyChangeSupport reportedHoursProperty = new PropertyChangeSupport(
this);
private PropertyChangeSupport moneyCostBarProperty = new PropertyChangeSupport(
this);
private final ITaskFundamentalProperties fundamentalProperties;
private boolean visible = true;
@ -83,6 +87,8 @@ public abstract class Task implements ITaskFundamentalProperties {
private boolean showingReportedHours = false;
private boolean showingMoneyCostBar = false;
private ConstraintViolationNotificator<GanttDate> violationNotificator = ConstraintViolationNotificator
.create();
@ -178,6 +184,17 @@ public abstract class Task implements ITaskFundamentalProperties {
return showingReportedHours;
}
public void setShowingMoneyCostBar(boolean showingMoneyCostBar) {
boolean previousValue = this.showingMoneyCostBar;
this.showingMoneyCostBar = showingMoneyCostBar;
moneyCostBarProperty.firePropertyChange("showingMoneyCostBar",
previousValue, this.showingMoneyCostBar);
}
public boolean isShowingMoneyCostBar() {
return showingMoneyCostBar;
}
public String getName() {
return fundamentalProperties.getName();
}
@ -242,6 +259,11 @@ public abstract class Task implements ITaskFundamentalProperties {
this.reportedHoursProperty.addPropertyChangeListener(listener);
}
public void addMoneyCostBarPropertyChangeListener(
PropertyChangeListener listener) {
this.moneyCostBarProperty.addPropertyChangeListener(listener);
}
public void addFundamentalPropertiesChangeListener(
PropertyChangeListener listener) {
this.fundamentalPropertiesListeners.addPropertyChangeListener(listener);

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -35,7 +35,9 @@ import org.zkoss.zk.ui.Component;
/**
* An implementation of {@link IContext} that delegates to another context and
* redefines its {@link IContext#getRelativeTo()}
*
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public class ContextRelativeToOtherComponent<T> implements IContext<T> {
@ -147,4 +149,15 @@ public class ContextRelativeToOtherComponent<T> implements IContext<T> {
public void showReportedHours() {
context.showReportedHours();
}
@Override
public void hideMoneyCostBar() {
context.hideMoneyCostBar();
}
@Override
public void showMoneyCostBar() {
context.showMoneyCostBar();
}
}

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -36,7 +36,9 @@ import org.zkoss.zk.ui.Component;
* An implementation of {@link IContextWithPlannerTask} that wraps another
* context and specifies the task to be returned by
* {@link IContextWithPlannerTask#getTask()}
*
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public class ContextWithPlannerTask<T> implements IContextWithPlannerTask<T> {
@ -149,4 +151,15 @@ public class ContextWithPlannerTask<T> implements IContextWithPlannerTask<T> {
public void showReportedHours() {
context.showReportedHours();
}
@Override
public void hideMoneyCostBar() {
context.hideMoneyCostBar();
}
@Override
public void showMoneyCostBar() {
context.showMoneyCostBar();
}
}

View file

@ -3,7 +3,7 @@
*
* 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.
* Copyright (C) 2010-2012 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
@ -38,7 +38,9 @@ import org.zkoss.zk.ui.Component;
/**
* A facade for operations allowed to extensions <br />
*
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public interface IContext<T> {
@ -143,4 +145,9 @@ public interface IContext<T> {
void showReportedHours();
void hideReportedHours();
void showMoneyCostBar();
void hideMoneyCostBar();
}

View file

@ -3,7 +3,7 @@
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.
Copyright (C) 2010-2012 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
@ -86,6 +86,13 @@ planner = self;
sclass="planner-command"/>
<separator />
<!-- TODO change icon -->
<button id="showMoneyCostBar" onClick="planner.showMoneyCostBar();"
image="/common/img/ico_costs.png"
tooltiptext="${ganttzk_i18n:_('Show/Hide money cost bar')}"
sclass="planner-command"/>
<separator />
<!-- Filtering -->
<vbox id="orderFilter"/>
<vbox id="orderElementFilter"/>

View file

@ -215,6 +215,9 @@ ganttz.TaskComponent = zk.$extends(zul.Widget, {
moveConsolidatedline : function(width){
jq('#consolidatedline' + this.parent.uuid).css('left', width);
},
resizeCompletionMoneyCostBar : function(width){
jq('#' + this.uuid + ' .completionMoneyCostBar:first').css('width', width);
},
resizeCompletionAdvance : function(width){
jq('#' + this.uuid + ' .completion:first').css('width', width);
},

View file

@ -5,6 +5,7 @@ function(out){
'z.autoz="true"',
'class="milestone"',
'>');
out.push('<div class="completionMoneyCostBar"></div>');
out.push('<div class="completion"></div>');
out.push('<div class="completion2"></div>');
out.push('<div class="milestone_end"></div>');

View file

@ -11,6 +11,7 @@ function(out){
out.push('<div class="task-resources-inner">', this.getResourcesText(),'</div>');
out.push('</div>');
out.push('<div class="completionMoneyCostBar"></div>');
out.push('<div class="completion"></div>');
out.push('<div class="completion2"></div>');

View file

@ -22,6 +22,7 @@ function(out){
'</div>');
out.push('<div class="taskcontainer_completion">',
'<div class="completionMoneyCostBar"></div>',
'<div class="completion"></div>',
'<div class="completion2"></div>',
'</div>');

View file

@ -258,6 +258,16 @@ div.box.limiting-unassigned {
opacity: 0.2;
}
.completionMoneyCostBar {
width: 0%;
margin-top: 0px;
height: 3px; /* zkTasklist.HEIGHT_PER_TASK / 2 */
/* TODO change color and review position */
background-color: #F21CFF;
border: 0px;
margin-top: -5px;
}
.completion {
width: 0%;
margin-top: 0px;
@ -1362,4 +1372,4 @@ div.z-grid-header .second_level_ tr {
.plannergraph .timeplot-timeflag {
opacity: 1 !important;
font-size: 12px;
}
}