Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearchPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2013 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.keywordsearch;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.List;
24 
27 import org.openide.util.NbBundle;
28 
35 abstract class KeywordSearchPanel extends javax.swing.JPanel {
36  private final String keywordSearchErrorDialogHeader = org.openide.util.NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.dialogErrorHeader");
37  protected int filesIndexed;
38 
39  KeywordSearchPanel() {
40  initListeners();
41  }
42 
43  private void initListeners() {
44  KeywordSearch.addNumIndexedFilesChangeListener(
45  new PropertyChangeListener() {
46  @Override
47  public void propertyChange(PropertyChangeEvent evt) {
48  String changed = evt.getPropertyName();
49  Object newValue = evt.getNewValue();
50 
51  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
52  int newFilesIndexed = ((Integer) newValue).intValue();
53  filesIndexed = newFilesIndexed;
54  postFilesIndexedChange();
55  }
56  }
57  });
58  }
59 
63  protected abstract void postFilesIndexedChange();
64 
65 
70  abstract List<KeywordList> getKeywordLists();
71 
76  public void setFilesIndexed(int filesIndexed) {
77  this.filesIndexed = filesIndexed;
78  }
79 
84  public void search() {
85  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
86 
87  if (filesIndexed == 0) {
88  if (isIngestRunning) {
89  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
90  "AbstractKeywordSearchPerformer.search.noFilesInIdxMsg",
91  KeywordSearchSettings.getUpdateFrequency().getTime()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
92  } else {
93  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
94  "AbstractKeywordSearchPerformer.search.noFilesIdxdMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
95  }
96  return;
97  }
98 
99  //check if keyword search module ingest is running (indexing, etc)
100  if (isIngestRunning) {
101  if (KeywordSearchUtil.displayConfirmDialog(org.openide.util.NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.searchIngestInProgressTitle"),
102  NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.ingestInProgressBody"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN) == false) {
103  return;
104  }
105  }
106 
107  KeywordSearchQueryDelegator man = null;
108 
109  final List<KeywordList> keywordLists = getKeywordLists();
110  if (keywordLists.isEmpty()) {
111  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
112  "AbstractKeywordSearchPerformer.search.emptyKeywordErrorBody"),
113  KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
114  return;
115  }
116  man = new KeywordSearchQueryDelegator(keywordLists);
117 
118  if (man.validate()) {
119  man.execute();
120  } else {
121  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
122  "AbstractKeywordSearchPerformer.search.invalidSyntaxHeader"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
123  }
124  }
125 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.