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;
34 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 EamDb dbManager = EamDb.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 (EamDbException 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() {
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();
128 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
129 setMinimumSize(
new java.awt.Dimension(400, 400));
131 casesSplitPane.setDividerLocation(380);
133 dataSourcesTable.setAutoCreateRowSorter(
true);
134 dataSourcesTable.setModel(dataSourcesTableModel);
135 dataSourcesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
136 dataSourcesScrollPane.setViewportView(dataSourcesTable);
138 notesScrollPane.setBorder(null);
140 notesTextArea.setEditable(
false);
141 notesTextArea.setBackground(
new java.awt.Color(240, 240, 240));
142 notesTextArea.setColumns(20);
143 notesTextArea.setFont(
new java.awt.Font(
"Tahoma", 0, 11));
144 notesTextArea.setLineWrap(
true);
145 notesTextArea.setRows(3);
146 notesTextArea.setWrapStyleWord(
true);
147 notesTextArea.setBorder(null);
148 notesScrollPane.setViewportView(notesTextArea);
150 org.openide.awt.Mnemonics.setLocalizedText(caseInfoLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseInfoLabel.text"));
152 org.openide.awt.Mnemonics.setLocalizedText(dataSourcesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.dataSourcesLabel.text"));
154 org.openide.awt.Mnemonics.setLocalizedText(notesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.notesLabel.text"));
156 org.openide.awt.Mnemonics.setLocalizedText(orgLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.orgLabel.text"));
158 org.openide.awt.Mnemonics.setLocalizedText(caseNumberLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseNumberLabel.text"));
160 org.openide.awt.Mnemonics.setLocalizedText(examinerEmailLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerEmailLabel.text"));
162 org.openide.awt.Mnemonics.setLocalizedText(examinerNameLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerNameLabel.text"));
164 org.openide.awt.Mnemonics.setLocalizedText(examinerPhoneLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerPhoneLabel.text"));
166 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.closeButton.text"));
167 closeButton.setMaximumSize(
new java.awt.Dimension(65, 23));
168 closeButton.setMinimumSize(
new java.awt.Dimension(65, 23));
169 closeButton.setPreferredSize(
new java.awt.Dimension(65, 23));
170 closeButton.addActionListener(
new java.awt.event.ActionListener() {
171 public void actionPerformed(java.awt.event.ActionEvent evt) {
172 closeButtonActionPerformed(evt);
176 javax.swing.GroupLayout caseInfoPanelLayout =
new javax.swing.GroupLayout(caseInfoPanel);
177 caseInfoPanel.setLayout(caseInfoPanelLayout);
178 caseInfoPanelLayout.setHorizontalGroup(
179 caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180 .addGroup(caseInfoPanelLayout.createSequentialGroup()
182 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
183 .addGroup(caseInfoPanelLayout.createSequentialGroup()
185 .addComponent(dataSourcesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
186 .addGroup(caseInfoPanelLayout.createSequentialGroup()
188 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189 .addGroup(caseInfoPanelLayout.createSequentialGroup()
190 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
191 .addComponent(orgLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
192 .addComponent(caseNumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
193 .addComponent(examinerNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
194 .addComponent(examinerEmailLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
195 .addComponent(examinerPhoneLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
196 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
197 .addGroup(caseInfoPanelLayout.createSequentialGroup()
198 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addComponent(caseNumberValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
201 .addComponent(orgValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
202 .addGroup(caseInfoPanelLayout.createSequentialGroup()
204 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205 .addComponent(examinerNameValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
206 .addComponent(examinerEmailValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
207 .addComponent(examinerPhoneValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
208 .addComponent(notesLabel)
209 .addGroup(caseInfoPanelLayout.createSequentialGroup()
211 .addComponent(notesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))))
212 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caseInfoPanelLayout.createSequentialGroup()
213 .addGap(0, 0, Short.MAX_VALUE)
214 .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
215 .addGroup(caseInfoPanelLayout.createSequentialGroup()
216 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217 .addComponent(caseInfoLabel)
218 .addComponent(dataSourcesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
219 .addGap(0, 0, Short.MAX_VALUE)))
222 caseInfoPanelLayout.setVerticalGroup(
223 caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caseInfoPanelLayout.createSequentialGroup()
226 .addComponent(caseInfoLabel)
227 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
229 .addGroup(caseInfoPanelLayout.createSequentialGroup()
230 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
231 .addGroup(caseInfoPanelLayout.createSequentialGroup()
232 .addComponent(orgLabel)
233 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
234 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
235 .addComponent(caseNumberLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
236 .addComponent(caseNumberValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
237 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
239 .addComponent(examinerNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
240 .addComponent(examinerNameValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
241 .addComponent(orgValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
242 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243 .addComponent(examinerEmailLabel))
244 .addComponent(examinerEmailValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
245 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247 .addComponent(examinerPhoneLabel)
248 .addComponent(examinerPhoneValueLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
249 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250 .addComponent(notesLabel)
251 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
252 .addComponent(notesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
253 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
254 .addComponent(dataSourcesLabel)
255 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256 .addComponent(dataSourcesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
257 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258 .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
262 casesSplitPane.setRightComponent(caseInfoPanel);
264 casesTable.setAutoCreateRowSorter(
true);
265 casesTable.setModel(casesTableModel);
266 casesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
267 casesScrollPane.setViewportView(casesTable);
269 javax.swing.GroupLayout casesPanelLayout =
new javax.swing.GroupLayout(casesPanel);
270 casesPanel.setLayout(casesPanelLayout);
271 casesPanelLayout.setHorizontalGroup(
272 casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
273 .addGroup(casesPanelLayout.createSequentialGroup()
274 .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
277 casesPanelLayout.setVerticalGroup(
278 casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
279 .addGroup(casesPanelLayout.createSequentialGroup()
280 .addComponent(casesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
284 casesSplitPane.setLeftComponent(casesPanel);
286 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
287 getContentPane().setLayout(layout);
288 layout.setHorizontalGroup(
289 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
290 .addComponent(casesSplitPane, javax.swing.GroupLayout.Alignment.TRAILING)
292 layout.setVerticalGroup(
293 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294 .addComponent(casesSplitPane)
300 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
307 private void updateSelection() {
308 dataSourcesTableModel.clearTable();
309 if (casesTable.getSelectedRow() >= 0 && casesTable.getSelectedRow() < casesTable.getRowCount()) {
310 CaseDataSourcesWrapper caseWrapper = casesTableModel.getEamCase(casesTable.convertRowIndexToModel(casesTable.getSelectedRow()));
311 orgValueLabel.setText(caseWrapper.getOrganizationName());
312 caseNumberValueLabel.setText(caseWrapper.getCaseNumber());
313 examinerNameValueLabel.setText(caseWrapper.getExaminerName());
314 examinerPhoneValueLabel.setText(caseWrapper.getExaminerPhone());
315 examinerEmailValueLabel.setText(caseWrapper.getExaminerEmail());
316 notesTextArea.setText(caseWrapper.getNotes());
317 dataSourcesTableModel.addDataSources(caseWrapper.getDataSources());
319 orgValueLabel.setText(
"");
320 caseNumberValueLabel.setText(
"");
321 examinerNameValueLabel.setText(
"");
322 examinerPhoneValueLabel.setText(
"");
323 examinerEmailValueLabel.setText(
"");
324 notesTextArea.setText(
"");
329 private javax.swing.JLabel caseInfoLabel;
330 private javax.swing.JPanel caseInfoPanel;
331 private javax.swing.JLabel caseNumberLabel;
332 private javax.swing.JLabel caseNumberValueLabel;
333 private javax.swing.JPanel casesPanel;
334 private javax.swing.JScrollPane casesScrollPane;
335 private javax.swing.JSplitPane casesSplitPane;
336 private javax.swing.JTable casesTable;
337 private javax.swing.JButton closeButton;
338 private javax.swing.JLabel dataSourcesLabel;
339 private javax.swing.JScrollPane dataSourcesScrollPane;
340 private javax.swing.JTable dataSourcesTable;
341 private javax.swing.JLabel examinerEmailLabel;
342 private javax.swing.JLabel examinerEmailValueLabel;
343 private javax.swing.JLabel examinerNameLabel;
344 private javax.swing.JLabel examinerNameValueLabel;
345 private javax.swing.JLabel examinerPhoneLabel;
346 private javax.swing.JLabel examinerPhoneValueLabel;
347 private javax.swing.JLabel notesLabel;
348 private javax.swing.JScrollPane notesScrollPane;
349 private javax.swing.JTextArea notesTextArea;
350 private javax.swing.JLabel orgLabel;
351 private javax.swing.JLabel orgValueLabel;