From 78e61c68274076139765a8788f92db1588340944 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 23 Oct 2019 18:27:51 -0400 Subject: [PATCH 01/14] 5677 display score and deleted status in icons for discovery tool --- .../filequery/Bundle.properties-MERGED | 4 + .../filequery/ImageThumbnailPanel.form | 38 ++++++-- .../filequery/ImageThumbnailPanel.java | 54 ++++++++++-- .../autopsy/filequery/ResultFile.java | 88 ++++++++++++++++++- 4 files changed, 169 insertions(+), 15 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED index bd8502abd8..0c2e867c95 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED @@ -121,6 +121,10 @@ FileSorter.SortingMethod.parent.displayName=By parent path ImageThumbnailPanel.countLabel.text=Number of Instances: {0} # {0} - fileSize ImageThumbnailPanel.sizeLabel.text=Size: {0} bytes +ResultFile.score.interestingResult.description=File has interesting result associated with it. +ResultFile.score.notableFile.description=File recognized as notable. +ResultFile.score.notableTaggedFile.description=File tagged with notable tag. +ResultFile.score.taggedFile.description=File has been tagged. ResultsDialog.dialogTitle.text=File search results ResultsDialog.exitButton.text=Exit ResultsDialog.searchButton.text=Run another search diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form index bc2f036c23..c772e37a42 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form @@ -18,12 +18,20 @@ - - - - + + + + + + + + + + + + - + @@ -35,7 +43,11 @@ - + + + + + @@ -63,5 +75,19 @@ + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index d73a6e4d0c..dbab20bba0 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -23,15 +23,21 @@ import java.awt.Component; import javax.swing.ImageIcon; import javax.swing.JList; import javax.swing.ListCellRenderer; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; /** * Class which displays a thumbnail and information for an image file. */ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellRenderer { - + private static final long serialVersionUID = 1L; private static final Color SELECTION_COLOR = new Color(0, 120, 215); + private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; + private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; + private static final ImageIcon INTERESTING_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH, false)); + private static final ImageIcon NOTABLE_ICON_SCORE = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); /** * Creates new form ImageThumbnailPanel @@ -53,21 +59,33 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR thumbnailLabel = new javax.swing.JLabel(); fileSizeLabel = new javax.swing.JLabel(); countLabel = new javax.swing.JLabel(); + isDeletedLabel = new javax.swing.JLabel(); + scoreLabel = new javax.swing.JLabel(); thumbnailPanel.setLayout(new java.awt.GridBagLayout()); thumbnailPanel.add(thumbnailLabel, new java.awt.GridBagConstraints()); + isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N + + scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(thumbnailPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(countLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) - .addComponent(fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(thumbnailPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) + .addComponent(fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scoreLabel))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -77,7 +95,10 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(scoreLabel) + .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(countLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); }// //GEN-END:initComponents @@ -86,6 +107,8 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel countLabel; private javax.swing.JLabel fileSizeLabel; + private javax.swing.JLabel isDeletedLabel; + private javax.swing.JLabel scoreLabel; private javax.swing.JLabel thumbnailLabel; // End of variables declaration//GEN-END:variables @@ -98,8 +121,23 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR fileSizeLabel.setText(Bundle.ImageThumbnailPanel_sizeLabel_text(value.getResultFile().getFirstInstance().getSize())); countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); thumbnailLabel.setIcon(new ImageIcon(value.getThumbnail())); + isDeletedLabel.setVisible(value.getResultFile().getIsDeleted()); + switch (value.getResultFile().getScore()) { + case NOTABLE_SCORE: + scoreLabel.setIcon(NOTABLE_ICON_SCORE); + break; + case INTERESTING_SCORE: + scoreLabel.setIcon(INTERESTING_SCORE_ICON); + break; + case NO_SCORE: + default: + scoreLabel.setIcon(null); + break; + } + setToolTipText(value.getResultFile().getScoreDescription()); setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); + return this; } - + } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java index 1e124b0e2c..f436d70f6c 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java @@ -23,13 +23,25 @@ import org.sleuthkit.datamodel.AbstractFile; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.logging.Level; +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; +import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.HashUtility; +import org.sleuthkit.datamodel.Tag; +import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.datamodel.TskData; /** * Container for files that holds all necessary data for grouping and sorting */ class ResultFile { + private final static Logger logger = Logger.getLogger(ResultFile.class.getName()); private FileSearchData.Frequency frequency; private final List keywordListNames; private final List hashSetNames; @@ -37,7 +49,9 @@ class ResultFile { private final List interestingSetNames; private final List objectDetectedNames; private final List instances = new ArrayList<>(); - ; + private DataResultViewerTable.Score currentScore = DataResultViewerTable.Score.NO_SCORE; + private String scoreDescription = null; + private boolean isDeleted = false; private FileType fileType; /** @@ -48,6 +62,10 @@ class ResultFile { ResultFile(AbstractFile abstractFile) { //store the file the ResultFile was created for as the first value in the instances list instances.add(abstractFile); + if (abstractFile.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) { + isDeleted = true; + } + updateScoreAndDescription(abstractFile); this.frequency = FileSearchData.Frequency.UNKNOWN; keywordListNames = new ArrayList<>(); hashSetNames = new ArrayList<>(); @@ -82,9 +100,25 @@ class ResultFile { * @param duplicate The abstract file to add as a duplicate. */ void addDuplicate(AbstractFile duplicate) { + if (isDeleted && !duplicate.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) { + isDeleted = false; + } + updateScoreAndDescription(duplicate); instances.add(duplicate); } + DataResultViewerTable.Score getScore() { + return currentScore; + } + + String getScoreDescription() { + return scoreDescription; + } + + boolean getIsDeleted() { + return isDeleted; + } + /** * Get the list of AbstractFiles which have been identified as instances of * this file. @@ -271,4 +305,56 @@ class ResultFile { return this.getFirstInstance().getMd5Hash().equals(((ResultFile) obj).getFirstInstance().getMd5Hash()); } } + + /** + * Get all tags from the case database that are associated with the file + * + * @return a list of tags that are associated with the file + */ + private List getContentTagsFromDatabase(AbstractFile file) { + List tags = new ArrayList<>(); + try { + tags.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagsByContent(file)); + } catch (TskCoreException | NoCurrentCaseException ex) { + logger.log(Level.SEVERE, "Failed to get tags for file " + file.getName(), ex); + } + return tags; + } + + @NbBundle.Messages({ + "ResultFile.score.notableFile.description=File recognized as notable.", + "ResultFile.score.interestingResult.description=File has interesting result associated with it.", + "ResultFile.score.taggedFile.description=File has been tagged.", + "ResultFile.score.notableTaggedFile.description=File tagged with notable tag."}) + private void updateScoreAndDescription(AbstractFile file) { + if (currentScore == DataResultViewerTable.Score.NOTABLE_SCORE) { + //already notable can return + return; + } + if (file.getKnown() == TskData.FileKnown.BAD) { + currentScore = DataResultViewerTable.Score.NOTABLE_SCORE; + scoreDescription = Bundle.ResultFile_score_notableFile_description(); + return; + } + try { + if (currentScore == DataResultViewerTable.Score.NO_SCORE && !file.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT).isEmpty()) { + currentScore = DataResultViewerTable.Score.INTERESTING_SCORE; + scoreDescription = Bundle.ResultFile_score_interestingResult_description(); + } + } catch (TskCoreException ex) { + logger.log(Level.WARNING, "Error getting artifacts for file: " + file.getName(), ex); + } + List tags = getContentTagsFromDatabase(file); + if (!tags.isEmpty()) { + currentScore = DataResultViewerTable.Score.INTERESTING_SCORE; + scoreDescription = Bundle.ResultFile_score_taggedFile_description(); + for (Tag tag : tags) { + if (tag.getName().getKnownStatus() == TskData.FileKnown.BAD) { + currentScore = DataResultViewerTable.Score.NOTABLE_SCORE; + scoreDescription = Bundle.ResultFile_score_notableTaggedFile_description(); + return; + } + } + } + } } From 04f2227c9eb971e8bf2760e13d40ddee47c4005c Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Thu, 24 Oct 2019 14:07:58 -0400 Subject: [PATCH 02/14] 5677 display score and deleted status --- .../filequery/ImageThumbnailPanel.form | 2 +- .../filequery/ImageThumbnailPanel.java | 6 +-- .../filequery/VideoThumbnailPanel.form | 44 ++++++++++++----- .../filequery/VideoThumbnailPanel.java | 48 ++++++++++++++++--- 4 files changed, 78 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form index c772e37a42..6e54f69042 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form @@ -78,7 +78,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index dbab20bba0..87103fb610 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -31,7 +31,7 @@ import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; * Class which displays a thumbnail and information for an image file. */ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellRenderer { - + private static final long serialVersionUID = 1L; private static final Color SELECTION_COLOR = new Color(0, 120, 215); private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; @@ -65,7 +65,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR thumbnailPanel.setLayout(new java.awt.GridBagLayout()); thumbnailPanel.add(thumbnailLabel, new java.awt.GridBagConstraints()); - isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N + isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N @@ -139,5 +139,5 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR return this; } - + } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form index 5f41c66123..5c2a75b28e 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form @@ -24,16 +24,20 @@ - + - - + + - + + + + + - + @@ -41,13 +45,17 @@ - - - - - + + + + + + + + + - + @@ -61,5 +69,19 @@ + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index 5dbe46cd3d..7b34a643c8 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -27,6 +27,7 @@ import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle.Messages; /** @@ -35,7 +36,11 @@ import org.openide.util.NbBundle.Messages; final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRenderer { private static final int GAP_SIZE = 4; - private static final Color SELECTION_COLOR = new Color(0,120,215); + private static final Color SELECTION_COLOR = new Color(0, 120, 215); + private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; + private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; + private static final ImageIcon INTERESTING_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH, false)); + private static final ImageIcon NOTABLE_ICON_SCORE = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); private static final long serialVersionUID = 1L; /** @@ -96,11 +101,17 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe imagePanel = new javax.swing.JPanel(); fileSizeLabel = new javax.swing.JLabel(); countLabel = new javax.swing.JLabel(); + scoreLabel = new javax.swing.JLabel(); + deletedLabel = new javax.swing.JLabel(); setBorder(javax.swing.BorderFactory.createEtchedBorder()); imagePanel.setLayout(new java.awt.GridBagLayout()); + scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N + + deletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -112,27 +123,36 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe .addGroup(layout.createSequentialGroup() .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(imagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(imagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) - .addComponent(countLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(deletedLabel) + .addComponent(scoreLabel) + .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel countLabel; + private javax.swing.JLabel deletedLabel; private javax.swing.JLabel fileSizeLabel; private javax.swing.JPanel imagePanel; + private javax.swing.JLabel scoreLabel; // End of variables declaration//GEN-END:variables @Messages({"# {0} - fileSize", @@ -145,6 +165,20 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe countLabel.setText(Bundle.VideoThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); addThumbnails(value); imagePanel.setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); + deletedLabel.setVisible(value.getResultFile().getIsDeleted()); + switch (value.getResultFile().getScore()) { + case NOTABLE_SCORE: + scoreLabel.setIcon(NOTABLE_ICON_SCORE); + break; + case INTERESTING_SCORE: + scoreLabel.setIcon(INTERESTING_SCORE_ICON); + break; + case NO_SCORE: + default: + scoreLabel.setIcon(null); + break; + } + setToolTipText(value.getResultFile().getScoreDescription()); setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); return this; } From 98606fc4719655b1700e79e0738c352ff192e260 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Thu, 24 Oct 2019 14:40:42 -0400 Subject: [PATCH 03/14] 5677 update comments --- .../autopsy/filequery/ImageThumbnailPanel.java | 1 - .../sleuthkit/autopsy/filequery/ResultFile.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 87103fb610..96dadce56a 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -25,7 +25,6 @@ import javax.swing.JList; import javax.swing.ListCellRenderer; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; /** * Class which displays a thumbnail and information for an image file. diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java index f436d70f6c..6097bb93ad 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java @@ -107,14 +107,31 @@ class ResultFile { instances.add(duplicate); } + /** + * Get the aggregate score of this ResultFile. Calculated as the highest + * score among all instances it represents. + * + * @return The score of this ResultFile. + */ DataResultViewerTable.Score getScore() { return currentScore; } + /** + * Get the description for the score assigned to this item. + * + * @return The score description of this ResultFile. + */ String getScoreDescription() { return scoreDescription; } + /** + * Get the aggregate deleted status of this ResultFile. A file is identified + * as deleted if all instances of it are deleted. + * + * @return The deleted status of this ResultFile. + */ boolean getIsDeleted() { return isDeleted; } From cad690a6005be912ee95ed80c3336641587dc689 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 25 Oct 2019 12:08:19 -0400 Subject: [PATCH 04/14] 5677 fix codacy complaints --- Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java | 2 +- .../org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java | 2 +- Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java | 2 +- .../org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java index 658aa3ad0a..1486c61551 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java @@ -145,7 +145,7 @@ class FileSearch { * * @throws FileSearchException */ - static LinkedHashMap getGroupSizes(String userName, + static Map getGroupSizes(String userName, List filters, AttributeType groupAttributeType, FileGroup.GroupSortingAlgorithm groupSortingType, diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 96dadce56a..21020dd700 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -120,7 +120,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR fileSizeLabel.setText(Bundle.ImageThumbnailPanel_sizeLabel_text(value.getResultFile().getFirstInstance().getSize())); countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); thumbnailLabel.setIcon(new ImageIcon(value.getThumbnail())); - isDeletedLabel.setVisible(value.getResultFile().getIsDeleted()); + isDeletedLabel.setVisible(value.getResultFile().isDeleted()); switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: scoreLabel.setIcon(NOTABLE_ICON_SCORE); diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java index 6097bb93ad..c1a53eb5c2 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java @@ -132,7 +132,7 @@ class ResultFile { * * @return The deleted status of this ResultFile. */ - boolean getIsDeleted() { + boolean isDeleted() { return isDeleted; } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index 7b34a643c8..06225e95f2 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -165,7 +165,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe countLabel.setText(Bundle.VideoThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); addThumbnails(value); imagePanel.setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); - deletedLabel.setVisible(value.getResultFile().getIsDeleted()); + deletedLabel.setVisible(value.getResultFile().isDeleted()); switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: scoreLabel.setIcon(NOTABLE_ICON_SCORE); From 242ea8112c66967feb826646e1a954c884f1b1b6 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Thu, 31 Oct 2019 12:41:45 -0400 Subject: [PATCH 05/14] 5677 change variable name for codacy --- .../org/sleuthkit/autopsy/filequery/ResultFile.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java index c1a53eb5c2..1123219b24 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java @@ -51,7 +51,7 @@ class ResultFile { private final List instances = new ArrayList<>(); private DataResultViewerTable.Score currentScore = DataResultViewerTable.Score.NO_SCORE; private String scoreDescription = null; - private boolean isDeleted = false; + private boolean deleted = false; private FileType fileType; /** @@ -63,7 +63,7 @@ class ResultFile { //store the file the ResultFile was created for as the first value in the instances list instances.add(abstractFile); if (abstractFile.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) { - isDeleted = true; + deleted = true; } updateScoreAndDescription(abstractFile); this.frequency = FileSearchData.Frequency.UNKNOWN; @@ -100,8 +100,8 @@ class ResultFile { * @param duplicate The abstract file to add as a duplicate. */ void addDuplicate(AbstractFile duplicate) { - if (isDeleted && !duplicate.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) { - isDeleted = false; + if (deleted && !duplicate.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) { + deleted = false; } updateScoreAndDescription(duplicate); instances.add(duplicate); @@ -133,7 +133,7 @@ class ResultFile { * @return The deleted status of this ResultFile. */ boolean isDeleted() { - return isDeleted; + return deleted; } /** From a94cb75479af24670d159220382884b1fa3499fe Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 11:01:21 -0500 Subject: [PATCH 06/14] 5677 get tooltips working as desired --- .../filequery/Bundle.properties-MERGED | 12 ++++-- .../filequery/ImageThumbnailPanel.form | 16 +++++++- .../filequery/ImageThumbnailPanel.java | 39 +++++++++++++++++-- .../filequery/ImageThumbnailViewer.java | 7 ++-- .../autopsy/filequery/ResultFile.java | 8 ++-- .../filequery/VideoThumbnailPanel.java | 30 ++++++++++++-- 6 files changed, 94 insertions(+), 18 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED index 0c2e867c95..d0e59ba183 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED @@ -119,12 +119,13 @@ FileSorter.SortingMethod.keywordlist.displayName=By keyword list names FileSorter.SortingMethod.parent.displayName=By parent path # {0} - numberOfInstances ImageThumbnailPanel.countLabel.text=Number of Instances: {0} +ImageThumbnailPanel.isDeleted.text=All instances of file are deleted. # {0} - fileSize ImageThumbnailPanel.sizeLabel.text=Size: {0} bytes -ResultFile.score.interestingResult.description=File has interesting result associated with it. -ResultFile.score.notableFile.description=File recognized as notable. -ResultFile.score.notableTaggedFile.description=File tagged with notable tag. -ResultFile.score.taggedFile.description=File has been tagged. +ResultFile.score.interestingResult.description=At least one instance of the file has an interesting result associated with it. +ResultFile.score.notableFile.description=At least one instance of the file was recognized as notable. +ResultFile.score.notableTaggedFile.description=At least one instance of the file is tagged with a notable tag. +ResultFile.score.taggedFile.description=At least one instance of the file has been tagged. ResultsDialog.dialogTitle.text=File search results ResultsDialog.exitButton.text=Exit ResultsDialog.searchButton.text=Run another search @@ -177,9 +178,12 @@ ResultsPanel.gotoPageLabel.text=Go to Page: ResultsPanel.pageSizeLabel.text=Page size: ResultsPanel.instancesList.border.title=Instances DiscoveryExtractAction.title.extractFiles.text=Extract File +ImageThumbnailPanel.toolTipText=BACKGROUND +ImageThumbnailPanel.isDeletedLabel.toolTipText= ResultsPanel.viewFileInDir.name=View File in Directory SearchNode.getName.text=Search Result # {0} - numberOfInstances VideoThumbnailPanel.countLabel.text=Number of Instances: {0} +VideoThumbnailPanel.deleted.text=All instances of file are deleted. # {0} - fileSize VideoThumbnailPanel.sizeLabel.text=Size: {0} bytes diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form index 6e54f69042..de3b90fcf5 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form @@ -1,6 +1,9 @@ -
+ + + + @@ -55,6 +58,9 @@ + + + @@ -72,14 +78,21 @@ + + + + + + + @@ -87,6 +100,7 @@ + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 21020dd700..7066ee8d5d 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -20,7 +20,10 @@ package org.sleuthkit.autopsy.filequery; import java.awt.Color; import java.awt.Component; +import java.awt.Point; +import java.awt.event.MouseEvent; import javax.swing.ImageIcon; +import javax.swing.JComponent; import javax.swing.JList; import javax.swing.ListCellRenderer; import org.openide.util.ImageUtilities; @@ -61,12 +64,21 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR isDeletedLabel = new javax.swing.JLabel(); scoreLabel = new javax.swing.JLabel(); + setToolTipText(""); + + thumbnailPanel.setToolTipText(""); thumbnailPanel.setLayout(new java.awt.GridBagLayout()); thumbnailPanel.add(thumbnailLabel, new java.awt.GridBagConstraints()); + fileSizeLabel.setToolTipText(""); + + countLabel.setToolTipText(""); + isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N + isDeletedLabel.setToolTipText(""); scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N + scoreLabel.setToolTipText(""); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -114,13 +126,20 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR @NbBundle.Messages({"# {0} - fileSize", "ImageThumbnailPanel.sizeLabel.text=Size: {0} bytes", "# {0} - numberOfInstances", - "ImageThumbnailPanel.countLabel.text=Number of Instances: {0}"}) + "ImageThumbnailPanel.countLabel.text=Number of Instances: {0}", + "ImageThumbnailPanel.isDeleted.text=All instances of file are deleted."}) @Override public Component getListCellRendererComponent(JList list, ImageThumbnailWrapper value, int index, boolean isSelected, boolean cellHasFocus) { fileSizeLabel.setText(Bundle.ImageThumbnailPanel_sizeLabel_text(value.getResultFile().getFirstInstance().getSize())); countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); thumbnailLabel.setIcon(new ImageIcon(value.getThumbnail())); - isDeletedLabel.setVisible(value.getResultFile().isDeleted()); + if (value.getResultFile().isDeleted()) { + isDeletedLabel.setVisible(true); + isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text()); + } else { + isDeletedLabel.setVisible(false); + isDeletedLabel.setToolTipText(""); + } switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: scoreLabel.setIcon(NOTABLE_ICON_SCORE); @@ -133,10 +152,24 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR scoreLabel.setIcon(null); break; } - setToolTipText(value.getResultFile().getScoreDescription()); + scoreLabel.setToolTipText(value.getResultFile().getScoreDescription()); setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); return this; } + @Override + public String getToolTipText(MouseEvent event) { + if (event != null) { + //gets tooltip of internal panel item mouse is over + Point p = event.getPoint(); + for (Component comp : getComponents()) { + if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { + return ((JComponent) comp).getToolTipText(); + } + } + } + return super.getToolTipText(); + } + } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailViewer.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailViewer.java index 1524f60820..542a7480a8 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailViewer.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailViewer.java @@ -39,6 +39,7 @@ public class ImageThumbnailViewer extends javax.swing.JPanel { */ public ImageThumbnailViewer() { initComponents(); + } /** @@ -78,13 +79,13 @@ public class ImageThumbnailViewer extends javax.swing.JPanel { void addListSelectionListener(ListSelectionListener listener) { thumbnailList.getSelectionModel().addListSelectionListener(listener); } - + /** * Get the list of AbstractFiles which are represented by the selected image * thumbnail. * - * @return The list of AbstractFiles which are represented by the selected image - * thumbnail. + * @return The list of AbstractFiles which are represented by the selected + * image thumbnail. */ List getInstancesForSelected() { synchronized (this) { diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java index 1123219b24..3b28a5e97d 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultFile.java @@ -339,10 +339,10 @@ class ResultFile { } @NbBundle.Messages({ - "ResultFile.score.notableFile.description=File recognized as notable.", - "ResultFile.score.interestingResult.description=File has interesting result associated with it.", - "ResultFile.score.taggedFile.description=File has been tagged.", - "ResultFile.score.notableTaggedFile.description=File tagged with notable tag."}) + "ResultFile.score.notableFile.description=At least one instance of the file was recognized as notable.", + "ResultFile.score.interestingResult.description=At least one instance of the file has an interesting result associated with it.", + "ResultFile.score.taggedFile.description=At least one instance of the file has been tagged.", + "ResultFile.score.notableTaggedFile.description=At least one instance of the file is tagged with a notable tag."}) private void updateScoreAndDescription(AbstractFile file) { if (currentScore == DataResultViewerTable.Score.NOTABLE_SCORE) { //already notable can return diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index 06225e95f2..3de9a9b31f 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -22,8 +22,11 @@ import java.awt.Color; import java.awt.Component; import java.awt.Image; import java.awt.GridBagConstraints; +import java.awt.Point; +import java.awt.event.MouseEvent; import java.util.concurrent.TimeUnit; import javax.swing.ImageIcon; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; @@ -158,14 +161,21 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe @Messages({"# {0} - fileSize", "VideoThumbnailPanel.sizeLabel.text=Size: {0} bytes", "# {0} - numberOfInstances", - "VideoThumbnailPanel.countLabel.text=Number of Instances: {0}"}) + "VideoThumbnailPanel.countLabel.text=Number of Instances: {0}", + "VideoThumbnailPanel.deleted.text=All instances of file are deleted."}) @Override public Component getListCellRendererComponent(JList list, VideoThumbnailsWrapper value, int index, boolean isSelected, boolean cellHasFocus) { fileSizeLabel.setText(Bundle.VideoThumbnailPanel_sizeLabel_text(value.getResultFile().getFirstInstance().getSize())); countLabel.setText(Bundle.VideoThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); addThumbnails(value); imagePanel.setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); - deletedLabel.setVisible(value.getResultFile().isDeleted()); + if (value.getResultFile().isDeleted()) { + deletedLabel.setVisible(true); + deletedLabel.setToolTipText(Bundle.VideoThumbnailPanel_deleted_text()); + } else { + deletedLabel.setVisible(false); + deletedLabel.setToolTipText(""); + } switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: scoreLabel.setIcon(NOTABLE_ICON_SCORE); @@ -178,8 +188,22 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe scoreLabel.setIcon(null); break; } - setToolTipText(value.getResultFile().getScoreDescription()); + scoreLabel.setToolTipText(value.getResultFile().getScoreDescription()); setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); return this; } + + @Override + public String getToolTipText(MouseEvent event) { + if (event != null) { + //gets tooltip of internal panel item mouse is over + Point p = event.getPoint(); + for (Component comp : getComponents()) { + if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { + return ((JComponent) comp).getToolTipText(); + } + } + } + return super.getToolTipText(); + } } From dbd7459738961ed44d769dcd5bc01d9d50093010 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 11:01:44 -0500 Subject: [PATCH 07/14] 5677 update merged properties file --- .../org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED | 2 -- 1 file changed, 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED index d0e59ba183..dc5dd875f8 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/filequery/Bundle.properties-MERGED @@ -178,8 +178,6 @@ ResultsPanel.gotoPageLabel.text=Go to Page: ResultsPanel.pageSizeLabel.text=Page size: ResultsPanel.instancesList.border.title=Instances DiscoveryExtractAction.title.extractFiles.text=Extract File -ImageThumbnailPanel.toolTipText=BACKGROUND -ImageThumbnailPanel.isDeletedLabel.toolTipText= ResultsPanel.viewFileInDir.name=View File in Directory SearchNode.getName.text=Search Result # {0} - numberOfInstances From 01e6be20c95ee253b3bb23a77c93082962bba207 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 11:21:44 -0500 Subject: [PATCH 08/14] 5677 fix empty tooltip displaying . --- .../autopsy/filequery/ImageThumbnailPanel.java | 11 ++++++++--- .../autopsy/filequery/VideoThumbnailPanel.java | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 7066ee8d5d..ef06aacb36 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -138,7 +138,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text()); } else { isDeletedLabel.setVisible(false); - isDeletedLabel.setToolTipText(""); + isDeletedLabel.setToolTipText(null); } switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: @@ -165,11 +165,16 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR Point p = event.getPoint(); for (Component comp : getComponents()) { if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { - return ((JComponent) comp).getToolTipText(); + String toolTip = ((JComponent) comp).getToolTipText(); + if (toolTip.isEmpty()) { + return null; + } else { + return toolTip; + } } } } - return super.getToolTipText(); + return null; } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index 3de9a9b31f..fa1714d39f 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -200,10 +200,15 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe Point p = event.getPoint(); for (Component comp : getComponents()) { if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { - return ((JComponent) comp).getToolTipText(); + String toolTip = ((JComponent) comp).getToolTipText(); + if (toolTip.isEmpty()) { + return null; + } else { + return toolTip; + } } } } - return super.getToolTipText(); + return null; } } From fc8bd4646a11168e2ab731eee46114aa86019f6b Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 13:11:28 -0500 Subject: [PATCH 09/14] 5677 fix NPE when case closed and filediscovery not open --- Core/src/org/sleuthkit/autopsy/casemodule/Case.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 89afa87707..3894fed46c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -1113,7 +1113,10 @@ public class Case { CallableSystemAction.get(OpenCommVisualizationToolAction.class).setEnabled(false); CallableSystemAction.get(OpenOutputFolderAction.class).setEnabled(false); CallableSystemAction.get(CommonAttributeSearchAction.class).setEnabled(false); - DiscoveryTopComponent.getTopComponent().resetTopComponent(); + DiscoveryTopComponent discoveryTopComp = DiscoveryTopComponent.getTopComponent(); + if (discoveryTopComp != null){ + discoveryTopComp.resetTopComponent(); + } /* * Clear the notifications in the notfier component in the lower * right hand corner of the main application window. From 51636a9fdbe987ef7d1fa039c65bf3bca7ad04e6 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 13:13:49 -0500 Subject: [PATCH 10/14] 5677 fix NPE when tooltip is null --- .../org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java | 2 +- .../org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index ef06aacb36..ada5da4441 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -166,7 +166,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR for (Component comp : getComponents()) { if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { String toolTip = ((JComponent) comp).getToolTipText(); - if (toolTip.isEmpty()) { + if (toolTip == null || toolTip.isEmpty()) { return null; } else { return toolTip; diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index fa1714d39f..f5ff5562ad 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -201,7 +201,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe for (Component comp : getComponents()) { if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { String toolTip = ((JComponent) comp).getToolTipText(); - if (toolTip.isEmpty()) { + if (toolTip == null || toolTip.isEmpty()) { return null; } else { return toolTip; From 1547259cefde70c180450e0dc4be707cdaf22306 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 5 Nov 2019 18:11:29 -0500 Subject: [PATCH 11/14] 5677 use static variable for width and height --- .../filequery/ImageThumbnailPanel.form | 41 +++++++++++++++---- .../filequery/ImageThumbnailPanel.java | 41 +++++++++++++------ .../filequery/VideoThumbnailPanel.form | 22 +++++++++- .../filequery/VideoThumbnailPanel.java | 28 +++++++++---- 4 files changed, 101 insertions(+), 31 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form index de3b90fcf5..e75effab93 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.form @@ -20,21 +20,21 @@ - + - - - + + + - + @@ -48,8 +48,8 @@ - - + + @@ -85,6 +85,15 @@ + + + + + + + + + @@ -93,6 +102,15 @@ + + + + + + + + + @@ -101,6 +119,15 @@ + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index ada5da4441..627bf75d48 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.filequery; import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; import java.awt.Point; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; @@ -36,16 +37,21 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR private static final long serialVersionUID = 1L; private static final Color SELECTION_COLOR = new Color(0, 120, 215); + private static final int ICON_SIZE =16; private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; + private static final String DELETE_ICON_PATH = "/org/sleuthkit/autopsy/images/file-icon-deleted.png"; private static final ImageIcon INTERESTING_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH, false)); - private static final ImageIcon NOTABLE_ICON_SCORE = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); + private static final ImageIcon NOTABLE_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); + private static final ImageIcon DELETED_ICON = new ImageIcon(ImageUtilities.loadImage(DELETE_ICON_PATH, false)); /** * Creates new form ImageThumbnailPanel */ public ImageThumbnailPanel() { initComponents(); + scoreLabel.setSize(16, 16); + isDeletedLabel.setSize(16, 16); } /** @@ -73,12 +79,21 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR fileSizeLabel.setToolTipText(""); countLabel.setToolTipText(""); + countLabel.setMaximumSize(new java.awt.Dimension(159, 12)); + countLabel.setMinimumSize(new java.awt.Dimension(159, 12)); + countLabel.setPreferredSize(new java.awt.Dimension(159, 12)); isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N isDeletedLabel.setToolTipText(""); + isDeletedLabel.setMaximumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + isDeletedLabel.setMinimumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + isDeletedLabel.setPreferredSize(new Dimension(ICON_SIZE,ICON_SIZE)); scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N scoreLabel.setToolTipText(""); + scoreLabel.setMaximumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + scoreLabel.setMinimumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + scoreLabel.setPreferredSize(new Dimension(ICON_SIZE,ICON_SIZE)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -91,12 +106,12 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR .addComponent(thumbnailPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE) .addComponent(fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() - .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(countLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(scoreLabel))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -107,9 +122,9 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(scoreLabel) - .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(countLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(countLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); }// //GEN-END:initComponents @@ -134,15 +149,15 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size())); thumbnailLabel.setIcon(new ImageIcon(value.getThumbnail())); if (value.getResultFile().isDeleted()) { - isDeletedLabel.setVisible(true); + isDeletedLabel.setIcon(DELETED_ICON); isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text()); } else { - isDeletedLabel.setVisible(false); + isDeletedLabel.setIcon(null); isDeletedLabel.setToolTipText(null); } switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: - scoreLabel.setIcon(NOTABLE_ICON_SCORE); + scoreLabel.setIcon(NOTABLE_SCORE_ICON); break; case INTERESTING_SCORE: scoreLabel.setIcon(INTERESTING_SCORE_ICON); @@ -164,10 +179,10 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR //gets tooltip of internal panel item mouse is over Point p = event.getPoint(); for (Component comp : getComponents()) { - if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { + if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE) { String toolTip = ((JComponent) comp).getToolTipText(); if (toolTip == null || toolTip.isEmpty()) { - return null; + return null; } else { return toolTip; } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form index 5c2a75b28e..86a30442f6 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.form @@ -32,9 +32,9 @@ - + - + @@ -74,6 +74,15 @@ + + + + + + + + + @@ -81,6 +90,15 @@ + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index f5ff5562ad..bfd9570c18 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.filequery; import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; import java.awt.Image; import java.awt.GridBagConstraints; import java.awt.Point; @@ -40,10 +41,13 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe private static final int GAP_SIZE = 4; private static final Color SELECTION_COLOR = new Color(0, 120, 215); + private static final int ICON_SIZE =16; private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; + private static final String DELETE_ICON_PATH = "/org/sleuthkit/autopsy/images/file-icon-deleted.png"; private static final ImageIcon INTERESTING_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH, false)); - private static final ImageIcon NOTABLE_ICON_SCORE = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); + private static final ImageIcon NOTABLE_SCORE_ICON = new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH, false)); + private static final ImageIcon DELETED_ICON = new ImageIcon(ImageUtilities.loadImage(DELETE_ICON_PATH, false)); private static final long serialVersionUID = 1L; /** @@ -112,8 +116,14 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe imagePanel.setLayout(new java.awt.GridBagLayout()); scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N + scoreLabel.setMaximumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + scoreLabel.setMinimumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + scoreLabel.setPreferredSize(new Dimension(ICON_SIZE,ICON_SIZE)); deletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N + deletedLabel.setMaximumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + deletedLabel.setMinimumSize(new Dimension(ICON_SIZE,ICON_SIZE)); + deletedLabel.setPreferredSize(new Dimension(ICON_SIZE,ICON_SIZE)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -128,9 +138,9 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( @@ -142,8 +152,8 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(deletedLabel) - .addComponent(scoreLabel) + .addComponent(deletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(countLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -170,15 +180,15 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe addThumbnails(value); imagePanel.setBackground(isSelected ? SELECTION_COLOR : list.getBackground()); if (value.getResultFile().isDeleted()) { - deletedLabel.setVisible(true); + deletedLabel.setIcon(DELETED_ICON); deletedLabel.setToolTipText(Bundle.VideoThumbnailPanel_deleted_text()); } else { - deletedLabel.setVisible(false); + deletedLabel.setIcon(null); deletedLabel.setToolTipText(""); } switch (value.getResultFile().getScore()) { case NOTABLE_SCORE: - scoreLabel.setIcon(NOTABLE_ICON_SCORE); + scoreLabel.setIcon(NOTABLE_SCORE_ICON); break; case INTERESTING_SCORE: scoreLabel.setIcon(INTERESTING_SCORE_ICON); @@ -199,7 +209,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe //gets tooltip of internal panel item mouse is over Point p = event.getPoint(); for (Component comp : getComponents()) { - if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + comp.getWidth() && p.y >= comp.getY() && p.y <= comp.getY() + comp.getHeight()) { + if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE) { String toolTip = ((JComponent) comp).getToolTipText(); if (toolTip == null || toolTip.isEmpty()) { return null; From 495682ca796ca8fce598e6c121fe0ad238ac620e Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 6 Nov 2019 10:53:13 -0500 Subject: [PATCH 12/14] 5677 remove unnecessary lines of code --- .../org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 627bf75d48..6e8f2a6c57 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -50,8 +50,6 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR */ public ImageThumbnailPanel() { initComponents(); - scoreLabel.setSize(16, 16); - isDeletedLabel.setSize(16, 16); } /** From 5efe34235cb1672d6d336c6907e5c3f40a88ce3f Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 6 Nov 2019 12:00:01 -0500 Subject: [PATCH 13/14] 5677 attempts to reduce cyclomatic complexity --- .../autopsy/filequery/ImageThumbnailPanel.java | 12 ++++++++---- .../autopsy/filequery/VideoThumbnailPanel.java | 11 +++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 6e8f2a6c57..38f8ac51e3 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -37,7 +37,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR private static final long serialVersionUID = 1L; private static final Color SELECTION_COLOR = new Color(0, 120, 215); - private static final int ICON_SIZE =16; + private static final int ICON_SIZE = 16; private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; private static final String DELETE_ICON_PATH = "/org/sleuthkit/autopsy/images/file-icon-deleted.png"; @@ -175,12 +175,12 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR public String getToolTipText(MouseEvent event) { if (event != null) { //gets tooltip of internal panel item mouse is over - Point p = event.getPoint(); + Point point = event.getPoint(); for (Component comp : getComponents()) { - if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE) { + if (isPointInComponent(comp, point)) { String toolTip = ((JComponent) comp).getToolTipText(); if (toolTip == null || toolTip.isEmpty()) { - return null; + return null; } else { return toolTip; } @@ -190,4 +190,8 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR return null; } + private boolean isPointInComponent(Component comp, Point point) { + return comp instanceof JComponent && point.x >= comp.getX() && point.x <= comp.getX() + ICON_SIZE && point.y >= comp.getY() && point.y <= comp.getY() + ICON_SIZE; + } + } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index bfd9570c18..96c3102e9d 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -41,7 +41,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe private static final int GAP_SIZE = 4; private static final Color SELECTION_COLOR = new Color(0, 120, 215); - private static final int ICON_SIZE =16; + private static final int ICON_SIZE = 16; private static final String RED_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/red-circle-exclamation.png"; private static final String YELLOW_CIRCLE_ICON_PATH = "org/sleuthkit/autopsy/images/yellow-circle-yield.png"; private static final String DELETE_ICON_PATH = "/org/sleuthkit/autopsy/images/file-icon-deleted.png"; @@ -209,13 +209,8 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe //gets tooltip of internal panel item mouse is over Point p = event.getPoint(); for (Component comp : getComponents()) { - if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE) { - String toolTip = ((JComponent) comp).getToolTipText(); - if (toolTip == null || toolTip.isEmpty()) { - return null; - } else { - return toolTip; - } + if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE && ((JComponent) comp).getToolTipText() != null && !((JComponent) comp).getToolTipText().isEmpty()) { + return ((JComponent) comp).getToolTipText(); } } } From 0fb679f4023bacddc69346506f3e3c5de6fb88b9 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 6 Nov 2019 12:10:53 -0500 Subject: [PATCH 14/14] 5677 reduce cyclomatic complexity of getToolTipText --- .../filequery/ImageThumbnailPanel.java | 12 ++++++++-- .../filequery/VideoThumbnailPanel.java | 23 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index 38f8ac51e3..2c4a1f4e9b 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -177,7 +177,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR //gets tooltip of internal panel item mouse is over Point point = event.getPoint(); for (Component comp : getComponents()) { - if (isPointInComponent(comp, point)) { + if (isPointOnIcon(comp, point)) { String toolTip = ((JComponent) comp).getToolTipText(); if (toolTip == null || toolTip.isEmpty()) { return null; @@ -190,7 +190,15 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR return null; } - private boolean isPointInComponent(Component comp, Point point) { + /** + * Helper method to see if point is on the icon. + * + * @param comp The component to check if the cursor is over the icon of + * @param point The point the cursor is at. + * + * @return True if the point is over the icon, false otherwise. + */ + private boolean isPointOnIcon(Component comp, Point point) { return comp instanceof JComponent && point.x >= comp.getX() && point.x <= comp.getX() + ICON_SIZE && point.y >= comp.getY() && point.y <= comp.getY() + ICON_SIZE; } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index 96c3102e9d..048fe1b8d5 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -207,13 +207,30 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe public String getToolTipText(MouseEvent event) { if (event != null) { //gets tooltip of internal panel item mouse is over - Point p = event.getPoint(); + Point point = event.getPoint(); for (Component comp : getComponents()) { - if (comp instanceof JComponent && p.x >= comp.getX() && p.x <= comp.getX() + ICON_SIZE && p.y >= comp.getY() && p.y <= comp.getY() + ICON_SIZE && ((JComponent) comp).getToolTipText() != null && !((JComponent) comp).getToolTipText().isEmpty()) { - return ((JComponent) comp).getToolTipText(); + if (isPointOnIcon(comp, point)) { + String toolTip = ((JComponent) comp).getToolTipText(); + if (toolTip == null || toolTip.isEmpty()) { + return null; + } else { + return toolTip; + } } } } return null; } + + /** + * Helper method to see if point is on the icon. + * + * @param comp The component to check if the cursor is over the icon of + * @param point The point the cursor is at. + * + * @return True if the point is over the icon, false otherwise. + */ + private boolean isPointOnIcon(Component comp, Point point) { + return comp instanceof JComponent && point.x >= comp.getX() && point.x <= comp.getX() + ICON_SIZE && point.y >= comp.getY() && point.y <= comp.getY() + ICON_SIZE; + } }