Refreshed calculated expense column on hours or budget changes
FEA: ItEr77S17AutomaticBudgeting
This commit is contained in:
parent
50a6f91b1a
commit
8c2c7996a2
2 changed files with 30 additions and 0 deletions
|
|
@ -631,6 +631,7 @@ public class OrderElementTreeController extends TreeController<OrderElement> {
|
||||||
BigDecimal value = currentElement.getSubstractedBudget();
|
BigDecimal value = currentElement.getSubstractedBudget();
|
||||||
Textbox autoBudgetCell = new Textbox(Util.addCurrencySymbol(value));
|
Textbox autoBudgetCell = new Textbox(Util.addCurrencySymbol(value));
|
||||||
autoBudgetCell.setDisabled(true);
|
autoBudgetCell.setDisabled(true);
|
||||||
|
calculatedExpensesBoxByElement.put(currentElement, autoBudgetCell);
|
||||||
addCell(autoBudgetCell);
|
addCell(autoBudgetCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.hibernate.validator.ClassValidator;
|
import org.hibernate.validator.ClassValidator;
|
||||||
import org.hibernate.validator.InvalidValue;
|
import org.hibernate.validator.InvalidValue;
|
||||||
|
import org.libreplan.business.orders.entities.OrderElement;
|
||||||
import org.libreplan.business.orders.entities.SchedulingState;
|
import org.libreplan.business.orders.entities.SchedulingState;
|
||||||
import org.libreplan.business.orders.entities.SchedulingState.ITypeChangedListener;
|
import org.libreplan.business.orders.entities.SchedulingState.ITypeChangedListener;
|
||||||
import org.libreplan.business.orders.entities.SchedulingState.Type;
|
import org.libreplan.business.orders.entities.SchedulingState.Type;
|
||||||
|
|
@ -629,6 +630,8 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
|
|
||||||
private Map<T, Decimalbox> budgetDecimalboxByElement = new HashMap<T, Decimalbox>();
|
private Map<T, Decimalbox> budgetDecimalboxByElement = new HashMap<T, Decimalbox>();
|
||||||
|
|
||||||
|
protected Map<T, Textbox> calculatedExpensesBoxByElement = new HashMap<T, Textbox>();
|
||||||
|
|
||||||
private Map<T, DynamicDatebox> initDateDynamicDateboxByElement = new HashMap<T, DynamicDatebox>();
|
private Map<T, DynamicDatebox> initDateDynamicDateboxByElement = new HashMap<T, DynamicDatebox>();
|
||||||
|
|
||||||
private Map<T, DynamicDatebox> endDateDynamicDateboxByElement = new HashMap<T, DynamicDatebox>();
|
private Map<T, DynamicDatebox> endDateDynamicDateboxByElement = new HashMap<T, DynamicDatebox>();
|
||||||
|
|
@ -862,6 +865,14 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
decimalboxBudget.setDisabled(true);
|
decimalboxBudget.setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
decimalboxBudget.addEventListener("onChange", new EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) {
|
||||||
|
refreshBudgetValueForThisNodeAndParents(getSelectedNode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addCell(decimalboxBudget);
|
addCell(decimalboxBudget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -949,6 +960,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
Decimalbox decimalbox = budgetDecimalboxByElement.get(element);
|
Decimalbox decimalbox = budgetDecimalboxByElement.get(element);
|
||||||
decimalbox.invalidate();
|
decimalbox.invalidate();
|
||||||
refreshBudgetValueForThisNodeAndParents(element);
|
refreshBudgetValueForThisNodeAndParents(element);
|
||||||
|
refreshCalculatedBudgetForNode(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -984,6 +996,7 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
public void refreshBudgetValueForNodes(List<T> nodes) {
|
public void refreshBudgetValueForNodes(List<T> nodes) {
|
||||||
for (T node : nodes) {
|
for (T node : nodes) {
|
||||||
Decimalbox decimalbox = budgetDecimalboxByElement.get(node);
|
Decimalbox decimalbox = budgetDecimalboxByElement.get(node);
|
||||||
|
refreshCalculatedBudgetForNode(node);
|
||||||
// For the Order node there is no associated decimalbox
|
// For the Order node there is no associated decimalbox
|
||||||
if (decimalbox != null) {
|
if (decimalbox != null) {
|
||||||
BigDecimal currentBudget = getBudgetHandler().getBudgetFor(node);
|
BigDecimal currentBudget = getBudgetHandler().getBudgetFor(node);
|
||||||
|
|
@ -992,6 +1005,15 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshCalculatedBudgetForNode(T node) {
|
||||||
|
Textbox textbox = calculatedExpensesBoxByElement.get(node);
|
||||||
|
OrderElement e = (OrderElement) node;
|
||||||
|
if (textbox != null) {
|
||||||
|
textbox.setValue(Util.addCurrencySymbol(e
|
||||||
|
.getSubstractedBudget()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Constraint getBudgetConstraintFor(final T line) {
|
private Constraint getBudgetConstraintFor(final T line) {
|
||||||
return new Constraint() {
|
return new Constraint() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1017,6 +1039,13 @@ public abstract class TreeController<T extends ITreeNode<T>> extends
|
||||||
intboxHours.setDisabled(true);
|
intboxHours.setDisabled(true);
|
||||||
}
|
}
|
||||||
Treecell cellHours = addCell(intboxHours);
|
Treecell cellHours = addCell(intboxHours);
|
||||||
|
intboxHours.addEventListener("onChange", new EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) {
|
||||||
|
refreshCalculatedBudgetForNode(getSelectedNode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setReadOnlyHoursCell(currentElement, intboxHours, cellHours);
|
setReadOnlyHoursCell(currentElement, intboxHours, cellHours);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue