19 package org.sleuthkit.autopsy.timeline.ui.filtering;
21 import java.util.Arrays;
22 import java.util.function.BiPredicate;
23 import javafx.scene.control.TreeItem;
24 import javafx.scene.control.TreeTableRow;
25 import org.controlsfx.control.action.Action;
26 import org.controlsfx.control.action.ActionGroup;
27 import org.controlsfx.control.action.ActionUtils;
28 import org.openide.util.NbBundle;
34 class FilterTreeTableRow
extends TreeTableRow<FilterState<?>> {
37 protected void updateItem(FilterState<?> item,
boolean empty) {
38 super.updateItem(item, empty);
39 if (item == null || empty) {
42 setContextMenu(ActionUtils.createContextMenu(Arrays.asList(
new SelectActionsGroup(
this))));
46 @NbBundle.Messages(value = {
47 "Timeline.ui.filtering.menuItem.select=select",
48 "Timeline.ui.filtering.menuItem.all=all",
49 "Timeline.ui.filtering.menuItem.none=none",
50 "Timeline.ui.filtering.menuItem.only=only",
51 "Timeline.ui.filtering.menuItem.others=others"})
53 ALL(Bundle.Timeline_ui_filtering_menuItem_all(),
54 (treeItem, row) ->
true),
55 NONE(Bundle.Timeline_ui_filtering_menuItem_none(),
56 (treeItem, row) ->
false),
57 ONLY(Bundle.Timeline_ui_filtering_menuItem_only(),
58 (treeItem, row) -> treeItem == row.getItem()),
59 OTHER(Bundle.Timeline_ui_filtering_menuItem_others(),
60 (treeItem, row) -> treeItem != row.getItem()),
61 SELECT(Bundle.Timeline_ui_filtering_menuItem_select(),
62 (treeItem, row) ->
false == row.isSelected());
69 this.selectionPredicate = predicate;
70 this.displayName = displayName;
74 treeItem.
setSelected(selectionPredicate.test(treeItem, row));
85 super(Bundle.Timeline_ui_filtering_menuItem_select(),
94 private static final class Select extends Action {
96 public TreeTableRow<FilterState<?>>
getRow() {
99 private final TreeTableRow<FilterState<?>>
row;
105 this.selectionAction = strategy;
106 setEventHandler(actionEvent -> row.getTreeItem().getParent().getChildren().stream()
107 .map(TreeItem::getValue)
108 .forEach(this::doSelection));
final TreeTableRow< FilterState<?> > row
void doSelection(FilterState<?> treeItem)
final SelectionAction selectionAction
final BiPredicate< FilterState<?>, TreeTableRow< FilterState<?> > > selectionPredicate
void doSelection(FilterState<?> treeItem, TreeTableRow< FilterState<?>> row)
SelectionAction(String displayName, BiPredicate< FilterState<?>, TreeTableRow< FilterState<?>>> predicate)
TreeTableRow< FilterState<?> > getRow()
void setSelected(Boolean value)