From b9590a9153c0834ab2d7ce20f25a07730aaf1b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 24 Jan 2011 20:47:01 +0100 Subject: [PATCH] Eliminate code repetition FEA: ItEr69S08AdvanceAllocationFix --- .../AdvancedAllocationController.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java index fbfccfaa2..1b3b9e151 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java @@ -1559,19 +1559,11 @@ class Row { } private void reloadHoursOnInterval(Component component, DetailItem item) { - if (isGroupingRow()) { + if (isGroupingRow() || isBeforeTaskStartDate(item) + || isBeforeLatestConsolidation(item)) { Label label = (Label) component; label.setValue(getHoursForDetailItem(item) + ""); - label.setClass("calculated-hours"); - } - else if (isBeforeTaskStartDate(item)) { - Label label = (Label) component; - label.setValue(getHoursForDetailItem(item) + ""); - label.setClass("unmodifiable-hours"); - } else if (isBeforeLatestConsolidation(item)) { - Label label = (Label) component; - label.setValue(getHoursForDetailItem(item) + ""); - label.setClass("consolidated-hours"); + label.setClass(getLabelClassFor(item)); } else { Intbox intbox = (Intbox) component; intbox.setValue(getHoursForDetailItem(item)); @@ -1581,6 +1573,19 @@ class Row { } } + private String getLabelClassFor(DetailItem item) { + if (isGroupingRow()) { + return "calculated-hours"; + } + if (isBeforeTaskStartDate(item)) { + return "unmodifiable-hours"; + } + if (isBeforeLatestConsolidation(item)) { + return "consolidated-hours"; + } + return ""; + } + private boolean isBeforeTaskStartDate(DetailItem item) { return task.getIntraDayStartDate().compareTo( item.getEndDate().toLocalDate()) >= 0;