19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.Toolkit;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import java.awt.datatransfer.StringSelection;
27 import java.text.SimpleDateFormat;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.Enumeration;
31 import java.util.List;
32 import java.util.concurrent.ExecutionException;
33 import java.util.logging.Level;
34 import javax.swing.JMenuItem;
35 import javax.swing.JTextArea;
36 import javax.swing.SwingWorker;
37 import javax.swing.event.ChangeEvent;
38 import javax.swing.event.ListSelectionEvent;
39 import javax.swing.event.TableColumnModelEvent;
40 import javax.swing.table.DefaultTableModel;
41 import javax.swing.table.TableColumn;
42 import javax.swing.event.TableColumnModelListener;
43 import javax.swing.text.View;
44 import org.apache.commons.lang.StringUtils;
45 import org.openide.nodes.Node;
46 import org.openide.util.Lookup;
47 import org.openide.util.NbBundle;
48 import org.openide.util.lookup.ServiceProvider;
53 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
58 import org.netbeans.swing.etable.ETable;
59 import com.google.gson.JsonElement;
60 import com.google.gson.JsonObject;
61 import com.google.gson.JsonParser;
62 import com.google.gson.JsonArray;
70 @ServiceProvider(service = DataContentViewer.class, position = 7)
71 @SuppressWarnings(
"PMD.SingularField")
75 "DataContentViewerArtifact.attrsTableHeader.type=Type",
76 "DataContentViewerArtifact.attrsTableHeader.value=Value",
77 "DataContentViewerArtifact.attrsTableHeader.sources=Source(s)",
78 "DataContentViewerArtifact.failedToGetSourcePath.message=Failed to get source file path from case database",
79 "DataContentViewerArtifact.failedToGetAttributes.message=Failed to get some or all attributes from case database"
83 private final static String ERROR_TEXT = NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.errorText");
85 private int currentPage = 1;
86 private final Object lock =
new Object();
88 SwingWorker<ViewUpdate, Void> currentTask;
89 private static final String[] COLUMN_HEADERS = {
90 Bundle.DataContentViewerArtifact_attrsTableHeader_type(),
91 Bundle.DataContentViewerArtifact_attrsTableHeader_value(),
92 Bundle.DataContentViewerArtifact_attrsTableHeader_sources()};
93 private static final int[] COLUMN_WIDTHS = {100, 800, 100};
94 private static final int CELL_BOTTOM_MARGIN = 5;
95 private static final int CELL_RIGHT_MARGIN = 1;
100 resultsTableScrollPane.setViewportView(resultsTable);
101 customizeComponents();
107 resultsTable =
new ETable();
108 resultsTable.setModel(
new javax.swing.table.DefaultTableModel() {
109 private static final long serialVersionUID = 1L;
111 public boolean isCellEditable(
int rowIndex,
int columnIndex) {
115 resultsTable.setCellSelectionEnabled(
true);
116 resultsTable.getTableHeader().setReorderingAllowed(
false);
117 resultsTable.setColumnHidingAllowed(
false);
118 resultsTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
119 resultsTable.getColumnModel().addColumnModelListener(
new TableColumnModelListener() {
122 public void columnAdded(TableColumnModelEvent e) {
126 public void columnRemoved(TableColumnModelEvent e) {
130 public void columnMoved(TableColumnModelEvent e) {
135 public void columnMarginChanged(ChangeEvent e) {
140 public void columnSelectionChanged(ListSelectionEvent e) {
143 resultsTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN);
151 int valueColIndex = -1;
152 for (
int col = 0; col < resultsTable.getColumnCount(); col++) {
153 if (resultsTable.getColumnName(col).equals(COLUMN_HEADERS[1])) {
157 if (valueColIndex != -1) {
158 for (
int row = 0; row < resultsTable.getRowCount(); row++) {
159 Component comp = resultsTable.prepareRenderer(
160 resultsTable.getCellRenderer(row, valueColIndex), row, valueColIndex);
162 if (comp instanceof JTextArea) {
163 final JTextArea tc = (JTextArea) comp;
164 final View rootView = tc.getUI().getRootView(tc);
165 java.awt.Insets i = tc.getInsets();
166 rootView.setSize(resultsTable.getColumnModel().getColumn(valueColIndex)
167 .getWidth() - (i.left + i.right +CELL_RIGHT_MARGIN),
169 rowHeight = (int) rootView.getPreferredSpan(View.Y_AXIS);
171 rowHeight = comp.getPreferredSize().height;
174 resultsTable.setRowHeight(row, rowHeight + CELL_BOTTOM_MARGIN);
184 Enumeration<TableColumn> columns = resultsTable.getColumnModel().getColumns();
185 while (columns.hasMoreElements()) {
186 TableColumn col = columns.nextElement();
187 if (col.getHeaderValue().equals(COLUMN_HEADERS[0])) {
188 col.setPreferredWidth(COLUMN_WIDTHS[0]);
189 }
else if (col.getHeaderValue().equals(COLUMN_HEADERS[1])) {
190 col.setPreferredWidth(COLUMN_WIDTHS[1]);
191 }
else if (col.getHeaderValue().equals(COLUMN_HEADERS[2])) {
192 col.setPreferredWidth(COLUMN_WIDTHS[2]);
202 @SuppressWarnings(
"unchecked")
204 private
void initComponents() {
206 rightClickMenu =
new javax.swing.JPopupMenu();
207 copyMenuItem =
new javax.swing.JMenuItem();
208 selectAllMenuItem =
new javax.swing.JMenuItem();
209 jScrollPane1 =
new javax.swing.JScrollPane();
210 jPanel1 =
new javax.swing.JPanel();
211 totalPageLabel =
new javax.swing.JLabel();
212 ofLabel =
new javax.swing.JLabel();
213 currentPageLabel =
new javax.swing.JLabel();
214 pageLabel =
new javax.swing.JLabel();
215 nextPageButton =
new javax.swing.JButton();
216 pageLabel2 =
new javax.swing.JLabel();
217 prevPageButton =
new javax.swing.JButton();
218 artifactLabel =
new javax.swing.JLabel();
219 resultsTableScrollPane =
new javax.swing.JScrollPane();
221 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.copyMenuItem.text"));
222 rightClickMenu.add(copyMenuItem);
224 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.selectAllMenuItem.text"));
225 rightClickMenu.add(selectAllMenuItem);
227 setPreferredSize(
new java.awt.Dimension(100, 58));
229 jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
230 jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
232 jPanel1.setPreferredSize(
new java.awt.Dimension(620, 58));
234 totalPageLabel.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.totalPageLabel.text"));
238 currentPageLabel.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.currentPageLabel.text"));
239 currentPageLabel.setMaximumSize(
new java.awt.Dimension(18, 14));
240 currentPageLabel.setMinimumSize(
new java.awt.Dimension(18, 14));
241 currentPageLabel.setPreferredSize(
new java.awt.Dimension(18, 14));
245 nextPageButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_forward.png")));
246 nextPageButton.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.nextPageButton.text"));
247 nextPageButton.setBorderPainted(
false);
248 nextPageButton.setContentAreaFilled(
false);
249 nextPageButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_forward_disabled.png")));
250 nextPageButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
251 nextPageButton.setPreferredSize(
new java.awt.Dimension(23, 23));
252 nextPageButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_forward_hover.png")));
253 nextPageButton.addActionListener(
new java.awt.event.ActionListener() {
254 public void actionPerformed(java.awt.event.ActionEvent evt) {
255 nextPageButtonActionPerformed(evt);
260 pageLabel2.setMaximumSize(
new java.awt.Dimension(29, 14));
261 pageLabel2.setMinimumSize(
new java.awt.Dimension(29, 14));
263 prevPageButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_back.png")));
264 prevPageButton.setText(
org.openide.util.NbBundle.getMessage(
DataContentViewerArtifact.class,
"DataContentViewerArtifact.prevPageButton.text"));
265 prevPageButton.setBorderPainted(
false);
266 prevPageButton.setContentAreaFilled(
false);
267 prevPageButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_back_disabled.png")));
268 prevPageButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
269 prevPageButton.setPreferredSize(
new java.awt.Dimension(23, 23));
270 prevPageButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/btn_step_back_hover.png")));
271 prevPageButton.addActionListener(
new java.awt.event.ActionListener() {
272 public void actionPerformed(java.awt.event.ActionEvent evt) {
273 prevPageButtonActionPerformed(evt);
277 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
278 jPanel1.setLayout(jPanel1Layout);
279 jPanel1Layout.setHorizontalGroup(
280 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
281 .addGroup(jPanel1Layout.createSequentialGroup()
283 .addComponent(pageLabel)
284 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
285 .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
286 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
287 .addComponent(ofLabel)
288 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
289 .addComponent(totalPageLabel)
291 .addComponent(pageLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
292 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
293 .addComponent(prevPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
295 .addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
296 .addContainerGap(383, Short.MAX_VALUE))
297 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
298 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
299 .addContainerGap(280, Short.MAX_VALUE)
300 .addComponent(artifactLabel)
301 .addContainerGap(84, Short.MAX_VALUE)))
303 jPanel1Layout.setVerticalGroup(
304 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
305 .addGroup(jPanel1Layout.createSequentialGroup()
306 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
307 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
308 .addComponent(pageLabel)
309 .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
310 .addComponent(ofLabel)
311 .addComponent(totalPageLabel))
312 .addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
313 .addComponent(prevPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
314 .addComponent(pageLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
315 .addContainerGap(35, Short.MAX_VALUE))
316 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
317 .addGroup(jPanel1Layout.createSequentialGroup()
318 .addComponent(artifactLabel)
319 .addGap(0, 58, Short.MAX_VALUE)))
322 jScrollPane1.setViewportView(jPanel1);
324 resultsTableScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
325 resultsTableScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
326 resultsTableScrollPane.setPreferredSize(
new java.awt.Dimension(620, 34));
328 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
329 this.setLayout(layout);
330 layout.setHorizontalGroup(
331 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
332 .addComponent(jScrollPane1)
333 .addComponent(resultsTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
335 layout.setVerticalGroup(
336 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
337 .addGroup(layout.createSequentialGroup()
338 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
339 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
340 .addComponent(resultsTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
345 currentPage = currentPage + 1;
346 currentPageLabel.setText(Integer.toString(currentPage));
347 artifactLabel.setText(artifactTableContents.get(currentPage - 1).getArtifactDisplayName());
352 currentPage = currentPage - 1;
353 currentPageLabel.setText(Integer.toString(currentPage));
354 artifactLabel.setText(artifactTableContents.get(currentPage - 1).getArtifactDisplayName());
377 resultsTable.setComponentPopupMenu(rightClickMenu);
378 ActionListener actList =
new ActionListener() {
380 public void actionPerformed(ActionEvent e) {
381 JMenuItem jmi = (JMenuItem) e.getSource();
382 if (jmi.equals(copyMenuItem)) {
383 StringBuilder selectedText =
new StringBuilder(512);
384 for (
int row : resultsTable.getSelectedRows()) {
385 for (
int col : resultsTable.getSelectedColumns()) {
386 selectedText.append((String) resultsTable.getValueAt(row, col));
387 selectedText.append(
"\t");
390 if (row != resultsTable.getSelectedRows()[resultsTable.getSelectedRows().length - 1]) {
391 selectedText.append(System.lineSeparator());
394 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
new StringSelection(selectedText.toString()), null);
395 }
else if (jmi.equals(selectAllMenuItem)) {
396 resultsTable.selectAll();
400 copyMenuItem.addActionListener(actList);
402 selectAllMenuItem.addActionListener(actList);
410 currentPageLabel.setText(
"");
411 artifactLabel.setText(
"");
412 totalPageLabel.setText(
"");
413 ((DefaultTableModel) resultsTable.getModel()).setRowCount(0);
414 prevPageButton.setEnabled(
false);
415 nextPageButton.setEnabled(
false);
421 if (currentNode == selectedNode) {
424 currentNode = selectedNode;
427 if (selectedNode == null) {
432 Lookup lookup = selectedNode.getLookup();
433 Content content = lookup.lookup(Content.class);
434 if (content == null) {
443 return NbBundle.getMessage(this.getClass(),
"DataContentViewerArtifact.title");
448 return NbBundle.getMessage(this.getClass(),
"DataContentViewerArtifact.toolTip");
472 for (Content content : node.getLookup().lookupAll(Content.class)) {
473 if ( (content != null) && (!(content instanceof BlackboardArtifact)) ){
475 return content.getAllArtifactsCount() > 0;
476 }
catch (TskException ex) {
477 logger.log(Level.SEVERE,
"Couldn't get count of BlackboardArtifacts for content", ex);
486 BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
490 if ((artifact == null)
491 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID())
492 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID())
493 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID())
494 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_OBJECT_DETECTED.getTypeID())
495 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_METADATA_EXIF.getTypeID())
496 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EXT_MISMATCH_DETECTED.getTypeID())) {
509 private final SimpleDateFormat dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
510 private String[][] rowData = null;
515 artifactDisplayName = artifact.getDisplayName();
516 this.content = content;
521 artifactDisplayName = errorMsg;
522 rowData =
new String[1][3];
523 rowData[0] =
new String[]{
"", errorMsg,
""};
531 private void addRows(BlackboardArtifact artifact) {
532 List<String[]> rowsToAdd =
new ArrayList<>();
537 for (BlackboardAttribute attr : artifact.getAttributes()) {
542 switch (attr.getAttributeType().getValueType()) {
549 value = attr.getDisplayString();
553 long epoch = attr.getValueLong();
554 value =
"0000-00-00 00:00:00";
555 if (null != content && 0 != epoch) {
557 value = dateFormatter.format(
new java.util.Date(epoch * 1000));
562 String jsonVal = attr.getValueString();
563 JsonParser parser =
new JsonParser();
564 JsonObject json = parser.parse(jsonVal).getAsJsonObject();
566 value = toJsonDisplayString(json,
"");
572 String sources = StringUtils.join(attr.getSources(),
", ");
573 rowsToAdd.add(
new String[]{attr.getAttributeType().getDisplayName(), value, sources});
580 if (null != content) {
581 path = content.getUniquePath();
583 }
catch (TskCoreException ex) {
584 logger.log(Level.SEVERE, String.format(
"Error getting source content path for artifact (artifact_id=%d, obj_id=%d)", artifact.getArtifactID(), artifact.getObjectID()), ex);
585 path = Bundle.DataContentViewerArtifact_failedToGetSourcePath_message();
587 rowsToAdd.add(
new String[]{
"Source File Path", path,
""});
591 rowsToAdd.add(
new String[]{
"Artifact ID", Long.toString(artifact.getArtifactID()),
""});
592 }
catch (TskCoreException ex) {
593 rowsToAdd.add(
new String[]{
"", Bundle.DataContentViewerArtifact_failedToGetAttributes_message(),
""});
595 rowData = rowsToAdd.toArray(
new String[0][0]);
601 String getArtifactDisplayName() {
602 return artifactDisplayName;
605 private static final String INDENT_RIGHT =
" ";
606 private static final String NEW_LINE =
"\n";
619 StringBuilder sb =
new StringBuilder(
"");
620 JsonObject obj = element.getAsJsonObject();
622 for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
623 appendJsonElementToString(entry.getKey(), entry.getValue(), startIndent, sb );
626 String returnString = sb.toString();
627 if (startIndent.length() == 0 && returnString.startsWith(NEW_LINE)) {
628 returnString = returnString.substring(NEW_LINE.length());
643 if (jsonElement.isJsonArray()) {
644 JsonArray jsonArray = jsonElement.getAsJsonArray();
645 if (jsonArray.size() > 0) {
647 sb.append(NEW_LINE).append(String.format(
"%s%s", startIndent, jsonKey));
648 for (JsonElement arrayMember : jsonArray) {
649 sb.append(NEW_LINE).append(String.format(
"%s%d", startIndent.concat(INDENT_RIGHT), count));
650 sb.append(toJsonDisplayString(arrayMember, startIndent.concat(INDENT_RIGHT).concat(INDENT_RIGHT)));
654 }
else if (jsonElement.isJsonObject()) {
655 sb.append(NEW_LINE).append(String.format(
"%s%s %s", startIndent, jsonKey, toJsonDisplayString(jsonElement.getAsJsonObject(), startIndent + INDENT_RIGHT)));
656 }
else if (jsonElement.isJsonPrimitive()) {
657 sb.append(NEW_LINE).append(String.format(
"%s%s = %s", startIndent, jsonKey, jsonElement.getAsString()));
658 }
else if (jsonElement.isJsonNull()) {
659 sb.append(NEW_LINE).append(String.format(
"%s%s = null", startIndent, jsonKey));
675 this.currentPage = currentPage;
676 this.numberOfPages = numberOfPages;
677 this.tableContents = contents;
680 ViewUpdate(
int numberOfPages,
int currentPage, String errorMsg) {
681 this.currentPage = currentPage;
682 this.numberOfPages = numberOfPages;
695 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
697 nextPageButton.setEnabled(viewUpdate.currentPage < viewUpdate.numberOfPages);
698 prevPageButton.setEnabled(viewUpdate.currentPage > 1);
699 currentPage = viewUpdate.currentPage;
700 totalPageLabel.setText(Integer.toString(viewUpdate.numberOfPages));
701 currentPageLabel.setText(Integer.toString(currentPage));
702 artifactLabel.setText(viewUpdate.tableContents.getArtifactDisplayName());
703 DefaultTableModel tModel = ((DefaultTableModel) resultsTable.getModel());
704 tModel.setDataVector(viewUpdate.tableContents.
getRows(), COLUMN_HEADERS);
707 resultsTable.clearSelection();
709 this.setCursor(null);
718 private synchronized void startNewTask(SwingWorker<ViewUpdate, Void> task) {
719 String[][] waitRow =
new String[1][3];
720 waitRow[0] =
new String[]{
"", WAIT_TEXT,
""};
721 DefaultTableModel tModel = ((DefaultTableModel) resultsTable.getModel());
722 tModel.setDataVector(waitRow, COLUMN_HEADERS);
725 resultsTable.clearSelection();
727 if (currentTask != null) {
730 currentTask.cancel(
false);
735 currentTask.execute();
745 synchronized (lock) {
746 this.artifactTableContents = artifactList;
756 synchronized (lock) {
757 return artifactTableContents;
771 this.selectedNode = selectedNode;
778 Lookup lookup = selectedNode.getLookup();
781 ArrayList<BlackboardArtifact> artifacts =
new ArrayList<>();
782 Collection<? extends Content> contents = lookup.lookupAll(Content.class);
783 if (contents.isEmpty()) {
784 return new ViewUpdate(getArtifactContents().size(), currentPage, ERROR_TEXT);
786 Content underlyingContent = null;
787 for (Content content : contents) {
788 if ( (content != null) && (!(content instanceof BlackboardArtifact)) ) {
792 artifacts = content.getAllArtifacts();
793 underlyingContent = content;
795 }
catch (TskException ex) {
796 logger.log(Level.SEVERE,
"Couldn't get artifacts", ex);
797 return new ViewUpdate(getArtifactContents().size(), currentPage, ERROR_TEXT);
807 ArrayList<ResultsTableArtifact> artifactContents =
new ArrayList<>();
808 for (BlackboardArtifact artifact : artifacts) {
815 BlackboardArtifact artifact = lookup.lookup(BlackboardArtifact.class);
816 if (artifact != null) {
817 index = artifacts.indexOf(artifact);
823 for (BlackboardAttribute attr : artifact.getAttributes()) {
824 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
825 long assocArtifactId = attr.getValueLong();
826 int assocArtifactIndex = -1;
827 for (BlackboardArtifact art : artifacts) {
828 if (assocArtifactId == art.getArtifactID()) {
829 assocArtifactIndex = artifacts.indexOf(art);
833 if (assocArtifactIndex >= 0) {
834 index = assocArtifactIndex;
839 }
catch (TskCoreException ex) {
840 logger.log(Level.WARNING,
"Couldn't get associated artifact to display in Content Viewer.", ex);
851 ViewUpdate viewUpdate =
new ViewUpdate(artifactContents.size(), index + 1, artifactContents.get(index));
859 setArtifactContents(artifactContents);
866 if (!isCancelled()) {
869 if (viewUpdate != null) {
870 updateView(viewUpdate);
872 }
catch (InterruptedException | ExecutionException ex) {
873 logger.log(Level.WARNING,
"Artifact display task unexpectedly interrupted or failed", ex);
889 this.pageIndex = pageIndex;
896 List<ResultsTableArtifact> artifactContents = getArtifactContents();
904 return new ViewUpdate(artifactContents.size(), pageIndex, artifactContent);
909 if (!isCancelled()) {
912 if (viewUpdate != null) {
913 updateView(viewUpdate);
915 }
catch (InterruptedException | ExecutionException ex) {
916 logger.log(Level.WARNING,
"Artifact display task unexpectedly interrupted or failed", ex);
929 javax.swing.JTextArea jtex =
new javax.swing.JTextArea();
930 if (value instanceof String) {
931 jtex.setText((String) value);
932 jtex.setLineWrap(
true);
933 jtex.setWrapStyleWord(
false);
937 jtex.setBackground(javax.swing.UIManager.getColor(
"Table.selectionBackground"));
939 jtex.setBackground(javax.swing.UIManager.getColor(
"Table.background"));
javax.swing.JPopupMenu rightClickMenu
void prevPageButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JScrollPane jScrollPane1
javax.swing.JLabel pageLabel
synchronized void startNewTask(SwingWorker< ViewUpdate, Void > task)
javax.swing.JPanel jPanel1
javax.swing.JLabel artifactLabel
javax.swing.JButton nextPageButton
void appendJsonElementToString(String jsonKey, JsonElement jsonElement, String startIndent, StringBuilder sb)
void setArtifactContents(List< ResultsTableArtifact > artifactList)
void nextPageButtonActionPerformed(java.awt.event.ActionEvent evt)
DataContentViewerArtifact()
List< ResultsTableArtifact > artifactTableContents
javax.swing.JScrollPane resultsTableScrollPane
String toJsonDisplayString(JsonElement element, String startIndent)
ViewUpdate doInBackground()
void updateView(ViewUpdate viewUpdate)
static TimeZone getTimeZone(Content content)
List< ResultsTableArtifact > getArtifactContents()
void setNode(Node selectedNode)
javax.swing.JMenuItem copyMenuItem
javax.swing.JLabel totalPageLabel
javax.swing.JButton prevPageButton
final String artifactDisplayName
javax.swing.JMenuItem selectAllMenuItem
Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
javax.swing.JLabel pageLabel2
javax.swing.JLabel ofLabel
DataContentViewer createInstance()
synchronized static Logger getLogger(String name)
ViewUpdate doInBackground()
boolean isSupported(Node node)
void addRows(BlackboardArtifact artifact)
int isPreferred(Node node)
void customizeComponents()
javax.swing.JLabel currentPageLabel