From 836486717c5cb48437975c41111d00b3a733581a Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Wed, 6 Mar 2019 11:35:40 -0500 Subject: [PATCH 1/2] Added sorting of the data sources to the classical tree view and the group by data source tree view --- .../datamodel/AutopsyTreeChildFactory.java | 16 ++++++++++++++-- .../autopsy/datamodel/DataSourcesNode.java | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java index 5af1d5c085..31b9e66b8f 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java @@ -22,6 +22,8 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.EnumSet; import java.util.List; import java.util.Objects; @@ -31,7 +33,6 @@ import org.openide.nodes.Node; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.CasePreferences; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.SleuthkitCase; @@ -87,6 +88,17 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable dataSources = tskCase.getDataSources(); + + //Sort the datasources so the user can find them easier in large cases + Collections.sort(dataSources, new Comparator() { + @Override + public int compare(DataSource dataS1, DataSource dataS2) { + String dataS1Name = dataS1.getName().toLowerCase(); + String dataS2Name = dataS2.getName().toLowerCase(); + return dataS1Name.compareTo(dataS2Name); + } + }); + List keys = new ArrayList<>(); dataSources.forEach((datasource) -> { keys.add(new DataSourceGrouping(datasource)); @@ -140,4 +152,4 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable(Arrays.asList(content)); } + + //Sort the datasources so the user can find them easier in large cases + Collections.sort(currentKeys, new Comparator() { + @Override + public int compare(Content content1, Content content2) { + String content1Name = content1.getName().toLowerCase(); + String content2Name = content2.getName().toLowerCase(); + return content1Name.compareTo(content2Name); + } + + }); + setKeys(currentKeys); } catch (TskCoreException | NoCurrentCaseException | TskDataException ex) { logger.log(Level.SEVERE, "Error getting data sources: {0}", ex.getMessage()); // NON-NLS @@ -165,4 +178,4 @@ public class DataSourcesNode extends DisplayableItemNode { NAME)); return sheet; } -} +} \ No newline at end of file From d3338d57e00a713df6db01f8c9f69048f41b1210 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Wed, 6 Mar 2019 11:36:43 -0500 Subject: [PATCH 2/2] Removed the comments --- .../org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java | 1 - Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java | 1 - 2 files changed, 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java index 31b9e66b8f..69e3787e99 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AutopsyTreeChildFactory.java @@ -89,7 +89,6 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable dataSources = tskCase.getDataSources(); - //Sort the datasources so the user can find them easier in large cases Collections.sort(dataSources, new Comparator() { @Override public int compare(DataSource dataS1, DataSource dataS2) { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java index a2e1d7d239..5b3f2fa32a 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java @@ -125,7 +125,6 @@ public class DataSourcesNode extends DisplayableItemNode { currentKeys = new ArrayList<>(Arrays.asList(content)); } - //Sort the datasources so the user can find them easier in large cases Collections.sort(currentKeys, new Comparator() { @Override public int compare(Content content1, Content content2) {