Improved list header generation editing an OrderElement. Now it's generated just one time and not for every HoursGroup.

This commit is contained in:
Manuel Rego Casasnovas 2009-08-06 10:13:27 +02:00 committed by Javier Moran Rua
parent 3d1d6fb9ab
commit 329a417894

View file

@ -233,6 +233,7 @@ public class OrderElementController extends GenericForwardComposer {
window.getFellow("hoursGroupsListbox").invalidate();
Util.reloadBindings(window);
generateListhead();
try {
window.doModal();
@ -341,6 +342,7 @@ public class OrderElementController extends GenericForwardComposer {
Set<CriterionType> selectedCriterionTypes) {
this.selectedCriterionTypes = selectedCriterionTypes;
Util.reloadBindings(window);
generateListhead();
}
/**
@ -399,8 +401,6 @@ public class OrderElementController extends GenericForwardComposer {
item.setValue(hoursGroup);
generateListhead(((Listbox) item.getParent()).getListheadApi());
Listcell cellWorkingHours = new Listcell();
cellWorkingHours.setParent(item);
Listcell cellPercentage = new Listcell();
@ -634,39 +634,6 @@ public class OrderElementController extends GenericForwardComposer {
}
}
/**
* Generates the {@link Listhead} depending on the {@link CriterionType}
* selected.
*
* @param listhead
* A {@link Listhead} to be updated
*/
private void generateListhead(Listhead listhead) {
// Remove the current header
listhead.getChildren().clear();
// Generate basi headers
Listheader hours = new Listheader("Hours");
listhead.appendChild(hours);
Listheader percentage = new Listheader("%");
listhead.appendChild(percentage);
// If it's a leaf add Fixed percentage column
if (getOrderElement() instanceof OrderLine) {
Listheader headerFixedPercentage = new Listheader(
"Fixed percentage");
listhead.appendChild(headerFixedPercentage);
}
// For each CriterionType selected
for (CriterionType criterionType : getSelectedCriterionTypes()) {
// Add a new column on the HoursGroup table
Listheader headerCriterion = new Listheader();
headerCriterion.setLabel(criterionType.getName());
listhead.appendChild(headerCriterion);
}
}
/**
* Disable workingHours and percentage components depending on the
* policy selected by the user.
@ -695,4 +662,36 @@ public class OrderElementController extends GenericForwardComposer {
}
}
/**
* Generates the {@link Listhead} of the {@link HoursGroup} {@link Listbox}
* depending on the {@link CriterionType} selected.
*/
private void generateListhead() {
Listhead listhead = hoursGroupsListbox.getListheadApi();
// Remove the current header
listhead.getChildren().clear();
// Generate basi headers
Listheader hours = new Listheader("Hours");
listhead.appendChild(hours);
Listheader percentage = new Listheader("%");
listhead.appendChild(percentage);
// If it's a leaf add Fixed percentage column
if (getOrderElement() instanceof OrderLine) {
Listheader headerFixedPercentage = new Listheader(
"Fixed percentage");
listhead.appendChild(headerFixedPercentage);
}
// For each CriterionType selected
for (CriterionType criterionType : getSelectedCriterionTypes()) {
// Add a new column on the HoursGroup table
Listheader headerCriterion = new Listheader();
headerCriterion.setLabel(criterionType.getName());
listhead.appendChild(headerCriterion);
}
}
}