Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExternalViewerGlobalSettingsTableModel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
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.directorytree;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import javax.swing.table.AbstractTableModel;
25 
30 class ExternalViewerGlobalSettingsTableModel extends AbstractTableModel {
31 
32  private final List<ExternalViewerRule> rules;
33  private final String[] columnNames;
34 
35  public ExternalViewerGlobalSettingsTableModel(String... columnNames) {
36  this.columnNames = Arrays.copyOf(columnNames, columnNames.length);
37  this.rules = new ArrayList<>();
38  }
39 
45  public void addRule(ExternalViewerRule rule) {
46  rules.add(rule);
47  fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
48  }
49 
55  @Override
56  public int getRowCount() {
57  return rules.size();
58  }
59 
67  @Override
68  public String getColumnName(int columnIndex) {
69  return columnNames[columnIndex];
70  }
71 
79  @Override
80  public Class<String> getColumnClass(int columnIndex) {
81  return String.class;
82  }
83 
89  @Override
90  public int getColumnCount() {
91  return columnNames.length;
92  }
93 
102  @Override
103  public Object getValueAt(int rowIndex, int columnIndex) {
104  if (columnIndex == 0) {
105  return rules.get(rowIndex).getName();
106  } else {
107  return rules.get(rowIndex).getExePath();
108  }
109  }
110 
118  public ExternalViewerRule getRuleAt(int rowIndex) {
119  return rules.get(rowIndex);
120  }
121 
128  public void setRule(int rowIndex, ExternalViewerRule rule) {
129  rules.set(rowIndex, rule);
130  fireTableDataChanged();
131  }
132 
138  public void removeRule(int rowIndex) {
139  rules.remove(rowIndex);
140  fireTableDataChanged();
141  }
142 
151  @Override
152  public boolean isCellEditable(int rowIndex, int colIndex) {
153  return false;
154  }
155 
163  public boolean containsRule(ExternalViewerRule rule) {
164  return rules.contains(rule);
165  }
166 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.