Merge branch '5370-AddFileSearchCaching' of https://github.com/wschaeferB/autopsy into 5369-DedupingCodeChanges

This commit is contained in:
William Schaefer 2019-08-13 16:06:03 -04:00
commit e1fb17040c
5 changed files with 111 additions and 88 deletions

View File

@ -158,7 +158,7 @@ ResultsPanel.currentPage.displayValue=Page: {0} of {1}
ResultsPanel.currentPageLabel.text=Page: -
# {0} - selectedPage
# {1} - maxPage
ResultsPanel.invalidPageNumber.message=The selected page number {0} does not exist. Please select a value of at least 1 and at most {1}
ResultsPanel.invalidPageNumber.message=The selected page number {0} does not exist. Please select a value from 1 to {1}.
ResultsPanel.invalidPageNumber.title=Invalid Page Number
ResultsPanel.pageControlsLabel.text=Pages:
ResultsPanel.gotoPageLabel.text=Go to Page:

View File

@ -201,6 +201,13 @@ final class DiscoveryEvents {
}
}
static final class NoResultsEvent {
NoResultsEvent(){
//no arg conustructor
}
}
/**
* Event to signal that a group has been selected.
*/

View File

@ -43,17 +43,16 @@ class FileSearchData {
"FileSearchData.Frequency.count_50.displayName=21 - 50",
"FileSearchData.Frequency.count_100.displayName=51 - 100",
"FileSearchData.Frequency.common.displayName=Common",
"FileSearchData.Frequency.unknown.displayName=Unknown",
})
"FileSearchData.Frequency.unknown.displayName=Unknown",})
enum Frequency {
UNIQUE(0, 1, Bundle.FileSearchData_Frequency_unique_displayName()),
RARE(1, 5, Bundle.FileSearchData_Frequency_rare_displayName()),
COUNT_10(2, 10, Bundle.FileSearchData_Frequency_count_10_displayName()),
COUNT_20(3, 20, Bundle.FileSearchData_Frequency_count_20_displayName()),
COUNT_50(4, 50, Bundle.FileSearchData_Frequency_count_50_displayName()),
COUNT_100(5, 100, Bundle.FileSearchData_Frequency_count_100_displayName()),
COMMON(6, 0, Bundle.FileSearchData_Frequency_common_displayName()),
UNKNOWN(7, 0, Bundle.FileSearchData_Frequency_unknown_displayName());
UNIQUE(0, 1, Bundle.FileSearchData_Frequency_unique_displayName()),
RARE(1, 5, Bundle.FileSearchData_Frequency_rare_displayName()),
COUNT_10(2, 10, Bundle.FileSearchData_Frequency_count_10_displayName()),
COUNT_20(3, 20, Bundle.FileSearchData_Frequency_count_20_displayName()),
COUNT_50(4, 50, Bundle.FileSearchData_Frequency_count_50_displayName()),
COUNT_100(5, 100, Bundle.FileSearchData_Frequency_count_100_displayName()),
COMMON(6, 0, Bundle.FileSearchData_Frequency_common_displayName()),
UNKNOWN(7, 0, Bundle.FileSearchData_Frequency_unknown_displayName());
private final int ranking;
private final String displayName;
@ -122,15 +121,14 @@ class FileSearchData {
"FileSearchData.FileSize.OVER_50MB.displayName=50 - 200 MB",
"FileSearchData.FileSize.OVER_1MB.displayName=1 - 50 MB",
"FileSearchData.FileSize.OVER_100KB.displayName=100 KB - 1 MB",
"FileSearchData.FileSize.UNDER_100KB.displayName=Under 100 KB",
})
"FileSearchData.FileSize.UNDER_100KB.displayName=Under 100 KB",})
enum FileSize {
OVER_1GB(0, 1000 * BYTES_PER_MB, -1, Bundle.FileSearchData_FileSize_OVER_1GB_displayName()),
OVER_200MB(1, 200 * BYTES_PER_MB, 1000, Bundle.FileSearchData_FileSize_OVER_200MB_displayName()),
OVER_50MB(2, 50 * BYTES_PER_MB, 200, Bundle.FileSearchData_FileSize_OVER_50MB_displayName()),
OVER_1MB(3, 1 * BYTES_PER_MB, 50, Bundle.FileSearchData_FileSize_OVER_1MB_displayName()),
OVER_100KB(4, 1000, 1 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_OVER_100KB_displayName()),
UNDER_100KB(5, 0, 1000, Bundle.FileSearchData_FileSize_UNDER_100KB_displayName());
OVER_200MB(1, 200 * BYTES_PER_MB, 1000 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_OVER_200MB_displayName()),
OVER_50MB(2, 50 * BYTES_PER_MB, 200 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_OVER_50MB_displayName()),
OVER_1MB(3, 1 * BYTES_PER_MB, 50 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_OVER_1MB_displayName()),
OVER_100KB(4, 100000, 1 * BYTES_PER_MB, Bundle.FileSearchData_FileSize_OVER_100KB_displayName()),
UNDER_100KB(5, 0, 100000, Bundle.FileSearchData_FileSize_UNDER_100KB_displayName());
private final int ranking; // Must be unique for each value
private final long minBytes; // Note that the size must be strictly greater than this to match
@ -138,11 +136,11 @@ class FileSearchData {
private final String displayName;
final static long NO_MAXIMUM = -1;
FileSize(int ranking, long minMB, long maxMB, String displayName) {
FileSize(int ranking, long minB, long maxB, String displayName) {
this.ranking = ranking;
this.minBytes = minMB;
if (maxMB >= 0) {
this.maxBytes = maxMB;
this.minBytes = minB;
if (maxB >= 0) {
this.maxBytes = maxB;
} else {
this.maxBytes = NO_MAXIMUM;
}
@ -150,8 +148,8 @@ class FileSearchData {
}
/**
* Get the enum corresponding to the given file size.
* The file size must be strictly greater than minBytes.
* Get the enum corresponding to the given file size. The file size must
* be strictly greater than minBytes.
*
* @param size the file size
*
@ -207,10 +205,10 @@ class FileSearchData {
}
/**
* Enum representing the file type.
* We don't simply use FileTypeUtils.FileTypeCategory because:
* - Some file types categories overlap
* - It is convenient to have the "OTHER" option for files that don't match the given types
* Enum representing the file type. We don't simply use
* FileTypeUtils.FileTypeCategory because: - Some file types categories
* overlap - It is convenient to have the "OTHER" option for files that
* don't match the given types
*/
@NbBundle.Messages({
"FileSearchData.FileType.Audio.displayName=Audio",
@ -232,7 +230,7 @@ class FileSearchData {
private final String displayName;
private final Collection<String> mediaTypes;
private FileType (int value, String displayName, Collection<String> mediaTypes) {
private FileType(int value, String displayName, Collection<String> mediaTypes) {
this.ranking = value;
this.displayName = displayName;
this.mediaTypes = mediaTypes;
@ -293,8 +291,7 @@ class FileSearchData {
@NbBundle.Messages({
"FileSearchData.Score.notable.displayName=Notable",
"FileSearchData.Score.interesting.displayName=Interesting",
"FileSearchData.Score.unknown.displayName=Unknown",
})
"FileSearchData.Score.unknown.displayName=Unknown",})
enum Score {
NOTABLE(0, Bundle.FileSearchData_Score_notable_displayName()),
INTERESTING(1, Bundle.FileSearchData_Score_interesting_displayName()),

View File

@ -121,15 +121,19 @@ class GroupListPanel extends javax.swing.JPanel {
*/
private void groupSelected(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_groupSelected
if (!evt.getValueIsAdjusting()) {
String selectedGroup = groupDisplayNameList.getSelectedValue().replaceAll(" \\([0-9]+\\)$", "");
for (String groupName : groupMap.keySet()) {
if (selectedGroup.equalsIgnoreCase(groupName)) {
selectedGroupName = groupName;
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.GroupSelectedEvent(
searchfilters, groupingAttribute, groupSort, fileSortMethod, selectedGroupName, groupMap.get(selectedGroupName), resultType));
if (groupDisplayNameList.getSelectedValue() != null) {
String selectedGroup = groupDisplayNameList.getSelectedValue().replaceAll(" \\([0-9]+\\)$", "");
for (String groupName : groupMap.keySet()) {
if (selectedGroup.equalsIgnoreCase(groupName)) {
selectedGroupName = groupName;
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.GroupSelectedEvent(
searchfilters, groupingAttribute, groupSort, fileSortMethod, selectedGroupName, groupMap.get(selectedGroupName), resultType));
break;
}
}
} else {
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.NoResultsEvent());
}
}
}//GEN-LAST:event_groupSelected

View File

@ -77,6 +77,7 @@ public class ResultsPanel extends javax.swing.JPanel {
currentPage = pageRetrievedEvent.getPageNumber();
updateControls();
thumbnailViewer.resetComponent();
tableViewer.resetComponent();
resultsViewerPanel.remove(thumbnailViewer);
resultsViewerPanel.remove(tableViewer);
if (pageRetrievedEvent.getType() == FileSearchData.FileType.IMAGE || pageRetrievedEvent.getType() == FileSearchData.FileType.VIDEO) {
@ -104,7 +105,7 @@ public class ResultsPanel extends javax.swing.JPanel {
* @param groupSelectedEvent The GroupSelectedEvent received.
*/
@Subscribe
void handlePageChangedEvent(DiscoveryEvents.GroupSelectedEvent groupSelectedEvent) {
void handleGroupSelectedEvent(DiscoveryEvents.GroupSelectedEvent groupSelectedEvent) {
SwingUtilities.invokeLater(() -> {
searchFilters = groupSelectedEvent.getFilters();
groupingAttribute = groupSelectedEvent.getGroupingAttr();
@ -117,6 +118,20 @@ public class ResultsPanel extends javax.swing.JPanel {
});
}
@Subscribe
void handleNoResultsEvent(DiscoveryEvents.NoResultsEvent noResultsEven) {
SwingUtilities.invokeLater(() -> {
groupSize = 0;
currentPage = 0;
updateControls();
thumbnailViewer.resetComponent();
thumbnailViewer.setNode(new TableFilterNode(new DataResultFilterNode(Node.EMPTY), true));
tableViewer.setNode(new TableFilterNode(new DataResultFilterNode(Node.EMPTY), true));
resultsViewerPanel.revalidate();
resultsViewerPanel.repaint();
});
}
/**
* Set the page number and retrieve its contents.
*
@ -332,7 +347,7 @@ public class ResultsPanel extends javax.swing.JPanel {
*/
@Messages({"# {0} - selectedPage",
"# {1} - maxPage",
"ResultsPanel.invalidPageNumber.message=The selected page number {0} does not exist. Please select a value of at least 1 and at most {1}",
"ResultsPanel.invalidPageNumber.message=The selected page number {0} does not exist. Please select a value from 1 to {1}.",
"ResultsPanel.invalidPageNumber.title=Invalid Page Number"})
private void gotoPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gotoPageFieldActionPerformed
int newPage;