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() {
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.setLineWrap(
true);
144 notesTextArea.setRows(3);
145 notesTextArea.setWrapStyleWord(
true);
146 notesTextArea.setBorder(null);
147 notesScrollPane.setViewportView(notesTextArea);
149 org.openide.awt.Mnemonics.setLocalizedText(caseInfoLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseInfoLabel.text"));
151 org.openide.awt.Mnemonics.setLocalizedText(dataSourcesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.dataSourcesLabel.text"));
153 org.openide.awt.Mnemonics.setLocalizedText(notesLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.notesLabel.text"));
155 org.openide.awt.Mnemonics.setLocalizedText(orgLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.orgLabel.text"));
157 org.openide.awt.Mnemonics.setLocalizedText(caseNumberLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.caseNumberLabel.text"));
159 org.openide.awt.Mnemonics.setLocalizedText(examinerEmailLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerEmailLabel.text"));
161 org.openide.awt.Mnemonics.setLocalizedText(examinerNameLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerNameLabel.text"));
163 org.openide.awt.Mnemonics.setLocalizedText(examinerPhoneLabel,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.examinerPhoneLabel.text"));
165 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(ManageCasesDialog.class,
"ManageCasesDialog.closeButton.text"));
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);
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()
181 .addGroup(caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
182 .addGroup(caseInfoPanelLayout.createSequentialGroup()
184 .addComponent(dataSourcesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
185 .addGroup(caseInfoPanelLayout.createSequentialGroup()
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()
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()
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)))
221 caseInfoPanelLayout.setVerticalGroup(
222 caseInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caseInfoPanelLayout.createSequentialGroup()
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)
261 casesSplitPane.setRightComponent(caseInfoPanel);
263 casesTable.setAutoCreateRowSorter(
true);
264 casesTable.setModel(casesTableModel);
265 casesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
266 casesScrollPane.setViewportView(casesTable);
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)
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)
283 casesSplitPane.setLeftComponent(casesPanel);
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)
291 layout.setVerticalGroup(
292 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
293 .addComponent(casesSplitPane)
299 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
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());
318 orgValueLabel.setText(
"");
319 caseNumberValueLabel.setText(
"");
320 examinerNameValueLabel.setText(
"");
321 examinerPhoneValueLabel.setText(
"");
322 examinerEmailValueLabel.setText(
"");
323 notesTextArea.setText(
"");
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;