19 package org.sleuthkit.autopsy.directorytree;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import javax.swing.table.AbstractTableModel;
30 class ExternalViewerGlobalSettingsTableModel
extends AbstractTableModel {
32 private final List<ExternalViewerRule> rules;
33 private final String[] columnNames;
35 public ExternalViewerGlobalSettingsTableModel(String... columnNames) {
36 this.columnNames = Arrays.copyOf(columnNames, columnNames.length);
37 this.rules =
new ArrayList<>();
45 public void addRule(ExternalViewerRule rule) {
47 fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
56 public int getRowCount() {
68 public String getColumnName(
int columnIndex) {
69 return columnNames[columnIndex];
80 public Class<String> getColumnClass(
int columnIndex) {
90 public int getColumnCount() {
91 return columnNames.length;
103 public Object getValueAt(
int rowIndex,
int columnIndex) {
104 if (columnIndex == 0) {
105 return rules.get(rowIndex).getName();
107 return rules.get(rowIndex).getExePath();
118 public ExternalViewerRule getRuleAt(
int rowIndex) {
119 return rules.get(rowIndex);
128 public void setRule(
int rowIndex, ExternalViewerRule rule) {
129 rules.set(rowIndex, rule);
130 fireTableDataChanged();
138 public void removeRule(
int rowIndex) {
139 rules.remove(rowIndex);
140 fireTableDataChanged();
152 public boolean isCellEditable(
int rowIndex,
int colIndex) {
163 public boolean containsRule(ExternalViewerRule rule) {
164 return rules.contains(rule);