mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Merge pull request #2040 from millmanorama/Tl-filter-checkboxes-disable
Tl disable subfilters if parent filter is unselected
This commit is contained in:
commit
0aa23bb64f
@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.binding.BooleanBinding;
|
import javafx.beans.binding.BooleanBinding;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation of a {@link Filter}. Implements active property.
|
* Base implementation of a {@link Filter}. Implements active property.
|
||||||
@ -38,7 +39,7 @@ public abstract class AbstractFilter implements Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SimpleBooleanProperty getDisabledProperty() {
|
public ObservableBooleanValue disabledProperty() {
|
||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +68,11 @@ public abstract class AbstractFilter implements Filter {
|
|||||||
return "[" + (isSelected() ? "x" : " ") + "]"; // NON-NLS
|
return "[" + (isSelected() ? "x" : " ") + "]"; // NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isActive() {
|
public boolean isActive() {
|
||||||
return activeProperty.get();
|
return activeProperty.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BooleanBinding activeProperty() {
|
public BooleanBinding activeProperty() {
|
||||||
return activeProperty;
|
return activeProperty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,13 @@ public abstract class CompoundFilter<SubFilterType extends Filter> extends Abstr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.subFilters.setAll(subFilters);
|
this.subFilters.setAll(subFilters);
|
||||||
|
|
||||||
|
this.selectedProperty().addListener(activeProperty -> {
|
||||||
|
getSubFilters().forEach(subFilter -> subFilter.setDisabled(isActive() == false));
|
||||||
|
});
|
||||||
|
this.disabledProperty().addListener(activeProperty -> {
|
||||||
|
getSubFilters().forEach(subFilter -> subFilter.setDisabled(isActive() == false));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSubFilterListeners(List<? extends SubFilterType> newSubfilters) {
|
private void addSubFilterListeners(List<? extends SubFilterType> newSubfilters) {
|
||||||
|
@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +30,6 @@ import org.openide.util.NbBundle;
|
|||||||
public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
|
public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
|
||||||
|
|
||||||
public DataSourcesFilter() {
|
public DataSourcesFilter() {
|
||||||
getDisabledProperty().bind(Bindings.size(getSubFilters()).lessThanOrEqualTo(1));
|
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,6 @@ public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
|
|||||||
.map(DataSourceFilter::getDataSourceID)
|
.map(DataSourceFilter::getDataSourceID)
|
||||||
.filter(t -> t == dataSourceFilter.getDataSourceID())
|
.filter(t -> t == dataSourceFilter.getDataSourceID())
|
||||||
.findAny().isPresent() == false) {
|
.findAny().isPresent() == false) {
|
||||||
dataSourceFilter.getDisabledProperty().bind(getDisabledProperty());
|
|
||||||
getSubFilters().add(dataSourceFilter);
|
getSubFilters().add(dataSourceFilter);
|
||||||
getSubFilters().sort(Comparator.comparing(DataSourceFilter::getDisplayName));
|
getSubFilters().sort(Comparator.comparing(DataSourceFilter::getDisplayName));
|
||||||
}
|
}
|
||||||
@ -100,4 +99,10 @@ public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObservableBooleanValue disabledProperty() {
|
||||||
|
return Bindings.or(super.disabledProperty(), Bindings.size(getSubFilters()).lessThanOrEqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
|
|
||||||
import javafx.beans.binding.BooleanBinding;
|
import javafx.beans.binding.BooleanBinding;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public interface Filter {
|
|||||||
*/
|
*/
|
||||||
void setDisabled(Boolean act);
|
void setDisabled(Boolean act);
|
||||||
|
|
||||||
SimpleBooleanProperty getDisabledProperty();
|
ObservableBooleanValue disabledProperty();
|
||||||
|
|
||||||
boolean isDisabled();
|
boolean isDisabled();
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,6 @@ public class HashHitsFilter extends UnionFilter<HashSetFilter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashHitsFilter() {
|
public HashHitsFilter() {
|
||||||
getDisabledProperty().bind(Bindings.size(getSubFilters()).lessThan(1));
|
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,4 +81,9 @@ public class HashHitsFilter extends UnionFilter<HashSetFilter> {
|
|||||||
getSubFilters().sort(Comparator.comparing(HashSetFilter::getDisplayName));
|
getSubFilters().sort(Comparator.comparing(HashSetFilter::getDisplayName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObservableBooleanValue disabledProperty() {
|
||||||
|
return Bindings.or(super.disabledProperty(), Bindings.isEmpty(getSubFilters()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javafx.beans.binding.BooleanBinding;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +71,7 @@ public class RootFilter extends IntersectionFilter<Filter> {
|
|||||||
public RootFilter copyOf() {
|
public RootFilter copyOf() {
|
||||||
Set<Filter> annonymousSubFilters = getSubFilters().stream()
|
Set<Filter> annonymousSubFilters = getSubFilters().stream()
|
||||||
.filter(subFilter ->
|
.filter(subFilter ->
|
||||||
!(subFilter.equals(knownFilter)
|
!(subFilter.equals(knownFilter)
|
||||||
|| subFilter.equals(tagsFilter)
|
|| subFilter.equals(tagsFilter)
|
||||||
|| subFilter.equals(hashFilter)
|
|| subFilter.equals(hashFilter)
|
||||||
|| subFilter.equals(typeFilter)
|
|| subFilter.equals(typeFilter)
|
||||||
@ -108,4 +109,17 @@ public class RootFilter extends IntersectionFilter<Filter> {
|
|||||||
}
|
}
|
||||||
return areSubFiltersEqual(this, (CompoundFilter<Filter>) obj);
|
return areSubFiltersEqual(this, (CompoundFilter<Filter>) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanBinding activeProperty() {
|
||||||
|
return new BooleanBinding() {
|
||||||
|
@Override
|
||||||
|
protected boolean computeValue() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ package org.sleuthkit.autopsy.timeline.filters;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.datamodel.TagName;
|
import org.sleuthkit.datamodel.TagName;
|
||||||
|
|
||||||
@ -23,7 +24,6 @@ public class TagsFilter extends UnionFilter<TagNameFilter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TagsFilter() {
|
public TagsFilter() {
|
||||||
getDisabledProperty().bind(Bindings.size(getSubFilters()).lessThan(1));
|
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,5 +89,8 @@ public class TagsFilter extends UnionFilter<TagNameFilter> {
|
|||||||
getSubFilters().sort(Comparator.comparing(TagNameFilter::getDisplayName));
|
getSubFilters().sort(Comparator.comparing(TagNameFilter::getDisplayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObservableBooleanValue disabledProperty() {
|
||||||
|
return Bindings.or(super.disabledProperty(), Bindings.isEmpty(getSubFilters()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.timeline.ui.filtering;
|
|||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.IndexedCell;
|
import javafx.scene.control.IndexedCell;
|
||||||
import org.sleuthkit.autopsy.timeline.filters.AbstractFilter;
|
import org.sleuthkit.autopsy.timeline.filters.AbstractFilter;
|
||||||
@ -29,7 +30,7 @@ class FilterCheckBoxCellFactory<X extends AbstractFilter> extends AbstractFXCell
|
|||||||
|
|
||||||
private final CheckBox checkBox = new CheckBox();
|
private final CheckBox checkBox = new CheckBox();
|
||||||
private SimpleBooleanProperty selectedProperty;
|
private SimpleBooleanProperty selectedProperty;
|
||||||
private SimpleBooleanProperty disabledProperty;
|
private ObservableBooleanValue disabledProperty;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureCell(IndexedCell<? extends X> cell, X item, boolean empty, Supplier<X> supplier) {
|
protected void configureCell(IndexedCell<? extends X> cell, X item, boolean empty, Supplier<X> supplier) {
|
||||||
@ -37,18 +38,17 @@ class FilterCheckBoxCellFactory<X extends AbstractFilter> extends AbstractFXCell
|
|||||||
checkBox.selectedProperty().unbindBidirectional(selectedProperty);
|
checkBox.selectedProperty().unbindBidirectional(selectedProperty);
|
||||||
}
|
}
|
||||||
if (disabledProperty != null) {
|
if (disabledProperty != null) {
|
||||||
checkBox.disableProperty().unbindBidirectional(disabledProperty);
|
checkBox.disableProperty().unbind();//disabledProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
cell.setText(null);
|
|
||||||
cell.setGraphic(null);
|
cell.setGraphic(null);
|
||||||
} else {
|
} else {
|
||||||
cell.setText(item.getDisplayName());
|
checkBox.setText(item.getDisplayName());
|
||||||
selectedProperty = item.selectedProperty();
|
selectedProperty = item.selectedProperty();
|
||||||
checkBox.selectedProperty().bindBidirectional(selectedProperty);
|
checkBox.selectedProperty().bindBidirectional(selectedProperty);
|
||||||
disabledProperty = item.getDisabledProperty();
|
disabledProperty = item.disabledProperty();
|
||||||
checkBox.disableProperty().bindBidirectional(disabledProperty);
|
checkBox.disableProperty().bind(disabledProperty);
|
||||||
cell.setGraphic(checkBox);
|
cell.setGraphic(checkBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user