19 package org.sleuthkit.autopsy.timeline.ui.filtering.datamodel;
21 import com.google.common.collect.Lists;
22 import java.util.Collection;
23 import java.util.List;
24 import java.util.Objects;
25 import java.util.stream.Collectors;
26 import javafx.collections.FXCollections;
27 import javafx.collections.ObservableList;
29 import org.
sleuthkit.datamodel.TimelineFilter.CompoundFilter;
41 private final ObservableList< FilterState<? extends SubFilterType>>
subFilterStates = FXCollections.observableArrayList();
51 filter.getSubFilters().forEach(newSubFilter -> {
53 if (newSubFilter instanceof CompoundFilter<?>) {
54 @SuppressWarnings(value =
"unchecked")
76 subFilterStates.forEach(this::addSubFilterStateInternal);
89 selectedProperty().addListener(selectedProperty -> {
91 subFilterStates.forEach(subFilterState -> subFilterState.setSelected(
true));
100 boolean inactive = isActive() ==
false;
102 subFilterStates.forEach(subFilterState -> subFilterState.setDisabled(inactive));
114 SubFilterType filter = newSubFilterState.
getFilter();
119 getFilter().getSubFilters().add(filter);
124 if (subFilterStates.contains(newSubFilterState) ==
false) {
125 subFilterStates.add(newSubFilterState);
130 newSubFilterState.
setDisabled(isActive() ==
false);
140 @SuppressWarnings(
"unchecked")
145 copy.setSelected(isSelected());
146 copy.setDisabled(isDisabled());
151 @SuppressWarnings(
"unchecked")
153 if (isActive() ==
false) {
157 List<SubFilterType> activeSubFilters = subFilterStates.stream()
158 .filter(filterState -> filterState.isActive())
159 .map(filterState -> filterState.getActiveFilter())
160 .collect(Collectors.toList());
161 FilterType copy = (FilterType) getFilter().copyOf();
162 copy.getSubFilters().clear();
163 copy.getSubFilters().addAll(activeSubFilters);
170 int hash = super.hashCode();
171 hash = 41 * hash + Objects.hashCode(this.subFilterStates);
185 if (getClass() != obj.getClass()) {
190 if (!Objects.equals(
this.getFilter(), other.getFilter())) {
193 if (!Objects.equals(
this.isSelected(), other.isSelected())) {
196 if (!Objects.equals(
this.isDisabled(), other.isDisabled())) {
204 return "CompoundFilterState{ selected=" + isSelected() +
", disabled=" + isDisabled() +
", activeProp=" + isActive() +
",subFilterStates=" + subFilterStates +
'}';
CompoundFilterState< SubFilterType, FilterType > copyOf()
FilterState< FilterType > copyOf()
void addSubFilterState(FilterState< ?extends SubFilterType > newSubFilterState)
boolean equals(Object obj)
void addSubFilterStateInternal(FilterState< ?extends SubFilterType > newSubFilterState)
void configureListeners()
void setDisabled(Boolean value)
void disableSubFiltersIfNotActive()
final ObservableList< FilterState<?extends SubFilterType > > subFilterStates
ObservableList< FilterState< ?extends SubFilterType > > getSubFilterStates()
FilterType getActiveFilter()
BooleanProperty selectedProperty()