Segregate the methods for updating the task from the UI
This is intented for segregating the methods that are intended to be used from the UI that will provide LocalDates from the the methods that will update the dates directly. FEA: ItEr61S08TimeUnitConfigurablePlanning
This commit is contained in:
parent
0bea855f98
commit
31e2a04c87
13 changed files with 35 additions and 23 deletions
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.util.ComponentsFinder;
|
||||
|
|
@ -383,10 +384,10 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
task.setName(getNameBox().getValue());
|
||||
} else if (updatedComponent == getStartDateBox()) {
|
||||
Date begin = getStartDateBox().getValue();
|
||||
task.moveTo(begin);
|
||||
task.moveTo(LocalDate.fromDateFields(begin));
|
||||
} else if (updatedComponent == getEndDateBox()) {
|
||||
Date newEnd = getEndDateBox().getValue();
|
||||
task.setEndDate(newEnd);
|
||||
task.resizeTo(LocalDate.fromDateFields(newEnd));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
void doUpdatePosition(String leftX, String topY) {
|
||||
Date startBeforeMoving = this.task.getBeginDate();
|
||||
LocalDate newPosition = getMapper().toDate(stripPx(leftX));
|
||||
this.task.moveTo(newPosition.toDateTimeAtStartOfDay().toDate());
|
||||
this.task.moveTo(newPosition);
|
||||
boolean remainsInOriginalPosition = this.task.getBeginDate().equals(
|
||||
startBeforeMoving);
|
||||
if (remainsInOriginalPosition) {
|
||||
|
|
@ -354,7 +354,7 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
int pixels = stripPx(size);
|
||||
DateTime end = new DateTime(this.task.getBeginDate().getTime())
|
||||
.plus(getMapper().toDuration(pixels));
|
||||
this.task.setEndDate(end.toDate());
|
||||
this.task.resizeTo(end.toLocalDate());
|
||||
updateWidth();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.zkoss.ganttz;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
|
|
@ -107,7 +108,7 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
private void copyFromDTO(TaskDTO taskDTO, Task currentTask) {
|
||||
currentTask.setName(taskDTO.name);
|
||||
currentTask.setBeginDate(taskDTO.beginDate);
|
||||
currentTask.setEndDate(taskDTO.endDate);
|
||||
currentTask.resizeTo(LocalDate.fromDateFields(taskDTO.endDate));
|
||||
currentTask.setNotes(taskDTO.notes);
|
||||
currentTask.setDeadline(taskDTO.deadlineDate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.data.constraint.Constraint;
|
||||
|
||||
/**
|
||||
|
|
@ -154,8 +155,8 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(Date date) {
|
||||
setBeginDate(date);
|
||||
public void moveTo(LocalDate date) {
|
||||
setBeginDate(date.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.math.BigDecimal;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.data.constraint.Constraint;
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +77,7 @@ public interface ITaskFundamentalProperties {
|
|||
|
||||
List<Constraint<Date>> getStartConstraints();
|
||||
|
||||
public void moveTo(Date date);
|
||||
public void moveTo(LocalDate date);
|
||||
|
||||
public boolean isSubcontracted();
|
||||
|
||||
|
|
|
|||
|
|
@ -180,10 +180,6 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
return new Date(fundamentalProperties.getBeginDate().getTime());
|
||||
}
|
||||
|
||||
public void setLengthMilliseconds(long lengthMilliseconds) {
|
||||
setEndDate(new Date(getBeginDate().getTime() + lengthMilliseconds));
|
||||
}
|
||||
|
||||
public long getLengthMilliseconds() {
|
||||
return getEndDate().getTime() - getBeginDate().getTime();
|
||||
}
|
||||
|
|
@ -252,6 +248,10 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
fundamentalProperties.getEndDate());
|
||||
}
|
||||
|
||||
public void resizeTo(LocalDate date) {
|
||||
setEndDate(date.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
|
@ -292,11 +292,12 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
return fundamentalProperties.getResourcesText();
|
||||
}
|
||||
|
||||
public void moveTo(Date date) {
|
||||
public void moveTo(LocalDate date) {
|
||||
Date previousStart = getBeginDate();
|
||||
Date previousEnd = getEndDate();
|
||||
fundamentalProperties.moveTo(date);
|
||||
dependenciesEnforcerHook.setStartDate(previousStart, previousEnd, date);
|
||||
dependenciesEnforcerHook.setStartDate(previousStart, previousEnd, date
|
||||
.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
}
|
||||
}
|
||||
|
||||
public void explicityMoved(Date date) {
|
||||
public void explicityMoved(LocalDate date) {
|
||||
getStartConstraint().explicityMovedTo(date);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,13 +262,13 @@ public abstract class TaskElement extends BaseEntity {
|
|||
* Sets the startDate to newStartDate. It can update the endDate
|
||||
* @param newStartDate
|
||||
*/
|
||||
public void moveTo(Scenario scenario, Date newStartDate) {
|
||||
public void moveTo(Scenario scenario, LocalDate newStartDate) {
|
||||
if (newStartDate == null) {
|
||||
return;
|
||||
}
|
||||
final boolean sameDay = this.startDate.areSameDay(newStartDate);
|
||||
long durationMilliseconds = getLengthMilliseconds();
|
||||
setStartDate(newStartDate);
|
||||
setIntraDayStartDate(IntraDayDate.startOfDay(newStartDate));
|
||||
DateTime newEnd = this.startDate.toDateTimeAtStartOfDay().plus(
|
||||
durationMilliseconds);
|
||||
this.endDate = IntraDayDate.create(newEnd.toLocalDate(),
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.commons.lang.Validate;
|
|||
import org.hibernate.validator.AssertTrue;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
|
||||
/**
|
||||
|
|
@ -144,7 +145,7 @@ public class TaskMilestone extends TaskElement implements ITaskLeafConstraint {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void explicityMoved(Date date) {
|
||||
public void explicityMoved(LocalDate date) {
|
||||
getStartConstraint().explicityMovedTo(date);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.business.planner.entities;
|
|||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Component class that encapsulates a {@link StartConstraintType} and its
|
||||
|
|
@ -42,10 +43,10 @@ public class TaskStartConstraint {
|
|||
: StartConstraintType.AS_SOON_AS_POSSIBLE;
|
||||
}
|
||||
|
||||
public void explicityMovedTo(Date date) {
|
||||
public void explicityMovedTo(LocalDate date) {
|
||||
Validate.notNull(date);
|
||||
startConstraintType = startConstraintType.newTypeAfterMoved();
|
||||
constraintDate = new Date(date.getTime());
|
||||
constraintDate = date.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
public Date getConstraintDate() {
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ public class TemplateModel implements ITemplateModel {
|
|||
|
||||
@Override
|
||||
public void setStartDateFor(TaskElement task, Date newStart) {
|
||||
task.moveTo(scenario, newStart);
|
||||
task.moveTo(scenario, LocalDate.fromDateFields(newStart));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
LocalDate endDate) {
|
||||
task.setStartDate(toDate(startDate));
|
||||
task.setEndDate(toDate(endDate));
|
||||
task.explicityMoved(toDate(startDate));
|
||||
task.explicityMoved(startDate);
|
||||
}
|
||||
|
||||
private Date toDate(LocalDate date) {
|
||||
|
|
|
|||
|
|
@ -184,6 +184,11 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
|
||||
@Override
|
||||
public void setBeginDate(final Date beginDate) {
|
||||
setBeginDate(beginDate != null ? LocalDate
|
||||
.fromDateFields(beginDate) : null);
|
||||
}
|
||||
|
||||
private void setBeginDate(final LocalDate beginDate) {
|
||||
transactionService
|
||||
.runOnReadOnlyTransaction(new IOnTransaction<Void>() {
|
||||
@Override
|
||||
|
|
@ -518,7 +523,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(Date date) {
|
||||
public void moveTo(LocalDate date) {
|
||||
setBeginDate(date);
|
||||
if (taskElement instanceof Task) {
|
||||
Task task = (Task) taskElement;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue