mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-09 14:49:32 +00:00
removed deprecated filters
This commit is contained in:
parent
5871aaea07
commit
99e44c9c3a
@ -1,6 +0,0 @@
|
||||
.list-cell:odd {
|
||||
-fx-background-color: transparent; /* derive(-fx-control-inner-background,-5%); */
|
||||
}
|
||||
.list-cell:even {
|
||||
-fx-background-color: transparent; /* derive(-fx-control-inner-background,-5%); */
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.net.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
|
||||
<fx:root type="javafx.scene.control.TitledPane" alignment="TOP_LEFT" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minWidth="-1.0" text="filter label" wrapText="true" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
|
||||
<content>
|
||||
<VBox fx:id="filtersBox" prefHeight="-1.0" prefWidth="-1.0" />
|
||||
</content>
|
||||
<graphic>
|
||||
<HBox alignment="CENTER_LEFT">
|
||||
<children>
|
||||
<CheckBox fx:id="selectedBox" mnemonicParsing="false" selected="true" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets left="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
</graphic>
|
||||
</fx:root>
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2013 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.FilterRow;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.AtomicFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.UnionFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FXMLConstructor;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TreeMap;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TitledPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
*
|
||||
*/
|
||||
public class FilterPane extends TitledPane {
|
||||
|
||||
@FXML
|
||||
private ResourceBundle resources;
|
||||
@FXML
|
||||
private URL location;
|
||||
@FXML
|
||||
private VBox filtersBox;
|
||||
@FXML
|
||||
private CheckBox selectedBox;
|
||||
private UnionFilter<AtomicFilter> filter;
|
||||
private Map<AtomicFilter, FilterRow> filterRowMap = new TreeMap<>(AtomicFilter.ALPHABETIC_COMPARATOR);
|
||||
|
||||
@FXML
|
||||
void initialize() {
|
||||
assert filtersBox != null : "fx:id=\"filtersBox\" was not injected: check your FXML file 'FilterPane.fxml'.";
|
||||
assert selectedBox != null : "fx:id=\"selectedBox\" was not injected: check your FXML file 'FilterPane.fxml'.";
|
||||
}
|
||||
|
||||
public FilterPane() {
|
||||
FXMLConstructor.construct(this, "FilterPane.fxml");
|
||||
}
|
||||
|
||||
private void rebuildChildren() {
|
||||
filtersBox.getChildren().clear();
|
||||
for (FilterRow af : filterRowMap.values()) {
|
||||
filtersBox.getChildren().add(af);
|
||||
}
|
||||
}
|
||||
|
||||
void setFilter(UnionFilter<AtomicFilter> filter) {
|
||||
//TODO : do this more reasonably
|
||||
this.filter = filter;
|
||||
this.setText(filter.getDisplayName());
|
||||
filterRowMap.clear();
|
||||
filtersBox.getChildren().clear();
|
||||
for (AtomicFilter af : filter.subFilters) {
|
||||
final FilterRow filterRow = af.getUI();
|
||||
filterRowMap.put(af, filterRow);
|
||||
}
|
||||
rebuildChildren();
|
||||
|
||||
this.filter.subFilters.addListener(new ListChangeListener<AtomicFilter>() {
|
||||
@Override
|
||||
public void onChanged(ListChangeListener.Change<? extends AtomicFilter> change) {
|
||||
while (change.next()) {
|
||||
for (AtomicFilter af : change.getAddedSubList()) {
|
||||
FilterRow filterRow = af.getUI();
|
||||
filterRowMap.put(af, filterRow);
|
||||
}
|
||||
for (AtomicFilter af : change.getRemoved()) {
|
||||
filterRowMap.remove(af);
|
||||
}
|
||||
}
|
||||
rebuildChildren();
|
||||
}
|
||||
});
|
||||
|
||||
this.filter.active.bindBidirectional(selectedBox.selectedProperty());
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
|
||||
<fx:root type="javafx.scene.layout.AnchorPane" id="AnchorPane" maxHeight="1.7976931348623157E308" maxWidth="-1.0" minHeight="-1.0" minWidth="200.0" prefHeight="-1.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
|
||||
<children>
|
||||
<TabPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="-1.0" prefWidth="-1.0" rotateGraphic="true" side="TOP" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<tabs>
|
||||
<Tab closable="false" text="Filters">
|
||||
<content>
|
||||
<ListView fx:id="filtersList" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="-1.0" prefWidth="-1.0" />
|
||||
</content>
|
||||
<graphic>
|
||||
<ImageView fitHeight="16.0" fitWidth="16.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../images/funnel.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Tab>
|
||||
<Tab closable="false" disable="true" text="File Tree">
|
||||
<content>
|
||||
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="-1.0" prefWidth="-1.0" />
|
||||
</content>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
</children>
|
||||
</fx:root>
|
@ -1,325 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2013 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javax.swing.SortOrder;
|
||||
import org.sleuthkit.autopsy.coreutils.LoggedTask;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FXMLConstructor;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FileUpdateEvent;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FileUpdateListener;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableDB;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.AbstractFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.AtomicFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.AttributeFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.FilterSet;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.NameFilter;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.grouping.GroupSortBy;
|
||||
|
||||
/**
|
||||
* This singleton acts as the controller for the Filters. It creates filters
|
||||
* based on values in the database, and broadcasts events when the activation
|
||||
* state or other ui configuration of the filters changes.
|
||||
*
|
||||
* deprecated until we revisit filtering
|
||||
*/
|
||||
@Deprecated
|
||||
public class FiltersPanel extends AnchorPane implements FileUpdateListener {
|
||||
|
||||
public static final String FILTER_STATE_CHANGED = "FILTER_STATE_CHANGED";
|
||||
@FXML
|
||||
private ResourceBundle resources;
|
||||
@FXML
|
||||
private URL location;
|
||||
@FXML
|
||||
private ListView< AttributeFilter> filtersList;
|
||||
private static final Logger LOGGER = Logger.getLogger(FiltersPanel.class.getName());
|
||||
volatile private DrawableDB db;
|
||||
final Map<DrawableAttribute, AttributeFilter> attrFilterMap = new HashMap<>();
|
||||
private static FiltersPanel instance;
|
||||
|
||||
/**
|
||||
* clear/reset state
|
||||
*/
|
||||
public void clear() {
|
||||
Platform.runLater(() -> {
|
||||
db = null;
|
||||
filterSet.clear();
|
||||
attrFilterMap.clear();
|
||||
});
|
||||
}
|
||||
|
||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
/**
|
||||
* listen to changes in individual filters and forward to external listeners
|
||||
* via the pcs
|
||||
*/
|
||||
private final ChangeListener filterForwardingListener = (ChangeListener<Object>) (ObservableValue<? extends Object> observable, Object oldValue, Object newValue) -> {
|
||||
pcs.firePropertyChange(new PropertyChangeEvent(observable, FILTER_STATE_CHANGED, oldValue, newValue));
|
||||
};
|
||||
|
||||
public FilterSet getFilterSet() {
|
||||
return filterSet;
|
||||
}
|
||||
/* top level filter */
|
||||
private final FilterSet filterSet = new FilterSet();
|
||||
/**
|
||||
* {@link Service} to (re)build filterset based on values in the database
|
||||
*/
|
||||
private final RebuildFiltersService rebuildFiltersService = new RebuildFiltersService();
|
||||
|
||||
|
||||
/**
|
||||
* register a {@link PropertyChangeListener}
|
||||
*
|
||||
* @param pcl
|
||||
*/
|
||||
public void addListener(PropertyChangeListener pcl) {
|
||||
pcs.addPropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void initialize() {
|
||||
assert filtersList != null : "fx:id=\"filtersList\" was not injected: check your FXML file 'FiltersPanel.fxml'.";
|
||||
|
||||
filtersList.setItems(filterSet.subFilters);
|
||||
|
||||
filtersList.setCellFactory((ListView<AttributeFilter> p) -> new FilterPaneListCell());
|
||||
for (final DrawableAttribute attr : DrawableAttribute.getValues()) {
|
||||
if (attr != DrawableAttribute.NAME && attr != DrawableAttribute.CREATED_TIME && attr != DrawableAttribute.MODIFIED_TIME) {
|
||||
final AttributeFilter attrFilter = new AttributeFilter(attr);
|
||||
filterSet.subFilters.add(attrFilter);
|
||||
attrFilterMap.put(attr, attrFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static synchronized public FiltersPanel getDefault() {
|
||||
if (instance == null) {
|
||||
instance = new FiltersPanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private FiltersPanel() {
|
||||
|
||||
FXMLConstructor.construct(this, "FiltersPanel.fxml");
|
||||
}
|
||||
|
||||
public void setDB(DrawableDB drawableDb) {
|
||||
db = drawableDb;
|
||||
db.addUpdatedFileListener(this);
|
||||
rebuildFilters();
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public void handleFileUpdate(FileUpdateEvent evt) {
|
||||
//updateFilters(evt.getUpdatedFiles());
|
||||
}
|
||||
|
||||
synchronized public void rebuildFilters() {
|
||||
/*
|
||||
* Platform.runLater(new Runnable() {
|
||||
* @Override
|
||||
* public void run() {
|
||||
* rebuildFiltersService.restart();
|
||||
* }
|
||||
* });
|
||||
* */
|
||||
}
|
||||
|
||||
synchronized public void updateFilters(final Collection< DrawableFile> files) {
|
||||
/*
|
||||
* for (DrawableFile file : files) {
|
||||
* for (final DrawableAttribute attr : DrawableAttribute.getValues()) {
|
||||
* AttributeFilter attributeFilter;
|
||||
* AbstractFilter.FilterComparison comparison = AtomicFilter.EQUALS;
|
||||
* switch (attr.attrName) {
|
||||
* case NAME:
|
||||
* case PATH:
|
||||
* case CREATED_TIME:
|
||||
* case MODIFIED_TIME:
|
||||
* case CATEGORY:
|
||||
* case OBJ_ID:
|
||||
* case ANALYZED:
|
||||
* //fall through all attributes that don't have per value filters
|
||||
* break;
|
||||
* case HASHSET:
|
||||
* comparison = AtomicFilter.CONTAINED_IN;
|
||||
* break;
|
||||
* default:
|
||||
* //default is make one == filter for each value in database
|
||||
* attributeFilter = getFilterForAttr(attr);
|
||||
*
|
||||
* ObservableList<Object> vals =
|
||||
* FXCollections.singletonObservableList(file.getValueOfAttribute(attr));
|
||||
*
|
||||
* addFilterForAttrValues(vals, attributeFilter, comparison);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
synchronized private AttributeFilter getFilterForAttr(final DrawableAttribute attr) {
|
||||
AttributeFilter attributeFilter = attrFilterMap.get(attr);
|
||||
if (attributeFilter == null) {
|
||||
attributeFilter = new AttributeFilter(attr);
|
||||
attributeFilter.active.addListener(filterForwardingListener);
|
||||
}
|
||||
|
||||
final AttributeFilter finalFilter = attributeFilter;
|
||||
|
||||
// Platform.runLater(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
if (filterSet.subFilters.contains(finalFilter) == false) {
|
||||
filterSet.subFilters.add(finalFilter);
|
||||
}
|
||||
// }
|
||||
// });
|
||||
|
||||
attrFilterMap.put(attr, attributeFilter);
|
||||
return attributeFilter;
|
||||
}
|
||||
|
||||
synchronized private void addFilterForAttrValues(List<? extends Object> vals, final AttributeFilter attributeFilter, final AbstractFilter.FilterComparison filterComparison) {
|
||||
for (final Object val : vals) {
|
||||
if (attributeFilter.containsSubFilterForValue(val) == false) {
|
||||
final AtomicFilter filter = new AtomicFilter(attributeFilter.getAttribute(), filterComparison, val);
|
||||
Platform.runLater(() -> {
|
||||
attributeFilter.subFilters.add(filter);
|
||||
});
|
||||
|
||||
filter.active.addListener(filterForwardingListener);
|
||||
// Logger.getAnonymousLogger().log(Level.INFO, "created filter " + filter);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static class FilterPaneListCell extends ListCell<AttributeFilter> {
|
||||
|
||||
private final FilterPane filterPane;
|
||||
|
||||
public FilterPaneListCell() {
|
||||
super();
|
||||
filterPane = new FilterPane();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(final AttributeFilter item, final boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
Platform.runLater(() -> {
|
||||
if (empty || item == null) {
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setGraphic(filterPane);
|
||||
filterPane.setFilter(item);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class RebuildFiltersService extends Service<Void> {
|
||||
|
||||
@Override
|
||||
protected Task<Void> createTask() {
|
||||
return new RebuildFiltersTask();
|
||||
}
|
||||
|
||||
private class RebuildFiltersTask extends LoggedTask<Void> {
|
||||
|
||||
public RebuildFiltersTask() {
|
||||
super("rebuilding filters", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
Platform.runLater(() -> {
|
||||
filterSet.subFilters.clear();
|
||||
attrFilterMap.clear();
|
||||
});
|
||||
|
||||
LOGGER.log(Level.INFO, "rebuilding filters started");
|
||||
|
||||
for (final DrawableAttribute attr : DrawableAttribute.getValues()) {
|
||||
AbstractFilter.FilterComparison comparison = AtomicFilter.EQUALS;
|
||||
switch (attr.attrName) {
|
||||
case NAME:
|
||||
final AttributeFilter nameFilter = getFilterForAttr(attr);
|
||||
final NameFilter filter = new NameFilter();
|
||||
Platform.runLater(() -> {
|
||||
nameFilter.subFilters.add(filter);
|
||||
});
|
||||
|
||||
filter.active.addListener(filterForwardingListener);
|
||||
filter.filterValue.addListener(filterForwardingListener);
|
||||
|
||||
LOGGER.log(Level.INFO, "createdfilter {0}", filter);
|
||||
break;
|
||||
|
||||
case PATH:
|
||||
case CREATED_TIME:
|
||||
case MODIFIED_TIME:
|
||||
case OBJ_ID:
|
||||
break;
|
||||
case HASHSET:
|
||||
comparison = AtomicFilter.CONTAINED_IN;
|
||||
break;
|
||||
default:
|
||||
|
||||
//default is make one == filter per attribute value in db
|
||||
final AttributeFilter attributeFilter = getFilterForAttr(attr);
|
||||
//TODO: FILE_COUNT is arbitrarty but maybe better than NONE, we can include file counts in labels in future
|
||||
List<? extends Object> vals = ImageAnalyzerController.getDefault().getGroupManager().findValuesForAttribute(attr, GroupSortBy.FILE_COUNT, SortOrder.DESCENDING);
|
||||
addFilterForAttrValues(vals, attributeFilter, comparison);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import java.util.List;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jonathan
|
||||
*/
|
||||
public abstract class AbstractFilter<R> {
|
||||
|
||||
public abstract void clear();
|
||||
public static final AtomicFilter.FilterComparison EQUALS = new AtomicFilter.EQUALS();
|
||||
public static final AtomicFilter.FilterComparison EQUALS_IGNORECASE = new AtomicFilter.EQUALS_IGNORECASE();
|
||||
public static final AtomicFilter.FilterComparison NOT_EQUALS = new AtomicFilter.NOT_EQUALS();
|
||||
public static final AtomicFilter.FilterComparison SUBSTRING = new AtomicFilter.SUBSTRING();
|
||||
public static final AtomicFilter.FilterComparison CONTAINED_IN = new AtomicFilter.CONTAINS();
|
||||
public final SimpleBooleanProperty active = new SimpleBooleanProperty(true);
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
abstract public Boolean accept(DrawableFile df);
|
||||
|
||||
public boolean isActive() {
|
||||
return active.get();
|
||||
}
|
||||
|
||||
final protected static class CONTAINS extends AtomicFilter.FilterComparison<List<String>, String> {
|
||||
|
||||
@Override
|
||||
public String getSqlOperator() {
|
||||
return " in ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean compare(List<String> attrVal, String filterVal) {
|
||||
return attrVal.contains(filterVal);
|
||||
}
|
||||
}
|
||||
|
||||
final protected static class SUBSTRING extends AtomicFilter.FilterComparison<String, String> {
|
||||
|
||||
@Override
|
||||
public Boolean compare(String attrVal, String filterVal) {
|
||||
return attrVal.toLowerCase().contains(filterVal.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlOperator() {
|
||||
return " like ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "in";
|
||||
}
|
||||
}
|
||||
|
||||
final protected static class EQUALS_IGNORECASE extends AtomicFilter.FilterComparison<String, String> {
|
||||
|
||||
@Override
|
||||
public Boolean compare(String attrVal, String filterVal) {
|
||||
return attrVal.equals(filterVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlOperator() {
|
||||
return " == ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "=";
|
||||
}
|
||||
}
|
||||
|
||||
final protected static class EQUALS<T> extends AtomicFilter.FilterComparison<T, T> {
|
||||
|
||||
@Override
|
||||
public Boolean compare(T attrVal, T filterVal) {
|
||||
return attrVal.equals(filterVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlOperator() {
|
||||
return " == ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "=";
|
||||
}
|
||||
}
|
||||
|
||||
final protected static class NOT_EQUALS<T> extends AtomicFilter.FilterComparison<T, T> {
|
||||
|
||||
@Override
|
||||
public Boolean compare(T attrVal, T filterVal) {
|
||||
return attrVal != filterVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlOperator() {
|
||||
return " != ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "≠";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static abstract class FilterComparison<A, F> {
|
||||
|
||||
private FilterComparison() {
|
||||
}
|
||||
|
||||
abstract public Boolean compare(A attrVal, F filterVal);
|
||||
|
||||
abstract public String getSqlOperator();
|
||||
}
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FXMLConstructor;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import java.net.URL;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AtomicFilter<A, F> extends AbstractFilter {
|
||||
|
||||
private DrawableAttribute<A> filterAttribute;
|
||||
|
||||
public DrawableAttribute<A> getFilterAttribute() {
|
||||
return filterAttribute;
|
||||
}
|
||||
|
||||
public F getFilterValue() {
|
||||
return filterValue.get();
|
||||
}
|
||||
|
||||
public FilterComparison<A, F> getFilterComparisson() {
|
||||
return filterComparisson;
|
||||
}
|
||||
public SimpleObjectProperty<F> filterValue;
|
||||
private FilterComparison<A, F> filterComparisson;
|
||||
|
||||
public AtomicFilter(DrawableAttribute filterAttribute, FilterComparison<A, F> filterComparisson, F filterValue) {
|
||||
this.filterAttribute = filterAttribute;
|
||||
this.filterValue = new SimpleObjectProperty<>(filterValue);
|
||||
this.filterComparisson = filterComparisson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean accept(DrawableFile df) {
|
||||
// Logger.getAnonymousLogger().log(Level.INFO, getDisplayName() + " : " + filterValue + " filtered " + df.getName() + " = " + compare);
|
||||
return isActive()
|
||||
? filterComparisson.compare((A) df.getValueOfAttribute(filterAttribute), filterValue.get())
|
||||
: false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 79 * hash + Objects.hashCode(this.filterAttribute);
|
||||
hash = 79 * hash + Objects.hashCode(this.filterValue);
|
||||
hash = 79 * hash + Objects.hashCode(this.filterComparisson);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final AtomicFilter other = (AtomicFilter) obj;
|
||||
if (this.filterAttribute != other.filterAttribute) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.filterValue, other.filterValue)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.filterComparisson, other.filterComparisson)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return filterValue.get().toString();
|
||||
}
|
||||
|
||||
public FilterRow getUI() {
|
||||
return new AtomicFilterRow(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
active.set(true);
|
||||
}
|
||||
public static final Comparator<AtomicFilter> ALPHABETIC_COMPARATOR = new Comparator<AtomicFilter>() {
|
||||
@Override
|
||||
public int compare(AtomicFilter o1, AtomicFilter o2) {
|
||||
return o1.getDisplayName().compareTo(o2.getDisplayName());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jonathan
|
||||
*/
|
||||
public static class AtomicFilterRow<A, F> extends FilterRow<AtomicFilter<A, F>> {
|
||||
|
||||
@FXML
|
||||
protected ResourceBundle resources;
|
||||
@FXML
|
||||
protected URL location;
|
||||
@FXML
|
||||
protected ChoiceBox comparisonBox;
|
||||
@FXML
|
||||
protected Label filterLabel;
|
||||
@FXML
|
||||
protected CheckBox selectedBox;
|
||||
protected final AtomicFilter<A, F> filter;
|
||||
|
||||
private AtomicFilterRow(AtomicFilter filter) {
|
||||
super();
|
||||
this.filter = filter;
|
||||
FXMLConstructor.construct(this, "FilterRow.fxml");
|
||||
}
|
||||
|
||||
public ReadOnlyBooleanProperty getSelectedProperty() {
|
||||
return selectedBox.selectedProperty();
|
||||
}
|
||||
|
||||
public ReadOnlyObjectProperty<AtomicFilter.FilterComparison> getComparisonProperty() {
|
||||
return comparisonBox.getSelectionModel().selectedItemProperty();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void initialize() {
|
||||
assert comparisonBox != null : "fx:id=\"comparisonBox\" was not injected: check your FXML file 'FilterRow.fxml'.";
|
||||
assert filterLabel != null : "fx:id=\"filterLabel\" was not injected: check your FXML file 'FilterRow.fxml'.";
|
||||
assert selectedBox != null : "fx:id=\"selectedBox\" was not injected: check your FXML file 'FilterRow.fxml'.";
|
||||
comparisonBox.getItems().setAll(AtomicFilter.EQUALS, AtomicFilter.EQUALS_IGNORECASE);
|
||||
switch (filter.filterAttribute.attrName) {
|
||||
case MAKE:
|
||||
case MODEL:
|
||||
comparisonBox.getSelectionModel().select(AtomicFilter.EQUALS_IGNORECASE);
|
||||
break;
|
||||
default:
|
||||
comparisonBox.getSelectionModel().select(AtomicFilter.EQUALS);
|
||||
}
|
||||
final F filterValue = filter.getFilterValue();
|
||||
|
||||
if (filterValue == null || "".equals(filterValue)) {
|
||||
filterLabel.setText("unknown");
|
||||
} else {
|
||||
filterLabel.setText(filterValue.toString());
|
||||
}
|
||||
selectedBox.selectedProperty().bindBidirectional(filter.active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AtomicFilter<A, F> getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
|
||||
|
||||
public class AtomicSqlFilter extends AtomicFilter implements SqlFilter {
|
||||
|
||||
public AtomicSqlFilter(DrawableAttribute filterAttribute, FilterComparison filterComparisson, Object filterValue) {
|
||||
super(filterAttribute, filterComparisson, filterValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFilterQueryString() {
|
||||
return getFilterAttribute().attrName.name() + " " + getFilterComparisson().getSqlOperator() + " " + getFilterValue().toString();
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jonathan
|
||||
*/
|
||||
public class AttributeFilter<AVT, FVT> extends UnionFilter<AtomicFilter<AVT, FVT>> {
|
||||
|
||||
DrawableAttribute filterAttribute;
|
||||
|
||||
public AttributeFilter(DrawableAttribute filterAttribute) {
|
||||
super();
|
||||
this.filterAttribute = filterAttribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return filterAttribute.getDisplayName();
|
||||
}
|
||||
|
||||
public DrawableAttribute getAttribute() {
|
||||
return filterAttribute;
|
||||
}
|
||||
|
||||
public boolean containsSubFilterForValue(FVT val) {
|
||||
try {
|
||||
for (AtomicFilter sf : subFilters) {
|
||||
if (val.equals(sf.getFilterValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class CompoundFilter<T extends AbstractFilter> extends AbstractFilter {
|
||||
|
||||
public ObservableList<T> subFilters;
|
||||
|
||||
public CompoundFilter(ObservableList< T> subFilters) {
|
||||
this.subFilters = FXCollections.synchronizedObservableList(subFilters);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (T filter : subFilters) {
|
||||
filter.clear();
|
||||
}
|
||||
active.set(true);
|
||||
subFilters.clear();
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.collections.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
|
||||
<fx:root type="javafx.scene.layout.AnchorPane" id="AnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="0.0" prefHeight="-1.0" prefWidth="-1.0" style="" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
|
||||
<children>
|
||||
<HBox alignment="CENTER_LEFT" fillHeight="true" prefHeight="-1.0" prefWidth="-1.0" spacing="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<CheckBox fx:id="selectedBox" mnemonicParsing="false" prefHeight="-1.0" prefWidth="-1.0" selected="true" text="" HBox.hgrow="NEVER" />
|
||||
<ChoiceBox fx:id="comparisonBox" minHeight="-1.0" minWidth="0.0" prefHeight="-1.0" prefWidth="0.0" style=" -fx-background-color: linear-gradient(to bottom, derive(-fx-base,-30%), derive(-fx-base,-60%)), linear-gradient(to bottom, derive(-fx-base,65%) 2%, derive(-fx-base,-20%) 95%);" visible="false" HBox.hgrow="NEVER">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="Item 1" />
|
||||
<String fx:value="Item 2" />
|
||||
<String fx:value="Item 3" />
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ChoiceBox>
|
||||
<Label fx:id="filterLabel" minWidth="50.0" text="Label" wrapText="true" HBox.hgrow="NEVER" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
</children>
|
||||
</fx:root>
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.filtering.filters.AbstractFilter;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jmillman
|
||||
*/
|
||||
public abstract class FilterRow<T extends AbstractFilter> extends AnchorPane {
|
||||
|
||||
public abstract T getFilter();
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jonathan
|
||||
*/
|
||||
public class FilterSet extends IntersectionFilter<AttributeFilter> {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Filters";
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
/**
|
||||
*
|
||||
* Intersection(And) filter
|
||||
*/
|
||||
public abstract class IntersectionFilter<T extends AbstractFilter> extends CompoundFilter<T> {
|
||||
|
||||
public IntersectionFilter(ObservableList< T> subFilters) {
|
||||
super(subFilters);
|
||||
}
|
||||
|
||||
public IntersectionFilter() {
|
||||
super(FXCollections.<T>observableArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean accept(DrawableFile df) {
|
||||
if (isActive()) {
|
||||
for (T f : subFilters) {
|
||||
if (f.isActive() && f.accept(df) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.FXMLConstructor;
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NameFilter extends AtomicFilter<String, String> {
|
||||
|
||||
public NameFilter() {
|
||||
super(DrawableAttribute.NAME, SUBSTRING, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterRow getUI() {
|
||||
return new NameRow(this);
|
||||
}
|
||||
|
||||
private void setValue(String text) {
|
||||
filterValue.set(text);
|
||||
}
|
||||
|
||||
private static class NameRow extends FilterRow<NameFilter> {
|
||||
|
||||
@FXML
|
||||
private ResourceBundle resources;
|
||||
@FXML
|
||||
private URL location;
|
||||
@FXML
|
||||
private TextField textField;
|
||||
private final NameFilter filter;
|
||||
|
||||
@FXML
|
||||
void initialize() {
|
||||
assert textField != null : "fx:id=\"textField\" was not injected: check your FXML file 'NameFilterRow.fxml'.";
|
||||
|
||||
textField.textProperty().addListener(new InvalidationListener() {
|
||||
@Override
|
||||
public void invalidated(Observable observable) {
|
||||
filter.setValue(textField.getText());
|
||||
}
|
||||
});
|
||||
|
||||
// //hack to make listener hear that this filter has changed
|
||||
// filter.active.set(!filter.isActive());
|
||||
// filter.active.set(!filter.isActive());
|
||||
}
|
||||
|
||||
private NameRow(NameFilter filter) {
|
||||
this.filter = filter;
|
||||
FXMLConstructor.construct(this, "NameFilterRow.fxml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
|
||||
<fx:root type="javafx.scene.layout.AnchorPane" id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="200.0" prefHeight="-1.0" prefWidth="-1.0" style="" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
|
||||
<children>
|
||||
<TextField fx:id="textField" disable="false" editable="true" focusTraversable="false" maxHeight="-Infinity" maxWidth="-Infinity" minWidth="-1.0" prefColumnCount="12" prefWidth="-1.0" promptText="enter search term" style="" text="" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</fx:root>
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface SqlFilter {
|
||||
|
||||
public Boolean accept(DrawableFile df);
|
||||
|
||||
public String getFilterQueryString();
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.imageanalyzer.filtering.filters;
|
||||
|
||||
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
/**
|
||||
*
|
||||
* Union(or) filter
|
||||
*/
|
||||
abstract public class UnionFilter<T extends AbstractFilter> extends CompoundFilter<T> {
|
||||
|
||||
public UnionFilter(ObservableList<T> subFilters) {
|
||||
super(subFilters);
|
||||
}
|
||||
|
||||
public UnionFilter() {
|
||||
super(FXCollections.<T>observableArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean accept(DrawableFile df) {
|
||||
if (isActive()) {
|
||||
for (T f : subFilters) {
|
||||
if (f.isActive() && f.accept(df) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user