Extended CellTablePO to select entries by Predicate and select all

entries
This commit is contained in:
Steffen Schaefer committed 2017-03-28 13:56:12 +02:00
1 parent 7f4684ad81
commit 540568ea76
1 file changed
+25
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -243,6 +244,30 @@ public abstract class CellTablePO<T extends DataEntryPO> extends PageArea {
});
}
/**
* <p>Selects entries based on the given Predicate.</p>
*
* <p>Note: If an entry is not contained in the table it will not be selected.</p>
*/
public void selectEntries(Predicate<T> toSelectPredicate) {
for (T entry : getEntries()) {
if(toSelectPredicate.test(entry)) {
entry.appendToSelection();
} else {
entry.deselect();
}
}
}
/**
* <p>Selects entries based on the given Predicate.</p>
*
* <p>Note: If an entry is not contained in the table it will not be selected.</p>
*/
public void selectAllEntries() {
selectEntries(e -> true);
}
/**
* <p>Returns all currently selected entries. If no entry is selected, an empty list is returned.</p>
*