From baeb53bf0ca40f46b264e48364f08a80d4c74130 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 6 Nov 2018 15:05:54 -0500 Subject: [PATCH] Got the settings panel to work --- .../case_uco/DataSourceComboBoxModel.java | 2 +- .../modules/case_uco/ReportCaseUco.java | 7 +- .../case_uco/ReportCaseUcoConfigPanel.form | 2 +- .../case_uco/ReportCaseUcoConfigPanel.java | 67 +++++++++---------- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java index 34fcdb3966..48dd3eab1b 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java @@ -26,7 +26,7 @@ import javax.swing.event.ListDataListener; /** * Encapsulates meta data needed to populate the data source selection drop down menu */ -public class DataSourceComboBoxModel extends AbstractListModel implements ComboBoxModel { +class DataSourceComboBoxModel extends AbstractListModel implements ComboBoxModel { private static final long serialVersionUID = 1L; private final String[] dataSourceList; diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java index 35b3c71b91..048aeb7821 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java @@ -93,6 +93,8 @@ class ReportCaseUco implements GeneralReportModule { progressPanel.start(); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.initializing")); + Long selectedDataSourceId = configPanel.getSelectedDataSourceId(); + // Create the JSON generator JsonFactory jsonGeneratorFactory = new JsonFactory(); String reportPath = baseReportDir + getRelativeFilePath(); //NON-NLS @@ -118,9 +120,10 @@ class ReportCaseUco implements GeneralReportModule { progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.querying")); // exclude non-fs files/dirs and . and .. files final String query = "select obj_id, name, size, crtime, atime, mtime, md5, parent_path, mime_type, extension from tsk_files where " - + "(meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_UNDEF.getValue() + + "data_source_obj_id = " + Long.toString(selectedDataSourceId) + + " AND ((meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_UNDEF.getValue() + ") OR (meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() - + ") OR (meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_VIRT.getValue() + ")"; //NON-NLS + + ") OR (meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_VIRT.getValue() + "))"; //NON-NLS progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportCaseUco.progress.loading")); diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form index f3fe980200..9bec50a37e 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form @@ -36,7 +36,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java index 756a25976a..2e2157caf1 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java @@ -19,13 +19,15 @@ */ package org.sleuthkit.autopsy.modules.case_uco; -import java.util.Collections; +import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.Observable; -import java.util.Observer; import javax.swing.ComboBoxModel; +import org.openide.util.Exceptions; +import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; +import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader; +import org.sleuthkit.datamodel.TskCoreException; /** * UI controls for Common Files Search scenario where the user intends to find @@ -33,49 +35,40 @@ import javax.swing.ComboBoxModel; * ability to select all datasources or a single datasource from a dropdown list * of sources in the current case. */ -public final class ReportCaseUcoConfigPanel extends javax.swing.JPanel { +final class ReportCaseUcoConfigPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; static final long NO_DATA_SOURCE_SELECTED = -1; - private final Observable fileTypeFilterObservable; private ComboBoxModel dataSourcesList = new DataSourceComboBoxModel(); - private final Map dataSourceMap; + private Map dataSourceMap; + private final DataSourceLoader dataSourceLoader; /** * Creates new form IntraCasePanel */ - public ReportCaseUcoConfigPanel() { + ReportCaseUcoConfigPanel() { initComponents(); - this.dataSourceMap = new HashMap<>(); - fileTypeFilterObservable = new Observable() { - @Override - public void notifyObservers() { - //set changed before notify observers - //we want this observerable to always cause the observer to update when notified - this.setChanged(); - super.notifyObservers(); + this.dataSourceLoader = new DataSourceLoader(); + try { + this.dataSourceMap = dataSourceLoader.getDataSourceMap(); + } catch (NoCurrentCaseException | TskCoreException | SQLException ex) { + Exceptions.printStackTrace(ex); + this.dataSourceMap = new HashMap<>(); + selectDataSourceComboBox.setEnabled(false); + return; + } + + String[] dataSourcesNames = new String[dataSourceMap.size()]; + if (dataSourcesNames.length > 0) { + dataSourcesNames = dataSourceMap.values().toArray(dataSourcesNames); + setDatasourceComboboxModel(new DataSourceComboBoxModel(dataSourcesNames)); + //setDataSourceMap(dataSourceMap); + + selectDataSourceComboBox.setEnabled(true); + if (selectDataSourceComboBox.isEnabled()) { + selectDataSourceComboBox.setSelectedIndex(0); } - }; - } - - /** - * Add an Observer to the Observable portion of this panel so that it can be - * notified of changes to this panel. - * - * @param observer the object which is observing this panel - */ - void addObserver(Observer observer) { - fileTypeFilterObservable.addObserver(observer); - } - - /** - * Get the map of datasources which was used to populate the combo box on - * this panel. - * - * @return an unmodifiable copy of the map of datasources - */ - Map getDataSourceMap() { - return Collections.unmodifiableMap(this.dataSourceMap); + } } /** @@ -130,7 +123,7 @@ public final class ReportCaseUcoConfigPanel extends javax.swing.JPanel { .addComponent(jLabelSelectDataSource) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(172, 172, 172)) + .addContainerGap(130, Short.MAX_VALUE)) ); }// //GEN-END:initComponents