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.Collections;
26 import java.util.Comparator;
27 import java.util.HashMap;
28 import java.util.List;
30 import java.util.logging.Level;
31 import javax.swing.JCheckBox;
32 import javax.swing.JLabel;
33 import javax.swing.JList;
34 import javax.swing.ListCellRenderer;
35 import javax.swing.ListModel;
36 import javax.swing.event.ListDataListener;
37 import org.openide.util.NbBundle;
47 @SuppressWarnings(
"PMD.SingularField")
71 @SuppressWarnings(
"deprecation")
72 private
void populateList() {
74 ArrayList<BlackboardArtifact.Type> doNotReport =
new ArrayList<>();
75 doNotReport.add(
new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getTypeID(),
76 BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getLabel(),
77 BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getDisplayName()));
78 doNotReport.add(
new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getTypeID(),
79 BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getLabel(),
80 BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getDisplayName()));
83 artifactTypes.removeAll(doNotReport);
84 Collections.sort(artifactTypes,
new Comparator<BlackboardArtifact.Type>() {
86 public int compare(BlackboardArtifact.Type o1, BlackboardArtifact.Type o2) {
87 return o1.getDisplayName().compareTo(o2.getDisplayName());
91 artifactTypeSelections =
new HashMap<>();
92 for (BlackboardArtifact.Type type : artifactTypes) {
93 artifactTypeSelections.put(type, Boolean.TRUE);
95 }
catch (TskCoreException ex) {
105 artifactList.setModel(model);
106 artifactList.setCellRenderer(renderer);
107 artifactList.setVisibleRowCount(-1);
109 artifactList.addMouseListener(
new MouseAdapter() {
111 public void mousePressed(MouseEvent evt) {
112 int index = artifactList.locationToIndex(evt.getPoint());
113 BlackboardArtifact.Type type = model.
getElementAt(index);
114 artifactTypeSelections.put(type, !artifactTypeSelections.get(type));
115 artifactList.repaint();
125 Map<BlackboardArtifact.Type, Boolean> display() {
126 this.setTitle(NbBundle.getMessage(
this.getClass(),
"ArtifactSelectionDialog.dlgTitle.text"));
127 this.setLocationRelativeTo(getOwner());
128 this.setVisible(
true);
129 return artifactTypeSelections;
137 @SuppressWarnings(
"unchecked")
139 private
void initComponents() {
141 artifactScrollPane =
new javax.swing.JScrollPane();
142 artifactList =
new javax.swing.JList<>();
143 okButton =
new javax.swing.JButton();
144 titleLabel =
new javax.swing.JLabel();
145 selectAllButton =
new javax.swing.JButton();
146 deselectAllButton =
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);
152 artifactScrollPane.setViewportView(artifactList);
154 org.openide.awt.Mnemonics.setLocalizedText(okButton,
org.openide.util.NbBundle.getMessage(
ArtifactSelectionDialog.class,
"ArtifactSelectionDialog.okButton.text"));
155 okButton.addActionListener(
new java.awt.event.ActionListener() {
156 public void actionPerformed(java.awt.event.ActionEvent evt) {
157 okButtonActionPerformed(evt);
161 org.openide.awt.Mnemonics.setLocalizedText(titleLabel,
org.openide.util.NbBundle.getMessage(
ArtifactSelectionDialog.class,
"ArtifactSelectionDialog.titleLabel.text"));
163 org.openide.awt.Mnemonics.setLocalizedText(selectAllButton,
org.openide.util.NbBundle.getMessage(
ArtifactSelectionDialog.class,
"ArtifactSelectionDialog.selectAllButton.text"));
164 selectAllButton.addActionListener(
new java.awt.event.ActionListener() {
165 public void actionPerformed(java.awt.event.ActionEvent evt) {
166 selectAllButtonActionPerformed(evt);
170 org.openide.awt.Mnemonics.setLocalizedText(deselectAllButton,
org.openide.util.NbBundle.getMessage(
ArtifactSelectionDialog.class,
"ArtifactSelectionDialog.deselectAllButton.text"));
171 deselectAllButton.addActionListener(
new java.awt.event.ActionListener() {
172 public void actionPerformed(java.awt.event.ActionEvent evt) {
173 deselectAllButtonActionPerformed(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()
185 .addComponent(artifactScrollPane)
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()
191 .addComponent(titleLabel)
192 .addGap(0, 221, Short.MAX_VALUE))
193 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
194 .addGap(0, 0, Short.MAX_VALUE)
195 .addComponent(okButton)))
198 layout.setVerticalGroup(
199 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addGroup(layout.createSequentialGroup()
202 .addComponent(titleLabel)
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()
207 .addComponent(selectAllButton)
208 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
209 .addComponent(deselectAllButton)
210 .addGap(0, 0, Short.MAX_VALUE)))
212 .addComponent(okButton)
224 for (BlackboardArtifact.Type type : artifactTypes) {
225 artifactTypeSelections.put(type, Boolean.TRUE);
227 artifactList.repaint();
231 for (BlackboardArtifact.Type type : artifactTypes) {
232 artifactTypeSelections.put(type, Boolean.FALSE);
234 artifactList.repaint();
249 return artifactTypes.size();
254 return artifactTypes.get(index);
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
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
Component getListCellRendererComponent(JList<?extends BlackboardArtifact.Type > list, BlackboardArtifact.Type value, int index, boolean isSelected, boolean cellHasFocus)