mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Keyword Search Panel on top right
This commit is contained in:
parent
2145782244
commit
53bcb90020
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.keywordsearch;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
import org.sleuthkit.autopsy.keywordsearch.KeywordSearch.QueryType;
|
||||
import org.sleuthkit.autopsy.keywordsearch.KeywordSearchQueryManager.Presentation;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dfickling
|
||||
*/
|
||||
abstract class AbstractKeywordSearchPerformer extends javax.swing.JPanel implements KeywordSearchPerformerInterface{
|
||||
|
||||
int filesIndexed;
|
||||
|
||||
AbstractKeywordSearchPerformer() {
|
||||
initListeners();
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
KeywordSearch.changeSupport.addPropertyChangeListener(KeywordSearch.NUM_FILES_CHANGE_EVT,
|
||||
new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String changed = evt.getPropertyName();
|
||||
Object oldValue = evt.getOldValue();
|
||||
Object newValue = evt.getNewValue();
|
||||
|
||||
if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
|
||||
int newFilesIndexed = ((Integer) newValue).intValue();
|
||||
filesIndexed = newFilesIndexed;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isMultiwordQuery();
|
||||
|
||||
@Override
|
||||
public abstract boolean isLuceneQuerySelected();
|
||||
|
||||
@Override
|
||||
public abstract String getQueryText();
|
||||
|
||||
@Override
|
||||
public abstract List<Keyword> getQueryList();
|
||||
|
||||
@Override
|
||||
public void setFilesIndexed(int filesIndexed) {
|
||||
this.filesIndexed = filesIndexed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search() {
|
||||
KeywordSearchQueryManager man = null;
|
||||
if (isMultiwordQuery()) {
|
||||
final List<Keyword> keywords = getQueryList();
|
||||
if (keywords.isEmpty()) {
|
||||
KeywordSearchUtil.displayDialog("Keyword Search Error", "Keyword list is empty, please add at least one keyword to the list", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
|
||||
return;
|
||||
}
|
||||
man = new KeywordSearchQueryManager(keywords, Presentation.COLLAPSE);
|
||||
} else {
|
||||
QueryType queryType = null;
|
||||
if (isLuceneQuerySelected()) {
|
||||
queryType = QueryType.WORD;
|
||||
} else {
|
||||
queryType = QueryType.REGEX;
|
||||
}
|
||||
final String queryText = getQueryText();
|
||||
if (queryText == null || queryText.trim().equals("")) {
|
||||
KeywordSearchUtil.displayDialog("Keyword Search Error", "Please enter a keyword to search for", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
|
||||
return;
|
||||
}
|
||||
man = new KeywordSearchQueryManager(getQueryText(), queryType, Presentation.COLLAPSE);
|
||||
}
|
||||
|
||||
if (man.validate()) {
|
||||
man.execute();
|
||||
} else {
|
||||
KeywordSearchUtil.displayDialog("Keyword Search Error", "Invalid query syntax.", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -76,3 +76,9 @@ KeywordSearchEditListPanel.deleteListButton.text=Delete List
|
||||
KeywordSearchListsManagementPanel.newListButton.text=New List
|
||||
KeywordSearchEditListPanel.useForIngestCheckbox.text=Use during triage / ingest
|
||||
KeywordSearchListsManagementPanel.importButton.text=Import List
|
||||
KeywordSearchPanel.searchBox.text=Search...
|
||||
KeywordSearchPanel.regExCheckboxMenuItem.text=Use Regular Expressions
|
||||
KeywordSearchPanel.settingsLabel.text=
|
||||
KeywordSearchPanel.listsButton.text=Watch Lists
|
||||
KeywordSearchListsViewerPanel.searchAddButton.text=Search
|
||||
KeywordSearchListsViewerPanel.manageListsButton.text=Manage Lists
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.keywordsearch;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.AbstractAction;
|
||||
import org.openide.util.actions.Presenter;
|
||||
|
||||
public final class KeywordSearchAction extends AbstractAction implements Presenter.Toolbar {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getToolbarPresenter() {
|
||||
return new KeywordSearchPanel();
|
||||
}
|
||||
}
|
@ -173,9 +173,6 @@
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchEditListPanel.useForIngestCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="useForIngestCheckboxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="addKeywordPanel">
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
//customize column witdhs
|
||||
final int width = jScrollPane1.getPreferredSize().width;
|
||||
TableColumn column = null;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < keywordTable.getColumnCount(); i++) {
|
||||
column = keywordTable.getColumnModel().getColumn(i);
|
||||
if (i == 0) {
|
||||
column.setPreferredWidth(((int) (width * 0.85)));
|
||||
@ -140,17 +140,17 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
//initialize save buttons
|
||||
if(currentKeywordList == null) {
|
||||
saveListButton.setEnabled(false);
|
||||
exportButton.setEnabled(false);
|
||||
deleteListButton.setEnabled(false);
|
||||
deleteWordButton.setEnabled(false);
|
||||
} else {
|
||||
saveListButton.setEnabled(true);
|
||||
exportButton.setEnabled(true);
|
||||
deleteListButton.setEnabled(true);
|
||||
}
|
||||
//initialize buttons
|
||||
boolean listSet = (currentKeywordList != null);
|
||||
addWordButton.setEnabled(listSet);
|
||||
addWordField.setEnabled(listSet);
|
||||
chRegex.setEnabled(listSet);
|
||||
useForIngestCheckbox.setEnabled(listSet);
|
||||
saveListButton.setEnabled(listSet);
|
||||
exportButton.setEnabled(listSet);
|
||||
deleteListButton.setEnabled(listSet);
|
||||
deleteWordButton.setEnabled(listSet);
|
||||
|
||||
if (getAllKeywords().isEmpty()) {
|
||||
saveListButton.setEnabled(false);
|
||||
exportButton.setEnabled(false);
|
||||
@ -220,11 +220,6 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
});
|
||||
|
||||
useForIngestCheckbox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.useForIngestCheckbox.text")); // NOI18N
|
||||
useForIngestCheckbox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
useForIngestCheckboxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
addWordButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.addWordButton.text")); // NOI18N
|
||||
addWordButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -496,12 +491,6 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
deleter.deleteList(toDelete);
|
||||
}//GEN-LAST:event_deleteListButtonActionPerformed
|
||||
|
||||
private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useForIngestCheckboxActionPerformed
|
||||
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
|
||||
KeywordSearchList currentList = loader.getList(currentKeywordList);
|
||||
currentList.setUseForIngest(useForIngestCheckbox.isSelected());
|
||||
}//GEN-LAST:event_useForIngestCheckboxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel addKeywordPanel;
|
||||
private javax.swing.JButton addWordButton;
|
||||
@ -536,6 +525,10 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
currentKeywordList = listsPanel.getAllLists().get(index);
|
||||
tableModel.resync(currentKeywordList);
|
||||
initButtons();
|
||||
} else {
|
||||
currentKeywordList = null;
|
||||
tableModel.deleteAll();
|
||||
initButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,15 +549,17 @@ public class KeywordSearchEditListPanel extends javax.swing.JPanel implements Li
|
||||
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
|
||||
KeywordSearchList oldList = loader.getList(currentKeywordList);
|
||||
List<Keyword> oldKeywords = oldList.getKeywords();
|
||||
boolean oldIngest = oldList.getUseForIngest();
|
||||
List<Keyword> newKeywords = getAllKeywords();
|
||||
boolean newIngest = useForIngestCheckbox.isSelected();
|
||||
|
||||
if (!oldKeywords.equals(newKeywords)) {
|
||||
if (!oldKeywords.equals(newKeywords) || oldIngest != newIngest) {
|
||||
/*boolean save = KeywordSearchUtil.displayConfirmDialog("Save List Changes",
|
||||
"Do you want to save the changes you made to list " + currentKeywordList + "?",
|
||||
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);*/
|
||||
boolean save = true;
|
||||
if (save) {
|
||||
loader.addList(currentKeywordList, newKeywords);
|
||||
loader.addList(currentKeywordList, newKeywords, newIngest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,16 +46,16 @@ import org.openide.awt.ActionReference;
|
||||
/**
|
||||
* Top component which displays something.
|
||||
*/
|
||||
@ConvertAsProperties(dtd = "-//org.sleuthkit.autopsy.keywordsearch//KeywordSearchListImportExport//EN",
|
||||
autostore = false)
|
||||
@TopComponent.Description(preferredID = "KeywordSearchListImportExportTopComponent",
|
||||
//iconBase="SET/PATH/TO/ICON/HERE",
|
||||
persistenceType = TopComponent.PERSISTENCE_NEVER)
|
||||
@TopComponent.Registration(mode = "explorer", openAtStartup = false)
|
||||
@ActionID(category = "Window", id = "org.sleuthkit.autopsy.keywordsearch.KeywordSearchListImportExportTopComponent")
|
||||
@ActionReference(path = "Menu/Window" /*, position = 333 */)
|
||||
@TopComponent.OpenActionRegistration(displayName = "#CTL_KeywordSearchListImportExportAction",
|
||||
preferredID = "KeywordSearchListImportExportTopComponent")
|
||||
//@ConvertAsProperties(dtd = "-//org.sleuthkit.autopsy.keywordsearch//KeywordSearchListImportExport//EN",
|
||||
//autostore = false)
|
||||
//@TopComponent.Description(preferredID = "KeywordSearchListImportExportTopComponent",
|
||||
////iconBase="SET/PATH/TO/ICON/HERE",
|
||||
//persistenceType = TopComponent.PERSISTENCE_NEVER)
|
||||
//@TopComponent.Registration(mode = "explorer", openAtStartup = false)
|
||||
//@ActionID(category = "Window", id = "org.sleuthkit.autopsy.keywordsearch.KeywordSearchListImportExportTopComponent")
|
||||
//@ActionReference(path = "Menu/Window" /*, position = 333 */)
|
||||
//@TopComponent.OpenActionRegistration(displayName = "#CTL_KeywordSearchListImportExportAction",
|
||||
//preferredID = "KeywordSearchListImportExportTopComponent")
|
||||
public final class KeywordSearchListImportExportTopComponent extends TopComponent {
|
||||
|
||||
private Logger logger = Logger.getLogger(KeywordSearchListImportExportTopComponent.class.getName());
|
||||
|
@ -41,7 +41,6 @@ import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -97,6 +96,8 @@ public class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
|
||||
tableModel.resync();
|
||||
if(listsTable.getRowCount() > 0)
|
||||
listsTable.getSelectionModel().setSelectionInterval(0, 0);
|
||||
else
|
||||
listsTable.getSelectionModel().clearSelection();
|
||||
} else if (evt.getPropertyName().equals(KeywordSearchListsXML.ListsEvt.LIST_UPDATED.toString())) {
|
||||
tableModel.resync((String) evt.getNewValue()); //changed list name
|
||||
}
|
||||
@ -294,35 +295,18 @@ public class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
String colName = null;
|
||||
switch (column) {
|
||||
case 0:
|
||||
colName = "Name";
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
||||
}
|
||||
return colName;
|
||||
return "Name";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object ret = null;
|
||||
TableEntry entry = null;
|
||||
//iterate until row
|
||||
Iterator<TableEntry> it = listData.iterator();
|
||||
for (int i = 0; i <= rowIndex; ++i) {
|
||||
entry = it.next();
|
||||
}
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
ret = (Object) entry.name;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
return (Object) entry.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,125 @@
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" alignment="0" pref="400" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="searchAddButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="220" max="32767" attributes="0"/>
|
||||
<Component id="manageListsButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jSplitPane1" min="-2" pref="268" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manageListsButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="searchAddButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="leftPane">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="cc" green="cc" red="cc" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 23]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="left"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="listsTable">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="f0" green="f0" red="f0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="listsTableModel" type="code"/>
|
||||
</Property>
|
||||
<Property name="showHorizontalLines" type="boolean" value="false"/>
|
||||
<Property name="showVerticalLines" type="boolean" value="false"/>
|
||||
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
|
||||
<TableHeader reorderingAllowed="false" resizingAllowed="true"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JScrollPane" name="rightPane">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="right"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="keywordsTable">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="f0" green="f0" red="f0" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="keywordsTableModel" type="code"/>
|
||||
</Property>
|
||||
<Property name="showHorizontalLines" type="boolean" value="false"/>
|
||||
<Property name="showVerticalLines" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="manageListsButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchListsViewerPanel.manageListsButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="manageListsButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="searchAddButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchListsViewerPanel.searchAddButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,620 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* KeywordSearchListsViewerPanel.java
|
||||
*
|
||||
* Created on Feb 17, 2012, 1:45:38 PM
|
||||
*/
|
||||
package org.sleuthkit.autopsy.keywordsearch;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import org.openide.util.actions.SystemAction;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dfickling
|
||||
*/
|
||||
public class KeywordSearchListsViewerPanel extends AbstractKeywordSearchPerformer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(KeywordSearchListsViewerPanel.class.getName());
|
||||
private static KeywordSearchListsViewerPanel instance;
|
||||
private KeywordSearchListsXML loader;
|
||||
private KeywordListsTableModel listsTableModel;
|
||||
private KeywordsTableModel keywordsTableModel;
|
||||
private ActionListener ingestListener;
|
||||
private ActionListener searchListener;
|
||||
private boolean ingestRunning;
|
||||
|
||||
/** Creates new form KeywordSearchListsViewerPanel */
|
||||
private KeywordSearchListsViewerPanel() {
|
||||
listsTableModel = new KeywordListsTableModel();
|
||||
keywordsTableModel = new KeywordsTableModel();
|
||||
initComponents();
|
||||
customizeComponents();
|
||||
}
|
||||
|
||||
public static KeywordSearchListsViewerPanel getDefault() {
|
||||
if (instance == null)
|
||||
return new KeywordSearchListsViewerPanel();
|
||||
else
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void customizeComponents() {
|
||||
listsTableModel.resync();
|
||||
|
||||
listsTable.setTableHeader(null);
|
||||
//customize column witdhs
|
||||
final int leftWidth = leftPane.getPreferredSize().width;
|
||||
TableColumn column = null;
|
||||
for (int i = 0; i < listsTable.getColumnCount(); i++) {
|
||||
column = listsTable.getColumnModel().getColumn(i);
|
||||
if (i == 0) {
|
||||
column.setPreferredWidth(((int) (leftWidth * 0.10)));
|
||||
} else {
|
||||
column.setPreferredWidth(((int) (leftWidth * 0.89)));
|
||||
}
|
||||
}
|
||||
final int rightWidth = rightPane.getPreferredSize().width;
|
||||
for (int i = 0; i < keywordsTable.getColumnCount(); i++) {
|
||||
column = keywordsTable.getColumnModel().getColumn(i);
|
||||
if (i == 0) {
|
||||
column.setPreferredWidth(((int) (rightWidth * 0.84)));
|
||||
} else {
|
||||
column.setPreferredWidth(((int) (rightWidth * 0.15)));
|
||||
}
|
||||
}
|
||||
|
||||
loader = KeywordSearchListsXML.getCurrent();
|
||||
loader.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String changed = evt.getPropertyName();
|
||||
Object oldValue = evt.getOldValue();
|
||||
Object newValue = evt.getNewValue();
|
||||
|
||||
if (changed.equals(KeywordSearchListsXML.ListsEvt.LIST_ADDED.toString())) {
|
||||
listsTableModel.resync();
|
||||
} else if (changed.equals(KeywordSearchListsXML.ListsEvt.LIST_DELETED.toString())) {
|
||||
listsTableModel.resync();
|
||||
if(listsTable.getRowCount() > 0)
|
||||
listsTable.getSelectionModel().setSelectionInterval(0, 0);
|
||||
else
|
||||
listsTable.getSelectionModel().clearSelection();
|
||||
} else if (changed.equals(KeywordSearchListsXML.ListsEvt.LIST_UPDATED.toString())) {
|
||||
listsTableModel.resync();
|
||||
}
|
||||
}
|
||||
});
|
||||
listsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
|
||||
if (!listSelectionModel.isSelectionEmpty()) {
|
||||
int index = listSelectionModel.getMinSelectionIndex();
|
||||
KeywordSearchList list = listsTableModel.getListAt(index);
|
||||
keywordsTableModel.resync(list);
|
||||
} else {
|
||||
keywordsTableModel.deleteAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
ingestListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addToIngestAction(e);
|
||||
}
|
||||
};
|
||||
searchListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
searchAction(e);
|
||||
}
|
||||
};
|
||||
|
||||
if(IngestManager.getDefault().isFileIngestRunning())
|
||||
initIngest(0);
|
||||
else
|
||||
initIngest(1);
|
||||
|
||||
IngestManager.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String changed = evt.getPropertyName();
|
||||
Object oldValue = evt.getOldValue();
|
||||
if(changed.equals(IngestManager.SERVICE_COMPLETED_EVT) &&
|
||||
((String) oldValue).equals(KeywordSearchIngestService.MODULE_NAME))
|
||||
initIngest(1);
|
||||
else if(changed.equals(IngestManager.SERVICE_STARTED_EVT) &&
|
||||
((String) oldValue).equals(KeywordSearchIngestService.MODULE_NAME))
|
||||
initIngest(0);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this panel depending on whether ingest is running
|
||||
* @param running
|
||||
* case 0: ingest running
|
||||
* case 1: ingest not running
|
||||
* case 2: ingest completed
|
||||
* case 3: ingest started
|
||||
*/
|
||||
private void initIngest(int running) {
|
||||
ActionListener[] current = searchAddButton.getActionListeners();
|
||||
for(int i = 0; i < current.length; i++) {
|
||||
if(current[i].equals(ingestListener) || current[i].equals(searchListener))
|
||||
searchAddButton.removeActionListener(current[i]);
|
||||
}
|
||||
switch (running) {
|
||||
case 0:
|
||||
ingestRunning = true;
|
||||
searchAddButton.setText("Add to Ingest");
|
||||
searchAddButton.addActionListener(ingestListener);
|
||||
listsTableModel.resync();
|
||||
break;
|
||||
case 1:
|
||||
ingestRunning = false;
|
||||
searchAddButton.setText("Search");
|
||||
searchAddButton.addActionListener(searchListener);
|
||||
listsTableModel.resync();
|
||||
break;
|
||||
case 2:
|
||||
ingestRunning = false;
|
||||
break;
|
||||
case 3:
|
||||
ingestRunning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
leftPane = new javax.swing.JScrollPane();
|
||||
listsTable = new javax.swing.JTable();
|
||||
rightPane = new javax.swing.JScrollPane();
|
||||
keywordsTable = new javax.swing.JTable();
|
||||
manageListsButton = new javax.swing.JButton();
|
||||
searchAddButton = new javax.swing.JButton();
|
||||
|
||||
leftPane.setBackground(new java.awt.Color(204, 204, 204));
|
||||
leftPane.setMinimumSize(new java.awt.Dimension(150, 23));
|
||||
|
||||
listsTable.setBackground(new java.awt.Color(240, 240, 240));
|
||||
listsTable.setModel(listsTableModel);
|
||||
listsTable.setShowHorizontalLines(false);
|
||||
listsTable.setShowVerticalLines(false);
|
||||
listsTable.getTableHeader().setReorderingAllowed(false);
|
||||
leftPane.setViewportView(listsTable);
|
||||
|
||||
jSplitPane1.setLeftComponent(leftPane);
|
||||
|
||||
keywordsTable.setBackground(new java.awt.Color(240, 240, 240));
|
||||
keywordsTable.setModel(keywordsTableModel);
|
||||
keywordsTable.setShowHorizontalLines(false);
|
||||
keywordsTable.setShowVerticalLines(false);
|
||||
rightPane.setViewportView(keywordsTable);
|
||||
|
||||
jSplitPane1.setRightComponent(rightPane);
|
||||
|
||||
manageListsButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchListsViewerPanel.class, "KeywordSearchListsViewerPanel.manageListsButton.text")); // NOI18N
|
||||
manageListsButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
manageListsButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
searchAddButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchListsViewerPanel.class, "KeywordSearchListsViewerPanel.searchAddButton.text")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(searchAddButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 220, Short.MAX_VALUE)
|
||||
.addComponent(manageListsButton)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manageListsButton)
|
||||
.addComponent(searchAddButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void manageListsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageListsButtonActionPerformed
|
||||
SystemAction.get(KeywordSearchConfigurationAction.class).performAction();
|
||||
}//GEN-LAST:event_manageListsButtonActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JTable keywordsTable;
|
||||
private javax.swing.JScrollPane leftPane;
|
||||
private javax.swing.JTable listsTable;
|
||||
private javax.swing.JButton manageListsButton;
|
||||
private javax.swing.JScrollPane rightPane;
|
||||
private javax.swing.JButton searchAddButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
|
||||
private void searchAction(ActionEvent e) {
|
||||
if (filesIndexed == 0)
|
||||
return;
|
||||
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
try {
|
||||
search();
|
||||
} finally {
|
||||
setCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToIngestAction(ActionEvent e) {
|
||||
//TODO: something
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Keyword> getQueryList() {
|
||||
List<Keyword> ret = new ArrayList<Keyword>();
|
||||
for(KeywordSearchList list : getSelectedLists()) {
|
||||
ret.addAll(list.getKeywords());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<KeywordSearchList> getSelectedLists() {
|
||||
return listsTableModel.getSelectedListsL();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiwordQuery() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLuceneQuerySelected() {
|
||||
throw new UnsupportedOperationException("Not supported for multi-word queries.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText() {
|
||||
throw new UnsupportedOperationException("Not supported for multi-word queries.");
|
||||
}
|
||||
|
||||
void addSearchButtonActionListener(ActionListener al) {
|
||||
searchAddButton.addActionListener(al);
|
||||
}
|
||||
|
||||
private class KeywordListsTableModel extends AbstractTableModel {
|
||||
//data
|
||||
|
||||
private KeywordSearchListsXML listsHandle = KeywordSearchListsXML.getCurrent();
|
||||
private Set<ListTableEntry> listData = new TreeSet<ListTableEntry>();
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return listData.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
String ret = null;
|
||||
switch(column) {
|
||||
case 0:
|
||||
ret = "Selected";
|
||||
break;
|
||||
case 1:
|
||||
ret = "Name";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object ret = null;
|
||||
ListTableEntry entry = null;
|
||||
//iterate until row
|
||||
Iterator<ListTableEntry> it = listData.iterator();
|
||||
for (int i = 0; i <= rowIndex; ++i) {
|
||||
entry = it.next();
|
||||
}
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
ret = (Object) entry.selected;
|
||||
break;
|
||||
case 1:
|
||||
ret = (Object) entry.name;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
if(columnIndex == 0){
|
||||
ListTableEntry entry = null;
|
||||
Iterator<ListTableEntry> it = listData.iterator();
|
||||
for(int i = 0; i <= rowIndex; i++) {
|
||||
entry = it.next();
|
||||
}
|
||||
if(entry != null) {
|
||||
entry.selected = (Boolean) aValue;
|
||||
if(ingestRunning) {
|
||||
updateUseForIngest(getListAt(rowIndex), (Boolean) aValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int c) {
|
||||
return getValueAt(0, c).getClass();
|
||||
}
|
||||
|
||||
private void updateUseForIngest(KeywordSearchList list, boolean selected) {
|
||||
listsHandle.addList(list.getName(), list.getKeywords(), selected);
|
||||
}
|
||||
|
||||
List<String> getAllLists() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (ListTableEntry e : listData) {
|
||||
ret.add(e.name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
KeywordSearchList getListAt(int rowIndex) {
|
||||
return listsHandle.getList((String)getValueAt(rowIndex, 1));
|
||||
}
|
||||
|
||||
List<String> getSelectedLists() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for(ListTableEntry e : listData) {
|
||||
if(e.selected)
|
||||
ret.add(e.name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<KeywordSearchList> getSelectedListsL() {
|
||||
List<KeywordSearchList> ret = new ArrayList<KeywordSearchList>();
|
||||
for(String s : getSelectedLists()) {
|
||||
ret.add(listsHandle.getList(s));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
boolean listExists(String list) {
|
||||
List<String> all = getAllLists();
|
||||
return all.contains(list);
|
||||
}
|
||||
|
||||
//resync model from handle, then update table
|
||||
void resync() {
|
||||
listData.clear();
|
||||
addLists(listsHandle.getListsL());
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
//resync single model entry from handle, then update table
|
||||
void resync(String listName) {
|
||||
ListTableEntry found = null;
|
||||
for (ListTableEntry e : listData) {
|
||||
if (e.name.equals(listName)) {
|
||||
found = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
listData.remove(found);
|
||||
addList(listsHandle.getList(listName));
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
//add list to the model
|
||||
private void addList(KeywordSearchList list) {
|
||||
if (!listExists(list.getName())) {
|
||||
listData.add(new ListTableEntry(list, ingestRunning));
|
||||
}
|
||||
}
|
||||
|
||||
//add lists to the model
|
||||
private void addLists(List<KeywordSearchList> lists) {
|
||||
for (KeywordSearchList list : lists) {
|
||||
if (!listExists(list.getName())) {
|
||||
listData.add(new ListTableEntry(list, ingestRunning));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//single model entry
|
||||
private class ListTableEntry implements Comparable {
|
||||
|
||||
String name;
|
||||
Boolean selected;
|
||||
|
||||
ListTableEntry(KeywordSearchList list, boolean ingestRunning) {
|
||||
this.name = list.getName();
|
||||
if(ingestRunning)
|
||||
this.selected = list.getUseForIngest();
|
||||
else
|
||||
this.selected = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.name.compareTo(((ListTableEntry) o).name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class KeywordsTableModel extends AbstractTableModel {
|
||||
|
||||
Set<KeywordTableEntry> listData = new TreeSet<KeywordTableEntry>();
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return listData.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
String ret = null;
|
||||
switch(column) {
|
||||
case 0:
|
||||
ret = "Name";
|
||||
break;
|
||||
case 1:
|
||||
ret = "RegEx";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object ret = null;
|
||||
KeywordTableEntry entry = null;
|
||||
//iterate until row
|
||||
Iterator<KeywordTableEntry> it = listData.iterator();
|
||||
for (int i = 0; i <= rowIndex; ++i) {
|
||||
entry = it.next();
|
||||
}
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
ret = (Object) entry.name;
|
||||
break;
|
||||
case 1:
|
||||
ret = (Object) entry.regex;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int c) {
|
||||
return getValueAt(0, c).getClass();
|
||||
}
|
||||
|
||||
void resync(KeywordSearchList list) {
|
||||
listData.clear();
|
||||
for(Keyword k : list.getKeywords()) {
|
||||
listData.add(new KeywordTableEntry(k));
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
listData.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
//single model entry
|
||||
private class KeywordTableEntry implements Comparable {
|
||||
|
||||
String name;
|
||||
Boolean regex;
|
||||
|
||||
KeywordTableEntry(Keyword keyword) {
|
||||
this.name = keyword.getQuery();
|
||||
this.regex = !keyword.isLiteral();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return this.name.compareTo(((KeywordTableEntry) o).name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -182,8 +182,27 @@ public class KeywordSearchListsXML {
|
||||
* replacing old one if exists with the same name
|
||||
* @param name the name of the new list or list to replace
|
||||
* @param newList list of keywords
|
||||
* @param useForIngest should this list be used for ingest
|
||||
* @return true if old list was replaced
|
||||
*/
|
||||
boolean addList(String name, List<Keyword> newList, boolean useForIngest) {
|
||||
boolean replaced = false;
|
||||
KeywordSearchList curList = getList(name);
|
||||
final Date now = new Date();
|
||||
if (curList == null) {
|
||||
theLists.put(name, new KeywordSearchList(name, now, now, useForIngest, newList));
|
||||
save();
|
||||
changeSupport.firePropertyChange(ListsEvt.LIST_ADDED.toString(), null, name);
|
||||
} else {
|
||||
theLists.put(name, new KeywordSearchList(name, curList.getDateCreated(), now, useForIngest, newList));
|
||||
save();
|
||||
replaced = true;
|
||||
changeSupport.firePropertyChange(ListsEvt.LIST_UPDATED.toString(), null, name);
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
||||
boolean addList(String name, List<Keyword> newList) {
|
||||
boolean replaced = false;
|
||||
KeywordSearchList curList = getList(name);
|
||||
|
@ -0,0 +1,171 @@
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Container class="javax.swing.JPopupMenu" name="settingsMenu">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="regExCheckboxMenuItem">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchPanel.regExCheckboxMenuItem.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPopupMenu" name="listsMenu">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[2000, 23]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace pref="1648" max="32767" attributes="0"/>
|
||||
<Component id="listsButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="searchBoxPanel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="searchBoxPanel" min="-2" pref="23" max="-2" attributes="2"/>
|
||||
<Component id="listsButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="searchBoxPanel">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true">
|
||||
<Color PropertyName="color" blue="c0" green="c0" id="lightGray" palette="1" red="c0" type="palette"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[255, 18]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="settingsLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="searchBox" pref="227" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="searchBox" min="-2" max="-2" attributes="2"/>
|
||||
<Component id="settingsLabel" alignment="0" min="-2" pref="21" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextField" name="searchBox">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="c0" green="c0" id="lightGray" palette="1" red="c0" type="palette"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchPanel.searchBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="4" left="3" right="1" top="1"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="settingsLabel">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/org/sleuthkit/autopsy/keywordsearch/search-icon.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchPanel.settingsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="1" left="2" right="2" top="1"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[23, 20]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[23, 20]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[23, 20]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="settingsLabelMousePressed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="listsButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchPanel.listsButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listsButtonMousePressed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* KeywordSearchPanel
|
||||
*
|
||||
*/
|
||||
package org.sleuthkit.autopsy.keywordsearch;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dfickling
|
||||
*/
|
||||
public class KeywordSearchPanel extends AbstractKeywordSearchPerformer{
|
||||
|
||||
private static final Logger logger = Logger.getLogger(KeywordSearchPanel.class.getName());
|
||||
private KeywordPropertyChangeListener listener;
|
||||
private boolean active = false;
|
||||
|
||||
/** Creates new form KeywordSearchPanel */
|
||||
public KeywordSearchPanel() {
|
||||
initComponents();
|
||||
customizeComponents();
|
||||
}
|
||||
|
||||
private void customizeComponents() {
|
||||
|
||||
listener = new KeywordPropertyChangeListener();
|
||||
|
||||
KeywordSearch.getServer().addServerActionListener(listener);
|
||||
|
||||
Case.addPropertyChangeListener(listener);
|
||||
|
||||
searchBox.addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (searchBox.getText().equals("Search...")) {
|
||||
searchBox.setText("");
|
||||
searchBox.setForeground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (searchBox.getText().equals("")) {
|
||||
resetSearchBox();
|
||||
}
|
||||
}
|
||||
});
|
||||
KeywordSearchListsViewerPanel listsPanel = KeywordSearchListsViewerPanel.getDefault();
|
||||
listsPanel.addSearchButtonActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listsMenu.setVisible(false);
|
||||
}
|
||||
|
||||
});
|
||||
listsMenu.add(listsPanel);
|
||||
|
||||
}
|
||||
|
||||
private void resetSearchBox() {
|
||||
searchBox.setEditable(true);
|
||||
searchBox.setText("Search...");
|
||||
searchBox.setForeground(Color.LIGHT_GRAY);
|
||||
regExCheckboxMenuItem.setEnabled(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
settingsMenu = new javax.swing.JPopupMenu();
|
||||
regExCheckboxMenuItem = new javax.swing.JCheckBoxMenuItem();
|
||||
listsMenu = new javax.swing.JPopupMenu();
|
||||
searchBoxPanel = new javax.swing.JPanel();
|
||||
searchBox = new javax.swing.JTextField();
|
||||
settingsLabel = new javax.swing.JLabel();
|
||||
listsButton = new javax.swing.JButton();
|
||||
|
||||
regExCheckboxMenuItem.setText(org.openide.util.NbBundle.getMessage(KeywordSearchPanel.class, "KeywordSearchPanel.regExCheckboxMenuItem.text")); // NOI18N
|
||||
settingsMenu.add(regExCheckboxMenuItem);
|
||||
|
||||
setOpaque(false);
|
||||
setPreferredSize(new java.awt.Dimension(2000, 23));
|
||||
|
||||
searchBoxPanel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.lightGray, 1, true));
|
||||
searchBoxPanel.setPreferredSize(new java.awt.Dimension(255, 18));
|
||||
|
||||
searchBox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
|
||||
searchBox.setForeground(java.awt.Color.lightGray);
|
||||
searchBox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchPanel.class, "KeywordSearchPanel.searchBox.text")); // NOI18N
|
||||
searchBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 3, 4, 1));
|
||||
searchBox.setEnabled(false);
|
||||
searchBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
searchBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
settingsLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/keywordsearch/search-icon.png"))); // NOI18N
|
||||
settingsLabel.setText(org.openide.util.NbBundle.getMessage(KeywordSearchPanel.class, "KeywordSearchPanel.settingsLabel.text")); // NOI18N
|
||||
settingsLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 2, 1, 2));
|
||||
settingsLabel.setMaximumSize(new java.awt.Dimension(23, 20));
|
||||
settingsLabel.setMinimumSize(new java.awt.Dimension(23, 20));
|
||||
settingsLabel.setPreferredSize(new java.awt.Dimension(23, 20));
|
||||
settingsLabel.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
settingsLabelMousePressed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout searchBoxPanelLayout = new javax.swing.GroupLayout(searchBoxPanel);
|
||||
searchBoxPanel.setLayout(searchBoxPanelLayout);
|
||||
searchBoxPanelLayout.setHorizontalGroup(
|
||||
searchBoxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(searchBoxPanelLayout.createSequentialGroup()
|
||||
.addComponent(settingsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(searchBox, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
|
||||
.addGap(3, 3, 3))
|
||||
);
|
||||
searchBoxPanelLayout.setVerticalGroup(
|
||||
searchBoxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(searchBoxPanelLayout.createSequentialGroup()
|
||||
.addGroup(searchBoxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(searchBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(settingsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
listsButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchPanel.class, "KeywordSearchPanel.listsButton.text")); // NOI18N
|
||||
listsButton.setEnabled(false);
|
||||
listsButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
listsButtonMousePressed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(1648, Short.MAX_VALUE)
|
||||
.addComponent(listsButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(searchBoxPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(searchBoxPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(listsButton))
|
||||
.addGap(0, 0, 0))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void searchBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchBoxActionPerformed
|
||||
if (filesIndexed == 0)
|
||||
return;
|
||||
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
try {
|
||||
search();
|
||||
} finally {
|
||||
setCursor(null);
|
||||
}
|
||||
}//GEN-LAST:event_searchBoxActionPerformed
|
||||
|
||||
private void settingsLabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_settingsLabelMousePressed
|
||||
maybeShowSettingsPopup(evt);
|
||||
}//GEN-LAST:event_settingsLabelMousePressed
|
||||
|
||||
private void listsButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listsButtonMousePressed
|
||||
maybeShowListsPopup(evt);
|
||||
}//GEN-LAST:event_listsButtonMousePressed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton listsButton;
|
||||
private javax.swing.JPopupMenu listsMenu;
|
||||
private javax.swing.JCheckBoxMenuItem regExCheckboxMenuItem;
|
||||
private javax.swing.JTextField searchBox;
|
||||
private javax.swing.JPanel searchBoxPanel;
|
||||
private javax.swing.JLabel settingsLabel;
|
||||
private javax.swing.JPopupMenu settingsMenu;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public String getQueryText() {
|
||||
return searchBox.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLuceneQuerySelected() {
|
||||
return !regExCheckboxMenuItem.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiwordQuery() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Keyword> getQueryList() {
|
||||
throw new UnsupportedOperationException("No list for single-keyword search");
|
||||
}
|
||||
|
||||
private class KeywordPropertyChangeListener implements PropertyChangeListener {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String changed = evt.getPropertyName();
|
||||
Object oldValue = evt.getOldValue();
|
||||
Object newValue = evt.getNewValue();
|
||||
|
||||
if (changed.equals(Case.CASE_CURRENT_CASE)) {
|
||||
if (newValue == null) {
|
||||
setFields(false);
|
||||
} else {
|
||||
setFields(true);
|
||||
}
|
||||
} else if (changed.equals(Server.CORE_EVT)) {
|
||||
final Server.CORE_EVT_STATES state = (Server.CORE_EVT_STATES) newValue;
|
||||
switch (state) {
|
||||
case STARTED:
|
||||
try {
|
||||
final int numIndexedFiles = KeywordSearch.getServer().getCore().queryNumIndexedFiles();
|
||||
KeywordSearch.changeSupport.firePropertyChange(KeywordSearch.NUM_FILES_CHANGE_EVT, null, new Integer(numIndexedFiles));
|
||||
//setFilesIndexed(numIndexedFiles);
|
||||
} catch (SolrServerException se) {
|
||||
logger.log(Level.SEVERE, "Error executing Solr query, " + se.getMessage());
|
||||
}
|
||||
break;
|
||||
case STOPPED:
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setFields(boolean enabled){
|
||||
searchBox.setEnabled(enabled);
|
||||
regExCheckboxMenuItem.setEnabled(enabled);
|
||||
settingsLabel.setEnabled(enabled);
|
||||
listsButton.setEnabled(enabled);
|
||||
active = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeShowSettingsPopup (MouseEvent evt) {
|
||||
if(!active) {
|
||||
return;
|
||||
}
|
||||
if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
settingsMenu.show(searchBoxPanel, 0, searchBoxPanel.getHeight());
|
||||
}
|
||||
|
||||
private void maybeShowListsPopup (MouseEvent evt) {
|
||||
if(!active) {
|
||||
return;
|
||||
}
|
||||
if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
listsMenu.show(listsButton, listsButton.getWidth()-listsMenu.getWidth(), listsButton.getHeight());
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.keywordsearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* common methods for the KeywordSearch performers
|
||||
*
|
||||
*/
|
||||
interface KeywordSearchPerformerInterface {
|
||||
|
||||
boolean isMultiwordQuery();
|
||||
boolean isLuceneQuerySelected();
|
||||
String getQueryText();
|
||||
List<Keyword> getQueryList();
|
||||
void setFilesIndexed(int filesIndexed);
|
||||
void search();
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 636 B |
@ -17,6 +17,10 @@
|
||||
<attr name="position" intvalue="999"/>
|
||||
</file>
|
||||
</folder>
|
||||
<!--<file name="org-sleuthkit-autopsy-keywordsearch-KeywordSearchAction.shadow">
|
||||
<attr name="originalFile" stringvalue="Actions/Tools/org-sleuthkit-autopsy-keywordsearch-KeywordSearchAction.instance"/>
|
||||
<attr name="position" intvalue="3000"/>
|
||||
</file>-->
|
||||
</folder>
|
||||
<folder name="Services">
|
||||
<file name="org-sleuthkit-autopsy-keywordsearch-KeywordSearchIngestService.instance">
|
||||
@ -24,10 +28,18 @@
|
||||
<attr name="instanceCreate" methodvalue="org.sleuthkit.autopsy.keywordsearch.KeywordSearchIngestService.getDefault"/>
|
||||
<attr name="position" intvalue="200"/>
|
||||
</file>
|
||||
<file name="org-sleuthkit-autopsy-keywordsearch-KeywordSearchDataExplorer.instance">
|
||||
<!--<file name="org-sleuthkit-autopsy-keywordsearch-KeywordSearchDataExplorer.instance">
|
||||
<attr name="instanceOf" stringvalue="org.sleuthkit.autopsy.corecomponentinterfaces.DataExplorer"/>
|
||||
<attr name="instanceCreate" methodvalue="org.sleuthkit.autopsy.keywordsearch.KeywordSearchDataExplorer.getDefault"/>
|
||||
<attr name="position" intvalue="300"/>
|
||||
</file>
|
||||
</file>-->
|
||||
</folder>
|
||||
<folder name="Toolbars">
|
||||
<folder name="File">
|
||||
<file name="org-sleuthkit-autopsy-keywordsearch-KeywordSearchAction.shadow">
|
||||
<attr name="originalFile" stringvalue="Actions/Tools/org-sleuthkit-autopsy-keywordsearch-KeywordSearchAction.instance"/>
|
||||
<attr name="position" intvalue="600"/>
|
||||
</file>
|
||||
</folder>
|
||||
</folder>
|
||||
</filesystem>
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 666 B |
Loading…
x
Reference in New Issue
Block a user