1 /*
 2  * Autopsy Forensic Browser
 3  *
 4  * Copyright 2013-2014 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  */
 19  package org.sleuthkit.autopsy.contentviewers;
 
 20 
 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;
 
 32 
 40 
 45  initComponents();
 46  customizeComponents();
 47  }
 48 
 54  @SuppressWarnings("unchecked")
 55  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 56   private 
void initComponents() {
 
 57 
 58  jPopupMenu1 = new javax.swing.JPopupMenu();
 59  jScrollPane2 = new javax.swing.JScrollPane();
 60  jTextPane1 = new javax.swing.JTextPane();
 61 
 62  jTextPane1.setEditable(false);
 63  jScrollPane2.setViewportView(jTextPane1);
 64 
 65  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
 66  this.setLayout(layout);
 67  layout.setHorizontalGroup(
 68  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 69  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
 70  );
 71  layout.setVerticalGroup(
 72  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 73  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
 74  );
 75  }// </editor-fold>//GEN-END:initComponents
 76  // Variables declaration - do not modify//GEN-BEGIN:variables
 80  // End of variables declaration//GEN-END:variables
 81 
 83  /*
 84  * jTextPane1.setComponentPopupMenu(rightClickMenu); ActionListener
 85  * actList = new ActionListener(){ @Override public void
 86  * actionPerformed(ActionEvent e){ JMenuItem jmi = (JMenuItem)
 87  * e.getSource(); if(jmi.equals(copyMenuItem)) outputViewPane.copy();
 88  * else if(jmi.equals(selectAllMenuItem)) outputViewPane.selectAll(); }
 89  * }; copyMenuItem.addActionListener(actList);
 90  * selectAllMenuItem.addActionListener(actList);
 91  */
 92 
 94  }
 95 
 97  jTextPane1.setText("<html><body>" + str + "</body></html>"); //NON-NLS
 98  }
 99 
 101  sb.append("<table>"); //NON-NLS
 102  }
 103 
 105  sb.append("</table>"); //NON-NLS
 106  }
 107 
 108   private void addRow(StringBuilder sb, String key, String value) {
 
 109  sb.append("<tr><td>"); //NON-NLS
 110  sb.append(key);
 111  sb.append("</td><td>"); //NON-NLS
 112  sb.append(value);
 113  sb.append("</td></tr>"); //NON-NLS
 114  }
 115 
 116  @Messages({"Metadata.tableRowTitle.mimeType=MIME Type"})
 117  @Override
 120  if (file == null) {
 121  setText(NbBundle.getMessage(this.getClass(), "Metadata.nodeText.nonFilePassedIn"));
 122  return;
 123  }
 124 
 125  StringBuilder sb = new StringBuilder();
 126  startTable(sb);
 127 
 128  try {
 129  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.name"), file.
getUniquePath());
 
 131  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.name"), file.
getParentPath() + 
"/" + file.
getName());
 
 132  }
 133 
 134  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.type"), file.
getType().getName());
 
 135  addRow(sb, Bundle.Metadata_tableRowTitle_mimeType(), file.
getMIMEType());
 
 136  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.size"), Long.toString(file.
getSize()));
 
 137  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.fileNameAlloc"), file.
getDirFlagAsString());
 
 138  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.metadataAlloc"), file.
getMetaFlagsAsString());
 
 143  
 144 
 146  if (md5 == null) {
 147  md5 = NbBundle.getMessage(this.getClass(), "Metadata.tableRowContent.md5notCalc");
 148  }
 149  addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.md5"), md5);
 150  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.hashLookupResults"), file.
getKnown().toString());
 
 151 
 152  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.internalid"), Long.toString(file.
getId()));
 
 154  addRow(sb, NbBundle.getMessage(
this.getClass(), 
"Metadata.tableRowTitle.localPath"), file.
getLocalAbsPath());
 
 155  }
 156 
 157  endTable(sb);
 158 
 159  /*
 160  * If we have a file system file, grab the more detailed metadata text
 161  * too
 162  */
 163  try {
 165  FsContent fsFile = (FsContent) file;
 166 
 167  sb.append("<hr /><pre>\n"); //NON-NLS
 168  sb.append(NbBundle.getMessage(this.getClass(), "Metadata.nodeText.text"));
 169  sb.append(" <br /><br />"); // NON-NLS
 171  sb.append(str).append("<br />"); //NON-NLS
 172  }
 173  sb.append("</pre>\n"); //NON-NLS
 174  }
 176  sb.append(NbBundle.getMessage(this.getClass(), "Metadata.nodeText.exceptionNotice.text")).append(ex.getLocalizedMessage());
 177  }
 178 
 179  setText(sb.toString());
 180  jTextPane1.setCaretPosition(0);
 181  this.setCursor(null);
 182  }
 183 
 184  @Override
 186  return NbBundle.getMessage(this.getClass(), "Metadata.title");
 187  }
 188 
 189  @Override
 191  return NbBundle.getMessage(this.getClass(), "Metadata.toolTip");
 192  }
 193 
 194  @Override
 197  }
 198 
 199  @Override
 201  return this;
 202  }
 203 
 204  @Override
 206  return;
 207  }
 208 
 209  @Override
 212  return file != null;
 213  }
 214 
 215  @Override
 217  return 1;
 218  }
 219 }
void endTable(StringBuilder sb)
static String getStringTime(long epochSeconds, TimeZone tzone)
String getMetaFlagsAsString()
void addRow(StringBuilder sb, String key, String value)
synchronized List< String > getMetaDataText()
TskData.TSK_DB_FILES_TYPE_ENUM getType()
String getDirFlagAsString()
javax.swing.JTextPane jTextPane1
synchronized String getUniquePath()
javax.swing.JPopupMenu jPopupMenu1
void customizeComponents()
TskData.FileKnown getKnown()
static void configureTextPaneAsHtml(JTextPane pane)
boolean isSupported(Node node)
DataContentViewer createInstance()
int isPreferred(Node node)
javax.swing.JScrollPane jScrollPane2
void startTable(StringBuilder sb)