19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Observable;
24 import java.util.Observer;
25 import java.util.TreeMap;
26 import javax.swing.JTable;
27 import javax.swing.table.AbstractTableModel;
28 import javax.swing.table.TableColumn;
35 final class FilesIdentifierIngestJobSettingsPanel
extends IngestModuleIngestJobSettingsPanel implements Observer {
37 private final FilesSetsTableModel tableModel;
42 private TreeMap<String, FilesSet> filesSetSnapshot;
51 static FilesIdentifierIngestJobSettingsPanel makePanel(FilesIdentifierIngestJobSettings settings) {
52 FilesIdentifierIngestJobSettingsPanel panel =
new FilesIdentifierIngestJobSettingsPanel(settings);
58 InterestingItemDefsManager.getInstance().addObserver(panel);
67 private FilesIdentifierIngestJobSettingsPanel(FilesIdentifierIngestJobSettings settings) {
76 List<FilesSetRow> filesSetRows =
new ArrayList<>();
77 this.filesSetSnapshot =
new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
78 for (FilesSet set : this.filesSetSnapshot.values()) {
79 filesSetRows.add(
new FilesSetRow(set, settings.interestingFilesSetIsEnabled(set.getName())));
83 this.tableModel =
new FilesSetsTableModel(filesSetRows);
88 this.filesSetTable.setModel(tableModel);
89 this.filesSetTable.setTableHeader(null);
90 this.filesSetTable.setRowSelectionAllowed(
false);
91 final int width = this.filesSetScrollPane.getPreferredSize().width;
92 this.filesSetTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
94 for (
int i = 0; i < this.filesSetTable.getColumnCount(); i++) {
95 column = this.filesSetTable.getColumnModel().getColumn(i);
97 column.setPreferredWidth(((
int) (width * 0.07)));
99 column.setPreferredWidth(((
int) (width * 0.92)));
108 public IngestModuleIngestJobSettings getSettings() {
109 List<String> enabledInterestingFilesSets =
new ArrayList<>();
110 List<String> disabledInterestingFilesSets =
new ArrayList<>();
111 for (FilesSetRow rowModel : this.tableModel.filesSetRows) {
112 if (rowModel.isEnabled()) {
113 enabledInterestingFilesSets.add(rowModel.getFilesSet().getName());
115 disabledInterestingFilesSets.add(rowModel.getFilesSet().getName());
118 return new FilesIdentifierIngestJobSettings(enabledInterestingFilesSets, disabledInterestingFilesSets);
125 public void update(Observable o, Object arg
128 FilesIdentifierIngestJobSettings settings = (FilesIdentifierIngestJobSettings) this.getSettings();
131 List<FilesSetRow> rowModels =
new ArrayList<>();
132 TreeMap<String, FilesSet> newFilesSetSnapshot =
new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
133 for (FilesSet set : newFilesSetSnapshot.values()) {
134 if (this.filesSetSnapshot.keySet().contains(set.getName())) {
136 rowModels.add(
new FilesSetRow(set, settings.interestingFilesSetIsEnabled(set.getName())));
139 rowModels.add(
new FilesSetRow(set,
true));
142 this.tableModel.resetTableData(rowModels);
145 this.filesSetSnapshot = newFilesSetSnapshot;
174 void resetTableData(List<FilesSetRow> filesSetRows) {
176 this.fireTableDataChanged();
184 return this.filesSetRows.size();
200 if (columnIndex == 0) {
201 return this.filesSetRows.get(rowIndex).isEnabled();
203 return this.filesSetRows.get(rowIndex).getFilesSet().getName();
212 return (columnIndex == 0);
219 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
220 if (columnIndex == 0) {
221 this.filesSetRows.get(rowIndex).setEnabled((Boolean) aValue);
239 private final FilesSet
set;
247 FilesSet getFilesSet() {
251 boolean isEnabled() {
255 void setEnabled(
boolean enabled) {
265 @SuppressWarnings(
"unchecked")
267 private
void initComponents() {
269 filesSetScrollPane =
new javax.swing.JScrollPane();
270 filesSetTable =
new javax.swing.JTable();
272 setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(FilesIdentifierIngestJobSettingsPanel.class,
"FilesIdentifierIngestJobSettingsPanel.border.title")));
274 filesSetTable.setBackground(
new java.awt.Color(240, 240, 240));
275 filesSetTable.setModel(
new javax.swing.table.DefaultTableModel(
283 filesSetTable.setShowHorizontalLines(
false);
284 filesSetTable.setShowVerticalLines(
false);
285 filesSetScrollPane.setViewportView(filesSetTable);
287 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
288 this.setLayout(layout);
289 layout.setHorizontalGroup(
290 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
291 .addGroup(layout.createSequentialGroup()
293 .addComponent(filesSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
296 layout.setVerticalGroup(
297 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
298 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
300 .addComponent(filesSetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
307 private javax.swing.JScrollPane filesSetScrollPane;
308 private javax.swing.JTable filesSetTable;
Class<?> getColumnClass(int c)
Object getValueAt(int rowIndex, int columnIndex)
boolean isCellEditable(int rowIndex, int columnIndex)
List< FilesSetRow > filesSetRows
void setValueAt(Object aValue, int rowIndex, int columnIndex)