Got the settings panel to work

This commit is contained in:
Eugene Livis 2018-11-06 15:05:54 -05:00
parent 46063c8ef7
commit baeb53bf0c
4 changed files with 37 additions and 41 deletions

View File

@ -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<String> implements ComboBoxModel<String> {
class DataSourceComboBoxModel extends AbstractListModel<String> implements ComboBoxModel<String> {
private static final long serialVersionUID = 1L;
private final String[] dataSourceList;

View File

@ -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"));

View File

@ -36,7 +36,7 @@
<Component id="jLabelSelectDataSource" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="selectDataSourceComboBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="172" max="-2" attributes="0"/>
<EmptySpace pref="130" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@ -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<String> dataSourcesList = new DataSourceComboBoxModel();
private final Map<Long, String> dataSourceMap;
private Map<Long, String> 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<Long, String> 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))
);
}// </editor-fold>//GEN-END:initComponents