diff --git a/iped-app/src/main/java/iped/app/ui/App.java b/iped-app/src/main/java/iped/app/ui/App.java index d3da39defe..a76f33d8da 100644 --- a/iped-app/src/main/java/iped/app/ui/App.java +++ b/iped-app/src/main/java/iped/app/ui/App.java @@ -811,7 +811,7 @@ public void actionPerformed(ActionEvent event) { filterManager.addQueryFilterer(TableHeaderFilterManager.get()); filterManager.addResultSetFilterer(bookmarksListener); filterManager.addResultSetFilterer(FilterSelectedEdges.getInstance()); - filterManager.addResultSetFilterer(duplicatesFilterer, false); + filterManager.addResultSetFilterer(duplicatesFilterer); filterManager.addResultSetFilterer(similarImagesFilterer); filterManager.addResultSetFilterer(similarFacesSearchFilterer); filterManager.addResultSetFilterer(timelineListener); @@ -1768,6 +1768,16 @@ public void setItem(IItemId itemId, IItem similarImagesFilterer) { item = similarImagesFilterer; imageFilter = new SimilarImageFilter(itemId, item); } + + @Override + public void restoreDefinedFilters(List filtersToRestore) { + for (IFilter filter : filtersToRestore) { + if (filter instanceof SimilarImageFilter) { + imageFilter = (SimilarImageFilter) filter; + break; + } + } + } }; class DuplicateFilter implements IResultSetFilter, IMutableFilter { @@ -1787,6 +1797,9 @@ public IMultiSearchResult filterResult(IMultiSearchResult src) throws ParseExcep IResultSetFilter duplicateFilter = new DuplicateFilter(); class DuplicatesFilterer implements IResultSetFilterer { + + IResultSetFilter cduplicateFilter = duplicateFilter; + @Override public List getDefinedFilters() { ArrayList result = new ArrayList(); @@ -1807,7 +1820,7 @@ public IFilter getFilter() { @Override public boolean hasFilters() { - return true; + return cduplicateFilter != null; } @Override @@ -1818,9 +1831,18 @@ public boolean hasFiltersApplied() { @Override public void clearFilter() { appletListener.clearAllFilters = true; + cduplicateFilter = null; if (filterDuplicates.isSelected()) filterDuplicates.doClick(); appletListener.clearAllFilters = false; + this.fireActionListener(new ActionEvent(this, IFilterer.DISABLE_FILTER_EVENT, "DESELECTED")); + } + + @Override + public void restoreDefinedFilters(List filtersToRestore) { + cduplicateFilter = duplicateFilter; + filterDuplicates.setSelected(true); + this.fireActionListener(new ActionEvent(this, IFilterer.ENABLE_FILTER_EVENT, "SELECTED")); } } @@ -1958,6 +1980,34 @@ public void clearFilter() { SimilarFacesFilterActions.clear(false); } + @Override + public void restoreDefinedFilters(List filtersToRestore) { + for (IFilter filter : filtersToRestore) { + if (filter instanceof SimilarFacesSearchFilter) { + filter = (SimilarFacesSearchFilter) filter; + break; + } + } + } + + } + + class SearchFilter implements IQueryFilter { + String filterText; + + public SearchFilter(String filterText) { + this.filterText = filterText; + } + + @Override + public Query getQuery() { + return query; + } + + public String toString() { + return filterText; + } + } class SearchFilterer implements IQueryFilterer { @@ -1969,18 +2019,7 @@ public List getDefinedFilters() { Query query; try { query = new QueryBuilder(appCase).getQuery(filterText); - result.add(new IQueryFilter() { - String title = filterText; - - @Override - public Query getQuery() { - return query; - } - - public String toString() { - return title; - } - }); + result.add(new SearchFilter(filterText)); } catch (ParseException | QueryNodeException e) { e.printStackTrace(); } @@ -2031,6 +2070,17 @@ public void clearFilter() { appletListener.clearAllFilters = false; } + @Override + public void restoreDefinedFilters(List filtersToRestore) { + for (IFilter filter : filtersToRestore) { + if (filter instanceof SearchFilter) { + filter = (SearchFilter) filter; + queryComboBox.setSelectedItem(((SearchFilter) filter).filterText); + break; + } + } + } + } public IItem getSimilarImagesQueryRefItem() { @@ -2173,9 +2223,29 @@ public void setPercent(int percent) { this.percent = percent; filter = null; } + + @Override + public void restoreDefinedFilters(List filtersToRestore) { + for (IFilter filter : filtersToRestore) { + if (filter instanceof SimilarDocumentFilter) { + filter = (SimilarDocumentFilter) filter; + break; + } + } + } } public AppListener getAppletListener() { return appletListener; } + + public void selectFilterDuplicates(boolean selected) { + if (selected) { + duplicatesFilterer.cduplicateFilter = duplicateFilter; + duplicatesFilterer.fireActionListener(new ActionEvent(this, IFilterer.ENABLE_FILTER_EVENT, "SELECTED")); + } else { + duplicatesFilterer.cduplicateFilter = null; + duplicatesFilterer.fireActionListener(new ActionEvent(this, IFilterer.DISABLE_FILTER_EVENT, "DESELECTED")); + } + } } diff --git a/iped-app/src/main/java/iped/app/ui/AppListener.java b/iped-app/src/main/java/iped/app/ui/AppListener.java index 4a553c0484..c37b76ab04 100644 --- a/iped-app/src/main/java/iped/app/ui/AppListener.java +++ b/iped-app/src/main/java/iped/app/ui/AppListener.java @@ -141,12 +141,8 @@ public void actionPerformed(ActionEvent evt) { } if (evt.getSource() == App.get().filterDuplicates) { - if (!App.get().filterDuplicates.isSelected()) { - App.get().filterManager.setFilterEnabled(App.get().duplicatesFilterer, false); - } else { - App.get().filterManager.setFilterEnabled(App.get().duplicatesFilterer, true); - } - + App.get().selectFilterDuplicates(App.get().filterDuplicates.isSelected()); + updateFileListing(); App.get().filtersPanel.updateUI(); updateFileList = true; } diff --git a/iped-app/src/main/java/iped/app/ui/CategoryTreeListener.java b/iped-app/src/main/java/iped/app/ui/CategoryTreeListener.java index c76b8c533c..ea6236b35a 100644 --- a/iped-app/src/main/java/iped/app/ui/CategoryTreeListener.java +++ b/iped-app/src/main/java/iped/app/ui/CategoryTreeListener.java @@ -168,7 +168,7 @@ public Category getCategory() { } @Override - public void restoreDefineFilters(List filtersToRestore) { + public void restoreDefinedFilters(List filtersToRestore) { if (filtersToRestore == null) { return; } diff --git a/iped-app/src/main/java/iped/app/ui/FiltersPanel.java b/iped-app/src/main/java/iped/app/ui/FiltersPanel.java index 4d3813e9c7..43dbbe2f59 100644 --- a/iped-app/src/main/java/iped/app/ui/FiltersPanel.java +++ b/iped-app/src/main/java/iped/app/ui/FiltersPanel.java @@ -137,7 +137,7 @@ public void actionPerformed(ActionEvent e) { } else { List clastFilters = lastFilters.get(filterer); if (clastFilters != null) { - filterer.restoreDefineFilters(clastFilters); + filterer.restoreDefinedFilters(clastFilters); App.get().getAppListener().updateFileListing(); App.get().filtersPanel.updateUI(); } diff --git a/iped-viewers/iped-viewers-api/src/main/java/iped/viewers/api/IFilterer.java b/iped-viewers/iped-viewers-api/src/main/java/iped/viewers/api/IFilterer.java index cd3094f42b..a5a7c60691 100644 --- a/iped-viewers/iped-viewers-api/src/main/java/iped/viewers/api/IFilterer.java +++ b/iped-viewers/iped-viewers-api/src/main/java/iped/viewers/api/IFilterer.java @@ -35,8 +35,8 @@ public interface IFilterer extends ClearFilterListener, ActionListenerControl { * * @return */ - default public void restoreDefineFilters(List filtersToRestore) { - return; + default public void restoreDefinedFilters(List filtersToRestore){ + } default public String getFilterName() {