19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.awt.Point;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.JPopupMenu;
26 import javax.swing.event.ListSelectionListener;
27 import javax.swing.table.AbstractTableModel;
28 import javax.swing.table.TableCellRenderer;
29 import org.apache.commons.io.FilenameUtils;
30 import org.apache.commons.lang.StringUtils;
31 import org.openide.util.NbBundle;
46 final class ArtifactsListPanel
extends AbstractArtifactListPanel {
48 private static final long serialVersionUID = 1L;
49 private static final Logger logger = Logger.getLogger(ArtifactsListPanel.class.getName());
50 private final DomainArtifactTableModel tableModel;
57 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
58 ArtifactsListPanel(BlackboardArtifact.ARTIFACT_TYPE artifactType) {
59 tableModel =
new DomainArtifactTableModel(artifactType);
62 TableCellRenderer renderer =
new SimpleTableCellRenderer();
63 for (
int i = 0; i < tableModel.getColumnCount(); ++i) {
64 artifactsTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
66 artifactsTable.getRowSorter().toggleSortOrder(0);
67 artifactsTable.getRowSorter().toggleSortOrder(0);
71 void addMouseListener(java.awt.event.MouseAdapter mouseListener) {
72 artifactsTable.addMouseListener(mouseListener);
76 void showPopupMenu(JPopupMenu popupMenu, Point point) {
77 popupMenu.show(artifactsTable, point.x, point.y);
81 void addSelectionListener(ListSelectionListener listener) {
82 artifactsTable.getSelectionModel().addListSelectionListener(listener);
86 void removeSelectionListener(ListSelectionListener listener) {
87 artifactsTable.getSelectionModel().removeListSelectionListener(listener);
91 boolean selectAtPoint(Point point) {
92 boolean pointSelected =
false;
93 int row = artifactsTable.rowAtPoint(point);
94 if (row < artifactsTable.getRowCount() && row >= 0) {
95 artifactsTable.clearSelection();
96 artifactsTable.addRowSelectionInterval(row, row);
103 BlackboardArtifact getSelectedArtifact() {
104 if (artifactsTable.getModel() instanceof DomainArtifactTableModel) {
105 int selectedIndex = artifactsTable.getSelectionModel().getLeadSelectionIndex();
106 if (selectedIndex < artifactsTable.getSelectionModel().getMinSelectionIndex() || artifactsTable.getSelectionModel().getMaxSelectionIndex() < 0 || selectedIndex > artifactsTable.getSelectionModel().getMaxSelectionIndex()) {
109 return tableModel.getArtifactByRow(artifactsTable.convertRowIndexToModel(selectedIndex));
117 return tableModel.getRowCount() <= 0;
123 artifactsTable.setRowSelectionInterval(0, 0);
125 artifactsTable.clearSelection();
135 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
137 void addArtifacts(List<BlackboardArtifact> artifactList) {
138 if (!artifactList.isEmpty()) {
139 artifactsTable.setModel(tableModel);
140 tableModel.setContents(artifactList);
142 artifactsTable.setModel(
new EmptyTableModel());
144 artifactsTable.validate();
145 artifactsTable.repaint();
146 tableModel.fireTableDataChanged();
152 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
155 tableModel.setContents(
new ArrayList<>());
156 tableModel.fireTableDataChanged();
165 private void initComponents() {
167 javax.swing.JScrollPane jScrollPane1 =
new javax.swing.JScrollPane();
168 artifactsTable =
new javax.swing.JTable();
171 setPreferredSize(
new java.awt.Dimension(350, 10));
173 jScrollPane1.setBorder(null);
174 jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
175 jScrollPane1.setMinimumSize(
new java.awt.Dimension(0, 0));
176 jScrollPane1.setPreferredSize(
new java.awt.Dimension(350, 10));
178 artifactsTable.setAutoCreateRowSorter(
true);
179 artifactsTable.setModel(tableModel);
180 artifactsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
181 jScrollPane1.setViewportView(artifactsTable);
183 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
184 this.setLayout(layout);
185 layout.setHorizontalGroup(
186 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
189 layout.setVerticalGroup(
190 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
201 private static final long serialVersionUID = 1L;
202 private final List<BlackboardArtifact> artifactList =
new ArrayList<>();
222 void setContents(List<BlackboardArtifact> artifacts) {
223 artifactsTable.clearSelection();
224 artifactList.clear();
225 artifactList.addAll(artifacts);
231 return artifactList.size();
237 if (artifactType == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE) {
252 BlackboardArtifact getArtifactByRow(
int rowIndex) {
253 return artifactList.get(rowIndex);
257 @NbBundle.Messages({
"ArtifactsListPanel.value.noValue=No value available."})
260 if (columnIndex < 2 || artifactType == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE) {
261 final BlackboardArtifact artifact = getArtifactByRow(rowIndex);
263 for (BlackboardAttribute bba : artifact.getAttributes()) {
264 if (!StringUtils.isBlank(bba.getDisplayString())) {
266 if (!StringUtils.isBlank(stringFromAttribute)) {
267 return stringFromAttribute;
272 }
catch (TskCoreException ex) {
273 logger.log(Level.WARNING,
"Error getting attributes for artifact " + artifact.getArtifactID(), ex);
276 return Bundle.ArtifactsListPanel_value_noValue();
295 private String
getStringForColumn(BlackboardArtifact artifact, BlackboardAttribute bba,
int columnIndex) throws TskCoreException {
296 if (columnIndex == 0 && bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID()) {
298 }
else if (columnIndex == 1) {
299 if (artifactType == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD || artifactType == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE) {
300 if (bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
302 }
else if (bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID()) {
303 return FilenameUtils.getName(bba.getDisplayString());
305 }
else if (bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE.getTypeID()) {
306 return bba.getDisplayString();
308 }
else if (columnIndex == 2 && bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
330 final BlackboardArtifact artifact = getArtifactByRow(rowIndex);
331 for (BlackboardAttribute bba : artifact.getAttributes()) {
332 if (columnIndex == 0 && bba.getAttributeType().getTypeName().startsWith(
"TSK_DATETIME") && !StringUtils.isBlank(bba.getDisplayString())) {
334 }
else if (columnIndex == 1 && bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID() && !StringUtils.isBlank(bba.getDisplayString())) {
335 return bba.getDisplayString();
336 }
else if (columnIndex == 1 && bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID() && !StringUtils.isBlank(bba.getDisplayString())) {
337 return bba.getDisplayString();
338 }
else if (columnIndex == 1 && bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT.getTypeID() && !StringUtils.isBlank(bba.getDisplayString())) {
339 return bba.getDisplayString();
342 return Bundle.ArtifactsListPanel_value_noValue();
346 @NbBundle.Messages({
"ArtifactsListPanel.titleColumn.name=Title",
347 "ArtifactsListPanel.fileNameColumn.name=Name",
348 "ArtifactsListPanel.dateColumn.name=Date/Time",
349 "ArtifactsListPanel.urlColumn.name=URL",
350 "ArtifactsListPanel.termColumn.name=Term",
351 "ArtifactsListPanel.mimeTypeColumn.name=MIME Type"})
356 return Bundle.ArtifactsListPanel_dateColumn_name();
358 if (artifactType != null) {
359 switch (artifactType) {
361 case TSK_WEB_DOWNLOAD:
362 return Bundle.ArtifactsListPanel_fileNameColumn_name();
364 return Bundle.ArtifactsListPanel_urlColumn_name();
365 case TSK_WEB_SEARCH_QUERY:
366 return Bundle.ArtifactsListPanel_termColumn_name();
370 return Bundle.ArtifactsListPanel_titleColumn_name();
372 return Bundle.ArtifactsListPanel_mimeTypeColumn_name();
384 private static final long serialVersionUID = 1L;
396 @NbBundle.Messages({
"ArtifactsListPanel.noResultsFound.text=No results found"})
399 return Bundle.ArtifactsListPanel_noResultsFound_text();
406 return Bundle.ArtifactsListPanel_dateColumn_name();
408 return Bundle.ArtifactsListPanel_titleColumn_name();
410 return Bundle.ArtifactsListPanel_mimeTypeColumn_name();
419 private javax.swing.JTable artifactsTable;
Object getValueAt(int rowIndex, int columnIndex)
String getFallbackValue(int rowIndex, int columnIndex)
Object getValueAt(int rowIndex, int columnIndex)
static TimeZone getTimeZone(Content content)
SleuthkitCase getSleuthkitCase()
String getStringForColumn(BlackboardArtifact artifact, BlackboardAttribute bba, int columnIndex)
static Case getCurrentCase()
String getColumnName(int column)
final BlackboardArtifact.ARTIFACT_TYPE artifactType
String getColumnName(int column)