Add getEndDate and setEndDate to ITaskFundamentalProperties

FEA: ItEr61S08TimeUnitConfigurablePlanning
This commit is contained in:
Óscar González Fernández 2010-09-28 17:28:49 +02:00
parent 79002df918
commit 749bf03981
4 changed files with 28 additions and 8 deletions

View file

@ -105,6 +105,16 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
this.lengthMilliseconds = lengthMilliseconds;
}
@Override
public Date getEndDate() {
return new Date(beginDate + getLengthMilliseconds());
}
@Override
public void setEndDate(Date endDate) {
this.lengthMilliseconds = endDate.getTime() - beginDate;
}
public String getNotes() {
return notes;
}

View file

@ -56,6 +56,10 @@ public interface ITaskFundamentalProperties {
public void setLengthMilliseconds(long lengthMilliseconds);
public Date getEndDate();
public void setEndDate(Date endDate);
public long getLengthMilliseconds();
public String getNotes();

View file

@ -34,8 +34,8 @@ import org.zkoss.ganttz.data.GanttDiagramGraph.IDependenciesEnforcerHook;
import org.zkoss.ganttz.data.GanttDiagramGraph.IDependenciesEnforcerHookFactory;
import org.zkoss.ganttz.data.GanttDiagramGraph.INotificationAfterDependenciesEnforcement;
import org.zkoss.ganttz.data.constraint.Constraint;
import org.zkoss.ganttz.data.constraint.DateConstraint;
import org.zkoss.ganttz.data.constraint.Constraint.IConstraintViolationListener;
import org.zkoss.ganttz.data.constraint.DateConstraint;
import org.zkoss.ganttz.util.ConstraintViolationNotificator;
/**
@ -233,6 +233,7 @@ public abstract class Task implements ITaskFundamentalProperties {
.removePropertyChangeListener(listener);
}
@Override
public Date getEndDate() {
return new Date(getBeginDate().getTime() + getLengthMilliseconds());
}
@ -261,6 +262,7 @@ public abstract class Task implements ITaskFundamentalProperties {
previousValue, this.fundamentalProperties.getNotes());
}
@Override
public void setEndDate(Date value) {
if (value == null) {
return;

View file

@ -208,23 +208,27 @@ public class TaskElementAdapter implements ITaskElementAdapter {
@Override
public void setLengthMilliseconds(final long lengthMilliseconds) {
setEndDate(new Date(getBeginDate().getTime()
+ lengthMilliseconds));
}
@Override
public Date getEndDate() {
return taskElement.getEndDate();
}
public void setEndDate(final Date endDate) {
transactionService
.runOnReadOnlyTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
stepsBeforePossibleReallocation();
updateEndDate(lengthMilliseconds);
taskElement.resizeTo(currentScenario, endDate);
return null;
}
});
}
private void updateEndDate(long lengthMilliseconds) {
Date endDate = new Date(getBeginDate().getTime()
+ lengthMilliseconds);
taskElement.resizeTo(currentScenario, endDate);
}
@Override
public Date getHoursAdvanceEndDate() {
OrderElement orderElement = taskElement.getOrderElement();