Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OtherOccurrencesCasesTableModel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2019 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.contentviewer;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.table.AbstractTableModel;
24 import org.openide.util.NbBundle.Messages;
25 
30 public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
31 
32  private static final long serialVersionUID = 1L;
33  private final List<CorrelationCaseWrapper> correlationCaseList = new ArrayList<>();
34 
36  }
37 
38  @Override
39  public int getColumnCount() {
40  return TableColumns.values().length;
41  }
42 
53  public int getColumnPreferredWidth(int colIdx) {
54  return TableColumns.values()[colIdx].columnWidth();
55  }
56 
57  @Override
58  public int getRowCount() {
59  return correlationCaseList.size();
60  }
61 
62  @Override
63  public String getColumnName(int colIdx) {
64  return TableColumns.values()[colIdx].columnName();
65  }
66 
67  @Override
68  public Object getValueAt(int rowIdx, int colIdx) {
69  if (0 == correlationCaseList.size()) {
70  return Bundle.OtherOccurrencesCasesTableModel_noData();
71  }
72 
73  CorrelationCaseWrapper caseWrapper = correlationCaseList.get(rowIdx);
74  TableColumns columnId = TableColumns.values()[colIdx];
75  return mapCorrelationCase(caseWrapper, columnId);
76  }
77 
86  @Messages({"OtherOccurrencesCasesTableModel.noData=No Data."})
87  private Object mapCorrelationCase(CorrelationCaseWrapper correlationCaseWrapper, TableColumns columnId) {
88  String value = Bundle.OtherOccurrencesCasesTableModel_noData();
89 
90  switch (columnId) {
91  case CASE_NAME:
92  value = correlationCaseWrapper.getMessage();
93  break;
94  default: //Use default "No data" value.
95  break;
96  }
97  return value;
98  }
99 
100  Object getCorrelationCase(int rowIdx) {
101  return correlationCaseList.get(rowIdx).getCorrelationCase();
102  }
103 
104  @Override
105  public Class<String> getColumnClass(int colIdx) {
106  return String.class;
107  }
108 
114  void addCorrelationCase(CorrelationCaseWrapper newCorrelationCaseWrapper) {
115  correlationCaseList.add(newCorrelationCaseWrapper);
116  fireTableDataChanged();
117  }
118 
122  void clearTable() {
123  correlationCaseList.clear();
124  fireTableDataChanged();
125  }
126 
127  @Messages({"OtherOccurrencesCasesTableModel.case=Case",})
128  enum TableColumns {
129  // Ordering here determines displayed column order in Content Viewer.
130  // If order is changed, update the CellRenderer to ensure correct row coloring.
131  CASE_NAME(Bundle.OtherOccurrencesCasesTableModel_case(), 100);
132 
133  private final String columnName;
134  private final int columnWidth;
135 
136  TableColumns(String columnName, int columnWidth) {
137  this.columnName = columnName;
138  this.columnWidth = columnWidth;
139  }
140 
141  public String columnName() {
142  return columnName;
143  }
144 
145  public int columnWidth() {
146  return columnWidth;
147  }
148  }
149 }
Object mapCorrelationCase(CorrelationCaseWrapper correlationCaseWrapper, TableColumns columnId)

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.