mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-20 19:20:04 +00:00
Extended CellTablePO to select entries by Predicate and select all
entries
This commit is contained in:
1 parent
7f4684ad81
commit
540568ea76
1 file changed
+25
+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>
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user