From ae0a708284da686399bc75876ff63289b6c1d8ff Mon Sep 17 00:00:00 2001 From: Brian Sweeney Date: Thu, 19 Apr 2018 10:53:18 -0600 Subject: [PATCH] tab title has more detail about search criteria # Conflicts: # Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java --- .../commonfilesearch/AllDataSources.java | 5 ++ .../commonfilesearch/Bundle.properties | 4 +- .../commonfilesearch/CommonFilesMetaData.java | 4 +- .../CommonFilesMetaDataBuilder.java | 33 ++++++- .../commonfilesearch/CommonFilesPanel.form | 57 +++++++------ .../commonfilesearch/CommonFilesPanel.java | 85 ++++++++++++------- .../commonfilesearch/SingleDataSource.java | 5 ++ 7 files changed, 132 insertions(+), 61 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java index 563ea0e582..d8ee4c8ab5 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java @@ -42,4 +42,9 @@ final class AllDataSources extends CommonFilesMetaDataBuilder { Object[] args = new String[] {SELECT_PREFIX, determineMimeTypeFilter()}; return String.format(WHERE_CLAUSE, args); } + + @Override + protected String buildTabTitle() { + return String.format(Bundle.CommonFilesMetaDataBuilder_buildTabTitle_titleAll(), new Object[]{this.buildCategorySelectionString()}); + } } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/Bundle.properties b/Core/src/org/sleuthkit/autopsy/commonfilesearch/Bundle.properties index 270b14bf98..fb574160d3 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/Bundle.properties @@ -3,10 +3,10 @@ CommonFilesPanel.withinDataSourceRadioButton.text=Files must be in data source: CommonFilesPanel.allDataSourcesRadioButton.text=Files can be in any data source CommonFilesPanel.cancelButton.text=Cancel CommonFilesPanel.cancelButton.actionCommand=Cancel -CommonFilesPanel.allRadioButton.text=Match on all file types CommonFilesPanel.selectedFileCategoriesButton.text=Match on the following file categories: CommonFilesPanel.selectedFileCategoriesButton.toolTipText=Select from the options below... -CommonFilesPanel.allRadioButton.toolTipText=No filtering applied to results... CommonFilesPanel.pictureVideoCheckbox.text=Pictures and Videos CommonFilesPanel.documentsCheckbox.text=Documents CommonFilesPanel.commonFilesSearchLabel.text=Search for files that exist in multiple data sources: +CommonFilesPanel.allFileCategoriesRadioButton.toolTipText=No filtering applied to results... +CommonFilesPanel.allFileCategoriesRadioButton.text=Match on all file types diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaData.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaData.java index 32ce695b03..13a965d365 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaData.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaData.java @@ -29,16 +29,14 @@ import java.util.Map; final class CommonFilesMetaData { private final Map metadata; - private final Map dataSourceIdToNameMap; /** * Create meta dat object which can be handed off to the node factories * @param metadata map of md5 to parent-level node meta data * @param dataSourcesMap map of obj_id to data source name */ - CommonFilesMetaData(Map metadata, Map dataSourcesMap) { + CommonFilesMetaData(Map metadata) { this.metadata = metadata; - this.dataSourceIdToNameMap = dataSourcesMap; } /** diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java index 1471826fc7..312902ce49 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java @@ -33,6 +33,7 @@ import org.openide.util.Exceptions; import org.openide.util.Exceptions; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; @@ -176,8 +177,8 @@ abstract class CommonFilesMetaDataBuilder { String md5 = resultSet.getString(2); Long dataSourceId = resultSet.getLong(3); String dataSource = this.dataSourceIdToNameMap.get(dataSourceId); - - if(md5 == null || HashUtility.isNoDataMd5(md5)){ + + if (md5 == null || HashUtility.isNoDataMd5(md5)) { continue; } @@ -193,7 +194,7 @@ abstract class CommonFilesMetaDataBuilder { } } - return new CommonFilesMetaData(commonFiles, this.dataSourceIdToNameMap); + return new CommonFilesMetaData(commonFiles); } String determineMimeTypeFilter() { @@ -216,4 +217,30 @@ abstract class CommonFilesMetaDataBuilder { } return mimeTypeString; } + + @NbBundle.Messages({ + "CommonFilesMetaDataBuilder.buildTabTitle.titleAll=Common Files (All Data Sources, %s)", + "CommonFilesMetaDataBuilder.buildTabTitle.titleSingle=Common Files (Match Within Data Source: %s, %s)" + }) + protected abstract String buildTabTitle(); + + @NbBundle.Messages({ + "CommonFilesMetaDataBuilder.buildCategorySelectionString.doc=Documents", + "CommonFilesMetaDataBuilder.buildCategorySelectionString.media=Media", + "CommonFilesMetaDataBuilder.buildCategorySelectionString.all=All File Categories" + }) + protected String buildCategorySelectionString(){ + if(!this.filterByDoc && !this.filterByMedia){ + return Bundle.CommonFilesMetaDataBuilder_buildCategorySelectionString_all(); + } else { + List filters = new ArrayList(); + if(this.filterByDoc){ + filters.add(Bundle.CommonFilesMetaDataBuilder_buildCategorySelectionString_doc()); + } + if(this.filterByMedia){ + filters.add(Bundle.CommonFilesMetaDataBuilder_buildCategorySelectionString_media()); + } + return String.join(", ", filters); + } + } } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.form b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.form index 51e008d5d8..6c14b8a653 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.form +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.form @@ -27,35 +27,38 @@ - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - @@ -86,7 +89,7 @@ - + @@ -172,18 +175,21 @@ - + - + - + + + + @@ -198,6 +204,9 @@ + + + diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java index 897ba6cd04..49667c60ac 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java @@ -246,11 +246,11 @@ public final class CommonFilesPanel extends javax.swing.JPanel { CommonFilesMetaDataBuilder builder; boolean filterByMedia = false; boolean filterByDocuments = false; - if(selectedFileCategoriesButton.isSelected()) { - if(pictureVideoCheckbox.isSelected()) { + if (selectedFileCategoriesButton.isSelected()) { + if (pictureVideoCheckbox.isSelected()) { filterByMedia = true; } - if(documentsCheckbox.isSelected()) { + if (documentsCheckbox.isSelected()) { filterByDocuments = true; } } @@ -263,9 +263,11 @@ public final class CommonFilesPanel extends javax.swing.JPanel { setTitleForSingleSource(dataSourceId); } - + + this.tabTitle = builder.buildTabTitle(); + CommonFilesMetaData metaData = builder.findCommonFiles(); - + return metaData; } @@ -382,7 +384,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel { selectDataSourceComboBox = new javax.swing.JComboBox<>(); commonFilesSearchLabel = new javax.swing.JLabel(); cancelButton = new javax.swing.JButton(); - allRadioButton = new javax.swing.JRadioButton(); + allFileCategoriesRadioButton = new javax.swing.JRadioButton(); selectedFileCategoriesButton = new javax.swing.JRadioButton(); pictureVideoCheckbox = new javax.swing.JCheckBox(); documentsCheckbox = new javax.swing.JCheckBox(); @@ -437,14 +439,24 @@ public final class CommonFilesPanel extends javax.swing.JPanel { } }); - fileTypeFilterButtonGroup.add(allRadioButton); - org.openide.awt.Mnemonics.setLocalizedText(allRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allRadioButton.text")); // NOI18N - allRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allRadioButton.toolTipText")); // NOI18N + fileTypeFilterButtonGroup.add(allFileCategoriesRadioButton); + org.openide.awt.Mnemonics.setLocalizedText(allFileCategoriesRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allFileCategoriesRadioButton.text")); // NOI18N + allFileCategoriesRadioButton.setToolTipText(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allFileCategoriesRadioButton.toolTipText")); // NOI18N + allFileCategoriesRadioButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + allFileCategoriesRadioButtonActionPerformed(evt); + } + }); fileTypeFilterButtonGroup.add(selectedFileCategoriesButton); selectedFileCategoriesButton.setSelected(true); org.openide.awt.Mnemonics.setLocalizedText(selectedFileCategoriesButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.selectedFileCategoriesButton.text")); // NOI18N selectedFileCategoriesButton.setToolTipText(org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.selectedFileCategoriesButton.toolTipText")); // NOI18N + selectedFileCategoriesButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + selectedFileCategoriesButtonActionPerformed(evt); + } + }); pictureVideoCheckbox.setSelected(true); org.openide.awt.Mnemonics.setLocalizedText(pictureVideoCheckbox, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.pictureVideoCheckbox.text")); // NOI18N @@ -457,28 +469,29 @@ public final class CommonFilesPanel extends javax.swing.JPanel { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(withinDataSourceRadioButton) - .addComponent(allDataSourcesRadioButton) - .addComponent(commonFilesSearchLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() - .addComponent(allRadioButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(searchButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cancelButton)) - .addComponent(selectedFileCategoriesButton) - .addGroup(layout.createSequentialGroup() - .addGap(21, 21, 21) + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(pictureVideoCheckbox) - .addComponent(documentsCheckbox)))) + .addComponent(withinDataSourceRadioButton) + .addComponent(allDataSourcesRadioButton) + .addComponent(commonFilesSearchLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(allFileCategoriesRadioButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton)) + .addComponent(selectedFileCategoriesButton) + .addGroup(layout.createSequentialGroup() + .addGap(21, 21, 21) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(pictureVideoCheckbox) + .addComponent(documentsCheckbox))))) + .addGroup(layout.createSequentialGroup() + .addGap(38, 38, 38) + .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(38, 38, 38) - .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(19, 19, 19)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -506,7 +519,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(documentsCheckbox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(allRadioButton) + .addComponent(allFileCategoriesRadioButton) .addGap(38, 38, 38)))) ); }// //GEN-END:initComponents @@ -538,6 +551,20 @@ public final class CommonFilesPanel extends javax.swing.JPanel { SwingUtilities.windowForComponent(this).dispose(); }//GEN-LAST:event_cancelButtonActionPerformed + private void allFileCategoriesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allFileCategoriesRadioButtonActionPerformed + if (this.allFileCategoriesRadioButton.isSelected()) { + this.pictureVideoCheckbox.setEnabled(false); + this.documentsCheckbox.setEnabled(false); + } + }//GEN-LAST:event_allFileCategoriesRadioButtonActionPerformed + + private void selectedFileCategoriesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectedFileCategoriesButtonActionPerformed + if (this.selectedFileCategoriesButton.isSelected()) { + this.pictureVideoCheckbox.setEnabled(true); + this.documentsCheckbox.setEnabled(true); + } + }//GEN-LAST:event_selectedFileCategoriesButtonActionPerformed + private void withinDataSourceSelected(boolean selected) { selectDataSourceComboBox.setEnabled(selected); if (selectDataSourceComboBox.isEnabled()) { @@ -548,7 +575,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JRadioButton allDataSourcesRadioButton; - private javax.swing.JRadioButton allRadioButton; + private javax.swing.JRadioButton allFileCategoriesRadioButton; private javax.swing.JButton cancelButton; private javax.swing.JLabel commonFilesSearchLabel; private javax.swing.ButtonGroup dataSourcesButtonGroup; diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java index 75d333efd0..d94b95fa13 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java @@ -45,4 +45,9 @@ final class SingleDataSource extends CommonFilesMetaDataBuilder { Object[] args = new String[]{SELECT_PREFIX, Long.toString(this.selectedDataSourceId), determineMimeTypeFilter()}; return String.format(SingleDataSource.WHERE_CLAUSE, args); } + + @Override + protected String buildTabTitle() { + return String.format(Bundle.CommonFilesMetaDataBuilder_buildTabTitle_titleSingle(), new Object[]{this.buildCategorySelectionString()}); + } }