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().getStyle() & ~java.awt.Font.BOLD, 10));
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.setFont(viewArtifactButton.getFont().deriveFont(viewArtifactButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
144 viewArtifactButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_res.png")));
145 viewArtifactButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewArtifactButton.text"));
146 viewArtifactButton.setIconTextGap(2);
147 viewArtifactButton.addActionListener(
new java.awt.event.ActionListener() {
148 public void actionPerformed(java.awt.event.ActionEvent evt) {
149 viewArtifactButtonActionPerformed(evt);
152 jToolBar1.add(viewArtifactButton);
154 viewContentButton.setFont(viewContentButton.getFont().deriveFont(viewContentButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
155 viewContentButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/goto_dir.png")));
156 viewContentButton.setText(
org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class,
"IngestMessageDetailsPanel.viewContentButton.text"));
157 viewContentButton.setIconTextGap(2);
158 viewContentButton.addActionListener(
new java.awt.event.ActionListener() {
159 public void actionPerformed(java.awt.event.ActionEvent evt) {
160 viewContentButtonActionPerformed(evt);
163 jToolBar1.add(viewContentButton);
165 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
166 this.setLayout(layout);
167 layout.setHorizontalGroup(
168 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
169 .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
170 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
172 layout.setVerticalGroup(
173 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174 .addGroup(layout.createSequentialGroup()
175 .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
177 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
181 private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {
182 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
183 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
184 if (messageGroup != null) {
185 BlackboardArtifact art = messageGroup.getData();
187 dtc.viewArtifactContent(art);
190 messageDetailsPane.setCursor(null);
193 private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {
194 messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
195 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
196 if (messageGroup != null) {
197 BlackboardArtifact art = messageGroup.getData();
199 dtc.viewArtifact(art);
202 messageDetailsPane.setCursor(null);
205 private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
206 mainPanel.showMessages();
209 private javax.swing.JButton backButton;
210 private javax.swing.JMenuItem copyMenuItem;
211 private javax.swing.Box.Filler filler1;
212 private javax.swing.JScrollPane jScrollPane1;
213 private javax.swing.JToolBar jToolBar1;
214 private javax.swing.JTextPane messageDetailsPane;
215 private javax.swing.JPopupMenu rightClickMenu;
216 private javax.swing.JMenuItem selectAllMenuItem;
217 private javax.swing.JButton viewArtifactButton;
218 private javax.swing.JButton viewContentButton;
226 void showDetails(
int rowNumber) {
227 final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
228 if (messageGroup != null) {
229 String details = messageGroup.getDetails();
230 if (details != null) {
231 StringBuilder b =
new StringBuilder();
232 if (details.startsWith(
"<html><body>") ==
false) {
233 b.append(
"<html><body>");
235 b.append(
"</body></html>");
239 this.messageDetailsPane.setText(b.toString());
241 this.messageDetailsPane.setText(
"");
244 BlackboardArtifact artifact = messageGroup.getData();
245 if (artifact != null && messageGroup.getCount() == 1) {
246 viewArtifactButton.setEnabled(
true);
249 long objId = artifact.getObjectID();
250 AbstractFile file = null;
252 file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(objId);
253 }
catch (TskException | NoCurrentCaseException ex) {
257 viewContentButton.setEnabled(
false);
258 }
else if (!file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
259 viewContentButton.setEnabled(
false);
261 viewContentButton.setEnabled(
true);
264 viewArtifactButton.setEnabled(
false);
265 viewContentButton.setEnabled(
false);
268 viewArtifactButton.setEnabled(
false);
269 viewContentButton.setEnabled(
false);
270 messageDetailsPane.setText(
"");