19 package org.sleuthkit.autopsy.centralrepository.optionspanel;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
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;
41 final class ManageCasesDialog
extends javax.swing.JDialog {
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());
51 @SuppressWarnings(
"PMD.SingularField")
52 @Messages({
"ManageCasesDialog.title.text=Manage Cases"})
53 private ManageCasesDialog() {
54 super(WindowManager.getDefault().getMainWindow(), Bundle.ManageCasesDialog_title_text(),
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);
66 for (CorrelationCase eamCase : dbManager.getCases()) {
67 casesTableModel.addEamCase(eamCase, dataSourcesByCaseId.getOrDefault(eamCase.getID(),
new ArrayList<>()));
69 }
catch (CentralRepoException ex) {
70 logger.log(Level.SEVERE,
"Error getting list of cases from database.", ex);
73 casesTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
75 public void valueChanged(ListSelectionEvent e) {
76 if (!e.getValueIsAdjusting()) {
82 casesTable.getRowSorter().toggleSortOrder(0);
89 static void displayManageCasesDialog() {
90 ManageCasesDialog caseInfoDialog =
new ManageCasesDialog();
91 caseInfoDialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
92 caseInfoDialog.setVisible(
true);
100 @SuppressWarnings(
"unchecked")
102 private
void initComponents() {
103 java.awt.GridBagConstraints gridBagConstraints;
105 casesSplitPane =
new javax.swing.JSplitPane();
106 caseInfoPanel =
new javax.swing.JPanel();
107 dataSourcesScrollPane =
new javax.swing.JScrollPane();
108 dataSourcesTable =
new javax.swing.JTable();
109 notesScrollPane =
new javax.swing.JScrollPane();
110 notesTextArea =
new javax.swing.JTextArea();
111 caseInfoLabel =
new javax.swing.JLabel();
112 dataSourcesLabel =
new javax.swing.JLabel();
113 notesLabel =
new javax.swing.JLabel();
114 orgLabel =
new javax.swing.JLabel();
115 caseNumberLabel =
new javax.swing.JLabel();
116 examinerEmailLabel =
new javax.swing.JLabel();
117 examinerNameLabel =
new javax.swing.JLabel();
118 examinerPhoneLabel =
new javax.swing.JLabel();
119 orgValueLabel =
new javax.swing.JLabel();
120 caseNumberValueLabel =
new javax.swing.JLabel();
121 examinerNameValueLabel =
new javax.swing.JLabel();
122 examinerEmailValueLabel =
new javax.swing.JLabel();
123 examinerPhoneValueLabel =
new javax.swing.JLabel();
124 closeButton =
new javax.swing.JButton();
125 javax.swing.Box.Filler filler1 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0),
new java.awt.Dimension(0, 0),
new java.awt.Dimension(32767, 0));
126 casesPanel =
new javax.swing.JPanel();
127 casesScrollPane =
new javax.swing.JScrollPane();
128 casesTable =
new javax.swing.JTable();
130 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
131 setMinimumSize(
new java.awt.Dimension(400, 400));
133 casesSplitPane.setDividerLocation(380);
134 casesSplitPane.setResizeWeight(0.5);
136 caseInfoPanel.setLayout(
new java.awt.GridBagLayout());
138 dataSourcesTable.setAutoCreateRowSorter(
true);
139 dataSourcesTable.setModel(dataSourcesTableModel);
140 dataSourcesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
141 dataSourcesScrollPane.setViewportView(dataSourcesTable);
143 gridBagConstraints =
new java.awt.GridBagConstraints();
144 gridBagConstraints.gridx = 0;
145 gridBagConstraints.gridy = 9;
146 gridBagConstraints.gridwidth = 5;
147 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
148 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
149 gridBagConstraints.weightx = 1.0;
150 gridBagConstraints.weighty = 1.0;
151 gridBagConstraints.insets =
new java.awt.Insets(7, 22, 0, 12);
152 caseInfoPanel.add(dataSourcesScrollPane, gridBagConstraints);
154 notesScrollPane.setBorder(null);
155 notesScrollPane.setMinimumSize(
new java.awt.Dimension(25, 54));
156 notesScrollPane.setPreferredSize(
new java.awt.Dimension(160, 70));
158 notesTextArea.setEditable(
false);
159 notesTextArea.setBackground(
new java.awt.Color(240, 240, 240));
160 notesTextArea.setColumns(20);
161 notesTextArea.setLineWrap(
true);
162 notesTextArea.setRows(3);
163 notesTextArea.setWrapStyleWord(
true);
164 notesTextArea.setBorder(null);
165 notesScrollPane.setViewportView(notesTextArea);
167 gridBagConstraints =
new java.awt.GridBagConstraints();
168 gridBagConstraints.gridx = 0;
169 gridBagConstraints.gridy = 7;
170 gridBagConstraints.gridwidth = 5;
171 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
173 gridBagConstraints.weightx = 1.0;
174 gridBagConstraints.insets =
new java.awt.Insets(7, 28, 0, 12);
175 caseInfoPanel.add(notesScrollPane, gridBagConstraints);
177 org.openide.awt.Mnemonics.setLocalizedText(caseInfoLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseInfoLabel.text"));
178 caseInfoLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
179 caseInfoLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
180 gridBagConstraints =
new java.awt.GridBagConstraints();
181 gridBagConstraints.gridx = 0;
182 gridBagConstraints.gridy = 0;
183 gridBagConstraints.gridwidth = 4;
184 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
186 gridBagConstraints.insets =
new java.awt.Insets(13, 12, 0, 0);
187 caseInfoPanel.add(caseInfoLabel, gridBagConstraints);
189 org.openide.awt.Mnemonics.setLocalizedText(dataSourcesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.dataSourcesLabel.text"));
190 dataSourcesLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
191 dataSourcesLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
192 gridBagConstraints =
new java.awt.GridBagConstraints();
193 gridBagConstraints.gridx = 0;
194 gridBagConstraints.gridy = 8;
195 gridBagConstraints.gridwidth = 3;
196 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
197 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
198 gridBagConstraints.weightx = 0.1;
199 gridBagConstraints.insets =
new java.awt.Insets(7, 12, 0, 0);
200 caseInfoPanel.add(dataSourcesLabel, gridBagConstraints);
202 org.openide.awt.Mnemonics.setLocalizedText(notesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.notesLabel.text"));
203 notesLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
204 notesLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
205 gridBagConstraints =
new java.awt.GridBagConstraints();
206 gridBagConstraints.gridx = 0;
207 gridBagConstraints.gridy = 6;
208 gridBagConstraints.gridwidth = 4;
209 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
210 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
211 gridBagConstraints.weightx = 0.1;
212 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
213 caseInfoPanel.add(notesLabel, gridBagConstraints);
215 org.openide.awt.Mnemonics.setLocalizedText(orgLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.orgLabel.text"));
216 orgLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
217 orgLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
218 gridBagConstraints =
new java.awt.GridBagConstraints();
219 gridBagConstraints.gridx = 0;
220 gridBagConstraints.gridy = 1;
221 gridBagConstraints.gridwidth = 4;
222 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
223 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
224 gridBagConstraints.weightx = 0.1;
225 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
226 caseInfoPanel.add(orgLabel, gridBagConstraints);
228 org.openide.awt.Mnemonics.setLocalizedText(caseNumberLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseNumberLabel.text"));
229 caseNumberLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
230 caseNumberLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
231 gridBagConstraints =
new java.awt.GridBagConstraints();
232 gridBagConstraints.gridx = 0;
233 gridBagConstraints.gridy = 2;
234 gridBagConstraints.gridwidth = 4;
235 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
236 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
237 gridBagConstraints.weightx = 0.1;
238 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
239 caseInfoPanel.add(caseNumberLabel, gridBagConstraints);
241 org.openide.awt.Mnemonics.setLocalizedText(examinerEmailLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerEmailLabel.text"));
242 examinerEmailLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
243 examinerEmailLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
244 gridBagConstraints =
new java.awt.GridBagConstraints();
245 gridBagConstraints.gridx = 0;
246 gridBagConstraints.gridy = 4;
247 gridBagConstraints.gridwidth = 4;
248 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
249 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
250 gridBagConstraints.weightx = 0.1;
251 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
252 caseInfoPanel.add(examinerEmailLabel, gridBagConstraints);
254 org.openide.awt.Mnemonics.setLocalizedText(examinerNameLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerNameLabel.text"));
255 examinerNameLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
256 examinerNameLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
257 gridBagConstraints =
new java.awt.GridBagConstraints();
258 gridBagConstraints.gridx = 0;
259 gridBagConstraints.gridy = 3;
260 gridBagConstraints.gridwidth = 4;
261 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
262 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
263 gridBagConstraints.weightx = 0.1;
264 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
265 caseInfoPanel.add(examinerNameLabel, gridBagConstraints);
267 org.openide.awt.Mnemonics.setLocalizedText(examinerPhoneLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerPhoneLabel.text"));
268 examinerPhoneLabel.setMaximumSize(
new java.awt.Dimension(237, 16));
269 examinerPhoneLabel.setPreferredSize(
new java.awt.Dimension(130, 16));
270 gridBagConstraints =
new java.awt.GridBagConstraints();
271 gridBagConstraints.gridx = 0;
272 gridBagConstraints.gridy = 5;
273 gridBagConstraints.gridwidth = 4;
274 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
275 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
276 gridBagConstraints.weightx = 0.1;
277 gridBagConstraints.insets =
new java.awt.Insets(7, 18, 0, 0);
278 caseInfoPanel.add(examinerPhoneLabel, gridBagConstraints);
279 gridBagConstraints =
new java.awt.GridBagConstraints();
280 gridBagConstraints.gridx = 4;
281 gridBagConstraints.gridy = 1;
282 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
283 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
284 gridBagConstraints.insets =
new java.awt.Insets(7, 7, 0, 12);
285 caseInfoPanel.add(orgValueLabel, gridBagConstraints);
286 gridBagConstraints =
new java.awt.GridBagConstraints();
287 gridBagConstraints.gridx = 4;
288 gridBagConstraints.gridy = 2;
289 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
290 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
291 gridBagConstraints.insets =
new java.awt.Insets(7, 7, 0, 12);
292 caseInfoPanel.add(caseNumberValueLabel, gridBagConstraints);
293 gridBagConstraints =
new java.awt.GridBagConstraints();
294 gridBagConstraints.gridx = 4;
295 gridBagConstraints.gridy = 3;
296 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
297 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
298 gridBagConstraints.insets =
new java.awt.Insets(7, 6, 0, 12);
299 caseInfoPanel.add(examinerNameValueLabel, gridBagConstraints);
300 gridBagConstraints =
new java.awt.GridBagConstraints();
301 gridBagConstraints.gridx = 4;
302 gridBagConstraints.gridy = 4;
303 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
304 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
305 gridBagConstraints.insets =
new java.awt.Insets(9, 6, 0, 12);
306 caseInfoPanel.add(examinerEmailValueLabel, gridBagConstraints);
307 gridBagConstraints =
new java.awt.GridBagConstraints();
308 gridBagConstraints.gridx = 4;
309 gridBagConstraints.gridy = 5;
310 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
311 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
312 gridBagConstraints.insets =
new java.awt.Insets(7, 6, 0, 12);
313 caseInfoPanel.add(examinerPhoneValueLabel, gridBagConstraints);
315 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.closeButton.text"));
316 closeButton.setMaximumSize(
new java.awt.Dimension(140, 23));
317 closeButton.setMinimumSize(
new java.awt.Dimension(65, 23));
318 closeButton.setPreferredSize(
new java.awt.Dimension(90, 23));
319 closeButton.addActionListener(
new java.awt.event.ActionListener() {
320 public void actionPerformed(java.awt.event.ActionEvent evt) {
321 closeButtonActionPerformed(evt);
324 gridBagConstraints =
new java.awt.GridBagConstraints();
325 gridBagConstraints.gridx = 4;
326 gridBagConstraints.gridy = 10;
327 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
328 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
329 gridBagConstraints.insets =
new java.awt.Insets(7, 285, 13, 12);
330 caseInfoPanel.add(closeButton, gridBagConstraints);
331 gridBagConstraints =
new java.awt.GridBagConstraints();
332 gridBagConstraints.gridx = 0;
333 gridBagConstraints.gridy = 10;
334 gridBagConstraints.gridwidth = 4;
335 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
336 gridBagConstraints.weightx = 1.0;
337 caseInfoPanel.add(filler1, gridBagConstraints);
339 casesSplitPane.setRightComponent(caseInfoPanel);
341 casesTable.setAutoCreateRowSorter(
true);
342 casesTable.setModel(casesTableModel);
343 casesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
344 casesScrollPane.setViewportView(casesTable);
346 javax.swing.GroupLayout casesPanelLayout =
new javax.swing.GroupLayout(casesPanel);
347 casesPanel.setLayout(casesPanelLayout);
348 casesPanelLayout.setHorizontalGroup(
349 casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
350 .addGroup(casesPanelLayout.createSequentialGroup()
351 .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
354 casesPanelLayout.setVerticalGroup(
355 casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
356 .addGroup(casesPanelLayout.createSequentialGroup()
357 .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
361 casesSplitPane.setLeftComponent(casesPanel);
363 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
364 getContentPane().setLayout(layout);
365 layout.setHorizontalGroup(
366 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
367 .addComponent(casesSplitPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)
369 layout.setVerticalGroup(
370 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
371 .addComponent(casesSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 570, Short.MAX_VALUE)
377 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
384 private void updateSelection() {
385 dataSourcesTableModel.clearTable();
386 if (casesTable.getSelectedRow() >= 0 && casesTable.getSelectedRow() < casesTable.getRowCount()) {
387 CaseDataSourcesWrapper caseWrapper = casesTableModel.getEamCase(casesTable.convertRowIndexToModel(casesTable.getSelectedRow()));
388 orgValueLabel.setText(caseWrapper.getOrganizationName());
389 caseNumberValueLabel.setText(caseWrapper.getCaseNumber());
390 examinerNameValueLabel.setText(caseWrapper.getExaminerName());
391 examinerPhoneValueLabel.setText(caseWrapper.getExaminerPhone());
392 examinerEmailValueLabel.setText(caseWrapper.getExaminerEmail());
393 notesTextArea.setText(caseWrapper.getNotes());
394 dataSourcesTableModel.addDataSources(caseWrapper.getDataSources());
396 orgValueLabel.setText(
"");
397 caseNumberValueLabel.setText(
"");
398 examinerNameValueLabel.setText(
"");
399 examinerPhoneValueLabel.setText(
"");
400 examinerEmailValueLabel.setText(
"");
401 notesTextArea.setText(
"");
406 private javax.swing.JLabel caseInfoLabel;
407 private javax.swing.JPanel caseInfoPanel;
408 private javax.swing.JLabel caseNumberLabel;
409 private javax.swing.JLabel caseNumberValueLabel;
410 private javax.swing.JPanel casesPanel;
411 private javax.swing.JScrollPane casesScrollPane;
412 private javax.swing.JSplitPane casesSplitPane;
413 private javax.swing.JTable casesTable;
414 private javax.swing.JButton closeButton;
415 private javax.swing.JLabel dataSourcesLabel;
416 private javax.swing.JScrollPane dataSourcesScrollPane;
417 private javax.swing.JTable dataSourcesTable;
418 private javax.swing.JLabel examinerEmailLabel;
419 private javax.swing.JLabel examinerEmailValueLabel;
420 private javax.swing.JLabel examinerNameLabel;
421 private javax.swing.JLabel examinerNameValueLabel;
422 private javax.swing.JLabel examinerPhoneLabel;
423 private javax.swing.JLabel examinerPhoneValueLabel;
424 private javax.swing.JLabel notesLabel;
425 private javax.swing.JScrollPane notesScrollPane;
426 private javax.swing.JTextArea notesTextArea;
427 private javax.swing.JLabel orgLabel;
428 private javax.swing.JLabel orgValueLabel;