19 package org.sleuthkit.autopsy.filesearch;
21 import java.awt.event.ActionEvent;
22 import java.beans.PropertyChangeEvent;
23 import java.util.EnumSet;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26 import org.openide.util.actions.CallableSystemAction;
30 final class FileSearchAction
extends CallableSystemAction implements FileSearchProvider {
32 private static final long serialVersionUID = 1L;
33 private static FileSearchAction instance = null;
34 private static FileSearchDialog searchDialog;
35 private static Long selectedDataSourceId;
39 setEnabled(Case.isCaseOpen());
40 Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
41 if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
42 setEnabled(evt.getNewValue() != null);
43 if (searchDialog != null && evt.getNewValue() != null) {
44 searchDialog.resetCaseDependentFilters();
50 public static FileSearchAction getDefault() {
51 if (instance == null) {
52 instance =
new FileSearchAction();
58 public void actionPerformed(ActionEvent e) {
59 if (searchDialog == null) {
60 searchDialog =
new FileSearchDialog();
63 selectedDataSourceId = null;
64 searchDialog.setVisible(
true);
68 public void performAction() {
69 if (searchDialog == null) {
70 searchDialog =
new FileSearchDialog();
73 searchDialog.setSelectedDataSourceFilter(selectedDataSourceId);
74 searchDialog.setVisible(
true);
78 public String getName() {
79 return NbBundle.getMessage(this.getClass(),
"FileSearchAction.getName.text");
83 public HelpCtx getHelpCtx() {
84 return HelpCtx.DEFAULT_HELP;
88 protected boolean asynchronous() {
93 public void showDialog(Long dataSourceId) {
94 selectedDataSourceId = dataSourceId;
101 public void showDialog() {