Skip to content

Commit

Permalink
'#2163 Removes unnecessary and complicated wrapping desing of
Browse files Browse the repository at this point in the history
FiltersPanel with its internal combinedFilterer. Implements
hasAppliedFilters of combinedFilterer to reflect on Filters Panel color.
  • Loading branch information
patrickdalla committed May 28, 2024
1 parent 55429bb commit 70dd932
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 34 deletions.
2 changes: 2 additions & 0 deletions iped-app/src/main/java/iped/app/ui/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,8 @@ public void setDockablesColors() {
}
}

setTabColor(filtersTabDock, !filterManager.isFiltererEnabled(filtersPanel.getCombinedFilterer())
|| !filtersPanel.getCombinedFilterer().hasFilters());
setTabColor(categoriesTabDock,
!filterManager.isFiltererEnabled(categoryListener) || !categoryListener.hasFilters());
setTabColor(metadataTabDock, !filterManager.isFiltererEnabled(metadataPanel) || !metadataPanel.hasFilters());
Expand Down
39 changes: 7 additions & 32 deletions iped-app/src/main/java/iped/app/ui/FiltersPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.net.URL;
import java.util.List;
import java.util.function.Predicate;

import javax.swing.DropMode;
Expand All @@ -34,8 +33,6 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

import org.apache.lucene.search.Query;

import iped.app.ui.controls.CheckBoxTreeCellRenderer;
import iped.app.ui.filterdecisiontree.CombinedFilterer;
import iped.app.ui.filterdecisiontree.DecisionNode;
Expand All @@ -48,9 +45,8 @@
import iped.viewers.api.IFilter;
import iped.viewers.api.IFilterer;
import iped.viewers.api.IMiniaturizable;
import iped.viewers.api.IQueryFilterer;

public class FiltersPanel extends JPanel implements ClearFilterListener, IQueryFilterer// internal combinedfilterer wrapper to reflect on panel color
public class FiltersPanel extends JPanel implements ClearFilterListener
{
private JTree filtersTree;
private JScrollPane filtersTreePane;
Expand Down Expand Up @@ -169,6 +165,12 @@ public void mouseMoved(MouseEvent e) {
filtersTree.setModel(new FiltersTreeModel(filterManager.getFilterers()));

combinedFilterer = new CombinedFilterer();
combinedFilterer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
App.get().setDockablesColors();
}
});

filterManager.addResultSetFilterer(combinedFilterer);
filterManager.setFilterEnabled(combinedFilterer, false);
Expand Down Expand Up @@ -387,31 +389,4 @@ public void clearFilter() {
public CombinedFilterer getCombinedFilterer() {
return combinedFilterer;
}

@Override
public List<IFilter> getDefinedFilters() {
// does not expose filters as it is not actually registered as result set
// filterer
return null;
}

@Override
public boolean hasFilters() {
// does not expose filters as it is not actually registered as result set
// filterer
return false;
}

@Override
public boolean hasFiltersApplied() {
// Wraps combofilterer
return ckStructuredFilterer != null && ckStructuredFilterer.isSelected();
}

@Override
public Query getQuery() {
// does not expose filters as it is not actually registered as result set
// filterer
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public boolean hasFilters() {

@Override
public boolean hasFiltersApplied() {
return false;
return rootNode.getChildren().size() > 0;
}

public void invertPreCached(IFilter op) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected void exportDone(JComponent source, Transferable data, int action) {

combinedFilterer.startSearchResult(App.get().getResults());

if (filtersPanel.hasFiltersApplied()) {
if (filtersPanel.getCombinedFilterer().hasFiltersApplied()) {
App.get().getAppListener().updateFileListing();
}
} catch (Exception e) {
Expand Down

0 comments on commit 70dd932

Please sign in to comment.