Merge pull request #912 from millmanorama/timeline-3.1.1_fixes

don't expand type filters by default
This commit is contained in:
Richard Cordovano 2014-10-22 14:55:54 -04:00
commit cf230c42bc
9 changed files with 71 additions and 41 deletions

View File

@ -59,6 +59,9 @@ public class RootEventType implements EventType {
private static class RootEventTypeHolder {
private static final RootEventType INSTANCE = new RootEventType();
private RootEventTypeHolder() {
}
}
@Override
@ -76,8 +79,6 @@ public class RootEventType implements EventType {
return Arrays.asList(BaseTypes.values());
}
@Override
public String getIconBase() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

View File

@ -13,7 +13,6 @@ import javafx.beans.property.SimpleBooleanProperty;
public abstract class AbstractFilter implements Filter {
private final SimpleBooleanProperty active = new SimpleBooleanProperty(true);
private final SimpleBooleanProperty disabled = new SimpleBooleanProperty(false);
@Override
@ -42,7 +41,7 @@ public abstract class AbstractFilter implements Filter {
}
@Override
public boolean isdisabled() {
public boolean isDisabled() {
return disabled.get();
}
@ -50,4 +49,7 @@ public abstract class AbstractFilter implements Filter {
public String getStringCheckBox() {
return "[" + (isActive() ? "x" : " ") + "]";
}
}

View File

@ -76,6 +76,5 @@ public interface Filter {
SimpleBooleanProperty getDisabledProperty();
boolean isdisabled();
boolean isDisabled();
}

View File

@ -37,7 +37,7 @@ public class HideKnownFilter extends AbstractFilter {
public HideKnownFilter copyOf() {
HideKnownFilter hideKnownFilter = new HideKnownFilter();
hideKnownFilter.setActive(isActive());
hideKnownFilter.setDisabled(isdisabled());
hideKnownFilter.setDisabled(isDisabled());
return hideKnownFilter;
}

View File

@ -26,13 +26,15 @@ public class IntersectionFilter extends CompoundFilter {
.map(Filter::copyOf)
.collect(Collectors.toList())));
filter.setActive(isActive());
filter.setDisabled(isdisabled());
filter.setDisabled(isDisabled());
return filter;
}
@Override
public String getDisplayName() {
return "Intersection";
return "Intersection" + getSubFilters().stream()
.map(Filter::getDisplayName)
.collect(Collectors.joining(",", "[", "]"));
}
@Override

View File

@ -56,7 +56,7 @@ public class TextFilter extends AbstractFilter {
synchronized public TextFilter copyOf() {
TextFilter textFilter = new TextFilter(getText());
textFilter.setActive(isActive());
textFilter.setDisabled(isdisabled());
textFilter.setDisabled(isDisabled());
return textFilter;
}

View File

@ -82,7 +82,7 @@ public class TypeFilter extends UnionFilter {
//make a nonrecursive copy of this filter
final TypeFilter typeFilter = new TypeFilter(eventType, false);
typeFilter.setActive(isActive());
typeFilter.setDisabled(isdisabled());
typeFilter.setDisabled(isDisabled());
//add a copy of each subfilter
this.getSubFilters().forEach((Filter t) -> {
typeFilter.getSubFilters().add(t.copyOf());

View File

@ -20,6 +20,9 @@ package org.sleuthkit.autopsy.timeline.ui.filtering;
import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
@ -67,6 +70,8 @@ public class FilterSetPanel extends BorderPane implements TimeLineView {
private TimeLineController controller;
private final ObservableMap<String, Boolean> expansionMap = FXCollections.observableHashMap();
@FXML
void initialize() {
assert applyButton != null : "fx:id=\"applyButton\" was not injected: check your FXML file 'FilterSetPanel.fxml'.";
@ -138,6 +143,7 @@ public class FilterSetPanel extends BorderPane implements TimeLineView {
public FilterSetPanel() {
FXMLConstructor.construct(this, "FilterSetPanel.fxml");
expansionMap.put("Event Type Filter", Boolean.TRUE);
}
@Override
@ -152,16 +158,14 @@ public class FilterSetPanel extends BorderPane implements TimeLineView {
@Override
public void setModel(FilteredEventsModel filteredEvents) {
this.filteredEvents = filteredEvents;
refresh();
this.filteredEvents.filter().addListener((Observable o) -> {
refresh();
});
}
private void refresh() {
filterTreeTable.setRoot(new FilterTreeItem(this.filteredEvents.filter().get().copyOf()));
filterTreeTable.setRoot(new FilterTreeItem(this.filteredEvents.filter().get().copyOf(), expansionMap));
}
/**
@ -171,23 +175,29 @@ public class FilterSetPanel extends BorderPane implements TimeLineView {
private static class FilterCheckBoxCell extends TreeTableCell<AbstractFilter, AbstractFilter> {
private final CheckBox checkBox = new CheckBox();
private SimpleBooleanProperty activeProperty;
@Override
protected void updateItem(AbstractFilter item, boolean empty) {
super.updateItem(item, empty);
Platform.runLater(() -> {
if (activeProperty != null) {
checkBox.selectedProperty().unbindBidirectional(activeProperty);
}
checkBox.disableProperty().unbind();
if (item == null) {
setText(null);
setGraphic(null);
checkBox.selectedProperty().unbind();
checkBox.disableProperty().unbind();
} else {
setText(item.getDisplayName());
checkBox.selectedProperty().bindBidirectional(item.getActiveProperty());
activeProperty = item.getActiveProperty();
checkBox.selectedProperty().bindBidirectional(activeProperty);
checkBox.disableProperty().bind(item.getDisabledProperty());
setGraphic(checkBox);
}
});
}
}
}

View File

@ -1,5 +1,8 @@
package org.sleuthkit.autopsy.timeline.ui.filtering;
import javafx.beans.Observable;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
import javafx.scene.control.TreeItem;
import org.sleuthkit.autopsy.timeline.filters.CompoundFilter;
import org.sleuthkit.autopsy.timeline.filters.Filter;
@ -16,15 +19,28 @@ public class FilterTreeItem extends TreeItem<Filter> {
* be made for them added added to the children of this
* FilterTreeItem
*/
public FilterTreeItem(Filter f) {
public FilterTreeItem(Filter f, ObservableMap<String, Boolean> expansionMap) {
super(f);
setExpanded(true);
expansionMap.addListener((MapChangeListener.Change<? extends String, ? extends Boolean> change) -> {
if (change.getKey() == f.getDisplayName()) {
setExpanded(expansionMap.get(change.getKey()));
}
});
if (expansionMap.get(f.getDisplayName()) != null) {
setExpanded(expansionMap.get(f.getDisplayName()));
}
expandedProperty().addListener((Observable observable) -> {
expansionMap.put(f.getDisplayName(), isExpanded());
});
if (f instanceof CompoundFilter) {
CompoundFilter cf = (CompoundFilter) f;
for (Filter af : cf.getSubFilters()) {
getChildren().add(new FilterTreeItem(af));
getChildren().add(new FilterTreeItem(af, expansionMap));
}
}
}