Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDbPanelSearchAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.hashdatabase;
20 
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.awt.event.WindowAdapter;
24 import java.awt.event.WindowEvent;
25 import java.beans.PropertyChangeEvent;
26 import java.util.EnumSet;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.util.actions.CallableSystemAction;
32 
37 class HashDbPanelSearchAction extends CallableSystemAction {
38 
39  private static final long serialVersionUID = 1L;
40  static final String ACTION_NAME = NbBundle.getMessage(HashDbPanelSearchAction.class, "HashDbPanelSearchAction.actionName");
41  private static HashDbPanelSearchAction instance = null;
42 
43  HashDbPanelSearchAction() {
44  super();
45  setEnabled(Case.isCaseOpen());
46  Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
47  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
48  setEnabled(evt.getNewValue() != null);
49  }
50  });
51  }
52 
53  public static HashDbPanelSearchAction getDefault() {
54  if (instance == null) {
55  instance = new HashDbPanelSearchAction();
56  }
57  return instance;
58  }
59 
60  @Override
61  public void performAction() {
62  final HashDbSearchPanel panel = HashDbSearchPanel.getDefault();
63  final AdvancedConfigurationCleanDialog dialog = new AdvancedConfigurationCleanDialog();
64  // Set the dialog close button to clear then close the window
65  dialog.addWindowListener(new WindowAdapter() {
66  @Override
67  public void windowClosing(WindowEvent e) {
68  panel.clear();
69  dialog.close();
70  }
71  });
72  // Have the search button close the window after searching
73  panel.addSearchActionListener(new ActionListener() {
74  @Override
75  public void actionPerformed(ActionEvent e) {
76  if (panel.search()) {
77  panel.clear();
78  dialog.close();
79  }
80  }
81  });
82  // Have the search button close the window after searching
83  panel.addCancelActionListener(new ActionListener() {
84  @Override
85  public void actionPerformed(ActionEvent e) {
86  panel.clear();
87  dialog.close();
88  }
89  });
90  panel.refresh();
91  dialog.display(panel);
92  }
93 
94  @Override
95  public String getName() {
96  return ACTION_NAME;
97  }
98 
99  @Override
100  public HelpCtx getHelpCtx() {
101  return HelpCtx.DEFAULT_HELP;
102  }
103 
104  @Override
105  protected boolean asynchronous() {
106  return false;
107  }
108 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.