5979 clean up document file discovery viewer

This commit is contained in:
William Schaefer 2020-01-31 13:20:19 -05:00
parent 7a5e911cee
commit f674556521
15 changed files with 402 additions and 352 deletions

View File

@ -67,6 +67,6 @@ DiscoveryTopComponent.stepOneLabel.text=Step 1: Pick File Type
DiscoveryTopComponent.documentsButton.text=Documents
DocumentPanel.countLabel.toolTipText=
DocumentPanel.fileSizeLabel.toolTipText=
DocumentPanel.scoreLabel.toolTipText=
DocumentPanel.isDeletedLabel.toolTipText=
DocumentPanel.documentType.text=
DocumentPanel.isDeletedLabel.toolTipText=
ImageThumbnailPanel.isDeletedLabel.toolTipText=

View File

@ -6,6 +6,14 @@ DataSourceModuleWrapper.fileTypeModule.text=File Type Identification module was
# {0} - dataSourceName
DataSourceModuleWrapper.hashModule.text=Hash Lookup module was not run on data source: {0}\n
DiscoveryTopComponent.name=\ File Discovery
DiscoveryUiUtility.bytes.text=bytes
DiscoveryUiUtility.gigaBytes.text=GB
DiscoveryUiUtility.kiloBytes.text=KB
DiscoveryUiUtility.megaBytes.text=MB
# {0} - fileSize
# {1} - units
DiscoveryUiUtility.sizeLabel.text=Size: {0} {1}
DiscoveryUiUtility.terraBytes.text=TB
FileGroup.groupSortingAlgorithm.groupName.text=Group Name
FileGroup.groupSortingAlgorithm.groupSize.text=Group Size
# {0} - Data source name
@ -162,17 +170,9 @@ FileSorter.SortingMethod.fullPath.displayName=Full Path
FileSorter.SortingMethod.keywordlist.displayName=Keyword List Names
GroupsListPanel.noResults.message.text=No results were found for the selected filters.
GroupsListPanel.noResults.title.text=No results found
ImageThumbnailPanel.bytes.text=bytes
# {0} - numberOfInstances
ImageThumbnailPanel.countLabel.text=Number of Instances: {0}
ImageThumbnailPanel.gigaBytes.text=GB
ImageThumbnailPanel.isDeleted.text=All instances of file are deleted.
ImageThumbnailPanel.kiloBytes.text=KB
ImageThumbnailPanel.megaBytes.text=MB
# {0} - fileSize
# {1} - units
ImageThumbnailPanel.sizeLabel.text=Size: {0} {1}
ImageThumbnailPanel.terraBytes.text=TB
OpenFileDiscoveryAction.resultsIncomplete.text=Results may be incomplete
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.
@ -203,6 +203,12 @@ ResultsPanel.resultsSplitPane.toolTipText=
FileSearchPanel.stepTwoLabel.text=Step 2: Filter which images to show
FileSearchPanel.stepThreeLabel.text=Step 3: Choose display settings
DiscoveryTopComponent.stepOneLabel.text=Step 1: Pick File Type
DiscoveryTopComponent.documentsButton.text=Documents
DocumentPanel.countLabel.toolTipText=
DocumentPanel.fileSizeLabel.toolTipText=
DocumentPanel.documentType.text=
DocumentPanel.isDeletedLabel.toolTipText=
ImageThumbnailPanel.isDeletedLabel.toolTipText=
ResultsPanel.viewFileInDir.name=View File in Directory
VideoThumbnailPanel.bytes.text=bytes
# {0} - numberOfInstances

View File

@ -34,7 +34,6 @@ import org.sleuthkit.autopsy.corecomponents.DataContentPanel;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
import org.sleuthkit.autopsy.datamodel.FileNode;
import org.sleuthkit.autopsy.filequery.FileSearchData.FileType;
import org.sleuthkit.datamodel.AbstractFile;
/**
@ -322,15 +321,23 @@ public final class DiscoveryTopComponent extends TopComponent {
@Subscribe
void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
SwingUtilities.invokeLater(() -> {
if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
imagesButton.setEnabled(true);
documentsButton.setEnabled(true);
} else if (fileSearchPanel.getSelectedType() == FileType.IMAGE) {
videosButton.setEnabled(true);
documentsButton.setEnabled(true);
} else if (fileSearchPanel.getSelectedType() == FileType.DOCUMENTS) {
videosButton.setEnabled(true);
imagesButton.setEnabled(true);
if (null != fileSearchPanel.getSelectedType()) {
switch (fileSearchPanel.getSelectedType()) {
case VIDEO:
imagesButton.setEnabled(true);
documentsButton.setEnabled(true);
break;
case IMAGE:
videosButton.setEnabled(true);
documentsButton.setEnabled(true);
break;
case DOCUMENTS:
videosButton.setEnabled(true);
imagesButton.setEnabled(true);
break;
default:
break;
}
}
});
@ -344,15 +351,23 @@ public final class DiscoveryTopComponent extends TopComponent {
@Subscribe
void handleSearchCompletedEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompletedEvent) {
SwingUtilities.invokeLater(() -> {
if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
imagesButton.setEnabled(true);
documentsButton.setEnabled(true);
} else if (fileSearchPanel.getSelectedType() == FileType.IMAGE) {
videosButton.setEnabled(true);
documentsButton.setEnabled(true);
} else if (fileSearchPanel.getSelectedType() == FileType.DOCUMENTS) {
videosButton.setEnabled(true);
imagesButton.setEnabled(true);
if (null != fileSearchPanel.getSelectedType()) {
switch (fileSearchPanel.getSelectedType()) {
case VIDEO:
imagesButton.setEnabled(true);
documentsButton.setEnabled(true);
break;
case IMAGE:
videosButton.setEnabled(true);
documentsButton.setEnabled(true);
break;
case DOCUMENTS:
videosButton.setEnabled(true);
imagesButton.setEnabled(true);
break;
default:
break;
}
}
});
}

View File

@ -0,0 +1,154 @@
/*
* Autopsy
*
* Copyright 2020 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.filequery;
import java.awt.Component;
import java.awt.Point;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
* Utility class for the various user interface elements used by File Discovery.
*/
class DiscoveryUiUtils {
private static final int BYTE_UNIT_CONVERSION = 1000;
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_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));
@NbBundle.Messages({"# {0} - fileSize",
"# {1} - units",
"DiscoveryUiUtility.sizeLabel.text=Size: {0} {1}",
"DiscoveryUiUtility.bytes.text=bytes",
"DiscoveryUiUtility.kiloBytes.text=KB",
"DiscoveryUiUtility.megaBytes.text=MB",
"DiscoveryUiUtility.gigaBytes.text=GB",
"DiscoveryUiUtility.terraBytes.text=TB"})
/**
* Convert a size in bytes to a string with representing the size in the
* largest units which represent the value as being greater than or equal to
* one. Result will be rounded down to the nearest whole number of those
* units.
*
* @param bytes Size in bytes.
*/
static String getFileSizeString(long bytes) {
long size = bytes;
int unitsSwitchValue = 0;
while (size > BYTE_UNIT_CONVERSION && unitsSwitchValue < 4) {
size /= BYTE_UNIT_CONVERSION;
unitsSwitchValue++;
}
String units;
switch (unitsSwitchValue) {
case 1:
units = Bundle.DiscoveryUiUtility_kiloBytes_text();
break;
case 2:
units = Bundle.DiscoveryUiUtility_megaBytes_text();
break;
case 3:
units = Bundle.DiscoveryUiUtility_gigaBytes_text();
break;
case 4:
units = Bundle.DiscoveryUiUtility_terraBytes_text();
break;
default:
units = Bundle.DiscoveryUiUtility_bytes_text();
break;
}
return Bundle.DiscoveryUiUtility_sizeLabel_text(size, units);
}
/**
* 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.
*/
static 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;
}
/**
* Method to set the icon and tool tip text for a label to show deleted
* status.
*
* @param isDeleted True if the label should reflect deleted status,
* false otherwise.
* @param isDeletedLabel The label to set the icon and tooltip for.
*/
static void setDeletedIcon(boolean isDeleted, javax.swing.JLabel isDeletedLabel) {
if (isDeleted) {
isDeletedLabel.setIcon(DELETED_ICON);
isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text());
} else {
isDeletedLabel.setIcon(null);
isDeletedLabel.setToolTipText(null);
}
}
/**
* Method to set the icon and tool tip text for a label to show the score.
*
* @param resultFile The result file which the label should reflect the
* score of.
* @param scoreLabel The label to set the icon and tooltip for.
*/
static void setScoreIcon(ResultFile resultFile, javax.swing.JLabel scoreLabel) {
switch (resultFile.getScore()) {
case NOTABLE_SCORE:
scoreLabel.setIcon(NOTABLE_SCORE_ICON);
break;
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
}
scoreLabel.setToolTipText(resultFile.getScoreDescription());
}
/**
* Get the size of the icons used by the UI.
*
* @return
*/
static int getIconSize() {
return ICON_SIZE;
}
/**
* Private constructor for DiscoveryUiUtils utility class.
*/
private DiscoveryUiUtils() {
//private constructor in a utility class intentionally left blank
}
}

View File

@ -87,13 +87,13 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="DocumentPanel.isDeletedLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>
@ -102,17 +102,15 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/sleuthkit/autopsy/images/red-circle-exclamation.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="DocumentPanel.scoreLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>

View File

@ -23,29 +23,18 @@ import java.awt.Component;
import java.awt.Dimension;
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;
import org.openide.util.NbBundle;
/**
*
* @author wschaefer
* Class which displays a preview and details about a document.
*/
public class DocumentPanel extends javax.swing.JPanel implements ListCellRenderer<DocumentWrapper> {
private static final long serialVersionUID = 1L;
private static final Color SELECTION_COLOR = new Color(0, 120, 215);
private static final int BYTE_UNIT_CONVERSION = 1000;
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_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 DocumentPanel
@ -80,15 +69,15 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
isDeletedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/file-icon-deleted.png"))); // NOI18N
isDeletedLabel.setToolTipText(org.openide.util.NbBundle.getMessage(DocumentPanel.class, "DocumentPanel.isDeletedLabel.toolTipText")); // NOI18N
isDeletedLabel.setMaximumSize(new Dimension(ICON_SIZE,ICON_SIZE));
isDeletedLabel.setMinimumSize(new Dimension(ICON_SIZE,ICON_SIZE));
isDeletedLabel.setPreferredSize(new Dimension(ICON_SIZE,ICON_SIZE));
isDeletedLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
isDeletedLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
isDeletedLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/red-circle-exclamation.png"))); // NOI18N
scoreLabel.setToolTipText(org.openide.util.NbBundle.getMessage(DocumentPanel.class, "DocumentPanel.scoreLabel.toolTipText")); // 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));
scoreLabel.setToolTipText("");
scoreLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
fileSizeLabel.setToolTipText(org.openide.util.NbBundle.getMessage(DocumentPanel.class, "DocumentPanel.fileSizeLabel.toolTipText")); // NOI18N
@ -143,49 +132,7 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
);
}// </editor-fold>//GEN-END:initComponents
@NbBundle.Messages({"# {0} - fileSize",
"# {1} - units",
"DocumentPanel.sizeLabel.text=Size: {0} {1}",
"DocumentPanel.bytes.text=bytes",
"DocumentPanel.kiloBytes.text=KB",
"DocumentPanel.megaBytes.text=MB",
"DocumentPanel.gigaBytes.text=GB",
"DocumentPanel.terraBytes.text=TB"})
/**
* Convert a size in bytes to a string with representing the size in the
* largest units which represent the value as being greater than or equal to
* one. Result will be rounded down to the nearest whole number of those
* units.
*
* @param bytes Size in bytes.
*/
private String getFileSizeString(long bytes) {
long size = bytes;
int unitsSwitchValue = 0;
while (size > BYTE_UNIT_CONVERSION && unitsSwitchValue < 4) {
size /= BYTE_UNIT_CONVERSION;
unitsSwitchValue++;
}
String units;
switch (unitsSwitchValue) {
case 1:
units = Bundle.DocumentPanel_kiloBytes_text();
break;
case 2:
units = Bundle.DocumentPanel_megaBytes_text();
break;
case 3:
units = Bundle.DocumentPanel_gigaBytes_text();
break;
case 4:
units = Bundle.DocumentPanel_terraBytes_text();
break;
default:
units = Bundle.DocumentPanel_bytes_text();
break;
}
return Bundle.DocumentPanel_sizeLabel_text(size, units);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel countLabel;
@ -199,31 +146,13 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
@Override
public Component getListCellRendererComponent(JList<? extends DocumentWrapper> list, DocumentWrapper value, int index, boolean isSelected, boolean cellHasFocus) {
fileSizeLabel.setText(getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
fileSizeLabel.setText(DiscoveryUiUtils.getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size()));
documentType.setText("Extension: " + value.getResultFile().getFirstInstance().getNameExtension()); //WJS-TODO fill this in with a document type instead of just DOCUMENT
previewTextArea.setText(value.getPreview());
previewTextArea.setCaretPosition(0);
if (value.getResultFile().isDeleted()) {
isDeletedLabel.setIcon(DELETED_ICON);
isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text());
} else {
isDeletedLabel.setIcon(null);
isDeletedLabel.setToolTipText(null);
}
switch (value.getResultFile().getScore()) {
case NOTABLE_SCORE:
scoreLabel.setIcon(NOTABLE_SCORE_ICON);
break;
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
}
scoreLabel.setToolTipText(value.getResultFile().getScoreDescription());
DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(), isDeletedLabel);
DiscoveryUiUtils.setScoreIcon(value.getResultFile(), scoreLabel);
setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
return this;
@ -235,7 +164,7 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
//gets tooltip of internal panel item mouse is over
Point point = event.getPoint();
for (Component comp : getComponents()) {
if (isPointOnIcon(comp, point)) {
if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
String toolTip = ((JComponent) comp).getToolTipText();
if (toolTip == null || toolTip.isEmpty()) {
return null;
@ -248,15 +177,4 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
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;
}
}

View File

@ -1,7 +1,20 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Autopsy
*
* Copyright 2020 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.filequery;
@ -12,17 +25,17 @@ import javax.swing.event.ListSelectionListener;
import org.sleuthkit.datamodel.AbstractFile;
/**
*
* @author wschaefer
* A JPanel to display document previews.
*/
public class DocumentViewer extends javax.swing.JPanel {
public class DocumentPreviewViewer extends javax.swing.JPanel {
private static final long serialVersionUID = 1L;
private final DefaultListModel<DocumentWrapper> documentListModel = new DefaultListModel<>();
/**
* Creates new form DocumentViewer
*/
public DocumentViewer() {
public DocumentPreviewViewer() {
initComponents();
}
@ -59,6 +72,9 @@ public class DocumentViewer extends javax.swing.JPanel {
);
}// </editor-fold>//GEN-END:initComponents
/**
* Clear the list of documents being displayed.
*/
void clearViewer() {
synchronized (this) {
documentListModel.removeAllElements();
@ -67,7 +83,8 @@ public class DocumentViewer extends javax.swing.JPanel {
}
/**
* Add a selection listener to the list of thumbnails being displayed.
* Add a selection listener to the list of document previews being
* displayed.
*
* @param listener The ListSelectionListener to add to the selection model.
*/
@ -75,6 +92,13 @@ public class DocumentViewer extends javax.swing.JPanel {
documentList.getSelectionModel().addListSelectionListener(listener);
}
/**
* Get the list of AbstractFiles which are represented by the selected
* document preview.
*
* @return The list of AbstractFiles which are represented by the selected
* document preview.
*/
List<AbstractFile> getInstancesForSelected() {
synchronized (this) {
if (documentList.getSelectedIndex() == -1) {
@ -90,6 +114,12 @@ public class DocumentViewer extends javax.swing.JPanel {
private javax.swing.JScrollPane documentScrollPane;
// End of variables declaration//GEN-END:variables
/**
* Add the preview for a document to the panel.
*
* @param documentWrapper The object which contains the document preview
* which will be displayed.
*/
void addDocument(DocumentWrapper documentWrapper) {
synchronized (this) {
documentListModel.addElement(documentWrapper);

View File

@ -18,22 +18,20 @@
*/
package org.sleuthkit.autopsy.filequery;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
* Class to wrap all the information necessary for a document preview to be
* displayed.
*/
public class DocumentWrapper {
private String preview;
private final ResultFile resultFile;
private static final Logger logger = Logger.getLogger(DocumentWrapper.class.getName());
//string extract utility
/**
* Construct a new ImageThumbnailsWrapper.
* Construct a new DocumentWrapper.
*
* @param file The ResultFile which represents the document which the
* summary is created for.
* preview summary is created for.
*/
DocumentWrapper(ResultFile file) {
this.preview = "Preview being generated.";
@ -43,18 +41,19 @@ public class DocumentWrapper {
/**
* Set the preview summary which exists.
*
* @param summary The String which summarizes this document.
* @param preview The String which should be displayed as a preview for this
* document.
*/
void setSummary(String summary) {
this.preview = summary;
void setPreview(String preview) {
this.preview = preview;
}
/**
* Get the ResultFile which represents the document the preview summary was
* created for.
*
* @return The ResultFile which represents the image file which the
* thumbnail was created for.
* @return The ResultFile which represents the document file which the
* preview was created for.
*/
ResultFile getResultFile() {
return resultFile;

View File

@ -511,6 +511,16 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
notableFilterSettings(false, false, false);
}
/**
* Set the UI elements available to be the set of UI elements available when
* a Document search is being performed.
*
* @param enabled Boolean indicating if the filters present for documents
* should be enabled.
* @param resetSelected Boolean indicating if selection of the filters
* present for documents should be reset to their default
* status.
*/
private void documentsSelected(boolean enabled, boolean resetSelected) {
dataSourceFilterSettings(true, enabled, !resetSelected && dataSourceCheckbox.isSelected(), null);
sizeFilterSettings(true, enabled, !resetSelected && sizeCheckbox.isSelected(), null);
@ -541,12 +551,20 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
void setSelectedType(FileType type) {
fileType = type;
setUpSizeFilter();
if (fileType == FileType.IMAGE) {
imagesSelected(true, true);
} else if (fileType == FileType.VIDEO) {
videosSelected(true, true);
} else if (fileType == FileType.DOCUMENTS) {
documentsSelected(true, true);
if (null != fileType) {
switch (fileType) {
case IMAGE:
imagesSelected(true, true);
break;
case VIDEO:
videosSelected(true, true);
break;
case DOCUMENTS:
documentsSelected(true, true);
break;
default:
break;
}
}
validateFields();
}
@ -1792,10 +1810,20 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
} else {
DiscoveryTopComponent.getTopComponent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
if (fileType == FileType.IMAGE) {
imagesSelected(enabled, false);
} else if (fileType == FileType.VIDEO) {
videosSelected(enabled, false);
if (null != fileType) {
switch (fileType) {
case IMAGE:
imagesSelected(enabled, false);
break;
case VIDEO:
videosSelected(enabled, false);
break;
case DOCUMENTS:
documentsSelected(enabled, false);
break;
default:
break;
}
}
searchButton.setEnabled(enabled);
cancelButton.setEnabled(!enabled);

View File

@ -101,15 +101,17 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/sleuthkit/autopsy/images/file-icon-deleted.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="ImageThumbnailPanel.isDeletedLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>
@ -120,13 +122,13 @@
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>

View File

@ -27,7 +27,6 @@ import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
@ -37,14 +36,6 @@ 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 BYTE_UNIT_CONVERSION = 1000;
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_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
@ -83,16 +74,16 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR
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));
isDeletedLabel.setToolTipText(org.openide.util.NbBundle.getMessage(ImageThumbnailPanel.class, "ImageThumbnailPanel.isDeletedLabel.toolTipText")); // NOI18N
isDeletedLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
isDeletedLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
isDeletedLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
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));
scoreLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@ -143,85 +134,23 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR
"ImageThumbnailPanel.isDeleted.text=All instances of file are deleted."})
@Override
public Component getListCellRendererComponent(JList<? extends ImageThumbnailWrapper> list, ImageThumbnailWrapper value, int index, boolean isSelected, boolean cellHasFocus) {
fileSizeLabel.setText(getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
fileSizeLabel.setText(DiscoveryUiUtils.getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size()));
thumbnailLabel.setIcon(new ImageIcon(value.getThumbnail()));
if (value.getResultFile().isDeleted()) {
isDeletedLabel.setIcon(DELETED_ICON);
isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text());
} else {
isDeletedLabel.setIcon(null);
isDeletedLabel.setToolTipText(null);
}
switch (value.getResultFile().getScore()) {
case NOTABLE_SCORE:
scoreLabel.setIcon(NOTABLE_SCORE_ICON);
break;
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
}
scoreLabel.setToolTipText(value.getResultFile().getScoreDescription());
DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(), isDeletedLabel);
DiscoveryUiUtils.setScoreIcon(value.getResultFile(), scoreLabel);
setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
return this;
}
@NbBundle.Messages({"# {0} - fileSize",
"# {1} - units",
"ImageThumbnailPanel.sizeLabel.text=Size: {0} {1}",
"ImageThumbnailPanel.bytes.text=bytes",
"ImageThumbnailPanel.kiloBytes.text=KB",
"ImageThumbnailPanel.megaBytes.text=MB",
"ImageThumbnailPanel.gigaBytes.text=GB",
"ImageThumbnailPanel.terraBytes.text=TB"})
/**
* Convert a size in bytes to a string with representing the size in the
* largest units which represent the value as being greater than or equal to
* one. Result will be rounded down to the nearest whole number of those
* units.
*
* @param bytes Size in bytes.
*/
private String getFileSizeString(long bytes) {
long size = bytes;
int unitsSwitchValue = 0;
while (size > BYTE_UNIT_CONVERSION && unitsSwitchValue < 4) {
size /= BYTE_UNIT_CONVERSION;
unitsSwitchValue++;
}
String units;
switch (unitsSwitchValue) {
case 1:
units = Bundle.ImageThumbnailPanel_kiloBytes_text();
break;
case 2:
units = Bundle.ImageThumbnailPanel_megaBytes_text();
break;
case 3:
units = Bundle.ImageThumbnailPanel_gigaBytes_text();
break;
case 4:
units = Bundle.ImageThumbnailPanel_terraBytes_text();
break;
default:
units = Bundle.ImageThumbnailPanel_bytes_text();
break;
}
return Bundle.ImageThumbnailPanel_sizeLabel_text(size, units);
}
@Override
public String getToolTipText(MouseEvent event) {
if (event != null) {
//gets tooltip of internal panel item mouse is over
Point point = event.getPoint();
for (Component comp : getComponents()) {
if (isPointOnIcon(comp, point)) {
if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
String toolTip = ((JComponent) comp).getToolTipText();
if (toolTip == null || toolTip.isEmpty()) {
return null;
@ -234,16 +163,5 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR
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;
}
}

View File

@ -66,7 +66,7 @@ public class ResultsPanel extends javax.swing.JPanel {
private final static Logger logger = Logger.getLogger(ResultsPanel.class.getName());
private final VideoThumbnailViewer videoThumbnailViewer;
private final ImageThumbnailViewer imageThumbnailViewer;
private final DocumentViewer documentViewer;
private final DocumentPreviewViewer documentPreviewViewer;
private List<FileSearchFiltering.FileFilter> searchFilters;
private FileSearch.AttributeType groupingAttribute;
private FileGroup.GroupSortingAlgorithm groupSort;
@ -90,7 +90,7 @@ public class ResultsPanel extends javax.swing.JPanel {
initComponents();
imageThumbnailViewer = new ImageThumbnailViewer();
videoThumbnailViewer = new VideoThumbnailViewer();
documentViewer = new DocumentViewer();
documentPreviewViewer = new DocumentPreviewViewer();
videoThumbnailViewer.addListSelectionListener((e) -> {
if (resultType == FileSearchData.FileType.VIDEO) {
if (!e.getValueIsAdjusting()) {
@ -109,7 +109,7 @@ public class ResultsPanel extends javax.swing.JPanel {
}
}
});
documentViewer.addListSelectionListener((e) -> {
documentPreviewViewer.addListSelectionListener((e) -> {
if (resultType == FileSearchData.FileType.DOCUMENTS) {
if (!e.getValueIsAdjusting()) {
populateInstancesList();
@ -201,12 +201,17 @@ public class ResultsPanel extends javax.swing.JPanel {
* selected in the results viewer area.
*/
private List<AbstractFile> getInstancesForSelected() {
if (resultType == FileSearchData.FileType.VIDEO) {
return videoThumbnailViewer.getInstancesForSelected();
} else if (resultType == FileSearchData.FileType.IMAGE) {
return imageThumbnailViewer.getInstancesForSelected();
} else if (resultType == FileSearchData.FileType.DOCUMENTS) {
return documentViewer.getInstancesForSelected();
if (null != resultType) {
switch (resultType) {
case VIDEO:
return videoThumbnailViewer.getInstancesForSelected();
case IMAGE:
return imageThumbnailViewer.getInstancesForSelected();
case DOCUMENTS:
return documentPreviewViewer.getInstancesForSelected();
default:
break;
}
}
return new ArrayList<>();
}
@ -223,15 +228,23 @@ public class ResultsPanel extends javax.swing.JPanel {
currentPage = pageRetrievedEvent.getPageNumber();
updateControls();
resetResultViewer();
if (pageRetrievedEvent.getType() == FileSearchData.FileType.IMAGE) {
populateImageViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(imageThumbnailViewer);
} else if (pageRetrievedEvent.getType() == FileSearchData.FileType.VIDEO) {
populateVideoViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(videoThumbnailViewer);
} else if (pageRetrievedEvent.getType() == FileSearchData.FileType.DOCUMENTS) {
populateDocumentViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(documentViewer);
if (null != pageRetrievedEvent.getType()) {
switch (pageRetrievedEvent.getType()) {
case IMAGE:
populateImageViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(imageThumbnailViewer);
break;
case VIDEO:
populateVideoViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(videoThumbnailViewer);
break;
case DOCUMENTS:
populateDocumentViewer(pageRetrievedEvent.getSearchResults());
resultsViewerPanel.add(documentPreviewViewer);
break;
default:
break;
}
}
resultsViewerPanel.revalidate();
resultsViewerPanel.repaint();
@ -246,7 +259,7 @@ public class ResultsPanel extends javax.swing.JPanel {
synchronized void resetResultViewer() {
resultsViewerPanel.remove(imageThumbnailViewer);
resultsViewerPanel.remove(videoThumbnailViewer);
resultsViewerPanel.remove(documentViewer);
resultsViewerPanel.remove(documentPreviewViewer);
//cancel any unfished thumb workers
for (SwingWorker<Void, Void> thumbWorker : resultContentWorkers) {
if (!thumbWorker.isDone()) {
@ -257,7 +270,7 @@ public class ResultsPanel extends javax.swing.JPanel {
resultContentWorkers.clear();
videoThumbnailViewer.clearViewer();
imageThumbnailViewer.clearViewer();
documentViewer.clearViewer();
documentPreviewViewer.clearViewer();
}
/**
@ -290,9 +303,15 @@ public class ResultsPanel extends javax.swing.JPanel {
}
}
/**
* Populate the document preview viewer, cancelling any content which is
* currently being created first.
*
* @param files The list of ResultFiles to populate the image viewer with.
*/
synchronized void populateDocumentViewer(List<ResultFile> files) {
for (ResultFile file : files) {
DocumentSummaryWorker documentWorker = new DocumentSummaryWorker(file);
DocumentPreviewWorker documentWorker = new DocumentPreviewWorker(file);
documentWorker.execute();
//keep track of thumb worker for possible cancelation
resultContentWorkers.add(documentWorker);
@ -332,7 +351,7 @@ public class ResultsPanel extends javax.swing.JPanel {
updateControls();
videoThumbnailViewer.clearViewer();
imageThumbnailViewer.clearViewer();
documentViewer.clearViewer();
documentPreviewViewer.clearViewer();
resultsViewerPanel.revalidate();
resultsViewerPanel.repaint();
});
@ -723,29 +742,29 @@ public class ResultsPanel extends javax.swing.JPanel {
}
/**
* Swing worker to handle the retrieval of image thumbnails and population
* of the Image Thumbnail Viewer.
* Swing worker to handle the retrieval of document previews and population
* of the Document Preview Viewer.
*/
private class DocumentSummaryWorker extends SwingWorker<Void, Void> {
private class DocumentPreviewWorker extends SwingWorker<Void, Void> {
private final DocumentWrapper documentWrapper;
/**
* Construct a new ImageThumbnailWorker.
* Construct a new DocumentPreviewWorker.
*
* @param file The ResultFile which represents the image file thumbnails
* are being retrieved for.
* @param file The ResultFile which represents the document file a
* preview is being retrieved for.
*/
DocumentSummaryWorker(ResultFile file) {
DocumentPreviewWorker(ResultFile file) {
documentWrapper = new DocumentWrapper(file);
documentViewer.addDocument(documentWrapper);
documentPreviewViewer.addDocument(documentWrapper);
}
@Override
protected Void doInBackground() throws Exception {
String preview = createPreview(documentWrapper.getResultFile().getFirstInstance());
if (preview != null) {
documentWrapper.setSummary(preview);
documentWrapper.setPreview(preview);
}
return null;
}
@ -779,7 +798,7 @@ public class ResultsPanel extends javax.swing.JPanel {
@Override
protected void done() {
documentViewer.repaint();
documentPreviewViewer.repaint();
}
}

View File

@ -75,13 +75,13 @@
<Image iconType="3" name="/org/sleuthkit/autopsy/images/red-circle-exclamation.png"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>
@ -91,13 +91,13 @@
<Image iconType="3" name="/org/sleuthkit/autopsy/images/file-icon-deleted.png"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension(ICON_SIZE,ICON_SIZE)" type="code"/>
<Connection code="new Dimension(org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize(),org.sleuthkit.autopsy.filequery.DiscoveryUiUtils.getIconSize())" type="code"/>
</Property>
</Properties>
</Component>

View File

@ -31,7 +31,6 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle.Messages;
/**
@ -42,13 +41,6 @@ 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 BYTE_UNIT_CONVERSION = 1000;
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_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;
/**
@ -117,14 +109,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));
scoreLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
scoreLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
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));
deletedLabel.setMaximumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
deletedLabel.setMinimumSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
deletedLabel.setPreferredSize(new Dimension(DiscoveryUiUtils.getIconSize(),DiscoveryUiUtils.getIconSize()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@ -179,26 +171,8 @@ 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());
if (value.getResultFile().isDeleted()) {
deletedLabel.setIcon(DELETED_ICON);
deletedLabel.setToolTipText(Bundle.VideoThumbnailPanel_deleted_text());
} else {
deletedLabel.setIcon(null);
deletedLabel.setToolTipText("");
}
switch (value.getResultFile().getScore()) {
case NOTABLE_SCORE:
scoreLabel.setIcon(NOTABLE_SCORE_ICON);
break;
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
}
scoreLabel.setToolTipText(value.getResultFile().getScoreDescription());
DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(), deletedLabel);
DiscoveryUiUtils.setScoreIcon(value.getResultFile(), scoreLabel);
setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
return this;
}
@ -253,7 +227,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe
//gets tooltip of internal panel item mouse is over
Point point = event.getPoint();
for (Component comp : getComponents()) {
if (isPointOnIcon(comp, point)) {
if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
String toolTip = ((JComponent) comp).getToolTipText();
if (toolTip == null || toolTip.isEmpty()) {
return null;
@ -266,15 +240,4 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe
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;
}
}