19 package org.sleuthkit.autopsy.ingest;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import javax.swing.JMenuItem;
25 import javax.swing.text.html.HTMLEditorKit;
26 import javax.swing.text.html.StyleSheet;
33 import org.
sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
39 class IngestMessageDetailsPanel
extends javax.swing.JPanel {
41 private final IngestMessageMainPanel mainPanel;
42 private final DirectoryTreeTopComponent dtc = DirectoryTreeTopComponent.findInstance();
47 IngestMessageDetailsPanel(IngestMessageMainPanel mainPanel) {
48 this.mainPanel = mainPanel;
50 customizeComponents();
53 private void customizeComponents() {
54 messageDetailsPane.setContentType(
"text/html");
55 viewArtifactButton.setEnabled(
false);
56 viewContentButton.setEnabled(
false);
57 HTMLEditorKit kit =
new HTMLEditorKit();
58 messageDetailsPane.setEditorKit(kit);
59 StyleSheet styleSheet = kit.getStyleSheet();
64 styleSheet.addRule(
"body {font-family:Arial;font-size:10pt;}");
65 styleSheet.addRule(
"p {font-family:Arial;font-size:10pt;}");
66 styleSheet.addRule(
"li {font-family:Arial;font-size:10pt;}");
67 styleSheet.addRule(
"table {table-layout:fixed;}");
68 styleSheet.addRule(
"td {white-space:pre-wrap;overflow:hidden;}");
69 styleSheet.addRule(
"th {font-weight:bold;}");
72 messageDetailsPane.setComponentPopupMenu(rightClickMenu);
73 ActionListener actList =
new ActionListener() {
75 public void actionPerformed(ActionEvent e) {
76 JMenuItem jmi = (JMenuItem) e.getSource();
77 if (jmi.equals(copyMenuItem)) {
78 messageDetailsPane.copy();
79 }
else if (jmi.equals(selectAllMenuItem)) {
80 messageDetailsPane.selectAll();
84 copyMenuItem.addActionListener(actList);
85 selectAllMenuItem.addActionListener(actList);
93 @SuppressWarnings(
"unchecked")
95 private
void initComponents() {
97 rightClickMenu =
new javax.swing.JPopupMenu();
98 copyMenuItem =
new javax.swing.JMenuItem();
99 selectAllMenuItem =
new javax.swing.JMenuItem();
100 jScrollPane1 =
new javax.swing.JScrollPane();
101 messageDetailsPane =
new javax.swing.JTextPane();
102 jToolBar1 =
new javax.swing.JToolBar();
103 backButton =
new javax.swing.JButton();
104 filler1 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0),
new java.awt.Dimension(0, 0),
new java.awt.Dimension(32767, 0));
105 viewArtifactButton =
new javax.swing.JButton();
106 viewContentButton =
new javax.swing.JButton();
108 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.copyMenuItem.text"));
109 rightClickMenu.add(copyMenuItem);
111 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.selectAllMenuItem.text"));
112 rightClickMenu.add(selectAllMenuItem);
114 messageDetailsPane.setEditable(
false);
115 messageDetailsPane.setBackground(
new java.awt.Color(221, 221, 235));
116 messageDetailsPane.setBorder(null);
117 messageDetailsPane.setContentType(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.contentType"));
118 messageDetailsPane.setFont(messageDetailsPane.getFont().deriveFont(messageDetailsPane.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
119 messageDetailsPane.setToolTipText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.toolTipText"));
120 jScrollPane1.setViewportView(messageDetailsPane);
122 jToolBar1.setFloatable(
false);
123 jToolBar1.setRollover(
true);
125 backButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back.png")));
126 backButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.backButton.text"));
127 backButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
128 backButton.setMargin(
new java.awt.Insets(2, 2, 2, 2));
129 backButton.setMaximumSize(
new java.awt.Dimension(23, 23));
130 backButton.setMinimumSize(
new java.awt.Dimension(23, 23));
131 backButton.setPreferredSize(
new java.awt.Dimension(23, 23));
132 backButton.setPressedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
133 backButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
134 backButton.addActionListener(
new java.awt.event.ActionListener() {
135 public void actionPerformed(java.awt.event.ActionEvent evt) {
136 backButtonActionPerformed(evt);
139 jToolBar1.add(backButton);
140 jToolBar1.add(filler1);
142 viewArtifactButton.setFont(viewArtifactButton.getFont().deriveFont(viewArtifactButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
143 viewArtifactButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_res.png")));
144 viewArtifactButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewArtifactButton.text"));
145 viewArtifactButton.setIconTextGap(2);
146 viewArtifactButton.addActionListener(
new java.awt.event.ActionListener() {
147 public void actionPerformed(java.awt.event.ActionEvent evt) {
148 viewArtifactButtonActionPerformed(evt);
151 jToolBar1.add(viewArtifactButton);
153 viewContentButton.setFont(viewContentButton.getFont().deriveFont(viewContentButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
154 viewContentButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_dir.png")));
155 viewContentButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewContentButton.text"));
156 viewContentButton.setIconTextGap(2);
157 viewContentButton.addActionListener(
new java.awt.event.ActionListener() {
158 public void actionPerformed(java.awt.event.ActionEvent evt) {
159 viewContentButtonActionPerformed(evt);
162 jToolBar1.add(viewContentButton);
164 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
165 this.setLayout(layout);
166 layout.setHorizontalGroup(
167 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
168 .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
169 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
171 layout.setVerticalGroup(
172 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addGroup(layout.createSequentialGroup()
174 .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
176 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
180 private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {
181 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
182 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
183 if (messageGroup != null) {
184 BlackboardArtifact art = messageGroup.getData();
186 dtc.viewArtifactContent(art);
189 messageDetailsPane.setCursor(null);
192 private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {
193 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
194 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
195 if (messageGroup != null) {
196 BlackboardArtifact art = messageGroup.getData();
198 dtc.viewArtifact(art);
201 messageDetailsPane.setCursor(null);
204 private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
205 mainPanel.showMessages();
208 private javax.swing.JButton backButton;
209 private javax.swing.JMenuItem copyMenuItem;
210 private javax.swing.Box.Filler filler1;
211 private javax.swing.JScrollPane jScrollPane1;
212 private javax.swing.JToolBar jToolBar1;
213 private javax.swing.JTextPane messageDetailsPane;
214 private javax.swing.JPopupMenu rightClickMenu;
215 private javax.swing.JMenuItem selectAllMenuItem;
216 private javax.swing.JButton viewArtifactButton;
217 private javax.swing.JButton viewContentButton;
225 void showDetails(
int rowNumber) {
226 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
227 if (messageGroup != null) {
228 String details = messageGroup.getDetails();
229 if (details != null) {
230 StringBuilder b =
new StringBuilder();
231 if (details.startsWith(
"<html><body>") ==
false) {
232 b.append(
"<html><body>");
234 b.append(
"</body></html>");
238 this.messageDetailsPane.setText(b.toString());
240 this.messageDetailsPane.setText(
"");
243 BlackboardArtifact artifact = messageGroup.getData();;
244 if (artifact != null && messageGroup.getCount() == 1) {
245 viewArtifactButton.setEnabled(
true);
248 long objId = artifact.getObjectID();
249 AbstractFile file = null;
251 file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(objId);
252 }
catch (TskException | NoCurrentCaseException ex) {
256 viewContentButton.setEnabled(
false);
257 }
else if (!file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
258 viewContentButton.setEnabled(
false);
260 viewContentButton.setEnabled(
true);
263 viewArtifactButton.setEnabled(
false);
264 viewContentButton.setEnabled(
false);
267 viewArtifactButton.setEnabled(
false);
268 viewContentButton.setEnabled(
false);
269 messageDetailsPane.setText(
"");