mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 19:14:55 +00:00
Merge pull request #4124 from millmanorama/select-subfilters
select subfilters automatically when base filter is selected and no s…
This commit is contained in:
commit
290411d1d2
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.timeline.ui.filtering;
|
||||
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableMap;
|
||||
import javafx.scene.control.TreeItem;
|
||||
@ -71,6 +73,15 @@ final public class FilterTreeItem extends TreeItem<FilterState<?>> {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
compoundFilter.selectedProperty().addListener(new InvalidationListener() {
|
||||
@Override
|
||||
public void invalidated(Observable observable) {
|
||||
if (compoundFilter.isSelected()) {
|
||||
setExpanded(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,28 +33,41 @@ class CompoundFilterStateImpl<SubFilterType extends TimelineFilter, C extends Co
|
||||
|
||||
private final ObservableList<FilterState<SubFilterType>> subFilterStates = FXCollections.observableArrayList();
|
||||
|
||||
CompoundFilterStateImpl(C delegate) {
|
||||
super(delegate);
|
||||
|
||||
delegate.getSubFilters().forEach(this::addSubFilterState);
|
||||
delegate.getSubFilters().addListener((ListChangeListener.Change<? extends SubFilterType> change) -> {
|
||||
/**
|
||||
* A constructor that automatically makes sub FilterStates for all the
|
||||
* subfilters of the given compound filter.
|
||||
*
|
||||
* @param filter The CompoundFilter this will represent the state of.
|
||||
*/
|
||||
CompoundFilterStateImpl(C filter) {
|
||||
super(filter);
|
||||
filter.getSubFilters().forEach(this::addSubFilterState);
|
||||
filter.getSubFilters().addListener((ListChangeListener.Change<? extends SubFilterType> change) -> {
|
||||
while (change.next()) {
|
||||
change.getAddedSubList().forEach(CompoundFilterStateImpl.this::addSubFilterState);
|
||||
}
|
||||
});
|
||||
/*
|
||||
* enforce the following relationship between a compound filter and its
|
||||
* subfilters: if a compound filter's active property changes, disable
|
||||
* the subfilters if the compound filter is not active.
|
||||
*/
|
||||
activeProperty().addListener(activeProperty -> disableSubFiltersIfNotActive());
|
||||
disableSubFiltersIfNotActive();
|
||||
|
||||
configureListeners();
|
||||
}
|
||||
|
||||
CompoundFilterStateImpl(C delegate, Collection<FilterState<SubFilterType>> subFilterStates) {
|
||||
super(delegate);
|
||||
|
||||
/**
|
||||
* A constructor that doesn't make subfilter states automatically, but
|
||||
* instead uses the given collection of sub filter states. Designed
|
||||
* primarily for use when making a copy of an existing filterstate tree.
|
||||
*
|
||||
* @param filter The CompoundFilter this will represent the state
|
||||
* of.
|
||||
* @param subFilterStates The filter states to use as the sub filter states.
|
||||
*/
|
||||
CompoundFilterStateImpl(C filter, Collection<FilterState<SubFilterType>> subFilterStates) {
|
||||
super(filter);
|
||||
subFilterStates.forEach(this::addSubFilterState);
|
||||
|
||||
configureListeners();
|
||||
}
|
||||
|
||||
private void configureListeners() {
|
||||
/*
|
||||
* enforce the following relationship between a compound filter and its
|
||||
* subfilters: if a compound filter's active property changes, disable
|
||||
@ -62,6 +75,12 @@ class CompoundFilterStateImpl<SubFilterType extends TimelineFilter, C extends Co
|
||||
*/
|
||||
activeProperty().addListener(activeProperty -> disableSubFiltersIfNotActive());
|
||||
disableSubFiltersIfNotActive();
|
||||
selectedProperty().addListener(selectedProperty -> {
|
||||
if (isSelected() && getSubFilterStates().stream().noneMatch(FilterState::isSelected)) {
|
||||
getSubFilterStates().forEach(subFilterState -> subFilterState.setSelected(true));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,10 +32,10 @@ import org.sleuthkit.datamodel.timeline.TimelineFilter;
|
||||
*/
|
||||
public class DefaultFilterState<FilterType extends TimelineFilter> implements FilterState<FilterType> {
|
||||
|
||||
private final FilterType delegate;
|
||||
private final FilterType filter;
|
||||
|
||||
public DefaultFilterState(FilterType delegate) {
|
||||
this.delegate = delegate;
|
||||
public DefaultFilterState(FilterType filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
private final SimpleBooleanProperty selected = new SimpleBooleanProperty(false);
|
||||
@ -84,21 +84,21 @@ public class DefaultFilterState<FilterType extends TimelineFilter> implements Fi
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return delegate.getDisplayName();
|
||||
return filter.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultFilterState<FilterType> copyOf() {
|
||||
@SuppressWarnings("unchecked")
|
||||
DefaultFilterState<FilterType> copy = new DefaultFilterState<>((FilterType) delegate.copyOf());
|
||||
copy.setSelected(isSelected( ));
|
||||
DefaultFilterState<FilterType> copy = new DefaultFilterState<>((FilterType) filter.copyOf());
|
||||
copy.setSelected(isSelected());
|
||||
copy.setDisabled(isDisabled());
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterType getFilter() {
|
||||
return delegate;
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user