mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
3849 - select data source automatically when performing search from context menu
This commit is contained in:
parent
e058d70f5f
commit
28a011c3e9
@ -110,7 +110,7 @@ public class ImageNode extends AbstractContentNode<Image> {
|
||||
actionsList.add(a);
|
||||
}
|
||||
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 RunIngestModulesAction(Collections.<Content>singletonList(content)));
|
||||
actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "ImageNode.getActions.viewInNewWin.text"), this));
|
||||
|
@ -65,7 +65,7 @@ public abstract class SpecialDirectoryNode extends AbstractAbstractFileNode<Spec
|
||||
actions.add(ExtractAction.getInstance());
|
||||
actions.add(ExportCSVAction.getInstance());
|
||||
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()) {
|
||||
actions.add(new ViewSummaryInformationAction(content.getId()));
|
||||
actions.add(new RunIngestModulesAction(Collections.<Content>singletonList(content)));
|
||||
|
@ -28,14 +28,26 @@ import org.openide.util.Lookup;
|
||||
*/
|
||||
public class FileSearchAction extends AbstractAction {
|
||||
|
||||
private final Long dataSourceId;
|
||||
|
||||
public FileSearchAction(String title, long dataSourceID) {
|
||||
super(title);
|
||||
dataSourceId = dataSourceID;
|
||||
}
|
||||
|
||||
public FileSearchAction(String title) {
|
||||
super(title);
|
||||
dataSourceId = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileSearchProvider searcher = Lookup.getDefault().lookup(FileSearchProvider.class);
|
||||
if (dataSourceId == null) {
|
||||
searcher.showDialog();
|
||||
} else {
|
||||
searcher.showDialog(dataSourceId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Copyright 2011-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -23,5 +23,7 @@ package org.sleuthkit.autopsy.directorytree;
|
||||
*/
|
||||
public interface FileSearchProvider {
|
||||
|
||||
public void showDialog(long dataSourceID);
|
||||
|
||||
public void showDialog();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2018 Basis Technology Corp.
|
||||
* Copyright 2018-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -28,16 +28,18 @@ class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
|
||||
|
||||
/**
|
||||
* Construct DataSourceFilter with the DataSourcePanel
|
||||
*
|
||||
* @param component A DataSourcePanel
|
||||
*/
|
||||
public DataSourceFilter(DataSourcePanel component) {
|
||||
DataSourceFilter(DataSourcePanel component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor to construct a new DataSourceFilter with a new DataSourcePanel
|
||||
* Default constructor to construct a new DataSourceFilter with a new
|
||||
* DataSourcePanel
|
||||
*/
|
||||
public DataSourceFilter() {
|
||||
DataSourceFilter() {
|
||||
this(new DataSourcePanel());
|
||||
}
|
||||
|
||||
@ -46,6 +48,10 @@ class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
|
||||
return this.getComponent().isSelected();
|
||||
}
|
||||
|
||||
void setSelectedDataSource(long dataSourceId) {
|
||||
this.getComponent().setDataSourceSelected(dataSourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPredicate() throws FilterValidationException {
|
||||
String predicate = "";
|
||||
@ -64,11 +70,11 @@ class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Messages ({
|
||||
@Messages({
|
||||
"DataSourceFilter.errorMessage.emptyDataSource=At least one data source must be selected."
|
||||
})
|
||||
public boolean isValid() {
|
||||
if(this.getComponent().getDataSourcesSelected().isEmpty()){
|
||||
if (this.getComponent().getDataSourcesSelected().isEmpty()) {
|
||||
setLastError(Bundle.DataSourceFilter_errorMessage_emptyDataSource());
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2018 Basis Technology Corp.
|
||||
* Copyright 2018-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -128,6 +128,19 @@ public class DataSourcePanel extends javax.swing.JPanel {
|
||||
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.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
@ -32,6 +32,7 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static FileSearchAction instance = null;
|
||||
private static FileSearchDialog searchDialog;
|
||||
private static Long selectedDataSourceId;
|
||||
|
||||
FileSearchAction() {
|
||||
super();
|
||||
@ -54,8 +55,9 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (searchDialog == null) {
|
||||
searchDialog = new FileSearchDialog();
|
||||
|
||||
}
|
||||
//Preserve whatever the previously selected data source was
|
||||
selectedDataSourceId = null;
|
||||
searchDialog.setVisible(true);
|
||||
}
|
||||
|
||||
@ -64,6 +66,8 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
|
||||
if (searchDialog == null) {
|
||||
searchDialog = new FileSearchDialog();
|
||||
}
|
||||
//
|
||||
searchDialog.setSelectedDataSourceFilter(selectedDataSourceId);
|
||||
searchDialog.setVisible(true);
|
||||
}
|
||||
|
||||
@ -82,8 +86,16 @@ final class FileSearchAction extends CallableSystemAction implements FileSearchP
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDialog(long dataSourceId) {
|
||||
selectedDataSourceId = dataSourceId;
|
||||
performAction();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDialog() {
|
||||
selectedDataSourceId = null;
|
||||
performAction();
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ final class FileSearchDialog extends javax.swing.JDialog {
|
||||
});
|
||||
}
|
||||
|
||||
void setSelectedDataSourceFilter(long dataSourceId){
|
||||
fileSearchPanel1.setDataSourceFilter(dataSourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -59,6 +59,7 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
private final List<FileSearchFilter> filters = new ArrayList<>();
|
||||
private static int resultWindowCount = 0; //keep track of result windows so they get unique names
|
||||
private static final String EMPTY_WHERE_CLAUSE = NbBundle.getMessage(DateSearchFilter.class, "FileSearchPanel.emptyWhereClause.text");
|
||||
private static DataSourceFilter dataSourceFilter;
|
||||
|
||||
enum EVENT {
|
||||
CHECKED
|
||||
@ -101,7 +102,7 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
KnownStatusSearchFilter knowStatusFilter = new KnownStatusSearchFilter();
|
||||
HashSearchFilter hashFilter = new HashSearchFilter();
|
||||
MimeTypeFilter mimeTypeFilter = new MimeTypeFilter();
|
||||
DataSourceFilter dataSourceFilter = new DataSourceFilter();
|
||||
dataSourceFilter = new DataSourceFilter();
|
||||
|
||||
panel2.add(new FilterArea(NbBundle.getMessage(this.getClass(), "FileSearchPanel.filterTitle.name"),nameFilter));
|
||||
|
||||
@ -145,6 +146,10 @@ class FileSearchPanel extends javax.swing.JPanel {
|
||||
searchButton.setEnabled(isValidSearch());
|
||||
}
|
||||
|
||||
void setDataSourceFilter(long dataSourceId){
|
||||
dataSourceFilter.setSelectedDataSource(dataSourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if any of the filters in the panel are enabled (checked)
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user