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;
35 import org.
sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
41 class IngestMessageDetailsPanel
extends javax.swing.JPanel {
43 private IngestMessageMainPanel mainPanel;
48 IngestMessageDetailsPanel(IngestMessageMainPanel mainPanel) {
49 this.mainPanel = mainPanel;
51 customizeComponents();
54 private void customizeComponents() {
55 messageDetailsPane.setContentType(
"text/html");
56 viewArtifactButton.setEnabled(
false);
57 viewContentButton.setEnabled(
false);
58 HTMLEditorKit kit =
new HTMLEditorKit();
59 messageDetailsPane.setEditorKit(kit);
60 StyleSheet styleSheet = kit.getStyleSheet();
65 styleSheet.addRule(
"body {font-family:Arial;font-size:10pt;}");
66 styleSheet.addRule(
"p {font-family:Arial;font-size:10pt;}");
67 styleSheet.addRule(
"li {font-family:Arial;font-size:10pt;}");
68 styleSheet.addRule(
"table {table-layout:fixed;}");
69 styleSheet.addRule(
"td {white-space:pre-wrap;overflow:hidden;}");
70 styleSheet.addRule(
"th {font-weight:bold;}");
72 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
73 v.addOnFinishedListener(
new PropertyChangeListener() {
76 public void propertyChange(PropertyChangeEvent evt) {
77 if (evt.getPropertyName().equals(BlackboardResultViewer.FINISHED_DISPLAY_EVT)) {
78 artifactViewerFinished();
85 messageDetailsPane.setComponentPopupMenu(rightClickMenu);
86 ActionListener actList =
new ActionListener() {
88 public void actionPerformed(ActionEvent e) {
89 JMenuItem jmi = (JMenuItem) e.getSource();
90 if (jmi.equals(copyMenuItem)) {
91 messageDetailsPane.copy();
92 }
else if (jmi.equals(selectAllMenuItem)) {
93 messageDetailsPane.selectAll();
97 copyMenuItem.addActionListener(actList);
98 selectAllMenuItem.addActionListener(actList);
106 @SuppressWarnings(
"unchecked")
108 private
void initComponents() {
110 rightClickMenu =
new javax.swing.JPopupMenu();
111 copyMenuItem =
new javax.swing.JMenuItem();
112 selectAllMenuItem =
new javax.swing.JMenuItem();
113 jScrollPane1 =
new javax.swing.JScrollPane();
114 messageDetailsPane =
new javax.swing.JTextPane();
115 jToolBar1 =
new javax.swing.JToolBar();
116 backButton =
new javax.swing.JButton();
117 filler1 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0),
new java.awt.Dimension(0, 0),
new java.awt.Dimension(32767, 0));
118 viewArtifactButton =
new javax.swing.JButton();
119 viewContentButton =
new javax.swing.JButton();
121 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.copyMenuItem.text"));
122 rightClickMenu.add(copyMenuItem);
124 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.selectAllMenuItem.text"));
125 rightClickMenu.add(selectAllMenuItem);
127 messageDetailsPane.setEditable(
false);
128 messageDetailsPane.setBackground(
new java.awt.Color(221, 221, 235));
129 messageDetailsPane.setBorder(null);
130 messageDetailsPane.setContentType(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.contentType"));
131 messageDetailsPane.setFont(messageDetailsPane.getFont().deriveFont(messageDetailsPane.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
132 messageDetailsPane.setToolTipText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.toolTipText"));
133 jScrollPane1.setViewportView(messageDetailsPane);
135 jToolBar1.setFloatable(
false);
136 jToolBar1.setRollover(
true);
138 backButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back.png")));
139 backButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.backButton.text"));
140 backButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
141 backButton.setMargin(
new java.awt.Insets(2, 2, 2, 2));
142 backButton.setMaximumSize(
new java.awt.Dimension(23, 23));
143 backButton.setMinimumSize(
new java.awt.Dimension(23, 23));
144 backButton.setPreferredSize(
new java.awt.Dimension(23, 23));
145 backButton.setPressedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
146 backButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
147 backButton.addActionListener(
new java.awt.event.ActionListener() {
148 public void actionPerformed(java.awt.event.ActionEvent evt) {
149 backButtonActionPerformed(evt);
152 jToolBar1.add(backButton);
153 jToolBar1.add(filler1);
155 viewArtifactButton.setFont(viewArtifactButton.getFont().deriveFont(viewArtifactButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
156 viewArtifactButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_res.png")));
157 viewArtifactButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewArtifactButton.text"));
158 viewArtifactButton.setIconTextGap(2);
159 viewArtifactButton.setPreferredSize(
new java.awt.Dimension(93, 23));
160 viewArtifactButton.addActionListener(
new java.awt.event.ActionListener() {
161 public void actionPerformed(java.awt.event.ActionEvent evt) {
162 viewArtifactButtonActionPerformed(evt);
165 jToolBar1.add(viewArtifactButton);
167 viewContentButton.setFont(viewContentButton.getFont().deriveFont(viewContentButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
168 viewContentButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_dir.png")));
169 viewContentButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewContentButton.text"));
170 viewContentButton.setIconTextGap(2);
171 viewContentButton.setPreferredSize(
new java.awt.Dimension(111, 23));
172 viewContentButton.addActionListener(
new java.awt.event.ActionListener() {
173 public void actionPerformed(java.awt.event.ActionEvent evt) {
174 viewContentButtonActionPerformed(evt);
177 jToolBar1.add(viewContentButton);
179 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
180 this.setLayout(layout);
181 layout.setHorizontalGroup(
182 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
183 .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
184 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
186 layout.setVerticalGroup(
187 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188 .addGroup(layout.createSequentialGroup()
189 .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
191 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
195 private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {
199 private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {
203 private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
204 mainPanel.showMessages();
207 private javax.swing.JButton backButton;
208 private javax.swing.JMenuItem copyMenuItem;
209 private javax.swing.Box.Filler filler1;
210 private javax.swing.JScrollPane jScrollPane1;
211 private javax.swing.JToolBar jToolBar1;
212 private javax.swing.JTextPane messageDetailsPane;
213 private javax.swing.JPopupMenu rightClickMenu;
214 private javax.swing.JMenuItem selectAllMenuItem;
215 private javax.swing.JButton viewArtifactButton;
216 private javax.swing.JButton viewContentButton;
219 private void viewArtifact(java.awt.event.ActionEvent evt) {
220 artifactViewerInvoked();
222 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
223 if (messageGroup != null) {
224 BlackboardArtifact art = messageGroup.getData();
226 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
233 private void viewContent(java.awt.event.ActionEvent evt) {
234 artifactViewerInvoked();
236 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
237 if (messageGroup != null) {
238 BlackboardArtifact art = messageGroup.getData();
240 BlackboardResultViewer v = Lookup.getDefault().lookup(BlackboardResultViewer.class);
241 v.viewArtifactContent(art);
246 private void artifactViewerInvoked() {
249 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
253 private void artifactViewerFinished() {
256 messageDetailsPane.setCursor(null);
264 void showDetails(
int rowNumber) {
265 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
266 if (messageGroup != null) {
267 String details = messageGroup.getDetails();
268 if (details != null) {
269 StringBuilder b =
new StringBuilder();
270 if (details.startsWith(
"<html><body>") ==
false) {
271 b.append(
"<html><body>");
273 b.append(
"</body></html>");
277 this.messageDetailsPane.setText(b.toString());
279 this.messageDetailsPane.setText(
"");
282 BlackboardArtifact artifact = messageGroup.getData();;
283 if (artifact != null && messageGroup.getCount() == 1) {
284 viewArtifactButton.setEnabled(
true);
287 long objId = artifact.getObjectID();
288 AbstractFile file = null;
290 file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId);
291 }
catch (TskException ex) {
295 viewContentButton.setEnabled(
false);
296 }
else if (!file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
297 viewContentButton.setEnabled(
false);
299 viewContentButton.setEnabled(
true);
302 viewArtifactButton.setEnabled(
false);
303 viewContentButton.setEnabled(
false);
306 viewArtifactButton.setEnabled(
false);
307 viewContentButton.setEnabled(
false);
308 messageDetailsPane.setText(
"");