19 package org.sleuthkit.autopsy.report;
21 import java.awt.Component;
22 import java.awt.event.MouseAdapter;
23 import java.awt.event.MouseEvent;
24 import java.util.ArrayList;
25 import java.util.EnumMap;
26 import java.util.LinkedHashMap;
27 import java.util.List;
29 import java.util.Map.Entry;
30 import java.util.logging.Level;
31 import javax.swing.JCheckBox;
32 import javax.swing.JFrame;
33 import javax.swing.JLabel;
34 import javax.swing.JList;
35 import javax.swing.JPanel;
36 import javax.swing.ListCellRenderer;
37 import javax.swing.ListModel;
38 import javax.swing.event.ListDataListener;
39 import org.openide.util.NbBundle;
47 final class ReportVisualPanel2
extends JPanel {
49 private ReportWizardPanel2 wizPanel;
50 private Map<String, Boolean> tagStates =
new LinkedHashMap<>();
51 private List<String> tags =
new ArrayList<>();
52 ArtifactSelectionDialog dialog =
new ArtifactSelectionDialog(
new JFrame(),
true);
53 private Map<ARTIFACT_TYPE, Boolean> artifactStates =
new EnumMap<>(ARTIFACT_TYPE.class);
54 private List<ARTIFACT_TYPE> artifacts =
new ArrayList<>();
55 private TagsListModel tagsModel;
56 private TagsListRenderer tagsRenderer;
61 public ReportVisualPanel2(ReportWizardPanel2 wizPanel) {
65 tagsList.setEnabled(
false);
66 selectAllButton.setEnabled(
false);
67 deselectAllButton.setEnabled(
false);
68 allResultsRadioButton.setSelected(
true);
69 this.wizPanel = wizPanel;
73 private void initTags() {
74 List<TagName> tagNamesInUse;
76 tagNamesInUse = Case.getCurrentCase().getServices().getTagsManager().getTagNamesInUse();
77 }
catch (TskCoreException ex) {
78 Logger.getLogger(ReportVisualPanel2.class.getName()).log(Level.SEVERE,
"Failed to get tag names", ex);
82 for (TagName tagName : tagNamesInUse) {
83 tagStates.put(tagName.getDisplayName(), Boolean.FALSE);
85 tags.addAll(tagStates.keySet());
87 tagsModel =
new TagsListModel();
88 tagsRenderer =
new TagsListRenderer();
89 tagsList.setModel(tagsModel);
90 tagsList.setCellRenderer(tagsRenderer);
91 tagsList.setVisibleRowCount(-1);
94 tagsList.addMouseListener(
new MouseAdapter() {
96 public void mousePressed(MouseEvent evt) {
98 int index = tagsList.locationToIndex(evt.getPoint());
99 String value = tagsModel.getElementAt(index);
100 tagStates.put(value, !tagStates.get(value));
102 updateFinishButton();
108 @SuppressWarnings(
"deprecation")
109 private
void initArtifactTypes() {
112 ArrayList<BlackboardArtifact.ARTIFACT_TYPE> doNotReport =
new ArrayList<>();
113 doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO);
114 doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT);
117 artifacts = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTypesInUse();
119 artifacts.removeAll(doNotReport);
121 artifactStates =
new EnumMap<>(ARTIFACT_TYPE.class);
122 for (ARTIFACT_TYPE type : artifacts) {
123 artifactStates.put(type, Boolean.TRUE);
125 }
catch (TskCoreException ex) {
126 Logger.getLogger(ReportVisualPanel2.class.getName()).log(Level.SEVERE,
"Error getting list of artifacts in use: " + ex.getLocalizedMessage(), ex);
131 public String getName() {
132 return NbBundle.getMessage(this.getClass(),
"ReportVisualPanel2.getName.text");
138 Map<ARTIFACT_TYPE, Boolean> getArtifactStates() {
139 return artifactStates;
145 Map<String, Boolean> getTagStates() {
149 private boolean areTagsSelected() {
150 boolean result =
false;
151 for (Entry<String, Boolean> entry : tagStates.entrySet()) {
152 if (entry.getValue()) {
159 private boolean areArtifactsSelected() {
160 boolean result =
false;
161 for (Entry<ARTIFACT_TYPE, Boolean> entry : artifactStates.entrySet()) {
162 if (entry.getValue()) {
169 private void updateFinishButton() {
170 if (taggedResultsRadioButton.isSelected()) {
171 wizPanel.setFinish(areTagsSelected());
173 wizPanel.setFinish(areArtifactsSelected());
180 boolean isTaggedResultsRadioButtonSelected() {
181 return taggedResultsRadioButton.isSelected();
190 private void initComponents() {
192 optionsButtonGroup =
new javax.swing.ButtonGroup();
193 taggedResultsRadioButton =
new javax.swing.JRadioButton();
194 allResultsRadioButton =
new javax.swing.JRadioButton();
195 dataLabel =
new javax.swing.JLabel();
196 selectAllButton =
new javax.swing.JButton();
197 deselectAllButton =
new javax.swing.JButton();
198 tagsScrollPane =
new javax.swing.JScrollPane();
199 tagsList =
new javax.swing.JList<>();
200 advancedButton =
new javax.swing.JButton();
202 setPreferredSize(
new java.awt.Dimension(650, 250));
204 optionsButtonGroup.add(taggedResultsRadioButton);
205 org.openide.awt.Mnemonics.setLocalizedText(taggedResultsRadioButton,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.taggedResultsRadioButton.text"));
206 taggedResultsRadioButton.addChangeListener(
new javax.swing.event.ChangeListener() {
207 public void stateChanged(javax.swing.event.ChangeEvent evt) {
208 taggedResultsRadioButtonStateChanged(evt);
212 optionsButtonGroup.add(allResultsRadioButton);
213 org.openide.awt.Mnemonics.setLocalizedText(allResultsRadioButton,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.allResultsRadioButton.text"));
215 org.openide.awt.Mnemonics.setLocalizedText(dataLabel,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.dataLabel.text"));
217 org.openide.awt.Mnemonics.setLocalizedText(selectAllButton,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.selectAllButton.text"));
218 selectAllButton.addActionListener(
new java.awt.event.ActionListener() {
219 public void actionPerformed(java.awt.event.ActionEvent evt) {
220 selectAllButtonActionPerformed(evt);
224 org.openide.awt.Mnemonics.setLocalizedText(deselectAllButton,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.deselectAllButton.text"));
225 deselectAllButton.addActionListener(
new java.awt.event.ActionListener() {
226 public void actionPerformed(java.awt.event.ActionEvent evt) {
227 deselectAllButtonActionPerformed(evt);
231 tagsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
232 tagsList.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
233 tagsScrollPane.setViewportView(tagsList);
235 org.openide.awt.Mnemonics.setLocalizedText(advancedButton,
org.openide.util.NbBundle.getMessage(ReportVisualPanel2.class,
"ReportVisualPanel2.advancedButton.text"));
236 advancedButton.addActionListener(
new java.awt.event.ActionListener() {
237 public void actionPerformed(java.awt.event.ActionEvent evt) {
238 advancedButtonActionPerformed(evt);
242 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
243 this.setLayout(layout);
244 layout.setHorizontalGroup(
245 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246 .addGroup(layout.createSequentialGroup()
248 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249 .addGroup(layout.createSequentialGroup()
251 .addComponent(tagsScrollPane)
252 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
253 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
254 .addComponent(advancedButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
255 .addComponent(deselectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
256 .addComponent(selectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
257 .addGroup(layout.createSequentialGroup()
258 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259 .addComponent(taggedResultsRadioButton)
260 .addComponent(dataLabel)
261 .addComponent(allResultsRadioButton))
262 .addGap(0, 481, Short.MAX_VALUE)))
265 layout.setVerticalGroup(
266 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
267 .addGroup(layout.createSequentialGroup()
269 .addComponent(dataLabel)
270 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
271 .addComponent(allResultsRadioButton)
272 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
273 .addComponent(taggedResultsRadioButton)
275 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
276 .addGroup(layout.createSequentialGroup()
277 .addComponent(selectAllButton)
278 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
279 .addComponent(deselectAllButton)
280 .addGap(0, 70, Short.MAX_VALUE))
281 .addComponent(tagsScrollPane))
282 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
283 .addComponent(advancedButton)
288 private void taggedResultsRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {
289 tagsList.setEnabled(taggedResultsRadioButton.isSelected());
290 selectAllButton.setEnabled(taggedResultsRadioButton.isSelected());
291 deselectAllButton.setEnabled(taggedResultsRadioButton.isSelected());
292 advancedButton.setEnabled(!taggedResultsRadioButton.isSelected());
293 updateFinishButton();
296 private void selectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {
297 for (String tag : tags) {
298 tagStates.put(tag, Boolean.TRUE);
301 wizPanel.setFinish(
true);
304 private void deselectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {
305 for (String tag : tags) {
306 tagStates.put(tag, Boolean.FALSE);
309 wizPanel.setFinish(
false);
312 private void advancedButtonActionPerformed(java.awt.event.ActionEvent evt) {
313 artifactStates = dialog.display();
314 wizPanel.setFinish(areArtifactsSelected());
317 private javax.swing.JButton advancedButton;
318 private javax.swing.JRadioButton allResultsRadioButton;
319 private javax.swing.JLabel dataLabel;
320 private javax.swing.JButton deselectAllButton;
321 private javax.swing.ButtonGroup optionsButtonGroup;
322 private javax.swing.JButton selectAllButton;
323 private javax.swing.JRadioButton taggedResultsRadioButton;
324 private javax.swing.JList<String> tagsList;
325 private javax.swing.JScrollPane tagsScrollPane;
337 return tags.get(index);
355 setEnabled(list.isEnabled());
356 setSelected(tagStates.get(value.toString()));
357 setFont(list.getFont());
358 setBackground(list.getBackground());
359 setForeground(list.getForeground());
360 setText(value.toString());