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 value = epochTimeToString(attr.getValueLong());
557 String jsonVal = attr.getValueString();
558 JsonParser parser =
new JsonParser();
559 JsonObject json = parser.parse(jsonVal).getAsJsonObject();
561 value = toJsonDisplayString(json,
"");
567 String sources = StringUtils.join(attr.getSources(),
", ");
568 rowsToAdd.add(
new String[]{attr.getAttributeType().getDisplayName(), value, sources});
575 if (null != content) {
576 path = content.getUniquePath();
578 }
catch (TskCoreException ex) {
579 logger.log(Level.SEVERE, String.format(
"Error getting source content path for artifact (artifact_id=%d, obj_id=%d)", artifact.getArtifactID(), artifact.getObjectID()), ex);
580 path = Bundle.DataContentViewerArtifact_failedToGetSourcePath_message();
582 rowsToAdd.add(
new String[]{
"Source File Path", path,
""});
586 rowsToAdd.add(
new String[]{
"Artifact ID", Long.toString(artifact.getArtifactID()),
""});
587 }
catch (TskCoreException ex) {
588 rowsToAdd.add(
new String[]{
"", Bundle.DataContentViewerArtifact_failedToGetAttributes_message(),
""});
590 rowData = rowsToAdd.toArray(
new String[0][0]);
596 String getArtifactDisplayName() {
597 return artifactDisplayName;
600 private static final String INDENT_RIGHT =
" ";
601 private static final String NEW_LINE =
"\n";
614 StringBuilder sb =
new StringBuilder(
"");
615 JsonObject obj = element.getAsJsonObject();
617 for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
618 appendJsonElementToString(entry.getKey(), entry.getValue(), startIndent, sb );
621 String returnString = sb.toString();
622 if (startIndent.length() == 0 && returnString.startsWith(NEW_LINE)) {
623 returnString = returnString.substring(NEW_LINE.length());
638 if (jsonElement.isJsonArray()) {
639 JsonArray jsonArray = jsonElement.getAsJsonArray();
640 if (jsonArray.size() > 0) {
642 sb.append(NEW_LINE).append(String.format(
"%s%s", startIndent, jsonKey));
643 for (JsonElement arrayMember : jsonArray) {
644 sb.append(NEW_LINE).append(String.format(
"%s%d", startIndent.concat(INDENT_RIGHT), count));
645 sb.append(toJsonDisplayString(arrayMember, startIndent.concat(INDENT_RIGHT).concat(INDENT_RIGHT)));
649 }
else if (jsonElement.isJsonObject()) {
650 sb.append(NEW_LINE).append(String.format(
"%s%s %s", startIndent, jsonKey, toJsonDisplayString(jsonElement.getAsJsonObject(), startIndent + INDENT_RIGHT)));
651 }
else if (jsonElement.isJsonPrimitive()) {
652 String attributeName = jsonKey;
653 String attributeValue;
654 if (attributeName.toUpperCase().contains(
"DATETIME")) {
655 attributeValue = epochTimeToString(Long.parseLong(jsonElement.getAsString()));
657 attributeValue = jsonElement.getAsString();
659 sb.append(NEW_LINE).append(String.format(
"%s%s = %s", startIndent, attributeName, attributeValue));
660 }
else if (jsonElement.isJsonNull()) {
661 sb.append(NEW_LINE).append(String.format(
"%s%s = null", startIndent, jsonKey));
672 String dateTimeString =
"0000-00-00 00:00:00";
673 if (null != content && 0 != epochTime) {
675 dateTimeString = dateFormatter.format(
new java.util.Date(epochTime * 1000));
677 return dateTimeString;
693 this.currentPage = currentPage;
694 this.numberOfPages = numberOfPages;
695 this.tableContents = contents;
698 ViewUpdate(
int numberOfPages,
int currentPage, String errorMsg) {
699 this.currentPage = currentPage;
700 this.numberOfPages = numberOfPages;
713 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
715 nextPageButton.setEnabled(viewUpdate.currentPage < viewUpdate.numberOfPages);
716 prevPageButton.setEnabled(viewUpdate.currentPage > 1);
717 currentPage = viewUpdate.currentPage;
718 totalPageLabel.setText(Integer.toString(viewUpdate.numberOfPages));
719 currentPageLabel.setText(Integer.toString(currentPage));
720 artifactLabel.setText(viewUpdate.tableContents.getArtifactDisplayName());
721 DefaultTableModel tModel = ((DefaultTableModel) resultsTable.getModel());
722 tModel.setDataVector(viewUpdate.tableContents.
getRows(), COLUMN_HEADERS);
725 resultsTable.clearSelection();
727 this.setCursor(null);
736 private synchronized void startNewTask(SwingWorker<ViewUpdate, Void> task) {
737 String[][] waitRow =
new String[1][3];
738 waitRow[0] =
new String[]{
"", WAIT_TEXT,
""};
739 DefaultTableModel tModel = ((DefaultTableModel) resultsTable.getModel());
740 tModel.setDataVector(waitRow, COLUMN_HEADERS);
743 resultsTable.clearSelection();
745 if (currentTask != null) {
748 currentTask.cancel(
false);
753 currentTask.execute();
763 synchronized (lock) {
764 this.artifactTableContents = artifactList;
774 synchronized (lock) {
775 return artifactTableContents;
789 this.selectedNode = selectedNode;
796 Lookup lookup = selectedNode.getLookup();
799 ArrayList<BlackboardArtifact> artifacts =
new ArrayList<>();
800 Collection<? extends Content> contents = lookup.lookupAll(Content.class);
801 if (contents.isEmpty()) {
802 return new ViewUpdate(getArtifactContents().size(), currentPage, ERROR_TEXT);
804 Content underlyingContent = null;
805 for (Content content : contents) {
806 if ( (content != null) && (!(content instanceof BlackboardArtifact)) ) {
810 artifacts = content.getAllArtifacts();
811 underlyingContent = content;
813 }
catch (TskException ex) {
814 logger.log(Level.SEVERE,
"Couldn't get artifacts", ex);
815 return new ViewUpdate(getArtifactContents().size(), currentPage, ERROR_TEXT);
825 ArrayList<ResultsTableArtifact> artifactContents =
new ArrayList<>();
826 for (BlackboardArtifact artifact : artifacts) {
833 BlackboardArtifact artifact = lookup.lookup(BlackboardArtifact.class);
834 if (artifact != null) {
835 index = artifacts.indexOf(artifact);
841 for (BlackboardAttribute attr : artifact.getAttributes()) {
842 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
843 long assocArtifactId = attr.getValueLong();
844 int assocArtifactIndex = -1;
845 for (BlackboardArtifact art : artifacts) {
846 if (assocArtifactId == art.getArtifactID()) {
847 assocArtifactIndex = artifacts.indexOf(art);
851 if (assocArtifactIndex >= 0) {
852 index = assocArtifactIndex;
857 }
catch (TskCoreException ex) {
858 logger.log(Level.WARNING,
"Couldn't get associated artifact to display in Content Viewer.", ex);
869 ViewUpdate viewUpdate =
new ViewUpdate(artifactContents.size(), index + 1, artifactContents.get(index));
877 setArtifactContents(artifactContents);
884 if (!isCancelled()) {
887 if (viewUpdate != null) {
888 updateView(viewUpdate);
890 }
catch (InterruptedException | ExecutionException ex) {
891 logger.log(Level.WARNING,
"Artifact display task unexpectedly interrupted or failed", ex);
907 this.pageIndex = pageIndex;
914 List<ResultsTableArtifact> artifactContents = getArtifactContents();
922 return new ViewUpdate(artifactContents.size(), pageIndex, artifactContent);
927 if (!isCancelled()) {
930 if (viewUpdate != null) {
931 updateView(viewUpdate);
933 }
catch (InterruptedException | ExecutionException ex) {
934 logger.log(Level.WARNING,
"Artifact display task unexpectedly interrupted or failed", ex);
947 javax.swing.JTextArea jtex =
new javax.swing.JTextArea();
948 if (value instanceof String) {
949 jtex.setText((String) value);
950 jtex.setLineWrap(
true);
951 jtex.setWrapStyleWord(
false);
955 jtex.setBackground(javax.swing.UIManager.getColor(
"Table.selectionBackground"));
957 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)
String epochTimeToString(long epochTime)
ViewUpdate doInBackground()
boolean isSupported(Node node)
void addRows(BlackboardArtifact artifact)
int isPreferred(Node node)
void customizeComponents()
javax.swing.JLabel currentPageLabel