bug4339 allow CellTablePo.select to finish without looping the whole

table, if requested
This commit is contained in:
Kai Börnert committed 2018-07-31 13:01:03 +02:00
1 parent 198a5952bb
commit 39d8e3301a
2 files changed
+7 -3

No files matched your search

@@ -249,7 +249,7 @@ public class TracTracEventManagementPanelPO extends PageArea {
final Set<TrackableRaceDescriptor> racesToProcess = new HashSet<>(races);
final CellTablePO<DataEntryPO> table = getTrackableRacesTable();
table.selectEntries(e -> racesToProcess.remove(new TrackableRaceDescriptor(e.getColumnContent("Event"),
e.getColumnContent("Race"), e.getColumnContent("Boat Class"))));
e.getColumnContent("Race"), e.getColumnContent("Boat Class"))), racesToProcess::isEmpty);
if (!racesToProcess.isEmpty()) {
throw new IllegalStateException("Not all given races where selected");
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -258,13 +259,16 @@ public abstract class CellTablePO<T extends DataEntryPO> extends PageArea {
*
* <p>Note: If an entry is not contained in the table it will not be selected.</p>
*/
public void selectEntries(Predicate<T> toSelectPredicate) {
public void selectEntries(Predicate<T> toSelectPredicate, BooleanSupplier canAbort) {
for (T entry : getEntries()) {
if(toSelectPredicate.test(entry)) {
entry.appendToSelection();
} else {
entry.deselect();
}
if (canAbort.getAsBoolean()) {
break;
}
}
}
@@ -274,7 +278,7 @@ public abstract class CellTablePO<T extends DataEntryPO> extends PageArea {
* <p>Note: If an entry is not contained in the table it will not be selected.</p>
*/
public void selectAllEntries() {
selectEntries(e -> true);
selectEntries(e -> true, Boolean.FALSE::booleanValue);
}
/**