19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.List;
25 import org.openide.util.NbBundle;
33 abstract class KeywordSearchPanel
extends javax.swing.JPanel {
35 private final String keywordSearchErrorDialogHeader =
org.openide.util.NbBundle.getMessage(this.getClass(),
"AbstractKeywordSearchPerformer.search.dialogErrorHeader");
36 protected int filesIndexed;
38 KeywordSearchPanel() {
42 private void initListeners() {
43 KeywordSearch.addNumIndexedFilesChangeListener(
44 new PropertyChangeListener() {
46 public void propertyChange(PropertyChangeEvent evt) {
47 String changed = evt.getPropertyName();
48 Object newValue = evt.getNewValue();
50 if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
51 int newFilesIndexed = ((Integer) newValue).intValue();
52 filesIndexed = newFilesIndexed;
53 postFilesIndexedChange();
62 protected abstract void postFilesIndexedChange();
69 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) {
89 filesIndexed = KeywordSearch.getServer().queryNumIndexedFiles();
90 }
catch (KeywordSearchModuleException | NoOpenCoreException ignored) {
93 if (filesIndexed == 0) {
94 if (isIngestRunning) {
95 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
96 "AbstractKeywordSearchPerformer.search.noFilesInIdxMsg",
97 KeywordSearchSettings.getUpdateFrequency().getTime()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
99 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
100 "AbstractKeywordSearchPerformer.search.noFilesIdxdMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
106 if (isIngestRunning) {
107 if (KeywordSearchUtil.displayConfirmDialog(
org.openide.util.NbBundle.getMessage(
this.getClass(),
"AbstractKeywordSearchPerformer.search.searchIngestInProgressTitle"),
108 NbBundle.getMessage(
this.getClass(),
"AbstractKeywordSearchPerformer.search.ingestInProgressBody"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN) ==
false) {
113 KeywordSearchQueryDelegator man = null;
115 final List<KeywordList> keywordLists = getKeywordLists();
116 if (keywordLists.isEmpty()) {
117 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
118 "AbstractKeywordSearchPerformer.search.emptyKeywordErrorBody"),
119 KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
122 man =
new KeywordSearchQueryDelegator(keywordLists);
124 if (man.validate()) {
127 KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(
this.getClass(),
128 "AbstractKeywordSearchPerformer.search.invalidSyntaxHeader"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);