19 package org.sleuthkit.autopsy.filequery;
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;
36 public class DocumentPanel extends javax.swing.JPanel implements ListCellRenderer<DocumentWrapper> {
54 @SuppressWarnings(
"unchecked")
66 setBorder(javax.swing.BorderFactory.createEtchedBorder());
68 isDeletedLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/file-icon-deleted.png")));
74 scoreLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/red-circle-exclamation.png")));
89 previewTextPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
91 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
92 this.setLayout(layout);
93 layout.setHorizontalGroup(
94 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95 .addGroup(layout.createSequentialGroup()
97 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
98 .addGroup(layout.createSequentialGroup()
99 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
100 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
101 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
102 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
103 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
104 .addGroup(layout.createSequentialGroup()
105 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106 .addComponent(
nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
107 .addComponent(
previewTextPane, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE))
108 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
109 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
110 .addComponent(
numberOfImagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
111 .addComponent(
sampleImageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
114 layout.setVerticalGroup(
115 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
118 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
119 .addComponent(
numberOfImagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
120 .addComponent(
nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
121 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
122 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
123 .addComponent(
sampleImageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
124 .addComponent(
previewTextPane, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
125 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
126 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
127 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
128 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
129 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
146 "# {0} - otherInstanceCount",
147 "DocumentPanel.nameLabel.more.text= and {0} more",
148 "# {0} - numberOfImages",
149 "DocumentPanel.numberOfImages.text=1 of {0} images",
150 "DocumentPanel.numberOfImages.noImages=No images",
151 "DocumentPanel.noImageExtraction.text=0 of ? images"})
155 fileSizeLabel.setText(DiscoveryUiUtils.getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
156 String nameText = value.getResultFile().getFirstInstance().getParentPath() + value.getResultFile().getFirstInstance().getName();
157 if (value.getResultFile().getAllInstances().size() > 1) {
158 nameText += Bundle.DocumentPanel_nameLabel_more_text(value.getResultFile().getAllInstances().size() - 1);
161 nameText =
"..." + nameText.substring(nameText.length() - (MAX_NAME_STRING - 3));
166 }
else if (FileSearchData.getDocTypesWithoutImageExtraction().contains(value.getResultFile().getFirstInstance().getMIMEType())) {
176 DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(),
isDeletedLabel);
177 DiscoveryUiUtils.setScoreIcon(value.getResultFile(),
scoreLabel);
178 setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
186 Point point =
event.getPoint();
187 for (Component comp : getComponents()) {
188 if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
189 String toolTip = ((JComponent) comp).getToolTipText();
190 if (toolTip == null || toolTip.isEmpty()) {
javax.swing.JLabel sampleImageLabel
javax.swing.JLabel fileSizeLabel
static final int MAX_NAME_STRING
String getToolTipText(MouseEvent event)
static final Color SELECTION_COLOR
javax.swing.JTextPane previewTextPane
javax.swing.JLabel nameLabel
javax.swing.JLabel numberOfImagesLabel
javax.swing.JLabel scoreLabel
Component getListCellRendererComponent(JList<?extends DocumentWrapper > list, DocumentWrapper value, int index, boolean isSelected, boolean cellHasFocus)
javax.swing.JLabel isDeletedLabel
static final long serialVersionUID