Autopsy  4.1
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.beans.PropertyChangeListener;
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.addPropertyChangeListener(new PropertyChangeListener() {
47 
48  @Override
49  public void propertyChange(PropertyChangeEvent evt) {
50  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
51  setEnabled(evt.getNewValue() != null);
52  }
53  }
54  });
55  }
56 
57  public static HashDbPanelSearchAction getDefault() {
58  if (instance == null) {
59  instance = new HashDbPanelSearchAction();
60  }
61  return instance;
62  }
63 
64  @Override
65  public void performAction() {
66  final HashDbSearchPanel panel = HashDbSearchPanel.getDefault();
67  final AdvancedConfigurationCleanDialog dialog = new AdvancedConfigurationCleanDialog();
68  // Set the dialog close button to clear then close the window
69  dialog.addWindowListener(new WindowAdapter() {
70  @Override
71  public void windowClosing(WindowEvent e) {
72  panel.clear();
73  dialog.close();
74  }
75  });
76  // Have the search button close the window after searching
77  panel.addSearchActionListener(new ActionListener() {
78  @Override
79  public void actionPerformed(ActionEvent e) {
80  if (panel.search()) {
81  panel.clear();
82  dialog.close();
83  }
84  }
85  });
86  // Have the search button close the window after searching
87  panel.addCancelActionListener(new ActionListener() {
88  @Override
89  public void actionPerformed(ActionEvent e) {
90  panel.clear();
91  dialog.close();
92  }
93  });
94  panel.refresh();
95  dialog.display(panel);
96  }
97 
98  @Override
99  public String getName() {
100  return ACTION_NAME;
101  }
102 
103  @Override
104  public HelpCtx getHelpCtx() {
105  return HelpCtx.DEFAULT_HELP;
106  }
107 
108  @Override
109  protected boolean asynchronous() {
110  return false;
111  }
112 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.