Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
GeneralPurposeArtifactViewer.java
Go to the documentation of this file.
1/*
2 * Autopsy
3 *
4 * Copyright 2020-2021 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.autopsy.contentviewers.artifactviewers;
20
21import java.awt.Component;
22import java.awt.Dimension;
23import java.awt.GridBagConstraints;
24import java.awt.GridBagLayout;
25import java.awt.Insets;
26import java.awt.Toolkit;
27import java.awt.datatransfer.StringSelection;
28import java.awt.event.ActionEvent;
29import java.awt.event.ActionListener;
30import java.util.ArrayList;
31import java.util.Arrays;
32import java.util.HashMap;
33import java.util.List;
34import java.util.Map;
35import java.util.Optional;
36import java.util.logging.Level;
37import javax.swing.JLabel;
38import javax.swing.JMenuItem;
39import javax.swing.JPopupMenu;
40import javax.swing.JTextPane;
41import javax.swing.SwingUtilities;
42import javax.swing.border.EmptyBorder;
43import org.apache.commons.lang.StringUtils;
44import org.openide.util.NbBundle;
45import org.openide.util.lookup.ServiceProvider;
46import org.sleuthkit.autopsy.casemodule.Case;
47import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
48import org.sleuthkit.autopsy.contentviewers.layout.ContentViewerDefaults;
49import org.sleuthkit.autopsy.coreutils.Logger;
50import org.sleuthkit.autopsy.coreutils.ThreadConfined;
51import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
52import org.sleuthkit.autopsy.discovery.ui.AbstractArtifactDetailsPanel;
53import org.sleuthkit.datamodel.BlackboardArtifact;
54import org.sleuthkit.datamodel.BlackboardAttribute;
55import org.sleuthkit.datamodel.DataSource;
56import org.sleuthkit.datamodel.TskCoreException;
57
61@ServiceProvider(service = ArtifactContentViewer.class)
63
64 private static final long serialVersionUID = 1L;
65 private static final Logger logger = Logger.getLogger(GeneralPurposeArtifactViewer.class.getName());
66 // Number of columns in the gridbag layout.
67 private final static int MAX_COLS = 4;
68 private final static Insets ZERO_INSETS = new java.awt.Insets(0, 0, 0, 0);
69
70 private final static Insets FIRST_HEADER_INSETS = ZERO_INSETS;
74
75 private final static double GLUE_WEIGHT_X = 1.0;
76 private final static double TEXT_WEIGHT_X = 0.0;
77 private final static int LABEL_COLUMN = 0;
78 private final static int VALUE_COLUMN = 1;
79 private final static int VALUE_WIDTH = 2;
80 private final static int LABEL_WIDTH = 1;
81 private static final Integer[] DEFAULT_ORDERING = new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(),
82 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
83 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
84 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
85 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_REFERRER.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(),
86 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_VALUE.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT.getTypeID(),
87 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID(),
88 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS.getTypeID()};
89 private static final List<Integer> TYPES_WITH_DATE_SECTION = Arrays.asList(new Integer[]{BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID()});
90 private final GridBagLayout gridBagLayout = new GridBagLayout();
91 private final GridBagConstraints gridBagConstraints = new GridBagConstraints();
92 private final Map<Integer, Integer[]> orderingMap = new HashMap<>();
93 private final javax.swing.JPanel detailsPanel = new javax.swing.JPanel();
94
100 addOrderings();
102 gridBagConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
103 detailsPanel.setLayout(gridBagLayout);
104 detailsPanel.setBorder(new EmptyBorder(ContentViewerDefaults.getPanelInsets()));
105 }
106
111 private void addOrderings() {
112 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(),
113 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE.getTypeID(),
114 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
115 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
116 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
117 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
118 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(),
119 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
120 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
121 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
122 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID(),
123 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
124 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(),
125 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
126 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
127 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
128 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID(),
129 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
130 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_SEARCH_QUERY.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT.getTypeID(),
131 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
132 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
133 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(),
134 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
135 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE.getTypeID(),
136 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_USER_NAME.getTypeID(),
137 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
138 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID(),
139 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
140 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_REFERRER.getTypeID(),
141 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
142 orderingMap.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID(), new Integer[]{BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN.getTypeID(),
143 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL.getTypeID(),
144 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(),
145 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_VALUE.getTypeID(),
146 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID()});
147 }
148
150 @NbBundle.Messages({"GeneralPurposeArtifactViewer.unknown.text=Unknown"})
151 @Override
152 public void setArtifact(BlackboardArtifact artifact) {
154 if (artifact != null) {
155 String dataSourceName = Bundle.GeneralPurposeArtifactViewer_unknown_text();
156 String hostName = Bundle.GeneralPurposeArtifactViewer_unknown_text();
157 String sourceFileName = Bundle.GeneralPurposeArtifactViewer_unknown_text();
158 Map<Integer, List<BlackboardAttribute>> attributeMap = new HashMap<>();
159 try {
160 // Get all the attributes and group them by the attributeType
161 for (BlackboardAttribute bba : artifact.getAttributes()) {
162 List<BlackboardAttribute> attrList = attributeMap.get(bba.getAttributeType().getTypeID());
163 if (attrList == null) {
164 attrList = new ArrayList<>();
165 }
166 attrList.add(bba);
167 attributeMap.put(bba.getAttributeType().getTypeID(), attrList);
168 }
169 dataSourceName = artifact.getDataSource().getName();
170
171 hostName = Optional.ofNullable(Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().getHostByDataSource((DataSource) artifact.getDataSource()))
172 .map(h -> h.getName())
173 .orElse(null);
174
175 sourceFileName = artifact.getParent().getUniquePath();
176 } catch (NoCurrentCaseException | TskCoreException ex) {
177 logger.log(Level.WARNING, "Unable to get attributes for artifact " + artifact.getArtifactID(), ex);
178 }
179 updateView(artifact, attributeMap, dataSourceName, hostName, sourceFileName);
180 }
181 detailsScrollPane.setViewportView(detailsPanel);
182 detailsScrollPane.revalidate();
183 revalidate();
184 }
185
190 private void resetComponent() {
191 // clear the panel
192 detailsPanel.removeAll();
193 detailsPanel.setLayout(gridBagLayout);
194 detailsPanel.revalidate();
195 gridBagConstraints.gridy = 0;
196 gridBagConstraints.gridx = LABEL_COLUMN;
197 gridBagConstraints.weighty = 0.0;
198 gridBagConstraints.weightx = TEXT_WEIGHT_X; // keep components fixed horizontally.
199 gridBagConstraints.fill = GridBagConstraints.NONE;
200 gridBagConstraints.insets = ZERO_INSETS;
201 }
202
204 @Override
205 public boolean isSupported(BlackboardArtifact artifact) {
206 return (artifact != null)
207 && (artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY.getTypeID()
208 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_SEARCH_QUERY.getTypeID()
209 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID()
210 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID()
211 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID()
212 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID()
213 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_ACCOUNT_TYPE.getTypeID()
214 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS.getTypeID()
215 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_AUTOFILL.getTypeID());
216 }
217
218 @NbBundle.Messages({"GeneralPurposeArtifactViewer.details.attrHeader=Details",
219 "GeneralPurposeArtifactViewer.details.sourceHeader=Source",
220 "GeneralPurposeArtifactViewer.details.dataSource=Data Source",
221 "GeneralPurposeArtifactViewer_details_host=Host",
222 "GeneralPurposeArtifactViewer.details.file=File",
223 "GeneralPurposeArtifactViewer.details.datesHeader=Dates"})
229 @SuppressWarnings("unchecked")
230 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
231 private void initComponents() {
232
233 detailsScrollPane = new javax.swing.JScrollPane();
234
235 detailsScrollPane.setPreferredSize(new java.awt.Dimension(300, 0));
236
237 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
238 this.setLayout(layout);
239 layout.setHorizontalGroup(
240 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241 .addComponent(detailsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
242 );
243 layout.setVerticalGroup(
244 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245 .addGroup(layout.createSequentialGroup()
246 .addComponent(detailsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
247 .addGap(0, 0, 0))
248 );
249 }// </editor-fold>//GEN-END:initComponents
250
262 @NbBundle.Messages({"GeneralPurposeArtifactViewer.dates.created=Created",
263 "GeneralPurposeArtifactViewer.dates.start=Start",
264 "GeneralPurposeArtifactViewer.dates.end=End",
265 "GeneralPurposeArtifactViewer.dates.time=Time",
266 "GeneralPurposeArtifactViewer.term.label=Term",
267 "GeneralPurposeArtifactViewer.details.otherHeader=Other",
268 "GeneralPurposeArtifactViewer.noFile.text= (no longer exists)"})
270 private void updateView(BlackboardArtifact artifact, Map<Integer, List<BlackboardAttribute>> attributeMap, String dataSourceName, String hostName, String sourceFilePath) {
271 final Integer artifactTypeId = artifact.getArtifactTypeID();
272 if (!(artifactTypeId < 1 || artifactTypeId >= Integer.MAX_VALUE)) {
273 JTextPane firstTextPane = addDetailsHeader(artifactTypeId);
274 Integer[] orderingArray = orderingMap.get(artifactTypeId);
275 if (orderingArray == null) {
276 orderingArray = DEFAULT_ORDERING;
277 }
278 for (Integer attrId : orderingArray) {
279 List<BlackboardAttribute> attrList = attributeMap.remove(attrId);
280 if (attrList != null) {
281 for (BlackboardAttribute bba : attrList) {
282 if (bba.getAttributeType().getTypeName().startsWith("TSK_DATETIME")) {
283 if (artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_SEARCH_QUERY.getTypeID()) {
284 addNameValueRow(Bundle.GeneralPurposeArtifactViewer_dates_time(), TimeZoneUtils.getFormattedTime(bba.getValueLong()));
285 } else {
286 addNameValueRow(bba.getAttributeType().getDisplayName(), TimeZoneUtils.getFormattedTime(bba.getValueLong()));
287 }
288 } else if (bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT.getTypeID() && artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_SEARCH_QUERY.getTypeID()) {
289 addNameValueRow(Bundle.GeneralPurposeArtifactViewer_term_label(), bba.getDisplayString());
290 } else if (bba.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH.getTypeID()) {
291 String displayString = bba.getDisplayString();
292 if (!attributeMap.containsKey(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID())) {
293 displayString += Bundle.GeneralPurposeArtifactViewer_noFile_text();
294 }
295 addNameValueRow(bba.getAttributeType().getDisplayName(), displayString);
296 } else {
297 addNameValueRow(bba.getAttributeType().getDisplayName(), bba.getDisplayString());
298 }
299 }
300 }
301 }
302 if (TYPES_WITH_DATE_SECTION.contains(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID())) {
303 boolean headerAdded = false;
304 headerAdded = addDates(Bundle.GeneralPurposeArtifactViewer_dates_created(), attributeMap.remove(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID()), headerAdded);
305 headerAdded = addDates(Bundle.GeneralPurposeArtifactViewer_dates_start(), attributeMap.remove(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID()), headerAdded);
306 headerAdded = addDates(Bundle.GeneralPurposeArtifactViewer_dates_end(), attributeMap.remove(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID()), headerAdded);
307 addDates(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getDisplayName(), attributeMap.remove(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID()), headerAdded);
308 }
309 if (!attributeMap.keySet().isEmpty()) {
310 addHeader(Bundle.GeneralPurposeArtifactViewer_details_otherHeader());
311 for (int key : attributeMap.keySet()) {
312 for (BlackboardAttribute bba : attributeMap.get(key)) {
313 if (bba.getAttributeType().getTypeName().startsWith("TSK_DATETIME")) {
314 addNameValueRow(bba.getAttributeType().getDisplayName(), TimeZoneUtils.getFormattedTime(bba.getValueLong()));
315 } else {
316 addNameValueRow(bba.getAttributeType().getDisplayName(), bba.getDisplayString());
317 }
318 }
319 }
320 }
321 addHeader(Bundle.GeneralPurposeArtifactViewer_details_sourceHeader());
322 addNameValueRow(Bundle.GeneralPurposeArtifactViewer_details_host(), StringUtils.defaultString(hostName));
323 addNameValueRow(Bundle.GeneralPurposeArtifactViewer_details_dataSource(), dataSourceName);
324 addNameValueRow(Bundle.GeneralPurposeArtifactViewer_details_file(), sourceFilePath);
325 // add veritcal glue at the end
327 if (firstTextPane != null) {
328 firstTextPane.setCaretPosition(0);
329 }
330 }
331 detailsPanel.revalidate();
332 }
333
344 private boolean addDates(String label, List<BlackboardAttribute> attrList, boolean headerExists) {
345 boolean headerAdded = headerExists;
346 if (attrList != null) {
347 if (!headerAdded) {
348 addHeader(Bundle.GeneralPurposeArtifactViewer_details_datesHeader());
349 headerAdded = true;
350 }
351 String labelToUse = label;
352 for (BlackboardAttribute bba : attrList) {
353 if (StringUtils.isBlank(label)) {
354 labelToUse = bba.getAttributeType().getDisplayName();
355 }
356 addNameValueRow(labelToUse, bba.getDisplayString());
357 }
358 }
359 return headerAdded;
360 }
361
367 @NbBundle.Messages({"GeneralPurposeArtifactViewer.details.bookmarkHeader=Bookmark Details",
368 "GeneralPurposeArtifactViewer.details.historyHeader=Visit Details",
369 "GeneralPurposeArtifactViewer.details.downloadHeader=Downloaded File",
370 "GeneralPurposeArtifactViewer.details.searchHeader=Web Search",
371 "GeneralPurposeArtifactViewer.details.cachedHeader=Cached File",
372 "GeneralPurposeArtifactViewer.details.cookieHeader=Cookie Details",})
373 private JTextPane addDetailsHeader(int artifactTypeId) {
374 String header;
375 if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY.getTypeID()) {
376 header = Bundle.GeneralPurposeArtifactViewer_details_historyHeader();
377 } else if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID()) {
378 header = Bundle.GeneralPurposeArtifactViewer_details_bookmarkHeader();
379 } else if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID()) {
380 header = Bundle.GeneralPurposeArtifactViewer_details_cachedHeader();
381 } else if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID()) {
382 header = Bundle.GeneralPurposeArtifactViewer_details_cookieHeader();
383 } else if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID()) {
384 header = Bundle.GeneralPurposeArtifactViewer_details_downloadHeader();
385 } else if (artifactTypeId == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_SEARCH_QUERY.getTypeID()) {
386 header = Bundle.GeneralPurposeArtifactViewer_details_searchHeader();
387 } else {
388 header = Bundle.GeneralPurposeArtifactViewer_details_attrHeader();
389 }
390 return addHeader(header);
391 }
392
401 private JTextPane addHeader(String headerString) {
402 // create label for heading
403 javax.swing.JTextPane headingLabel = new javax.swing.JTextPane();
404 headingLabel.setOpaque(false);
405 headingLabel.setFocusable(false);
406 headingLabel.setEditable(false);
407 // add a blank line before the start of new section, unless it's
408 // the first section
409 gridBagConstraints.insets = (gridBagConstraints.gridy == 0)
412
413 gridBagConstraints.gridy++;
414 gridBagConstraints.gridx = LABEL_COLUMN;;
415 // let the header span all of the row
416 gridBagConstraints.gridwidth = MAX_COLS;
417 // set text
418 headingLabel.setText(headerString);
419 // make it large and bold
420 headingLabel.setFont(ContentViewerDefaults.getHeaderFont());
421 headingLabel.setMargin(ZERO_INSETS);
422 // add to panel
423 addToPanel(headingLabel);
424 // reset constraints to normal
425 gridBagConstraints.gridwidth = LABEL_WIDTH;
426 // add line end glue
428 gridBagConstraints.insets = ZERO_INSETS;
429 return headingLabel;
430 }
431
439 private JTextPane addNameValueRow(String keyString, String valueString) {
440 addKeyAtCol(keyString);
441 return addValueAtCol(valueString);
442 }
443
448 private void addLineEndGlue() {
449 // Place the filler just past the last column.
450 gridBagConstraints.gridx = MAX_COLS;
451 gridBagConstraints.weightx = GLUE_WEIGHT_X; // take up all the horizontal space
452 gridBagConstraints.fill = GridBagConstraints.BOTH;
453 javax.swing.Box.Filler horizontalFiller = new javax.swing.Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(32767, 0));
454 // add to panel
455 addToPanel(horizontalFiller);
456 // restore fill & weight
457 gridBagConstraints.fill = GridBagConstraints.NONE;
458 gridBagConstraints.weightx = TEXT_WEIGHT_X;
459 }
460
465 private void addPageEndGlue() {
466 gridBagConstraints.weighty = 1.0; // take up all the vertical space
467 gridBagConstraints.fill = GridBagConstraints.VERTICAL;
468 javax.swing.Box.Filler vertFiller = new javax.swing.Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(0, 32767));
469 // add to panel
470 addToPanel(vertFiller);
471 }
472
480 private JLabel addKeyAtCol(String keyString) {
481 // create label
482 javax.swing.JLabel keyLabel = new javax.swing.JLabel();
483 keyLabel.setFocusable(false);
484 gridBagConstraints.gridy++;
485 gridBagConstraints.insets = KEY_COLUMN_INSETS;
486 gridBagConstraints.gridx = LABEL_COLUMN;
487 gridBagConstraints.gridwidth = LABEL_WIDTH;
488 // set text
489 keyLabel.setText(keyString + ": ");
490 // add to panel
491 addToPanel(keyLabel);
492 return keyLabel;
493 }
494
495 private void addToPanel(Component comp) {
497 detailsPanel.revalidate();
498 }
499
507 private JTextPane addValueAtCol(String valueString) {
508 // create label,
509 JTextPane valueField = new JTextPane();
510 valueField.setFocusable(false);
511 valueField.setEditable(false);
512 valueField.setOpaque(false);
513 valueField.setMargin(ZERO_INSETS);
514 gridBagConstraints.gridx = VALUE_COLUMN;
515 gridBagConstraints.insets = VALUE_COLUMN_INSETS;
516 GridBagConstraints cloneConstraints = (GridBagConstraints) gridBagConstraints.clone();
517 // let the value span 2 cols
518 cloneConstraints.gridwidth = VALUE_WIDTH;
519 cloneConstraints.fill = GridBagConstraints.BOTH;
520 // set text
521 valueField.setText(valueString);
522 // attach a right click menu with Copy option
523 valueField.addMouseListener(new java.awt.event.MouseAdapter() {
524 @Override
525 public void mouseClicked(java.awt.event.MouseEvent evt) {
526 valueLabelMouseClicked(evt, valueField);
527 }
528 });
529 // add label to panel with cloned contraintsF
530 detailsPanel.add(valueField, cloneConstraints);
531 revalidate();
532 // end the line
533 addLineEndGlue();
534 return valueField;
535 }
536
544 @NbBundle.Messages({
545 "GeneralPurposeArtifactViewer_menuitem_copy=Copy"
546 })
547 private void valueLabelMouseClicked(java.awt.event.MouseEvent evt, JTextPane valueLabel) {
548 if (SwingUtilities.isRightMouseButton(evt)) {
549 JPopupMenu popup = new JPopupMenu();
550 JMenuItem copyMenu = new JMenuItem(Bundle.CommunicationArtifactViewerHelper_menuitem_copy()); // NON-NLS
551 copyMenu.addActionListener(new ActionListener() {
552 @Override
553 public void actionPerformed(ActionEvent e) {
554 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(valueLabel.getText()), null);
555 }
556 });
557 popup.add(copyMenu);
558 popup.show(valueLabel, evt.getX(), evt.getY());
559 }
560 }
561
562
563 // Variables declaration - do not modify//GEN-BEGIN:variables
564 private javax.swing.JScrollPane detailsScrollPane;
565 // End of variables declaration//GEN-END:variables
566}
void updateView(BlackboardArtifact artifact, Map< Integer, List< BlackboardAttribute > > attributeMap, String dataSourceName, String hostName, String sourceFilePath)
boolean addDates(String label, List< BlackboardAttribute > attrList, boolean headerExists)
synchronized static Logger getLogger(String name)
Definition Logger.java:124
static String getFormattedTime(long epochTime)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.