19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.awt.Color;
22 import java.awt.Component;
23 import java.awt.Dimension;
24 import java.awt.Point;
25 import java.awt.event.MouseEvent;
26 import javax.swing.ImageIcon;
27 import javax.swing.JComponent;
28 import javax.swing.JList;
29 import javax.swing.ListCellRenderer;
30 import org.openide.util.NbBundle.Messages;
38 class DocumentPanel
extends javax.swing.JPanel implements ListCellRenderer<DocumentWrapper> {
40 private static final long serialVersionUID = 1L;
41 private static final Color SELECTION_COLOR =
new Color(0, 120, 215);
42 private static final int MAX_NAME_STRING = 90;
47 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
57 @SuppressWarnings(
"unchecked")
59 private
void initComponents() {
61 isDeletedLabel =
new javax.swing.JLabel();
62 scoreLabel =
new javax.swing.JLabel();
63 fileSizeLabel =
new javax.swing.JLabel();
64 nameLabel =
new javax.swing.JLabel();
65 sampleImageLabel =
new javax.swing.JLabel();
66 numberOfImagesLabel =
new javax.swing.JLabel();
67 previewTextPane =
new AutoWrappingJTextPane();
69 setBorder(javax.swing.BorderFactory.createEtchedBorder());
71 isDeletedLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/file-icon-deleted.png")));
72 isDeletedLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(DocumentPanel.class,
"DocumentPanel.isDeletedLabel.toolTipText"));
77 scoreLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/red-circle-exclamation.png")));
78 scoreLabel.setToolTipText(
"");
83 fileSizeLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(DocumentPanel.class,
"DocumentPanel.fileSizeLabel.toolTipText"));
85 sampleImageLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
86 sampleImageLabel.setIconTextGap(0);
87 sampleImageLabel.setMaximumSize(
new java.awt.Dimension(100, 100));
88 sampleImageLabel.setMinimumSize(
new java.awt.Dimension(100, 100));
89 sampleImageLabel.setPreferredSize(
new java.awt.Dimension(100, 100));
91 previewTextPane.setEditable(
false);
92 previewTextPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
94 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
95 this.setLayout(layout);
96 layout.setHorizontalGroup(
97 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
98 .addGroup(layout.createSequentialGroup()
100 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
101 .addGroup(layout.createSequentialGroup()
102 .addComponent(fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
103 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
104 .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
105 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
106 .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
107 .addGroup(layout.createSequentialGroup()
108 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109 .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
110 .addComponent(previewTextPane, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE))
111 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
112 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
113 .addComponent(numberOfImagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
114 .addComponent(sampleImageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
117 layout.setVerticalGroup(
118 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
121 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
122 .addComponent(numberOfImagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
123 .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
124 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
125 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
126 .addComponent(sampleImageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
127 .addComponent(previewTextPane, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
128 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
129 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
130 .addComponent(scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
131 .addComponent(isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
132 .addComponent(fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
139 private javax.swing.JLabel fileSizeLabel;
140 private javax.swing.JLabel isDeletedLabel;
141 private javax.swing.JLabel nameLabel;
142 private javax.swing.JLabel numberOfImagesLabel;
143 private javax.swing.JTextPane previewTextPane;
144 private javax.swing.JLabel sampleImageLabel;
145 private javax.swing.JLabel scoreLabel;
149 "# {0} - otherInstanceCount",
150 "DocumentPanel.nameLabel.more.text= and {0} more",
151 "# {0} - numberOfImages",
152 "DocumentPanel.numberOfImages.text=1 of {0} images",
153 "DocumentPanel.numberOfImages.noImages=No images",
154 "DocumentPanel.noImageExtraction.text=0 of ? images"})
155 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
157 public Component getListCellRendererComponent(JList<? extends DocumentWrapper> list, DocumentWrapper value,
int index,
boolean isSelected,
boolean cellHasFocus) {
158 fileSizeLabel.setText(DiscoveryUiUtils.getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
159 String nameText = value.getResultFile().getFirstInstance().getParentPath() + value.getResultFile().getFirstInstance().getName();
160 if (value.getResultFile().getAllInstances().size() > 1) {
161 nameText += Bundle.DocumentPanel_nameLabel_more_text(value.getResultFile().getAllInstances().size() - 1);
163 if (nameText.length() > MAX_NAME_STRING) {
164 nameText =
"..." + nameText.substring(nameText.length() - (MAX_NAME_STRING - 3));
166 if (value.getSummary().getNumberOfImages() > 0) {
167 numberOfImagesLabel.setText(Bundle.DocumentPanel_numberOfImages_text(value.getSummary().getNumberOfImages()));
168 sampleImageLabel.setIcon(
new ImageIcon(value.getSummary().getSampleImage()));
169 }
else if (SearchData.getDocTypesWithoutImageExtraction().contains(value.getResultFile().getFirstInstance().getMIMEType())) {
170 numberOfImagesLabel.setText(Bundle.DocumentPanel_noImageExtraction_text());
171 sampleImageLabel.setIcon(DiscoveryUiUtils.getUnsupportedImageThumbnail());
173 numberOfImagesLabel.setText(Bundle.DocumentPanel_numberOfImages_noImages());
174 sampleImageLabel.setIcon(null);
176 nameLabel.setText(nameText);
177 previewTextPane.setText(value.getSummary().getSummaryText());
178 previewTextPane.setCaretPosition(0);
179 DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(), isDeletedLabel);
180 DiscoveryUiUtils.setScoreIcon(value.getResultFile(), scoreLabel);
181 setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
185 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
187 public String getToolTipText(MouseEvent event) {
190 Point point =
event.getPoint();
191 for (Component comp : getComponents()) {
192 if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
193 String toolTip = ((JComponent) comp).getToolTipText();
194 if (toolTip == null || toolTip.isEmpty()) {