Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ShowCasesTableModel.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.List;
23 import javax.swing.table.AbstractTableModel;
24 import org.openide.util.NbBundle.Messages;
26 
30 class ShowCasesTableModel extends AbstractTableModel {
31 
32  private static final long serialVersionUID = 1L;
33 
34  @Messages({"ShowCasesTableModel.case=Case Name",
35  "ShowCasesTableModel.creationDate=Creation Date",
36  "ShowCasesTableModel.caseNumber=Case Number",
37  "ShowCasesTableModel.examinerName=Examiner Name",
38  "ShowCasesTableModel.examinerEmail=Examiner Email",
39  "ShowCasesTableModel.examinerPhone=Examiner Phone",
40  "ShowCasesTableModel.notes=Notes",
41  "ShowCasesTableModel.noData=No Cases"})
45  enum TableColumns {
46  // Ordering here determines displayed column order in Content Viewer.
47  // If order is changed, update the CellRenderer to ensure correct row coloring.
48  CASE_NAME(Bundle.ShowCasesTableModel_case(), 200),
49  CREATION_DATE(Bundle.ShowCasesTableModel_creationDate(), 150),
50  CASE_NUMBER(Bundle.ShowCasesTableModel_caseNumber(), 100),
51  EXAMINER_NAME(Bundle.ShowCasesTableModel_examinerName(), 200),
52  EXAMINER_EMAIL(Bundle.ShowCasesTableModel_examinerEmail(), 100),
53  EXAMINER_PHONE(Bundle.ShowCasesTableModel_examinerPhone(), 100),
54  NOTES(Bundle.ShowCasesTableModel_notes(), 450);
55 
56  private final String columnName;
57  private final int columnWidth;
58 
59  TableColumns(String columnName, int columnWidth) {
60  this.columnName = columnName;
61  this.columnWidth = columnWidth;
62  }
63 
64  String columnName() {
65  return columnName;
66  }
67 
68  int columnWidth() {
69  return columnWidth;
70  }
71  };
72 
76  private List<CorrelationCase> eamCases;
77 
78  ShowCasesTableModel() {
79  eamCases = new ArrayList<>();
80  }
81 
82  @Override
83  public int getColumnCount() {
84  return TableColumns.values().length;
85  }
86 
97  int getColumnPreferredWidth(int colIdx) {
98  return TableColumns.values()[colIdx].columnWidth();
99  }
100 
101  @Override
102  public int getRowCount() {
103  return eamCases.size();
104  }
105 
106  @Override
107  public String getColumnName(int colIdx) {
108  return TableColumns.values()[colIdx].columnName();
109  }
110 
111  @Override
112  public Object getValueAt(int rowIdx, int colIdx) {
113  if (eamCases.isEmpty()) {
114  return Bundle.ShowCasesTableModel_noData();
115  }
116 
117  return mapValueById(rowIdx, TableColumns.values()[colIdx]);
118  }
119 
120  Object getRow(int rowIdx) {
121  return eamCases.get(rowIdx);
122  }
123 
132  private Object mapValueById(int rowIdx, TableColumns colId) {
133  CorrelationCase eamCase = eamCases.get(rowIdx);
134  String value = Bundle.ShowCasesTableModel_noData();
135 
136  switch (colId) {
137  case CASE_NAME:
138  value = eamCase.getDisplayName();
139  break;
140  case CREATION_DATE:
141  value = eamCase.getCreationDate();
142  break;
143  case CASE_NUMBER:
144  value = eamCase.getCaseNumber();
145  break;
146  case EXAMINER_NAME:
147  value = eamCase.getExaminerName();
148  break;
149  case EXAMINER_EMAIL:
150  value = eamCase.getExaminerEmail();
151  break;
152  case EXAMINER_PHONE:
153  value = eamCase.getExaminerPhone();
154  break;
155  case NOTES:
156  value = eamCase.getNotes();
157  break;
158  default:
159  break;
160  }
161  return value;
162  }
163 
164  @Override
165  public Class<String> getColumnClass(int colIdx) {
166  return String.class;
167  }
168 
175  void addEamCase(CorrelationCase eamCase) {
176  eamCases.add(eamCase);
177  fireTableDataChanged();
178  }
179 
180  void clearTable() {
181  eamCases.clear();
182  fireTableDataChanged();
183  }
184 
185 
186 
187 }

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.