4219 add no results node for common property search

This commit is contained in:
William Schaefer 2018-09-20 14:08:21 -04:00
parent 58d5b61bb5
commit 08143fc082

View File

@ -37,6 +37,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandle;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.nodes.Node;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
@ -51,6 +52,7 @@ import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode; import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.datamodel.EmptyNode;
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode; import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
@ -191,9 +193,9 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
"CommonAttributePanel.search.done.noCurrentCaseException=Unable to open case file.", "CommonAttributePanel.search.done.noCurrentCaseException=Unable to open case file.",
"CommonAttributePanel.search.done.exception=Unexpected exception running Common Property Search.", "CommonAttributePanel.search.done.exception=Unexpected exception running Common Property Search.",
"CommonAttributePanel.search.done.interupted=Something went wrong finding common properties.", "CommonAttributePanel.search.done.interupted=Something went wrong finding common properties.",
"CommonAttributePanel.search.done.sqlException=Unable to query db for properties or data sources."}) "CommonAttributePanel.search.done.sqlException=Unable to query db for properties or data sources.",
"CommonAttributePanel.search.done.noResults=No results found."})
private void search() { private void search() {
new SwingWorker<CommonAttributeSearchResults, Void>() { new SwingWorker<CommonAttributeSearchResults, Void>() {
private String tabTitle; private String tabTitle;
@ -259,24 +261,28 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
protected void done() { protected void done() {
try { try {
super.done(); super.done();
CommonAttributeSearchResults metadata = this.get(); CommonAttributeSearchResults metadata = this.get();
boolean noKeysExist = true;
CommonAttributeSearchResultRootNode commonFilesNode = new CommonAttributeSearchResultRootNode(metadata); try {
noKeysExist = metadata.getMetadata().keySet().isEmpty();
// -3969 } catch (EamDbException ex) {
DataResultFilterNode dataResultFilterNode = new DataResultFilterNode(commonFilesNode, ExplorerManager.find(CommonAttributePanel.this)); LOGGER.log(Level.SEVERE, "Unable to get keys from metadata", ex);
}
TableFilterNode tableFilterWithDescendantsNode = new TableFilterNode(dataResultFilterNode, 3); if (noKeysExist) {
Node commonFilesNode = new TableFilterNode(new EmptyNode(Bundle.CommonAttributePanel_search_done_noResults()), true);
DataResultViewerTable table = new CommonAttributesSearchResultsViewerTable(); progress.setDisplayName(Bundle.CommonAttributePanel_search_done_searchProgressDisplay());
DataResultTopComponent.createInstance(tabTitle, Bundle.CommonAttributePanel_search_results_pathText(), commonFilesNode, 1);
Collection<DataResultViewer> viewers = new ArrayList<>(1); } else {
viewers.add(table); // -3969
Node commonFilesNode = new CommonAttributeSearchResultRootNode(metadata);
progress.setDisplayName(Bundle.CommonAttributePanel_search_done_searchProgressDisplay()); DataResultFilterNode dataResultFilterNode = new DataResultFilterNode(commonFilesNode, ExplorerManager.find(CommonAttributePanel.this));
DataResultTopComponent.createInstance(tabTitle, Bundle.CommonAttributePanel_search_results_pathText(), tableFilterWithDescendantsNode, metadata.size(), viewers); TableFilterNode tableFilterWithDescendantsNode = new TableFilterNode(dataResultFilterNode, 3);
progress.finish(); DataResultViewerTable table = new CommonAttributesSearchResultsViewerTable();
Collection<DataResultViewer> viewers = new ArrayList<>(1);
viewers.add(table);
progress.setDisplayName(Bundle.CommonAttributePanel_search_done_searchProgressDisplay());
DataResultTopComponent.createInstance(tabTitle, Bundle.CommonAttributePanel_search_results_pathText(), tableFilterWithDescendantsNode, metadata.size(), viewers);
}
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
LOGGER.log(Level.SEVERE, "Interrupted while loading Common Files", ex); LOGGER.log(Level.SEVERE, "Interrupted while loading Common Files", ex);
@ -298,6 +304,8 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
errorMessage = Bundle.CommonAttributePanel_search_done_exception(); errorMessage = Bundle.CommonAttributePanel_search_done_exception();
} }
MessageNotifyUtil.Message.error(errorMessage); MessageNotifyUtil.Message.error(errorMessage);
} finally {
progress.finish();
} }
} }
}.execute(); }.execute();
@ -317,6 +325,7 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
"CommonAttributePanel.setupDataSources.done.interupted=Something went wrong building the Common Files Search dialog box.", "CommonAttributePanel.setupDataSources.done.interupted=Something went wrong building the Common Files Search dialog box.",
"CommonAttributePanel.setupDataSources.done.sqlException=Unable to query db for data sources.", "CommonAttributePanel.setupDataSources.done.sqlException=Unable to query db for data sources.",
"CommonAttributePanel.setupDataSources.updateUi.noDataSources=No data sources were found."}) "CommonAttributePanel.setupDataSources.updateUi.noDataSources=No data sources were found."})
private void setupDataSources() { private void setupDataSources() {
new SwingWorker<Map<Long, String>, Void>() { new SwingWorker<Map<Long, String>, Void>() {