Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataContentViewerOtherCasesTableModel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2017 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;
27 
31 public class DataContentViewerOtherCasesTableModel extends AbstractTableModel {
32 
33  @Messages({"DataContentViewerOtherCasesTableModel.case=Case",
34  "DataContentViewerOtherCasesTableModel.device=Device",
35  "DataContentViewerOtherCasesTableModel.dataSource=Data Source",
36  "DataContentViewerOtherCasesTableModel.path=Path",
37  "DataContentViewerOtherCasesTableModel.type=Correlation Type",
38  "DataContentViewerOtherCasesTableModel.value=Correlation Value",
39  "DataContentViewerOtherCasesTableModel.known=Tagged",
40  "DataContentViewerOtherCasesTableModel.comment=Comment",
41  "DataContentViewerOtherCasesTableModel.noData=No Data.",})
42  enum TableColumns {
43  // Ordering here determines displayed column order in Content Viewer.
44  // If order is changed, update the CellRenderer to ensure correct row coloring.
45  CASE_NAME(Bundle.DataContentViewerOtherCasesTableModel_case(), 100),
46  DATA_SOURCE(Bundle.DataContentViewerOtherCasesTableModel_dataSource(), 100),
47  TYPE(Bundle.DataContentViewerOtherCasesTableModel_type(), 100),
48  VALUE(Bundle.DataContentViewerOtherCasesTableModel_value(), 200),
49  KNOWN(Bundle.DataContentViewerOtherCasesTableModel_known(), 50),
50  FILE_PATH(Bundle.DataContentViewerOtherCasesTableModel_path(), 450),
51  COMMENT(Bundle.DataContentViewerOtherCasesTableModel_comment(), 200),
52  DEVICE(Bundle.DataContentViewerOtherCasesTableModel_device(), 250);
53 
54  private final String columnName;
55  private final int columnWidth;
56 
57  TableColumns(String columnName, int columnWidth) {
58  this.columnName = columnName;
59  this.columnWidth = columnWidth;
60  }
61 
62  public String columnName() {
63  return columnName;
64  }
65 
66  public int columnWidth() {
67  return columnWidth;
68  }
69  };
70 
71  List<CorrelationAttribute> eamArtifacts;
72 
74  eamArtifacts = new ArrayList<>();
75  }
76 
77  @Override
78  public int getColumnCount() {
79  return TableColumns.values().length;
80  }
81 
92  public int getColumnPreferredWidth(int colIdx) {
93  return TableColumns.values()[colIdx].columnWidth();
94  }
95 
96  @Override
97  public int getRowCount() {
98  return eamArtifacts.size();
99  }
100 
101  @Override
102  public String getColumnName(int colIdx) {
103  return TableColumns.values()[colIdx].columnName();
104  }
105 
106  @Override
107  public Object getValueAt(int rowIdx, int colIdx) {
108  if (0 == eamArtifacts.size()) {
109  return Bundle.DataContentViewerOtherCasesTableModel_noData();
110  }
111 
112  return mapValueById(rowIdx, TableColumns.values()[colIdx]);
113  }
114 
115  public Object getRow(int rowIdx) {
116  return eamArtifacts.get(rowIdx);
117  }
118 
127  private Object mapValueById(int rowIdx, TableColumns colId) {
128  CorrelationAttribute eamArtifact = eamArtifacts.get(rowIdx);
129  CorrelationAttributeInstance eamArtifactInstance = eamArtifact.getInstances().get(0);
130  String value = Bundle.DataContentViewerOtherCasesTableModel_noData();
131 
132  switch (colId) {
133  case CASE_NAME:
134  if (null != eamArtifactInstance.getCorrelationCase()) {
135  value = eamArtifactInstance.getCorrelationCase().getDisplayName();
136  }
137  break;
138  case DEVICE:
139  if (null != eamArtifactInstance.getCorrelationDataSource()) {
140  value = eamArtifactInstance.getCorrelationDataSource().getDeviceID();
141  }
142  break;
143  case DATA_SOURCE:
144  if (null != eamArtifactInstance.getCorrelationDataSource()) {
145  value = eamArtifactInstance.getCorrelationDataSource().getName();
146  }
147  break;
148  case FILE_PATH:
149  value = eamArtifactInstance.getFilePath();
150  break;
151  case TYPE:
152  value = eamArtifact.getCorrelationType().getDisplayName();
153  break;
154  case VALUE:
155  value = eamArtifact.getCorrelationValue();
156  break;
157  case KNOWN:
158  value = eamArtifactInstance.getKnownStatus().getName();
159  break;
160  case COMMENT:
161  value = eamArtifactInstance.getComment();
162  break;
163  }
164  return value;
165  }
166 
167  @Override
168  public Class<String> getColumnClass(int colIdx) {
169  return String.class;
170  }
171 
178  public void addEamArtifact(CorrelationAttribute eamArtifact) {
179  eamArtifacts.add(eamArtifact);
180  fireTableDataChanged();
181  }
182 
183  public void clearTable() {
184  eamArtifacts.clear();
185  fireTableDataChanged();
186  }
187 
188 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.