Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ManageCasesDialog.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.centralrepository.optionspanel;
20 
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.logging.Level;
26 import javax.swing.event.ListSelectionEvent;
27 import javax.swing.event.ListSelectionListener;
28 import org.openide.windows.WindowManager;
33 import org.openide.util.NbBundle.Messages;
35 
41 final class ManageCasesDialog extends javax.swing.JDialog {
42 
43  private static final long serialVersionUID = 1L;
44  private final CasesTableModel casesTableModel = new CasesTableModel();
45  private final DataSourcesTableModel dataSourcesTableModel = new DataSourcesTableModel();
46  private final static Logger logger = Logger.getLogger(ManageCasesDialog.class.getName());
47 
51  @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
52  @Messages({"ManageCasesDialog.title.text=Manage Cases"})
53  private ManageCasesDialog() {
54  super(WindowManager.getDefault().getMainWindow(), Bundle.ManageCasesDialog_title_text(),
55  true);
56  initComponents();
57  try {
58  CentralRepository dbManager = CentralRepository.getInstance();
59  Map<Integer, List<CorrelationDataSource>> dataSourcesByCaseId = new HashMap<>();
60  for (CorrelationDataSource dataSource : dbManager.getDataSources()) {
61  int caseID = dataSource.getCaseID();
62  List<CorrelationDataSource> dataSourceNames = dataSourcesByCaseId.getOrDefault(caseID, new ArrayList<>());
63  dataSourceNames.add(dataSource);
64  dataSourcesByCaseId.put(caseID, dataSourceNames);
65  }
66  for (CorrelationCase eamCase : dbManager.getCases()) {
67  casesTableModel.addEamCase(eamCase, dataSourcesByCaseId.getOrDefault(eamCase.getID(), new ArrayList<>()));
68  }
69  } catch (CentralRepoException ex) {
70  logger.log(Level.SEVERE, "Error getting list of cases from database.", ex); // NON-NLS
71  }
72 
73  casesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
74  @Override
75  public void valueChanged(ListSelectionEvent e) {
76  if (!e.getValueIsAdjusting()) {
77  updateSelection();
78  }
79  }
80  });
81  //sort on first column by default
82  casesTable.getRowSorter().toggleSortOrder(0);
83  }
84 
89  static void displayManageCasesDialog() {
90  ManageCasesDialog caseInfoDialog = new ManageCasesDialog();
91  caseInfoDialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
92  caseInfoDialog.setVisible(true);
93  }
94 
100  @SuppressWarnings("unchecked")
101  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
102  private void initComponents() {
103 
104  casesSplitPane = new javax.swing.JSplitPane();
105  caseInfoPanel = new javax.swing.JPanel();
106  dataSourcesScrollPane = new javax.swing.JScrollPane();
107  dataSourcesTable = new javax.swing.JTable();
108  notesScrollPane = new javax.swing.JScrollPane();
109  notesTextArea = new javax.swing.JTextArea();
110  caseInfoLabel = new javax.swing.JLabel();
111  dataSourcesLabel = new javax.swing.JLabel();
112  notesLabel = new javax.swing.JLabel();
113  orgLabel = new javax.swing.JLabel();
114  caseNumberLabel = new javax.swing.JLabel();
115  examinerEmailLabel = new javax.swing.JLabel();
116  examinerNameLabel = new javax.swing.JLabel();
117  examinerPhoneLabel = new javax.swing.JLabel();
118  orgValueLabel = new javax.swing.JLabel();
119  caseNumberValueLabel = new javax.swing.JLabel();
120  examinerNameValueLabel = new javax.swing.JLabel();
121  examinerEmailValueLabel = new javax.swing.JLabel();
122  examinerPhoneValueLabel = new javax.swing.JLabel();
123  closeButton = new javax.swing.JButton();
124  casesPanel = new javax.swing.JPanel();
125  casesScrollPane = new javax.swing.JScrollPane();
126  casesTable = new javax.swing.JTable();
127 
128  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
129  setMinimumSize(new java.awt.Dimension(400, 400));
130 
131  casesSplitPane.setDividerLocation(380);
132 
133  dataSourcesTable.setAutoCreateRowSorter(true);
134  dataSourcesTable.setModel(dataSourcesTableModel);
135  dataSourcesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
136  dataSourcesScrollPane.setViewportView(dataSourcesTable);
137 
138  notesScrollPane.setBorder(null);
139 
140  notesTextArea.setEditable(false);
141  notesTextArea.setBackground(new java.awt.Color(240, 240, 240));
142  notesTextArea.setColumns(20);
143  notesTextArea.setLineWrap(true);
144  notesTextArea.setRows(3);
145  notesTextArea.setWrapStyleWord(true);
146  notesTextArea.setBorder(null);
147  notesScrollPane.setViewportView(notesTextArea);
148 
149  org.openide.awt.Mnemonics.setLocalizedText(caseInfoLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.caseInfoLabel.text")); // NOI18N
150 
151  org.openide.awt.Mnemonics.setLocalizedText(dataSourcesLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.dataSourcesLabel.text")); // NOI18N
152 
153  org.openide.awt.Mnemonics.setLocalizedText(notesLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.notesLabel.text")); // NOI18N
154 
155  org.openide.awt.Mnemonics.setLocalizedText(orgLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.orgLabel.text")); // NOI18N
156 
157  org.openide.awt.Mnemonics.setLocalizedText(caseNumberLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.caseNumberLabel.text")); // NOI18N
158 
159  org.openide.awt.Mnemonics.setLocalizedText(examinerEmailLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.examinerEmailLabel.text")); // NOI18N
160 
161  org.openide.awt.Mnemonics.setLocalizedText(examinerNameLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.examinerNameLabel.text")); // NOI18N
162 
163  org.openide.awt.Mnemonics.setLocalizedText(examinerPhoneLabel, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.examinerPhoneLabel.text")); // NOI18N
164 
165  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(ManageCasesDialog.class, "ManageCasesDialog.closeButton.text")); // NOI18N
166  closeButton.setMaximumSize(new java.awt.Dimension(65, 23));
167  closeButton.setMinimumSize(new java.awt.Dimension(65, 23));
168  closeButton.setPreferredSize(new java.awt.Dimension(65, 23));
169  closeButton.addActionListener(new java.awt.event.ActionListener() {
170  public void actionPerformed(java.awt.event.ActionEvent evt) {
171  closeButtonActionPerformed(evt);
172  }
173  });
174 
175  javax.swing.GroupLayout caseInfoPanelLayout = new javax.swing.GroupLayout(caseInfoPanel);
176  caseInfoPanel.setLayout(caseInfoPanelLayout);
177  caseInfoPanelLayout.setHorizontalGroup(
178  caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
179  .addGroup(caseInfoPanelLayout.createSequentialGroup()
180  .addContainerGap()
181  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
182  .addGroup(caseInfoPanelLayout.createSequentialGroup()
183  .addGap(10, 10, 10)
184  .addComponent(dataSourcesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
185  .addGroup(caseInfoPanelLayout.createSequentialGroup()
186  .addGap(6, 6, 6)
187  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188  .addGroup(caseInfoPanelLayout.createSequentialGroup()
189  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
190  .addComponent(orgLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
191  .addComponent(caseNumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
192  .addComponent(examinerNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
193  .addComponent(examinerEmailLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
194  .addComponent(examinerPhoneLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
195  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196  .addGroup(caseInfoPanelLayout.createSequentialGroup()
197  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
198  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199  .addComponent(caseNumberValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
200  .addComponent(orgValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
201  .addGroup(caseInfoPanelLayout.createSequentialGroup()
202  .addGap(6, 6, 6)
203  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204  .addComponent(examinerNameValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
205  .addComponent(examinerEmailValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
206  .addComponent(examinerPhoneValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
207  .addComponent(notesLabel)
208  .addGroup(caseInfoPanelLayout.createSequentialGroup()
209  .addGap(10, 10, 10)
210  .addComponent(notesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))))
211  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caseInfoPanelLayout.createSequentialGroup()
212  .addGap(0, 0, Short.MAX_VALUE)
213  .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
214  .addGroup(caseInfoPanelLayout.createSequentialGroup()
215  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216  .addComponent(caseInfoLabel)
217  .addComponent(dataSourcesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
218  .addGap(0, 0, Short.MAX_VALUE)))
219  .addContainerGap())
220  );
221  caseInfoPanelLayout.setVerticalGroup(
222  caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caseInfoPanelLayout.createSequentialGroup()
224  .addContainerGap()
225  .addComponent(caseInfoLabel)
226  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
228  .addGroup(caseInfoPanelLayout.createSequentialGroup()
229  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
230  .addGroup(caseInfoPanelLayout.createSequentialGroup()
231  .addComponent(orgLabel)
232  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
233  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
234  .addComponent(caseNumberLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
235  .addComponent(caseNumberValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
236  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
238  .addComponent(examinerNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
239  .addComponent(examinerNameValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
240  .addComponent(orgValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
241  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
242  .addComponent(examinerEmailLabel))
243  .addComponent(examinerEmailValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245  .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246  .addComponent(examinerPhoneLabel)
247  .addComponent(examinerPhoneValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
248  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249  .addComponent(notesLabel)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addComponent(notesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
252  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253  .addComponent(dataSourcesLabel)
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255  .addComponent(dataSourcesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
256  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257  .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
258  .addContainerGap())
259  );
260 
261  casesSplitPane.setRightComponent(caseInfoPanel);
262 
263  casesTable.setAutoCreateRowSorter(true);
264  casesTable.setModel(casesTableModel);
265  casesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
266  casesScrollPane.setViewportView(casesTable);
267 
268  javax.swing.GroupLayout casesPanelLayout = new javax.swing.GroupLayout(casesPanel);
269  casesPanel.setLayout(casesPanelLayout);
270  casesPanelLayout.setHorizontalGroup(
271  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
272  .addGroup(casesPanelLayout.createSequentialGroup()
273  .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
274  .addGap(0, 0, 0))
275  );
276  casesPanelLayout.setVerticalGroup(
277  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
278  .addGroup(casesPanelLayout.createSequentialGroup()
279  .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
280  .addGap(40, 40, 40))
281  );
282 
283  casesSplitPane.setLeftComponent(casesPanel);
284 
285  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
286  getContentPane().setLayout(layout);
287  layout.setHorizontalGroup(
288  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289  .addComponent(casesSplitPane, javax.swing.GroupLayout.Alignment.TRAILING)
290  );
291  layout.setVerticalGroup(
292  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
293  .addComponent(casesSplitPane)
294  );
295 
296  pack();
297  }// </editor-fold>//GEN-END:initComponents
298 
299  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
300  this.dispose();
301  }//GEN-LAST:event_closeButtonActionPerformed
302 
306  private void updateSelection() {
307  dataSourcesTableModel.clearTable();
308  if (casesTable.getSelectedRow() >= 0 && casesTable.getSelectedRow() < casesTable.getRowCount()) {
309  CaseDataSourcesWrapper caseWrapper = casesTableModel.getEamCase(casesTable.convertRowIndexToModel(casesTable.getSelectedRow()));
310  orgValueLabel.setText(caseWrapper.getOrganizationName());
311  caseNumberValueLabel.setText(caseWrapper.getCaseNumber());
312  examinerNameValueLabel.setText(caseWrapper.getExaminerName());
313  examinerPhoneValueLabel.setText(caseWrapper.getExaminerPhone());
314  examinerEmailValueLabel.setText(caseWrapper.getExaminerEmail());
315  notesTextArea.setText(caseWrapper.getNotes());
316  dataSourcesTableModel.addDataSources(caseWrapper.getDataSources());
317  } else {
318  orgValueLabel.setText("");
319  caseNumberValueLabel.setText("");
320  examinerNameValueLabel.setText("");
321  examinerPhoneValueLabel.setText("");
322  examinerEmailValueLabel.setText("");
323  notesTextArea.setText("");
324  }
325  }
326 
327  // Variables declaration - do not modify//GEN-BEGIN:variables
328  private javax.swing.JLabel caseInfoLabel;
329  private javax.swing.JPanel caseInfoPanel;
330  private javax.swing.JLabel caseNumberLabel;
331  private javax.swing.JLabel caseNumberValueLabel;
332  private javax.swing.JPanel casesPanel;
333  private javax.swing.JScrollPane casesScrollPane;
334  private javax.swing.JSplitPane casesSplitPane;
335  private javax.swing.JTable casesTable;
336  private javax.swing.JButton closeButton;
337  private javax.swing.JLabel dataSourcesLabel;
338  private javax.swing.JScrollPane dataSourcesScrollPane;
339  private javax.swing.JTable dataSourcesTable;
340  private javax.swing.JLabel examinerEmailLabel;
341  private javax.swing.JLabel examinerEmailValueLabel;
342  private javax.swing.JLabel examinerNameLabel;
343  private javax.swing.JLabel examinerNameValueLabel;
344  private javax.swing.JLabel examinerPhoneLabel;
345  private javax.swing.JLabel examinerPhoneValueLabel;
346  private javax.swing.JLabel notesLabel;
347  private javax.swing.JScrollPane notesScrollPane;
348  private javax.swing.JTextArea notesTextArea;
349  private javax.swing.JLabel orgLabel;
350  private javax.swing.JLabel orgValueLabel;
351  // End of variables declaration//GEN-END:variables
352 }

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.