Adds graphic representation of the avaliability as a color progress bar and a icon for warning non-zero overload.

FEA: ItEr77S10ResourceAllocationLoadInformation
This commit is contained in:
Javier Moran Rua 2012-10-13 17:36:42 +02:00 committed by Manuel Rego Casasnovas
parent 3944232a98
commit c90fd3aaed
2 changed files with 49 additions and 2 deletions

View file

@ -57,6 +57,8 @@ import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.InputEvent;
import org.zkoss.zul.Constraint;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Div;
import org.zkoss.zul.Image;
import org.zkoss.zul.Label;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
@ -84,6 +86,11 @@ import org.zkoss.zul.Treerow;
public class NewAllocationSelectorController extends
AllocationSelectorController {
private static final BigDecimal AVALIABILITY_GOOD_VALUE = new BigDecimal(
0.50);
private static final BigDecimal AVALIABILITY_INTERMEDIUM_VALUE = new BigDecimal(
0.25);
private ResourceListRenderer resourceListRenderer = new ResourceListRenderer();
private Radiogroup allocationTypeSelector;
@ -592,14 +599,46 @@ public class NewAllocationSelectorController extends
Listcell cellAvailability = new Listcell();
BigDecimal availability = dataToRender.getRatios()
.getAvailiabilityRatio();
cellAvailability.appendChild(new Label(availability.toString()));
Div totalDiv = new Div();
totalDiv.setStyle("width:50px;height:12px;border: solid 1px black");
Div containedDiv = new Div();
String styleValue = "width:" + availability.movePointRight(2)
+ "%;height:12px;background-color:"
+ calculateRgba(availability) + ";float:left;left:0";
containedDiv.setStyle(styleValue);
Label l = new Label(availability.movePointRight(2).toString() + "%");
l.setStyle("width:50px;margin-left: 12px");
containedDiv.appendChild(l);
totalDiv.appendChild(containedDiv);
cellAvailability.appendChild(totalDiv);
item.appendChild(cellAvailability);
Listcell cellOvertime = new Listcell();
BigDecimal overtime = dataToRender.getRatios().getOvertimeRatio();
cellOvertime.appendChild(new Label(overtime.toString()));
Label overtimeLabel = new Label(overtime.toString());
cellOvertime.appendChild(overtimeLabel);
if (!overtime.equals(BigDecimal.ZERO.setScale(2))) {
overtimeLabel.setStyle("position: relative; top: -12px");
Image img = new Image(
"/dashboard/img/value-meaning-negative.png");
img.setStyle("width: 25px; position: relative; top: -5px");
cellOvertime.appendChild(img);
}
item.appendChild(cellOvertime);
}
private String calculateRgba(BigDecimal avaliability) {
String result;
if (avaliability.compareTo(AVALIABILITY_INTERMEDIUM_VALUE) < 0) {
result = "rgba(150,0,0,0.3)";
} else if (avaliability.compareTo(AVALIABILITY_GOOD_VALUE) < 0) {
result = "rgba(255,255,0,0.5)";
} else {
result = "rgba(102,204,0,0.3)";
}
return result;
}
}
public CriterionRenderer getCriterionRenderer() {

View file

@ -64,6 +64,14 @@
</row>
</rows>
</grid>
<style>
.z-listcell-cnt {
height: 20px;
}
div.z-listcell-cnt {
padding: 5px 0 1px 0;
}
</style>
<listbox id="listBoxResources" width="420px" height="340px"
vflex="true" multiple="@{selectorController.allowSelectMultipleResources}" style="margin:5px;"
itemRenderer="@{selectorController.listitemRenderer}" >