Merge pull request #7165 from wschaeferB/3849-PreSelectDataSourceForFileSearch

3849 pre select data source for file search
This commit is contained in:
Richard Cordovano 2021-08-26 16:04:45 -04:00 committed by GitHub
commit 2e08c1fcba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 95 additions and 26 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2012-2019 Basis Technology Corp. * Copyright 2012-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -110,7 +110,7 @@ public class ImageNode extends AbstractContentNode<Image> {
actionsList.add(a); actionsList.add(a);
} }
actionsList.addAll(ExplorerNodeActionVisitor.getActions(content)); actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
actionsList.add(new FileSearchAction(Bundle.ImageNode_getActions_openFileSearchByAttr_text())); actionsList.add(new FileSearchAction(Bundle.ImageNode_getActions_openFileSearchByAttr_text(), content.getId()));
actionsList.add(new ViewSummaryInformationAction(content.getId())); actionsList.add(new ViewSummaryInformationAction(content.getId()));
actionsList.add(new RunIngestModulesAction(Collections.<Content>singletonList(content))); actionsList.add(new RunIngestModulesAction(Collections.<Content>singletonList(content)));
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "ImageNode.getActions.viewInNewWin.text"), this)); actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "ImageNode.getActions.viewInNewWin.text"), this));

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2017-2019 Basis Technology Corp. * Copyright 2017-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -65,7 +65,7 @@ public abstract class SpecialDirectoryNode extends AbstractAbstractFileNode<Spec
actions.add(ExtractAction.getInstance()); actions.add(ExtractAction.getInstance());
actions.add(ExportCSVAction.getInstance()); actions.add(ExportCSVAction.getInstance());
actions.add(null); // creates a menu separator actions.add(null); // creates a menu separator
actions.add(new FileSearchAction(Bundle.ImageNode_getActions_openFileSearchByAttr_text())); actions.add(new FileSearchAction(Bundle.ImageNode_getActions_openFileSearchByAttr_text(), content.getId()));
if (content.isDataSource()) { if (content.isDataSource()) {
actions.add(new ViewSummaryInformationAction(content.getId())); actions.add(new ViewSummaryInformationAction(content.getId()));
actions.add(new RunIngestModulesAction(Collections.<Content>singletonList(content))); actions.add(new RunIngestModulesAction(Collections.<Content>singletonList(content)));

View File

@ -1,15 +1,15 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -28,14 +28,26 @@ import org.openide.util.Lookup;
*/ */
public class FileSearchAction extends AbstractAction { public class FileSearchAction extends AbstractAction {
private final Long dataSourceId;
public FileSearchAction(String title, long dataSourceID) {
super(title);
dataSourceId = dataSourceID;
}
public FileSearchAction(String title) { public FileSearchAction(String title) {
super(title); super(title);
dataSourceId = null;
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FileSearchProvider searcher = Lookup.getDefault().lookup(FileSearchProvider.class); FileSearchProvider searcher = Lookup.getDefault().lookup(FileSearchProvider.class);
searcher.showDialog(); if (dataSourceId == null) {
searcher.showDialog();
} else {
searcher.showDialog(dataSourceId);
}
} }
} }

View File

@ -1,15 +1,15 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,5 +23,8 @@ package org.sleuthkit.autopsy.directorytree;
*/ */
public interface FileSearchProvider { public interface FileSearchProvider {
public void showDialog(Long dataSourceID);
@Deprecated
public void showDialog(); public void showDialog();
} }

View File

@ -48,6 +48,15 @@ class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
return this.getComponent().isSelected(); return this.getComponent().isSelected();
} }
/**
* Set the data source filter to select the specified data source initially.
*
* @param dataSourceId - The data source to select.
*/
void setSelectedDataSource(long dataSourceId) {
this.getComponent().setDataSourceSelected(dataSourceId);
}
/** /**
* Reset the data source filter to be up to date with the current case. * Reset the data source filter to be up to date with the current case.
*/ */

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2018 Basis Technology Corp. * Copyright 2018-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -152,6 +152,19 @@ public class DataSourcePanel extends javax.swing.JPanel {
this.dataSourceNoteLabel.setEnabled(enabled); this.dataSourceNoteLabel.setEnabled(enabled);
} }
/**
* Set the data source initially selected in this filter.
*
* @param dataSourceId - The object ID of the data source which will be
* selected.
*/
void setDataSourceSelected(long dataSourceId) {
this.dataSourceCheckBox.setSelected(true);
setComponentsEnabled();
String dataSourceName = dataSourceMap.get(dataSourceId);
dataSourceList.setSelectedValue(dataSourceName, true);
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always

View File

@ -32,6 +32,7 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static FileSearchAction instance = null; private static FileSearchAction instance = null;
private static FileSearchDialog searchDialog; private static FileSearchDialog searchDialog;
private static Long selectedDataSourceId;
FileSearchAction() { FileSearchAction() {
super(); super();
@ -39,7 +40,7 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> { Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) { if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
setEnabled(evt.getNewValue() != null); setEnabled(evt.getNewValue() != null);
if (searchDialog != null && evt.getNewValue() != null){ if (searchDialog != null && evt.getNewValue() != null) {
searchDialog.resetCaseDependentFilters(); searchDialog.resetCaseDependentFilters();
} }
} }
@ -57,7 +58,9 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (searchDialog == null) { if (searchDialog == null) {
searchDialog = new FileSearchDialog(); searchDialog = new FileSearchDialog();
} }
//Preserve whatever the previously selected data source was
selectedDataSourceId = null;
searchDialog.setVisible(true); searchDialog.setVisible(true);
} }
@ -66,6 +69,8 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
if (searchDialog == null) { if (searchDialog == null) {
searchDialog = new FileSearchDialog(); searchDialog = new FileSearchDialog();
} }
//
searchDialog.setSelectedDataSourceFilter(selectedDataSourceId);
searchDialog.setVisible(true); searchDialog.setVisible(true);
} }
@ -85,7 +90,15 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
} }
@Override @Override
public void showDialog() { public void showDialog(Long dataSourceId) {
selectedDataSourceId = dataSourceId;
performAction(); performAction();
}
@Override
@Deprecated
public void showDialog() {
showDialog(null);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -29,6 +29,8 @@ import org.openide.windows.WindowManager;
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
final class FileSearchDialog extends javax.swing.JDialog { final class FileSearchDialog extends javax.swing.JDialog {
private static final long serialVersionUID = 1L;
/** /**
* Creates new form FileSearchDialog * Creates new form FileSearchDialog
*/ */
@ -48,6 +50,15 @@ final class FileSearchDialog extends javax.swing.JDialog {
}); });
} }
/**
* Set the data source filter to select the specified data source initially.
*
* @param dataSourceId - The data source to select.
*/
void setSelectedDataSourceFilter(long dataSourceId) {
fileSearchPanel1.setDataSourceFilter(dataSourceId);
}
/** /**
* Reset the filters which are populated with options based on the contents * Reset the filters which are populated with options based on the contents
* of the current case. * of the current case.

View File

@ -57,13 +57,13 @@ import org.sleuthkit.datamodel.TskCoreException;
*/ */
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
class FileSearchPanel extends javax.swing.JPanel { class FileSearchPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(FileSearchPanel.class.getName()); private static final Logger logger = Logger.getLogger(FileSearchPanel.class.getName());
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final List<FileSearchFilter> filters = new ArrayList<>(); private final List<FileSearchFilter> filters = new ArrayList<>();
private static int resultWindowCount = 0; //keep track of result windows so they get unique names private static int resultWindowCount = 0; //keep track of result windows so they get unique names
private static MimeTypeFilter mimeTypeFilter = new MimeTypeFilter(); private static final MimeTypeFilter mimeTypeFilter = new MimeTypeFilter();
private static DataSourceFilter dataSourceFilter = new DataSourceFilter(); private static final DataSourceFilter dataSourceFilter = new DataSourceFilter();
private static final String EMPTY_WHERE_CLAUSE = NbBundle.getMessage(DateSearchFilter.class, "FileSearchPanel.emptyWhereClause.text"); private static final String EMPTY_WHERE_CLAUSE = NbBundle.getMessage(DateSearchFilter.class, "FileSearchPanel.emptyWhereClause.text");
private static SwingWorker<TableFilterNode, Void> searchWorker = null; private static SwingWorker<TableFilterNode, Void> searchWorker = null;
@ -106,7 +106,6 @@ class FileSearchPanel extends javax.swing.JPanel {
DateSearchFilter dateFilter = new DateSearchFilter(); DateSearchFilter dateFilter = new DateSearchFilter();
KnownStatusSearchFilter knowStatusFilter = new KnownStatusSearchFilter(); KnownStatusSearchFilter knowStatusFilter = new KnownStatusSearchFilter();
HashSearchFilter hashFilter = new HashSearchFilter(); HashSearchFilter hashFilter = new HashSearchFilter();
panel2.add(new FilterArea(NbBundle.getMessage(this.getClass(), "FileSearchPanel.filterTitle.name"), nameFilter)); panel2.add(new FilterArea(NbBundle.getMessage(this.getClass(), "FileSearchPanel.filterTitle.name"), nameFilter));
panel3.add(new FilterArea(NbBundle.getMessage(this.getClass(), "FileSearchPanel.filterTitle.metadata"), sizeFilter)); panel3.add(new FilterArea(NbBundle.getMessage(this.getClass(), "FileSearchPanel.filterTitle.metadata"), sizeFilter));
@ -149,6 +148,15 @@ class FileSearchPanel extends javax.swing.JPanel {
searchButton.setEnabled(isValidSearch()); searchButton.setEnabled(isValidSearch());
} }
/**
* Set the data source filter to select the specified data source initially.
*
* @param dataSourceId - The data source to select.
*/
void setDataSourceFilter(long dataSourceId) {
dataSourceFilter.setSelectedDataSource(dataSourceId);
}
/** /**
* @return true if any of the filters in the panel are enabled (checked) * @return true if any of the filters in the panel are enabled (checked)
*/ */
@ -334,7 +342,7 @@ class FileSearchPanel extends javax.swing.JPanel {
return enabledFilters; return enabledFilters;
} }
/** /**
* Reset the filters which are populated with options based on the contents * Reset the filters which are populated with options based on the contents
* of the current case. * of the current case.

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");