5114 support cancellation of search

This commit is contained in:
William Schaefer 2019-07-17 14:45:58 -04:00
parent 4dbdcb79bd
commit b0c9ee96ab
9 changed files with 57 additions and 22 deletions

View File

@ -17,7 +17,6 @@ FileSearchDialog.jLabel5.text=Order files by:
FileSearchDialog.parentCheckBox.text=Parent
ResultsDialog.exitButton.text=Exit
ResultsDialog.searchButton.text=Run another search
FileSearchDialog.errorLabel.text=jLabel6
FileSearchPanel.sortingPanel.border.title=Sorting
FileSearchPanel.searchButton.text=Show
FileSearchPanel.fileTypeLabel.text=File Type:
@ -45,3 +44,4 @@ FileSearchDialog.objCheckBox.text=Objects
FileSearchDialog.exifCheckBox.text=Must contain EXIF data
FileSearchDialog.notableCheckBox.text=Must have been tagged as notable
FileSearchDialog.scoreCheckBox.text=Has score
FileSearchPanel.cancelButton.text=Cancel

View File

@ -112,7 +112,6 @@ FileSorter.SortingMethod.parent.displayName=By parent path
ResultsDialog.dialogTitle.text=File search results
ResultsDialog.exitButton.text=Exit
ResultsDialog.searchButton.text=Run another search
FileSearchDialog.errorLabel.text=jLabel6
FileSearchPanel.sortingPanel.border.title=Sorting
FileSearchPanel.searchButton.text=Show
FileSearchPanel.fileTypeLabel.text=File Type:
@ -140,4 +139,5 @@ FileSearchDialog.objCheckBox.text=Objects
FileSearchDialog.exifCheckBox.text=Must contain EXIF data
FileSearchDialog.notableCheckBox.text=Must have been tagged as notable
FileSearchDialog.scoreCheckBox.text=Has score
FileSearchPanel.cancelButton.text=Cancel
SearchNode.getName.text=Search Result

View File

@ -123,6 +123,7 @@ class FileDiscoveryDialog extends javax.swing.JDialog {
@Override
public void dispose() {
fileSearchPanel.cancelSearch();
DiscoveryEvents.getDiscoveryEventBus().unregister(groupListPanel);
DiscoveryEvents.getDiscoveryEventBus().unregister(this);
super.dispose();

View File

@ -64,8 +64,8 @@ public final class FileDiscoveryTestAction extends CallableSystemAction {
return;
}
}
FileDiscoveryDialog dialog = new FileDiscoveryDialog(WindowManager.getDefault().getMainWindow(), false, Case.getCurrentCase().getSleuthkitCase(), crDb);
//modal set to true currently to prevent multiple dialogs being opened because messaging uses a shared eventbus
FileDiscoveryDialog dialog = new FileDiscoveryDialog(WindowManager.getDefault().getMainWindow(), true, Case.getCurrentCase().getSleuthkitCase(), crDb);
//register the dialog with the event bus
DiscoveryEvents.getDiscoveryEventBus().register(dialog);
// Display the dialog

View File

@ -437,9 +437,6 @@
</Component>
<Component class="javax.swing.JTextField" name="parentTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchDialog.parentTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 20]"/>
@ -539,9 +536,6 @@
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchDialog.errorLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">

View File

@ -745,7 +745,6 @@ public class FileSearchDialog extends javax.swing.JDialog implements ActionListe
}
});
parentTextField.setText(org.openide.util.NbBundle.getMessage(FileSearchDialog.class, "FileSearchDialog.parentTextField.text")); // NOI18N
parentTextField.setEnabled(false);
parentTextField.setMaximumSize(new java.awt.Dimension(6, 20));
@ -775,7 +774,6 @@ public class FileSearchDialog extends javax.swing.JDialog implements ActionListe
});
errorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(FileSearchDialog.class, "FileSearchDialog.errorLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(hashCheckBox, org.openide.util.NbBundle.getMessage(FileSearchDialog.class, "FileSearchDialog.hashCheckBox.text")); // NOI18N
hashCheckBox.addActionListener(new java.awt.event.ActionListener() {

View File

@ -33,7 +33,9 @@
<Group type="102" attributes="0">
<Component id="errorLabel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="searchButton" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="searchButton" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
@ -61,9 +63,12 @@
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="filtersScrollPane" pref="290" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="searchButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="errorLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="searchButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="errorLabel" min="-2" pref="0" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
@ -586,5 +591,15 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.cancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -59,12 +59,12 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
private DefaultListModel<FileSearchFiltering.ParentSearchTerm> parentListModel;
private final SleuthkitCase caseDb;
private final EamDb centralRepoDb;
private SearchWorker searchWorker = null;
/**
* Creates new form FileSearchDialog
*/
@NbBundle.Messages({
"FileSearchPanel.dialogTitle.text=Test file search",})
@NbBundle.Messages({"FileSearchPanel.dialogTitle.text=Test file search"})
FileSearchPanel(SleuthkitCase caseDb, EamDb centralRepoDb) {
this.caseDb = caseDb;
this.centralRepoDb = centralRepoDb;
@ -439,6 +439,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
groupByLabel = new javax.swing.JLabel();
fileTypeComboBox = new javax.swing.JComboBox<>();
errorLabel = new javax.swing.JLabel();
cancelButton = new javax.swing.JButton();
setMinimumSize(new java.awt.Dimension(408, 0));
@ -754,6 +755,13 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
errorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(FileSearchPanel.class, "FileSearchPanel.cancelButton.text")); // NOI18N
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -764,6 +772,8 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
.addGroup(layout.createSequentialGroup()
.addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(searchButton))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(6, 6, 6)
@ -774,6 +784,9 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
.addComponent(filtersScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(4, 4, 4))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, searchButton});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
@ -786,9 +799,11 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filtersScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchButton)
.addComponent(errorLabel))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchButton)
.addComponent(cancelButton))
.addComponent(errorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
@ -808,7 +823,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
// Get the file sorting method
FileSorter.SortingMethod fileSort = getFileSortingMethod();
SearchWorker searchWorker = new SearchWorker(centralRepoDb, searchButton, filters, groupingAttr, groupSortAlgorithm, fileSort);
searchWorker = new SearchWorker(centralRepoDb, searchButton, filters, groupingAttr, groupSortAlgorithm, fileSort);
searchWorker.execute();
}//GEN-LAST:event_searchButtonActionPerformed
@ -846,6 +861,12 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
}
}//GEN-LAST:event_addButtonActionPerformed
void cancelSearch(){
if (searchWorker != null){
searchWorker.cancel(true);
}
}
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
int index = parentList.getSelectedIndex();
parentListModel.remove(index);
@ -863,10 +884,15 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
dataSourceList.setEnabled(dataSourceCheckbox.isSelected());
}//GEN-LAST:event_dataSourceCheckboxActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
cancelSearch();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addButton;
private javax.swing.JRadioButton attributeRadioButton;
private javax.swing.JButton cancelButton;
private javax.swing.JCheckBox crFrequencyCheckbox;
private javax.swing.JList<Frequency> crFrequencyList;
private javax.swing.JScrollPane crFrequencyScrollPane;

View File

@ -93,5 +93,6 @@ final class SearchWorker extends SwingWorker<Void, Void> {
if (searchButtonToEnable != null) {
searchButtonToEnable.setEnabled(true);
}
System.out.println("SEARCH FINISHED");
}
}