Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CasesTableModel.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 */
19package org.sleuthkit.autopsy.centralrepository.optionspanel;
20
21import java.util.ArrayList;
22import java.util.List;
23import javax.swing.table.AbstractTableModel;
24import org.openide.util.NbBundle.Messages;
25import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase;
26import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource;
27
31class CasesTableModel extends AbstractTableModel {
32
33 private static final long serialVersionUID = 1L;
34
38 private final List<CaseDataSourcesWrapper> eamCases;
39
43 CasesTableModel() {
44 eamCases = new ArrayList<>();
45 }
46
47 @Override
48 public int getColumnCount() {
49 return CaseTableColumns.values().length;
50 }
51
52 @Override
53 public int getRowCount() {
54 return eamCases.size();
55 }
56
57 @Override
58 public String getColumnName(int colIdx) {
59 return CaseTableColumns.values()[colIdx].columnName();
60 }
61
62 @Override
63 public Object getValueAt(int rowIdx, int colIdx) {
64 if (eamCases.isEmpty()) {
65 return Bundle.CasesTableModel_noData();
66 }
67
68 return mapValueById(rowIdx, CaseTableColumns.values()[colIdx]);
69 }
70
79 @Messages({"CasesTableModel.noData=No Cases"})
80 private Object mapValueById(int rowIdx, CaseTableColumns colId) {
81 CaseDataSourcesWrapper eamCase = eamCases.get(rowIdx);
82 String value = Bundle.CasesTableModel_noData();
83
84 switch (colId) {
85 case CASE_NAME:
86 value = eamCase.getDisplayName();
87 break;
88 case CREATION_DATE:
89 value = eamCase.getCreationDate();
90 break;
91 default:
92 break;
93 }
94 return value;
95 }
96
97 @Override
98 public Class<String> getColumnClass(int colIdx) {
99 return String.class;
100 }
101
107 void addEamCase(CorrelationCase eamCase, List<CorrelationDataSource> dataSourceList) {
108 eamCases.add(new CaseDataSourcesWrapper(eamCase, dataSourceList));
109 fireTableDataChanged();
110 }
111
121 CaseDataSourcesWrapper getEamCase(int listIndex) {
122 return eamCases.get(listIndex);
123 }
124
128 @Messages({"CasesTableModel.case=Case Name",
129 "CasesTableModel.creationDate=Creation Date"})
130 private enum CaseTableColumns {
131 // Ordering here determines displayed column order in Content Viewer.
132 // If order is changed, update the CellRenderer to ensure correct row coloring.
133 CASE_NAME(Bundle.CasesTableModel_case()),
134 CREATION_DATE(Bundle.CasesTableModel_creationDate());
135
136 private final String columnName;
137
144 this.columnName = columnName;
145 }
146
152 String columnName() {
153 return columnName;
154 }
155 }
156}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.