[Bug #976] Add an initial only-read stretch in advance allocation functions
FEA: ItEr74S04BugFixing
This commit is contained in:
parent
0eac049b1d
commit
73fbbbdbaa
3 changed files with 54 additions and 15 deletions
|
|
@ -52,6 +52,9 @@ public class Stretch {
|
|||
@NotNull
|
||||
private BigDecimal amountWorkPercentage = BigDecimal.ZERO;
|
||||
|
||||
// Transient value
|
||||
private boolean readOnly = false;
|
||||
|
||||
private Stretch(LocalDate date, BigDecimal lengthPercent, BigDecimal progressPercent) {
|
||||
this.date = date;
|
||||
this.lengthPercentage = lengthPercent;
|
||||
|
|
@ -114,4 +117,12 @@ public class Stretch {
|
|||
return String.format("(%s, %s, %s) ", date, lengthPercentage, amountWorkPercentage);
|
||||
}
|
||||
|
||||
}
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
public void readOnly(boolean value) {
|
||||
readOnly = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -270,7 +270,9 @@ public class StretchesFunctionController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void render(Listitem item, Object data) throws Exception {
|
||||
Stretch stretch = (Stretch) data;
|
||||
|
||||
item.setValue(stretch);
|
||||
item.setDisabled(stretch.isReadOnly());
|
||||
|
||||
appendDate(item, stretch);
|
||||
appendLengthPercentage(item, stretch);
|
||||
|
|
@ -376,19 +378,26 @@ public class StretchesFunctionController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void appendOperations(Listitem item, final Stretch stretch) {
|
||||
Button button = new Button("", "/common/img/ico_borrar1.png");
|
||||
button.setHoverImage("/common/img/ico_borrar.png");
|
||||
button.setSclass("icono");
|
||||
button.setTooltiptext(_("Delete"));
|
||||
|
||||
button.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
stretchesFunctionModel.removeStretch(stretch);
|
||||
reloadStretchesListAndCharts();
|
||||
}
|
||||
});
|
||||
Button button;
|
||||
if (item.isDisabled()) {
|
||||
button = new Button("", "/common/img/ico_borrar_out.png");
|
||||
button.setHoverImage("/common/img/ico_borrar_out.png");
|
||||
button.setSclass("icono");
|
||||
button.setDisabled(true);
|
||||
} else {
|
||||
button = new Button("", "/common/img/ico_borrar1.png");
|
||||
button.setHoverImage("/common/img/ico_borrar.png");
|
||||
button.setSclass("icono");
|
||||
button.setTooltiptext(_("Delete"));
|
||||
|
||||
button.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
stretchesFunctionModel.removeStretch(stretch);
|
||||
reloadStretchesListAndCharts();
|
||||
}
|
||||
});
|
||||
}
|
||||
appendChild(item, button);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.math.BigDecimal;
|
|||
import java.math.RoundingMode;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -119,9 +120,27 @@ public class StretchesFunctionModel implements IStretchesFunctionModel {
|
|||
@Override
|
||||
public List<Stretch> getStretches() {
|
||||
if (stretchesFunction == null) {
|
||||
return new ArrayList<Stretch>();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return stretchesFunction.getStretches();
|
||||
return allStretches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty stretch plus the stretches from stretchesFunction
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<Stretch> allStretches() {
|
||||
List<Stretch> result = new ArrayList<Stretch>();
|
||||
result.add(firstStretch());
|
||||
result.addAll(stretchesFunction.getStretches());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Stretch firstStretch() {
|
||||
Stretch result = Stretch.create(task.getStartAsLocalDate(), BigDecimal.ZERO, BigDecimal.ZERO);
|
||||
result.readOnly(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue