19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.List;
27 import org.openide.util.NbBundle;
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;
39 KeywordSearchPanel() {
43 private void initListeners() {
44 KeywordSearch.addNumIndexedFilesChangeListener(
45 new PropertyChangeListener() {
47 public void propertyChange(PropertyChangeEvent evt) {
48 String changed = evt.getPropertyName();
49 Object newValue = evt.getNewValue();
51 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
52 int newFilesIndexed = ((Integer) newValue).intValue();
53 filesIndexed = newFilesIndexed;
54 postFilesIndexedChange();
63 protected abstract void postFilesIndexedChange();
70 abstract List<KeywordList> getKeywordLists();
76 public void setFilesIndexed(
int filesIndexed) {
77 this.filesIndexed = filesIndexed;
84 public void search() {
85 boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
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);
93 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
94 "AbstractKeywordSearchPerformer.search.noFilesIdxdMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
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) {
107 KeywordSearchQueryDelegator man = null;
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);
116 man =
new KeywordSearchQueryDelegator(keywordLists);
118 if (man.validate()) {
121 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
122 "AbstractKeywordSearchPerformer.search.invalidSyntaxHeader"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);