19 package org.sleuthkit.autopsy.report.infrastructure;
 
   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") 
 
   48 class ArtifactSelectionDialog 
extends javax.swing.JDialog {
 
   50     private ArtifactModel model;
 
   51     private ArtifactRenderer renderer;
 
   61     ArtifactSelectionDialog(java.awt.Frame parent, 
boolean modal) {
 
   71     @SuppressWarnings(
"deprecation")
 
   72     private void populateList() {
 
   81             artifactTypes.removeAll(doNotReport);
 
   82             Collections.sort(artifactTypes, 
new Comparator<BlackboardArtifact.Type>() {
 
   85                     return o1.getDisplayName().compareTo(o2.getDisplayName());
 
   89             artifactTypeSelections = 
new HashMap<>();
 
   91                 artifactTypeSelections.put(type, Boolean.TRUE);
 
   94             Logger.
getLogger(ArtifactSelectionDialog.class.getName()).log(Level.SEVERE, 
"Error getting list of artifacts in use: {0}", ex.getLocalizedMessage()); 
 
   98                 Logger.
getLogger(ArtifactSelectionDialog.class.getName()).log(Level.SEVERE, 
"Exception while getting open case.", ex.getLocalizedMessage()); 
 
  103     private void customInit() {
 
  104         model = 
new ArtifactModel();
 
  105         renderer = 
new ArtifactRenderer();
 
  106         artifactList.setModel(model);
 
  107         artifactList.setCellRenderer(renderer);
 
  108         artifactList.setVisibleRowCount(-1);
 
  110         artifactList.addMouseListener(
new MouseAdapter() {
 
  112             public void mousePressed(MouseEvent evt) {
 
  113                 int index = artifactList.locationToIndex(evt.getPoint());
 
  116                     artifactTypeSelections.put(type, !artifactTypeSelections.get(type));
 
  117                     artifactList.repaint();
 
  129         this.setTitle(NbBundle.getMessage(
this.getClass(), 
"ArtifactSelectionDialog.dlgTitle.text"));
 
  130         this.setLocationRelativeTo(getOwner());
 
  131         this.setVisible(
true);
 
  132         return artifactTypeSelections;
 
  140     @SuppressWarnings(
"unchecked")
 
  142     private void initComponents() {
 
  144         artifactScrollPane = 
new javax.swing.JScrollPane();
 
  145         artifactList = 
new javax.swing.JList<>();
 
  146         okButton = 
new javax.swing.JButton();
 
  147         titleLabel = 
new javax.swing.JLabel();
 
  148         selectAllButton = 
new javax.swing.JButton();
 
  149         deselectAllButton = 
new javax.swing.JButton();
 
  151         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
 
  153         artifactList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
 
  154         artifactList.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
 
  155         artifactScrollPane.setViewportView(artifactList);
 
  157         org.openide.awt.Mnemonics.setLocalizedText(okButton, 
org.openide.util.NbBundle.getMessage(ArtifactSelectionDialog.class, 
"ArtifactSelectionDialog.okButton.text")); 
 
  158         okButton.addActionListener(
new java.awt.event.ActionListener() {
 
  159             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  160                 okButtonActionPerformed(evt);
 
  164         org.openide.awt.Mnemonics.setLocalizedText(titleLabel, 
org.openide.util.NbBundle.getMessage(ArtifactSelectionDialog.class, 
"ArtifactSelectionDialog.titleLabel.text")); 
 
  165         titleLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(ArtifactSelectionDialog.class, 
"ArtifactSelectionDialog.titleLabel.toolTipText")); 
 
  167         org.openide.awt.Mnemonics.setLocalizedText(selectAllButton, 
org.openide.util.NbBundle.getMessage(ArtifactSelectionDialog.class, 
"ArtifactSelectionDialog.selectAllButton.text")); 
 
  168         selectAllButton.addActionListener(
new java.awt.event.ActionListener() {
 
  169             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  170                 selectAllButtonActionPerformed(evt);
 
  174         org.openide.awt.Mnemonics.setLocalizedText(deselectAllButton, 
org.openide.util.NbBundle.getMessage(ArtifactSelectionDialog.class, 
"ArtifactSelectionDialog.deselectAllButton.text")); 
 
  175         deselectAllButton.addActionListener(
new java.awt.event.ActionListener() {
 
  176             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  177                 deselectAllButtonActionPerformed(evt);
 
  181         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(getContentPane());
 
  182         getContentPane().setLayout(layout);
 
  183         layout.setHorizontalGroup(
 
  184             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  185             .addGroup(layout.createSequentialGroup()
 
  187                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  188                     .addGroup(layout.createSequentialGroup()
 
  189                         .addComponent(artifactScrollPane)
 
  190                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  191                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, 
false)
 
  192                             .addComponent(deselectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  193                             .addComponent(selectAllButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
 
  194                     .addGroup(layout.createSequentialGroup()
 
  195                         .addComponent(titleLabel)
 
  196                         .addGap(0, 195, Short.MAX_VALUE))
 
  197                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
 
  198                         .addGap(0, 0, Short.MAX_VALUE)
 
  199                         .addComponent(okButton)))
 
  202         layout.setVerticalGroup(
 
  203             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  204             .addGroup(layout.createSequentialGroup()
 
  206                 .addComponent(titleLabel)
 
  207                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  208                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  209                     .addComponent(artifactScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
 
  210                     .addGroup(layout.createSequentialGroup()
 
  211                         .addComponent(selectAllButton)
 
  212                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  213                         .addComponent(deselectAllButton)
 
  214                         .addGap(0, 0, Short.MAX_VALUE)))
 
  216                 .addComponent(okButton)
 
  223     private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  227     private void selectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  229             artifactTypeSelections.put(type, Boolean.TRUE);
 
  231         artifactList.repaint();
 
  234     private void deselectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  236             artifactTypeSelections.put(type, Boolean.FALSE);
 
  238         artifactList.repaint();
 
  242     private javax.swing.JScrollPane artifactScrollPane;
 
  243     private javax.swing.JButton deselectAllButton;
 
  244     private javax.swing.JButton okButton;
 
  245     private javax.swing.JButton selectAllButton;
 
  246     private javax.swing.JLabel titleLabel;
 
  253             return artifactTypes.size();
 
  258             return artifactTypes.get(index);
 
  270     private class ArtifactRenderer extends JCheckBox implements ListCellRenderer<BlackboardArtifact.Type> {
 
  275                 setEnabled(list.isEnabled());
 
  276                 setSelected(artifactTypeSelections.get(value));
 
  277                 setFont(list.getFont());
 
  278                 setBackground(list.getBackground());
 
  279                 setForeground(list.getForeground());
 
  280                 setText(value.getDisplayName());
 
void addListDataListener(ListDataListener l)
 
List< BlackboardArtifact.Type > getArtifactTypesInUse()
 
BlackboardArtifact.Type getElementAt(int index)
 
SleuthkitCase getSleuthkitCase()
 
synchronized static Logger getLogger(String name)
 
static Case getCurrentCaseThrows()
 
void removeListDataListener(ListDataListener l)
 
Component getListCellRendererComponent(JList<?extends BlackboardArtifact.Type > list, BlackboardArtifact.Type value, int index, boolean isSelected, boolean cellHasFocus)
 
static boolean isCaseOpen()