diff --git a/iped-app/src/main/java/iped/app/ui/filterdecisiontree/CombinedFilterer.java b/iped-app/src/main/java/iped/app/ui/filterdecisiontree/CombinedFilterer.java index 3dbf5da88a..64b63438d5 100644 --- a/iped-app/src/main/java/iped/app/ui/filterdecisiontree/CombinedFilterer.java +++ b/iped-app/src/main/java/iped/app/ui/filterdecisiontree/CombinedFilterer.java @@ -36,7 +36,7 @@ public class CombinedFilterer implements IResultSetFilterer, IFilterChangeListener { OperandNode rootNode = new OperandNode(Operand.OR); - private final Map cachedBitSet = new HashMap(); + private final Map cachedBitSet = new HashMap<>(); int queueCount = 0; @@ -62,8 +62,8 @@ public IMultiSearchResult filterResult(IMultiSearchResult src) throws ParseExcep }; } - public void removePreCachedFilter(IFilter filter) { - cachedBitSet.remove(filter); + public void removePreCachedFilter(FilterNode node) { + cachedBitSet.remove(node); } /** @@ -167,8 +167,9 @@ public RoaringBitmap[] get(long timeout, TimeUnit unit) throws InterruptedExcept } - public void preCacheFilter(IFilter filter) { - cachedBitSet.put(filter, new FutureBitSetResult(this, filter)); + public void preCacheFilter(FilterNode node) { + IFilter filter = node.getFilter(); + cachedBitSet.put(node, new FutureBitSetResult(this, filter)); if (filter instanceof IMutableFilter) { ((IMutableFilter) filter).addFilterChangeListener(this); } @@ -370,17 +371,15 @@ public RoaringBitmap[] getBitSet(MultiSearchResult input, OperandNode op, Future } } - for (Iterator iterator = op.getChildren().iterator(); iterator.hasNext();) { + for (DecisionNode node : op.getChildren()) { if (cancelCheck != null && cancelCheck.isCancelled()) { return null; } - DecisionNode node = (DecisionNode) iterator.next(); - RoaringBitmap[] fbitset = null; if (node instanceof FilterNode) { try { - fbitset = cachedBitSet.get(((FilterNode) node).getFilter()).get(); + fbitset = cachedBitSet.get(((FilterNode) node)).get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } @@ -533,8 +532,8 @@ public boolean hasFiltersApplied() { return false; } - public void invertPreCached(IFilter op) { - FutureBitSetResult fbitset = cachedBitSet.get(op); + public void invertPreCached(FilterNode node) { + FutureBitSetResult fbitset = cachedBitSet.get(node); fbitset.invert(); } @@ -553,8 +552,4 @@ public void invalidateCache() { cbs = null; } - public void preCacheFilterClone(IFilter filter, IFilter filterClonedSrc) { - cachedBitSet.put(filter, cachedBitSet.get(filterClonedSrc)); - } - } diff --git a/iped-app/src/main/java/iped/app/ui/filterdecisiontree/OperandPopupMenu.java b/iped-app/src/main/java/iped/app/ui/filterdecisiontree/OperandPopupMenu.java index 79608472a1..6a0d7b9a27 100644 --- a/iped-app/src/main/java/iped/app/ui/filterdecisiontree/OperandPopupMenu.java +++ b/iped-app/src/main/java/iped/app/ui/filterdecisiontree/OperandPopupMenu.java @@ -14,7 +14,6 @@ import iped.app.ui.SliderMenuItem; import iped.app.ui.filterdecisiontree.OperandNode.Operand; import iped.data.IItemId; -import iped.viewers.api.IFilter; import iped.viewers.api.IItemRef; import iped.viewers.api.IQuantifiableFilter; @@ -97,13 +96,13 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == removeMenuitem) { ((DecisionNode) op).getParent().remove(op); if (op instanceof FilterNode) { - logicFilterer.removePreCachedFilter((IFilter) ((FilterNode) op).getFilter()); + logicFilterer.removePreCachedFilter((FilterNode) op); } } if (e.getSource() == inverMenuitem) { ((DecisionNode) op).invert(); if (op instanceof FilterNode) { - logicFilterer.invertPreCached(((FilterNode) op).getFilter()); + logicFilterer.invertPreCached((FilterNode) op); } logicFilterer.invalidateCache(); } @@ -162,8 +161,8 @@ public void enableRemove() { @Override public void setVisible(boolean b) { if (!b && sliderMenuItem.hasSliderChanged()) { - logicFilterer.removePreCachedFilter((IFilter) ((FilterNode) op).getFilter()); - logicFilterer.preCacheFilter((IFilter) ((FilterNode) op).getFilter()); + logicFilterer.removePreCachedFilter((FilterNode) op); + logicFilterer.preCacheFilter((FilterNode) op); logicFilterer.startSearchResult(App.get().getResults()); diff --git a/iped-app/src/main/java/iped/app/ui/filters/FilterTransferHandler.java b/iped-app/src/main/java/iped/app/ui/filters/FilterTransferHandler.java index 0940cc4fc8..f26179667d 100644 --- a/iped-app/src/main/java/iped/app/ui/filters/FilterTransferHandler.java +++ b/iped-app/src/main/java/iped/app/ui/filters/FilterTransferHandler.java @@ -173,41 +173,24 @@ public boolean importData(TransferSupport support) { } if (dest != null) { FilterNode filterNode = (FilterNode) data.getTransferData(filterNodeFlavor); - IFilter filter = null; - IFilter filterClonedSrc = null; if (filterNode != null) { if (support.getDropAction() == COPY) { - filterClonedSrc = filter; - filter = (IFilter) clone(((FilterNode) filterNode).getFilter()); - if (filter != null) { - dest.addFilter(new FilterNode(filter)); - } else { - return false; - } - } else { - if (support.getDropAction() == MOVE) { - dest.addFilter(filterNode); - tree.expandPath(destPath.pathByAddingChild(filterNode)); - } + filterNode = new FilterNode(filterNode.getFilter()); + } else if (support.getDropAction() != MOVE) { + filterNode = null; } } else { - filter = (IFilter) data.getTransferData(filterFlavor); + IFilter filter = (IFilter) data.getTransferData(filterFlavor); if (filter != null) { - FilterNode fn = new FilterNode(filter); - dest.addFilter(fn); - tree.expandPath(destPath.pathByAddingChild(fn)); + filterNode = new FilterNode(filter); } } - if (filter != null) { + if (filterNode != null) { + dest.addFilter(filterNode); + tree.expandPath(destPath.pathByAddingChild(filterNode)); tree.updateUI(); try { - if (filterClonedSrc == null) { - combinedFilterer.preCacheFilter(filter); - } else { - if (filter != filterClonedSrc) { - combinedFilterer.preCacheFilterClone(filter, filterClonedSrc); - } - } + combinedFilterer.preCacheFilter(filterNode); } catch (Exception e) { if (e.getCause() instanceof QueryNodeException) { JOptionPane.showMessageDialog(tree.getRootPane(), Messages.get("FiltersPanel.addQueryFilterError"));