From d5efa31defab8bdbeef35bb009691f6704c7f2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Wed, 6 Oct 2010 16:57:08 +0200 Subject: [PATCH] Change types to GanttDate in IDependenciesEnforcerHook and INotificationAfterDependenciesEnforcement FEA: ItEr61S08TimeUnitConfigurablePlanning --- .../zkoss/ganttz/data/GanttDiagramGraph.java | 58 ++++++++++--------- .../main/java/org/zkoss/ganttz/data/Task.java | 37 +++++------- .../web/common/TemplateModel.java | 5 +- 3 files changed, 49 insertions(+), 51 deletions(-) diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/data/GanttDiagramGraph.java b/ganttzk/src/main/java/org/zkoss/ganttz/data/GanttDiagramGraph.java index 100273881..f50739ecb 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/data/GanttDiagramGraph.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/data/GanttDiagramGraph.java @@ -61,12 +61,12 @@ public class GanttDiagramGraph { return new IDependenciesEnforcerHook() { @Override - public void setNewEnd(Date previousEnd, Date newEnd) { + public void setNewEnd(GanttDate previousEnd, GanttDate newEnd) { } @Override - public void setStartDate(Date previousStart, Date previousEnd, - Date newStart) { + public void setStartDate(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart) { } }; } @@ -408,10 +408,10 @@ public class GanttDiagramGraph { } public interface IDependenciesEnforcerHook { - public void setStartDate(Date previousStart, Date previousEnd, - Date newStart); + public void setStartDate(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart); - public void setNewEnd(Date previousEnd, Date newEnd); + public void setNewEnd(GanttDate previousEnd, GanttDate newEnd); } public interface IDependenciesEnforcerHookFactory { @@ -422,21 +422,21 @@ public class GanttDiagramGraph { } public interface INotificationAfterDependenciesEnforcement { - public void onStartDateChange(Date previousStart, Date previousEnd, - Date newStart); + public void onStartDateChange(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart); - public void onEndDateChange(Date previousEnd, Date newEnd); + public void onEndDateChange(GanttDate previousEnd, GanttDate newEnd); } private static final INotificationAfterDependenciesEnforcement EMPTY_NOTIFICATOR = new INotificationAfterDependenciesEnforcement() { @Override - public void onStartDateChange(Date previousStart, Date previousEnd, - Date newStart) { + public void onStartDateChange(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart) { } @Override - public void onEndDateChange(Date previousEnd, Date newEnd) { + public void onEndDateChange(GanttDate previousEnd, GanttDate newEnd) { } }; @@ -501,13 +501,14 @@ public class GanttDiagramGraph { private class StartDateNofitication { private final INotificationAfterDependenciesEnforcement notification; - private final Date previousStart; - private final Date previousEnd; - private final Date newStart; + private final GanttDate previousStart; + private final GanttDate previousEnd; + private final GanttDate newStart; public StartDateNofitication( INotificationAfterDependenciesEnforcement notification, - Date previousStart, Date previousEnd, Date newStart) { + GanttDate previousStart, GanttDate previousEnd, + GanttDate newStart) { this.notification = notification; this.previousStart = previousStart; this.previousEnd = previousEnd; @@ -529,12 +530,12 @@ public class GanttDiagramGraph { private class LengthNotification { private final INotificationAfterDependenciesEnforcement notification; - private final Date previousEnd; - private final Date newEnd; + private final GanttDate previousEnd; + private final GanttDate newEnd; public LengthNotification( INotificationAfterDependenciesEnforcement notification, - Date previousEnd, Date newEnd) { + GanttDate previousEnd, GanttDate newEnd) { this.notification = notification; this.previousEnd = previousEnd; this.newEnd = newEnd; @@ -571,13 +572,13 @@ public class GanttDiagramGraph { private IDependenciesEnforcerHook onEntrance(final V task) { return new IDependenciesEnforcerHook() { - public void setStartDate(Date previousStart, Date previousEnd, - Date newStart) { + public void setStartDate(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart) { taskPositionModified(task); } @Override - public void setNewEnd(Date previousEnd, Date newEnd) { + public void setNewEnd(GanttDate previousEnd, GanttDate newEnd) { taskPositionModified(task); } @@ -589,8 +590,8 @@ public class GanttDiagramGraph { return new IDependenciesEnforcerHook() { @Override - public void setStartDate(Date previousStart, Date previousEnd, - Date newStart) { + public void setStartDate(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart) { StartDateNofitication startDateNotification = new StartDateNofitication( notification, previousStart, previousEnd, newStart); @@ -599,7 +600,7 @@ public class GanttDiagramGraph { } @Override - public void setNewEnd(Date previousEnd, Date newEnd) { + public void setNewEnd(GanttDate previousEnd, GanttDate newEnd) { LengthNotification lengthNotification = new LengthNotification( notification, previousEnd, newEnd); deferedNotifier.get().add(task, lengthNotification); @@ -614,8 +615,8 @@ public class GanttDiagramGraph { return new IDependenciesEnforcerHook() { @Override - public void setStartDate(final Date previousStart, - final Date previousEnd, final Date newStart) { + public void setStartDate(final GanttDate previousStart, + final GanttDate previousEnd, final GanttDate newStart) { positionsUpdatingGuard .entranceRequested(new IReentranceCases() { @@ -645,7 +646,8 @@ public class GanttDiagramGraph { } @Override - public void setNewEnd(final Date previousEnd, final Date newEnd) { + public void setNewEnd(final GanttDate previousEnd, + final GanttDate newEnd) { positionsUpdatingGuard .entranceRequested(new IReentranceCases() { diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/data/Task.java b/ganttzk/src/main/java/org/zkoss/ganttz/data/Task.java index 6bcbdf931..7d3bfb000 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/data/Task.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/data/Task.java @@ -77,8 +77,8 @@ public abstract class Task implements ITaskFundamentalProperties { private final INotificationAfterDependenciesEnforcement notifyDates = new INotificationAfterDependenciesEnforcement() { @Override - public void onStartDateChange(Date previousStart, Date previousEnd, - Date newStart) { + public void onStartDateChange(GanttDate previousStart, + GanttDate previousEnd, GanttDate newStart) { fundamentalPropertiesListeners.firePropertyChange("beginDate", previousStart, fundamentalProperties.getBeginDate()); fireEndDate(previousEnd); @@ -86,11 +86,11 @@ public abstract class Task implements ITaskFundamentalProperties { } @Override - public void onEndDateChange(Date previousEnd, Date newEnd) { + public void onEndDateChange(GanttDate previousEnd, GanttDate newEnd) { fireEndDate(previousEnd); } - private void fireEndDate(Date previousEnd) { + private void fireEndDate(GanttDate previousEnd) { fundamentalPropertiesListeners.firePropertyChange("endDate", previousEnd, fundamentalProperties.getEndDate()); } @@ -159,14 +159,12 @@ public abstract class Task implements ITaskFundamentalProperties { GanttDate previousValue = fundamentalProperties.getBeginDate(); GanttDate previousEnd = fundamentalProperties.getEndDate(); fundamentalProperties.setBeginDate(newStart); - Date newStartDate = newStart != null ? newStart.toDateApproximation() - : null; - dependenciesEnforcerHook.setStartDate( - previousValue.toDateApproximation(), - previousEnd.toDateApproximation(), newStartDate); + dependenciesEnforcerHook.setStartDate(previousValue, previousEnd, + newStart); } - private void reloadResourcesTextIfChange(Date newDate, Date previousDate) { + private void reloadResourcesTextIfChange(GanttDate newDate, + GanttDate previousDate) { if (!ObjectUtils.equals(newDate, previousDate)) { reloadResourcesText(); } @@ -174,11 +172,9 @@ public abstract class Task implements ITaskFundamentalProperties { public void fireChangesForPreviousValues(GanttDate previousStart, GanttDate previousEnd) { - dependenciesEnforcerHook.setStartDate(previousStart - .toDateApproximation(), previousEnd.toDateApproximation(), - fundamentalProperties.getBeginDate().toDateApproximation()); - dependenciesEnforcerHook.setNewEnd(previousEnd.toDateApproximation(), - getEndDate().toDateApproximation()); + dependenciesEnforcerHook.setStartDate(previousStart, previousStart, + fundamentalProperties.getBeginDate()); + dependenciesEnforcerHook.setNewEnd(previousEnd, getEndDate()); } public GanttDate getBeginDate() { @@ -251,8 +247,8 @@ public abstract class Task implements ITaskFundamentalProperties { } GanttDate previousEnd = fundamentalProperties.getEndDate(); fundamentalProperties.setEndDate(value); - dependenciesEnforcerHook.setNewEnd(previousEnd.toDateApproximation(), - fundamentalProperties.getEndDate().toDateApproximation()); + dependenciesEnforcerHook.setNewEnd(previousEnd, + fundamentalProperties.getEndDate()); } public void resizeTo(LocalDate date) { @@ -304,11 +300,10 @@ public abstract class Task implements ITaskFundamentalProperties { } public void moveTo(GanttDate date) { - Date previousStart = getBeginDate().toDateApproximation(); - Date previousEnd = getEndDate().toDateApproximation(); + GanttDate previousStart = getBeginDate(); + GanttDate previousEnd = getEndDate(); fundamentalProperties.moveTo(date); - dependenciesEnforcerHook.setStartDate(previousStart, previousEnd, - date.toDateApproximation()); + dependenciesEnforcerHook.setStartDate(previousStart, previousEnd, date); } @Override diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java index 8c09aed08..c478d0f6b 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java @@ -62,6 +62,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.zkoss.ganttz.adapters.PlannerConfiguration; import org.zkoss.ganttz.data.DependencyType; +import org.zkoss.ganttz.data.GanttDate; import org.zkoss.ganttz.data.GanttDiagramGraph; import org.zkoss.ganttz.data.GanttDiagramGraph.IAdapter; import org.zkoss.ganttz.data.GanttDiagramGraph.IDependenciesEnforcerHook; @@ -203,8 +204,8 @@ public class TemplateModel implements ITemplateModel { }; } - private static Date convert(LocalDate date) { - return date.toDateTimeAtStartOfDay().toDate(); + private static GanttDate convert(LocalDate date) { + return GanttDate.createFrom(date); } public class Adapter implements