19 package org.sleuthkit.autopsy.report;
21 import java.awt.Component;
22 import java.awt.Dimension;
23 import java.awt.Toolkit;
24 import java.awt.event.MouseAdapter;
25 import java.awt.event.MouseEvent;
26 import java.util.ArrayList;
27 import java.util.Collections;
28 import java.util.Comparator;
29 import java.util.EnumMap;
30 import java.util.HashMap;
31 import java.util.List;
33 import java.util.logging.Level;
34 import javax.swing.JCheckBox;
35 import javax.swing.JLabel;
36 import javax.swing.JList;
37 import javax.swing.ListCellRenderer;
38 import javax.swing.ListModel;
39 import javax.swing.event.ListDataListener;
40 import org.openide.util.NbBundle;
66 @SuppressWarnings(
"deprecation")
69 ArrayList<BlackboardArtifact.Type> doNotReport =
new ArrayList<>();
70 doNotReport.add(
new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getTypeID(),
71 BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getLabel(),
72 BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getDisplayName()));
73 doNotReport.add(
new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getTypeID(),
74 BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getLabel(),
75 BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getDisplayName()));
79 Collections.sort(
artifactTypes,
new Comparator<BlackboardArtifact.Type>() {
81 public int compare(BlackboardArtifact.Type o1, BlackboardArtifact.Type o2) {
82 return o1.getDisplayName().compareTo(o2.getDisplayName());
86 artifactTypeSelections =
new HashMap<>();
88 artifactTypeSelections.put(type, Boolean.TRUE);
90 }
catch (TskCoreException ex) {
104 public void mousePressed(MouseEvent evt) {
105 int index =
artifactList.locationToIndex(evt.getPoint());
106 BlackboardArtifact.Type type = model.
getElementAt(index);
107 artifactTypeSelections.put(type, !artifactTypeSelections.get(type));
118 Map<BlackboardArtifact.Type, Boolean> display() {
119 this.setTitle(NbBundle.getMessage(
this.getClass(),
"ArtifactSelectionDialog.dlgTitle.text"));
120 Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
122 int w = this.getSize().width;
123 int h = this.getSize().height;
126 setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
128 this.setVisible(
true);
137 @SuppressWarnings(
"unchecked")
143 okButton =
new javax.swing.JButton();
148 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
150 artifactList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
151 artifactList.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
155 okButton.addActionListener(
new java.awt.event.ActionListener() {
156 public void actionPerformed(java.awt.event.ActionEvent evt) {
164 selectAllButton.addActionListener(
new java.awt.event.ActionListener() {
165 public void actionPerformed(java.awt.event.ActionEvent evt) {
172 public void actionPerformed(java.awt.event.ActionEvent evt) {
177 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
178 getContentPane().setLayout(layout);
179 layout.setHorizontalGroup(
180 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(layout.createSequentialGroup()
183 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addGroup(layout.createSequentialGroup()
186 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
187 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
188 .addComponent(
deselectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
189 .addComponent(
selectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
190 .addGroup(layout.createSequentialGroup()
192 .addGap(0, 221, Short.MAX_VALUE))
193 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
194 .addGap(0, 0, Short.MAX_VALUE)
198 layout.setVerticalGroup(
199 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addGroup(layout.createSequentialGroup()
203 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
204 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205 .addComponent(
artifactScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
206 .addGroup(layout.createSequentialGroup()
208 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
210 .addGap(0, 0, Short.MAX_VALUE)))
225 artifactTypeSelections.put(type, Boolean.TRUE);
232 artifactTypeSelections.put(type, Boolean.FALSE);
266 private class ArtifactRenderer extends JCheckBox implements ListCellRenderer<BlackboardArtifact.Type> {
269 public Component
getListCellRendererComponent(JList<? extends BlackboardArtifact.Type> list, BlackboardArtifact.Type value,
int index,
boolean isSelected,
boolean cellHasFocus) {
271 setEnabled(list.isEnabled());
272 setSelected(artifactTypeSelections.get(value));
273 setFont(list.getFont());
274 setBackground(list.getBackground());
275 setForeground(list.getForeground());
276 setText(value.getDisplayName());
ArtifactSelectionDialog(java.awt.Frame parent, boolean modal)
void selectAllButtonActionPerformed(java.awt.event.ActionEvent evt)
void removeListDataListener(ListDataListener l)
List< BlackboardArtifact.Type > artifactTypes
BlackboardArtifact.Type getElementAt(int index)
Map< BlackboardArtifact.Type, Boolean > artifactTypeSelections
javax.swing.JButton okButton
void deselectAllButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JList< BlackboardArtifact.Type > artifactList
ArtifactRenderer renderer
void okButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel titleLabel
javax.swing.JButton selectAllButton
SleuthkitCase getSleuthkitCase()
void addListDataListener(ListDataListener l)
javax.swing.JButton deselectAllButton
javax.swing.JScrollPane artifactScrollPane
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
Component getListCellRendererComponent(JList<?extends BlackboardArtifact.Type > list, BlackboardArtifact.Type value, int index, boolean isSelected, boolean cellHasFocus)