19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.Component;
22 import org.openide.nodes.Node;
23 import org.openide.util.NbBundle;
24 import org.openide.util.NbBundle.Messages;
25 import org.openide.util.lookup.ServiceProvider;
31 import org.
sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
38 @ServiceProvider(service = DataContentViewer.class, position = 6)
39 @SuppressWarnings(
"PMD.SingularField")
47 customizeComponents();
55 @SuppressWarnings(
"unchecked")
57 private
void initComponents() {
59 jPopupMenu1 =
new javax.swing.JPopupMenu();
60 jScrollPane2 =
new javax.swing.JScrollPane();
61 jTextPane1 =
new javax.swing.JTextPane();
63 setPreferredSize(
new java.awt.Dimension(100, 52));
65 jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
66 jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
67 jScrollPane2.setPreferredSize(
new java.awt.Dimension(610, 52));
69 jTextPane1.setEditable(
false);
70 jTextPane1.setPreferredSize(
new java.awt.Dimension(600, 52));
71 jScrollPane2.setViewportView(jTextPane1);
73 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
74 this.setLayout(layout);
75 layout.setHorizontalGroup(
76 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
77 .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
79 layout.setVerticalGroup(
80 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
81 .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
105 jTextPane1.setText(
"<html><body>" + str +
"</body></html>");
109 sb.append(
"<table>");
113 sb.append(
"</table>");
116 private void addRow(StringBuilder sb, String key, String value) {
117 sb.append(
"<tr><td>");
119 sb.append(
"</td><td>");
121 sb.append(
"</td></tr>");
125 "Metadata.tableRowTitle.mimeType=MIME Type",
126 "Metadata.nodeText.truncated=(results truncated)"})
129 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
131 setText(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.nonFilePassedIn"));
135 StringBuilder sb =
new StringBuilder();
139 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), file.getUniquePath());
140 }
catch (TskCoreException ex) {
141 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), file.getParentPath() +
"/" + file.getName());
144 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.type"), file.getType().getName());
145 addRow(sb, Bundle.Metadata_tableRowTitle_mimeType(), file.getMIMEType());
146 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.size"), Long.toString(file.getSize()));
147 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.fileNameAlloc"), file.getDirFlagAsString());
148 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.metadataAlloc"), file.getMetaFlagsAsString());
149 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.modified"),
ContentUtils.
getStringTime(file.getMtime(), file));
150 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.accessed"),
ContentUtils.
getStringTime(file.getAtime(), file));
151 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.created"),
ContentUtils.
getStringTime(file.getCrtime(), file));
152 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.changed"),
ContentUtils.
getStringTime(file.getCtime(), file));
155 String md5 = file.getMd5Hash();
157 md5 = NbBundle.getMessage(this.getClass(),
"Metadata.tableRowContent.md5notCalc");
159 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.md5"), md5);
160 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.hashLookupResults"), file.getKnown().toString());
162 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.internalid"), Long.toString(file.getId()));
163 if (file.getType().compareTo(TSK_DB_FILES_TYPE_ENUM.LOCAL) == 0) {
164 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.localPath"), file.getLocalAbsPath());
174 if (file instanceof FsContent) {
175 FsContent fsFile = (FsContent) file;
177 sb.append(
"<hr /><pre>\n");
178 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.text"));
179 sb.append(
" <br /><br />");
180 for (String str : fsFile.getMetaDataText()) {
181 sb.append(str).append(
"<br />");
187 if(sb.length() > 50000){
188 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.truncated"));
192 sb.append(
"</pre>\n");
194 }
catch (TskCoreException ex) {
195 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.exceptionNotice.text")).append(ex.getLocalizedMessage());
198 setText(sb.toString());
199 jTextPane1.setCaretPosition(0);
200 this.setCursor(null);
205 return NbBundle.getMessage(this.getClass(),
"Metadata.title");
210 return NbBundle.getMessage(this.getClass(),
"Metadata.toolTip");
230 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
void endTable(StringBuilder sb)
static String getStringTime(long epochSeconds, TimeZone tzone)
void addRow(StringBuilder sb, String key, String value)
javax.swing.JTextPane jTextPane1
javax.swing.JPopupMenu jPopupMenu1
void customizeComponents()
static void configureTextPaneAsHtml(JTextPane pane)
boolean isSupported(Node node)
DataContentViewer createInstance()
int isPreferred(Node node)
javax.swing.JScrollPane jScrollPane2
void startTable(StringBuilder sb)