19 package org.sleuthkit.autopsy.ingest;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import javax.swing.JMenuItem;
27 import javax.swing.text.html.HTMLEditorKit;
28 import javax.swing.text.html.StyleSheet;
29 import org.openide.util.Lookup;
41 class IngestMessageDetailsPanel
extends javax.swing.JPanel {
43 private IngestMessageMainPanel mainPanel;
46 IngestMessageDetailsPanel(IngestMessageMainPanel mainPanel) {
47 this.mainPanel = mainPanel;
49 customizeComponents();
52 private void customizeComponents() {
53 messageDetailsPane.setContentType(
"text/html");
54 viewArtifactButton.setEnabled(
false);
55 viewContentButton.setEnabled(
false);
56 HTMLEditorKit kit =
new HTMLEditorKit();
57 messageDetailsPane.setEditorKit(kit);
58 StyleSheet styleSheet = kit.getStyleSheet();
61 styleSheet.addRule(
"body {font-family:Arial;font-size:10pt;}");
62 styleSheet.addRule(
"p {font-family:Arial;font-size:10pt;}");
63 styleSheet.addRule(
"li {font-family:Arial;font-size:10pt;}");
64 styleSheet.addRule(
"table {table-layout:fixed;}");
65 styleSheet.addRule(
"td {white-space:pre-wrap;overflow:hidden;}");
66 styleSheet.addRule(
"th {font-weight:bold;}");
68 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
69 v.addOnFinishedListener(
new PropertyChangeListener() {
72 public void propertyChange(PropertyChangeEvent evt) {
73 if (evt.getPropertyName().equals(BlackboardResultViewer.FINISHED_DISPLAY_EVT)) {
74 artifactViewerFinished();
82 messageDetailsPane.setComponentPopupMenu(rightClickMenu);
83 ActionListener actList =
new ActionListener(){
85 public void actionPerformed(ActionEvent e){
86 JMenuItem jmi = (JMenuItem) e.getSource();
87 if(jmi.equals(copyMenuItem))
88 messageDetailsPane.copy();
89 else if(jmi.equals(selectAllMenuItem))
90 messageDetailsPane.selectAll();
93 copyMenuItem.addActionListener(actList);
94 selectAllMenuItem.addActionListener(actList);
102 @SuppressWarnings(
"unchecked")
104 private
void initComponents() {
106 rightClickMenu =
new javax.swing.JPopupMenu();
107 copyMenuItem =
new javax.swing.JMenuItem();
108 selectAllMenuItem =
new javax.swing.JMenuItem();
109 jScrollPane1 =
new javax.swing.JScrollPane();
110 messageDetailsPane =
new javax.swing.JTextPane();
111 jToolBar1 =
new javax.swing.JToolBar();
112 backButton =
new javax.swing.JButton();
113 filler1 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0),
new java.awt.Dimension(0, 0),
new java.awt.Dimension(32767, 0));
114 viewArtifactButton =
new javax.swing.JButton();
115 viewContentButton =
new javax.swing.JButton();
117 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.copyMenuItem.text"));
118 rightClickMenu.add(copyMenuItem);
120 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.selectAllMenuItem.text"));
121 rightClickMenu.add(selectAllMenuItem);
123 messageDetailsPane.setEditable(
false);
124 messageDetailsPane.setBackground(
new java.awt.Color(221, 221, 235));
125 messageDetailsPane.setBorder(null);
126 messageDetailsPane.setContentType(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
127 "IngestMessageDetailsPanel.messageDetailsPane.contentType"));
128 messageDetailsPane.setFont(messageDetailsPane.getFont().deriveFont(Font.PLAIN, 10));
129 messageDetailsPane.setToolTipText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
130 "IngestMessageDetailsPanel.messageDetailsPane.toolTipText"));
131 jScrollPane1.setViewportView(messageDetailsPane);
133 jToolBar1.setFloatable(
false);
134 jToolBar1.setRollover(
true);
136 backButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back.png")));
137 backButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.backButton.text"));
138 backButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
139 backButton.setMargin(
new java.awt.Insets(2, 2, 2, 2));
140 backButton.setMaximumSize(
new java.awt.Dimension(23, 23));
141 backButton.setMinimumSize(
new java.awt.Dimension(23, 23));
142 backButton.setPreferredSize(
new java.awt.Dimension(23, 23));
143 backButton.setPressedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
144 backButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
145 backButton.addActionListener(
new java.awt.event.ActionListener() {
146 public void actionPerformed(java.awt.event.ActionEvent evt) {
147 backButtonActionPerformed(evt);
150 jToolBar1.add(backButton);
151 jToolBar1.add(filler1);
153 viewArtifactButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_res.png")));
154 viewArtifactButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewArtifactButton.text"));
155 viewArtifactButton.setIconTextGap(2);
156 viewArtifactButton.setPreferredSize(
new java.awt.Dimension(93, 23));
157 viewArtifactButton.addActionListener(
new java.awt.event.ActionListener() {
158 public void actionPerformed(java.awt.event.ActionEvent evt) {
159 viewArtifactButtonActionPerformed(evt);
162 jToolBar1.add(viewArtifactButton);
164 viewContentButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_dir.png")));
165 viewContentButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewContentButton.text"));
166 viewContentButton.setIconTextGap(2);
167 viewContentButton.setPreferredSize(
new java.awt.Dimension(111, 23));
168 viewContentButton.addActionListener(
new java.awt.event.ActionListener() {
169 public void actionPerformed(java.awt.event.ActionEvent evt) {
170 viewContentButtonActionPerformed(evt);
173 jToolBar1.add(viewContentButton);
175 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
176 this.setLayout(layout);
177 layout.setHorizontalGroup(
178 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
179 .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
180 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
182 layout.setVerticalGroup(
183 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addGroup(layout.createSequentialGroup()
185 .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
187 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
191 private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {
195 private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {
199 private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
200 mainPanel.showMessages();
203 private javax.swing.JButton backButton;
204 private javax.swing.JMenuItem copyMenuItem;
205 private javax.swing.Box.Filler filler1;
206 private javax.swing.JScrollPane jScrollPane1;
207 private javax.swing.JToolBar jToolBar1;
208 private javax.swing.JTextPane messageDetailsPane;
209 private javax.swing.JPopupMenu rightClickMenu;
210 private javax.swing.JMenuItem selectAllMenuItem;
211 private javax.swing.JButton viewArtifactButton;
212 private javax.swing.JButton viewContentButton;
215 private void viewArtifact(java.awt.event.ActionEvent evt) {
216 artifactViewerInvoked();
218 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
219 if (messageGroup != null) {
220 BlackboardArtifact art = messageGroup.getData();
222 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
229 private void viewContent(java.awt.event.ActionEvent evt) {
230 artifactViewerInvoked();
232 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
233 if (messageGroup != null) {
234 BlackboardArtifact art = messageGroup.getData();
236 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
237 v.viewArtifactContent(art);
242 private void artifactViewerInvoked() {
245 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
249 private void artifactViewerFinished() {
252 messageDetailsPane.setCursor(null);
259 void showDetails(
int rowNumber) {
260 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
261 if (messageGroup != null) {
262 String details = messageGroup.getDetails();
263 if (details != null) {
264 StringBuilder b =
new StringBuilder();
265 if (details.startsWith(
"<html><body>") ==
false) {
266 b.append(
"<html><body>");
268 b.append(
"</body></html>");
273 this.messageDetailsPane.setText(b.toString());
275 this.messageDetailsPane.setText(
"");
278 BlackboardArtifact artifact = messageGroup.getData();;
279 if (artifact != null && messageGroup.getCount() == 1) {
280 viewArtifactButton.setEnabled(
true);
283 long objId = artifact.getObjectID();
284 AbstractFile file = null;
286 file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId);
287 }
catch (TskException ex) {
291 viewContentButton.setEnabled(
false);
293 else if (! file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
294 viewContentButton.setEnabled(
false);
297 viewContentButton.setEnabled(
true);
300 viewArtifactButton.setEnabled(
false);
301 viewContentButton.setEnabled(
false);
304 viewArtifactButton.setEnabled(
false);
305 viewContentButton.setEnabled(
false);
306 messageDetailsPane.setText(
"");