19 package org.sleuthkit.autopsy.ingest;
21 import java.awt.Cursor;
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 @SuppressWarnings(
"PMD.SingularField")
40 class IngestMessageDetailsPanel extends javax.swing.JPanel {
42 private final IngestMessageMainPanel mainPanel;
43 private final DirectoryTreeTopComponent dtc = DirectoryTreeTopComponent.findInstance();
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;}");
73 messageDetailsPane.setComponentPopupMenu(rightClickMenu);
74 ActionListener actList =
new ActionListener() {
76 public void actionPerformed(ActionEvent e) {
77 JMenuItem jmi = (JMenuItem) e.getSource();
78 if (jmi.equals(copyMenuItem)) {
79 messageDetailsPane.copy();
80 }
else if (jmi.equals(selectAllMenuItem)) {
81 messageDetailsPane.selectAll();
85 copyMenuItem.addActionListener(actList);
86 selectAllMenuItem.addActionListener(actList);
94 @SuppressWarnings(
"unchecked")
96 private
void initComponents() {
98 rightClickMenu =
new javax.swing.JPopupMenu();
99 copyMenuItem =
new javax.swing.JMenuItem();
100 selectAllMenuItem =
new javax.swing.JMenuItem();
101 jScrollPane1 =
new javax.swing.JScrollPane();
102 messageDetailsPane =
new javax.swing.JTextPane();
103 jToolBar1 =
new javax.swing.JToolBar();
104 backButton =
new javax.swing.JButton();
105 filler1 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0),
new java.awt.Dimension(0, 0),
new java.awt.Dimension(32767, 0));
106 viewArtifactButton =
new javax.swing.JButton();
107 viewContentButton =
new javax.swing.JButton();
109 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.copyMenuItem.text"));
110 rightClickMenu.add(copyMenuItem);
112 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.selectAllMenuItem.text"));
113 rightClickMenu.add(selectAllMenuItem);
115 messageDetailsPane.setEditable(
false);
116 messageDetailsPane.setBackground(
new java.awt.Color(221, 221, 235));
117 messageDetailsPane.setBorder(null);
118 messageDetailsPane.setContentType(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.contentType"));
119 messageDetailsPane.setFont(messageDetailsPane.getFont().deriveFont(messageDetailsPane.getFont().getSize()-1f));
120 messageDetailsPane.setToolTipText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.messageDetailsPane.toolTipText"));
121 jScrollPane1.setViewportView(messageDetailsPane);
123 jToolBar1.setFloatable(
false);
124 jToolBar1.setRollover(
true);
126 backButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back.png")));
127 backButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.backButton.text"));
128 backButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
129 backButton.setMargin(
new java.awt.Insets(2, 2, 2, 2));
130 backButton.setMaximumSize(
new java.awt.Dimension(23, 23));
131 backButton.setMinimumSize(
new java.awt.Dimension(23, 23));
132 backButton.setPreferredSize(
new java.awt.Dimension(23, 23));
133 backButton.setPressedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
134 backButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png")));
135 backButton.addActionListener(
new java.awt.event.ActionListener() {
136 public void actionPerformed(java.awt.event.ActionEvent evt) {
137 backButtonActionPerformed(evt);
140 jToolBar1.add(backButton);
141 jToolBar1.add(filler1);
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.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_dir.png")));
154 viewContentButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewContentButton.text"));
155 viewContentButton.setIconTextGap(2);
156 viewContentButton.addActionListener(
new java.awt.event.ActionListener() {
157 public void actionPerformed(java.awt.event.ActionEvent evt) {
158 viewContentButtonActionPerformed(evt);
161 jToolBar1.add(viewContentButton);
163 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
164 this.setLayout(layout);
165 layout.setHorizontalGroup(
166 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167 .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
168 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
170 layout.setVerticalGroup(
171 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
172 .addGroup(layout.createSequentialGroup()
173 .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
175 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
179 private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {
180 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
181 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
182 if (messageGroup != null) {
183 BlackboardArtifact art = messageGroup.getData();
185 dtc.viewArtifactContent(art);
188 messageDetailsPane.setCursor(null);
191 private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {
192 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
193 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
194 if (messageGroup != null) {
195 BlackboardArtifact art = messageGroup.getData();
197 dtc.viewArtifact(art);
200 messageDetailsPane.setCursor(null);
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;
224 void showDetails(
int rowNumber) {
225 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
226 if (messageGroup != null) {
227 String details = messageGroup.getDetails();
228 if (details != null) {
229 StringBuilder b =
new StringBuilder();
230 if (details.startsWith(
"<html><body>") ==
false) {
231 b.append(
"<html><body>");
233 b.append(
"</body></html>");
237 this.messageDetailsPane.setText(b.toString());
239 this.messageDetailsPane.setText(
"");
242 BlackboardArtifact artifact = messageGroup.getData();
243 if (artifact != null && messageGroup.getCount() == 1) {
244 viewArtifactButton.setEnabled(
true);
247 long objId = artifact.getObjectID();
248 AbstractFile file = null;
250 file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(objId);
251 }
catch (TskException | NoCurrentCaseException ex) {
255 viewContentButton.setEnabled(
false);
256 }
else if (!file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
257 viewContentButton.setEnabled(
false);
259 viewContentButton.setEnabled(
true);
262 viewArtifactButton.setEnabled(
false);
263 viewContentButton.setEnabled(
false);
266 viewArtifactButton.setEnabled(
false);
267 viewContentButton.setEnabled(
false);
268 messageDetailsPane.setText(
"");