mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
graceful handling in the event that no datasources are available
This commit is contained in:
parent
62c5f037b5
commit
f29af7e012
@ -52,8 +52,8 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final Long NO_DATA_SOURCE_SELECTED = -1L;
|
public static final Long NO_DATA_SOURCE_SELECTED = -1L;
|
||||||
|
|
||||||
private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
|
private ComboBoxModel<String> dataSourcesList = new DataSourceComboBoxModel();
|
||||||
private Map<Long, String> dataSourceMap;
|
private Map<Long, String> dataSourceMap;
|
||||||
|
|
||||||
@ -85,7 +85,8 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
"CommonFilesPanel.buildDataSourceMap.done.noCurrentCaseException=Unable to open case file.",
|
"CommonFilesPanel.buildDataSourceMap.done.noCurrentCaseException=Unable to open case file.",
|
||||||
"CommonFilesPanel.buildDataSourceMap.done.exception=Unexpected exception building data sources map.",
|
"CommonFilesPanel.buildDataSourceMap.done.exception=Unexpected exception building data sources map.",
|
||||||
"CommonFilesPanel.buildDataSourceMap.done.interupted=Something went wrong building the Common Files Search dialog box.",
|
"CommonFilesPanel.buildDataSourceMap.done.interupted=Something went wrong building the Common Files Search dialog box.",
|
||||||
"CommonFilesPanel.buildDataSourceMap.done.sqlException=Unable to query db for data sources."})
|
"CommonFilesPanel.buildDataSourceMap.done.sqlException=Unable to query db for data sources.",
|
||||||
|
"CommonFilesPanel.buildDataSourcesMap.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>() {
|
||||||
@ -95,20 +96,27 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
private void updateUi() {
|
private void updateUi() {
|
||||||
|
|
||||||
String[] dataSourcesNames = new String[CommonFilesPanel.this.dataSourceMap.size()];
|
String[] dataSourcesNames = new String[CommonFilesPanel.this.dataSourceMap.size()];
|
||||||
dataSourcesNames = CommonFilesPanel.this.dataSourceMap.values().toArray(dataSourcesNames);
|
|
||||||
CommonFilesPanel.this.dataSourcesList = new DataSourceComboBoxModel(dataSourcesNames);
|
//only enable all this stuff if we actually have datasources
|
||||||
CommonFilesPanel.this.selectDataSourceComboBox.setModel(CommonFilesPanel.this.dataSourcesList);
|
if (dataSourcesNames.length > 0) {
|
||||||
|
dataSourcesNames = CommonFilesPanel.this.dataSourceMap.values().toArray(dataSourcesNames);
|
||||||
|
CommonFilesPanel.this.dataSourcesList = new DataSourceComboBoxModel(dataSourcesNames);
|
||||||
|
CommonFilesPanel.this.selectDataSourceComboBox.setModel(CommonFilesPanel.this.dataSourcesList);
|
||||||
|
|
||||||
boolean multipleDataSources = this.caseHasMultipleSources();
|
boolean multipleDataSources = this.caseHasMultipleSources();
|
||||||
CommonFilesPanel.this.allDataSourcesRadioButton.setEnabled(multipleDataSources);
|
CommonFilesPanel.this.allDataSourcesRadioButton.setEnabled(multipleDataSources);
|
||||||
CommonFilesPanel.this.allDataSourcesRadioButton.setSelected(multipleDataSources);
|
CommonFilesPanel.this.allDataSourcesRadioButton.setSelected(multipleDataSources);
|
||||||
|
|
||||||
if (!multipleDataSources) {
|
if (!multipleDataSources) {
|
||||||
CommonFilesPanel.this.withinDataSourceRadioButton.setSelected(true);
|
CommonFilesPanel.this.withinDataSourceRadioButton.setSelected(true);
|
||||||
withinDataSourceSelected(true);
|
withinDataSourceSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommonFilesPanel.this.searchButton.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
MessageNotifyUtil.Message.error(Bundle.CommonFilesPanel_buildDataSourcesMap_updateUi_noDataSources());
|
||||||
|
CommonFilesPanel.this.cancelButtonActionPerformed(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonFilesPanel.this.searchButton.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean caseHasMultipleSources() {
|
private boolean caseHasMultipleSources() {
|
||||||
@ -168,7 +176,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NbBundle.Messages({
|
@NbBundle.Messages({
|
||||||
"CommonFilesPanel.search.results.titleAll=Common Files (All Data Sources)",
|
"CommonFilesPanel.search.results.titleAll=Common Files (All Data Sources)",
|
||||||
"CommonFilesPanel.search.results.titleSingle=Common Files (Match Within Data Source: %s)",
|
"CommonFilesPanel.search.results.titleSingle=Common Files (Match Within Data Source: %s)",
|
||||||
@ -184,7 +192,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
new SwingWorker<List<CommonFilesMetaData>, Void>() {
|
new SwingWorker<List<CommonFilesMetaData>, Void>() {
|
||||||
|
|
||||||
private String tabTitle;
|
private String tabTitle;
|
||||||
|
|
||||||
private void setTitleForAllDataSources() {
|
private void setTitleForAllDataSources() {
|
||||||
this.tabTitle = Bundle.CommonFilesPanel_search_results_titleAll();
|
this.tabTitle = Bundle.CommonFilesPanel_search_results_titleAll();
|
||||||
}
|
}
|
||||||
@ -192,10 +200,10 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
private void setTitleForSingleSource(Long dataSourceId) {
|
private void setTitleForSingleSource(Long dataSourceId) {
|
||||||
final String CommonFilesPanel_search_results_titleSingle = Bundle.CommonFilesPanel_search_results_titleSingle();
|
final String CommonFilesPanel_search_results_titleSingle = Bundle.CommonFilesPanel_search_results_titleSingle();
|
||||||
final Object[] dataSourceName = new Object[]{dataSourceMap.get(dataSourceId)};
|
final Object[] dataSourceName = new Object[]{dataSourceMap.get(dataSourceId)};
|
||||||
|
|
||||||
this.tabTitle = String.format(CommonFilesPanel_search_results_titleSingle, dataSourceName);
|
this.tabTitle = String.format(CommonFilesPanel_search_results_titleSingle, dataSourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long determineDataSourceId() {
|
private Long determineDataSourceId() {
|
||||||
Long selectedObjId = CommonFilesPanel.NO_DATA_SOURCE_SELECTED;
|
Long selectedObjId = CommonFilesPanel.NO_DATA_SOURCE_SELECTED;
|
||||||
if (CommonFilesPanel.this.singleDataSource) {
|
if (CommonFilesPanel.this.singleDataSource) {
|
||||||
@ -213,19 +221,19 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
@SuppressWarnings({"BoxedValueEquality", "NumberEquality"})
|
@SuppressWarnings({"BoxedValueEquality", "NumberEquality"})
|
||||||
protected List<CommonFilesMetaData> doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException {
|
protected List<CommonFilesMetaData> doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException {
|
||||||
Long dataSourceId = determineDataSourceId();
|
Long dataSourceId = determineDataSourceId();
|
||||||
|
|
||||||
CommonFilesMetaDataBuilder builder;
|
CommonFilesMetaDataBuilder builder;
|
||||||
|
|
||||||
if (dataSourceId == CommonFilesPanel.NO_DATA_SOURCE_SELECTED) {
|
if (dataSourceId == CommonFilesPanel.NO_DATA_SOURCE_SELECTED) {
|
||||||
builder = new AllDataSources(dataSourceMap);
|
builder = new AllDataSources(dataSourceMap);
|
||||||
|
|
||||||
setTitleForAllDataSources();
|
setTitleForAllDataSources();
|
||||||
} else {
|
} else {
|
||||||
builder = new SingleDataSource(dataSourceId, dataSourceMap);
|
builder = new SingleDataSource(dataSourceId, dataSourceMap);
|
||||||
|
|
||||||
setTitleForSingleSource(dataSourceId);
|
setTitleForSingleSource(dataSourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.collateFiles();
|
return builder.collateFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,9 +256,9 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
for (CommonFilesMetaData meta : metadata) {
|
for (CommonFilesMetaData meta : metadata) {
|
||||||
totalNodes += meta.getChildren().size();
|
totalNodes += meta.getChildren().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataResultTopComponent component = DataResultTopComponent.createInstance(this.tabTitle);
|
DataResultTopComponent component = DataResultTopComponent.createInstance(this.tabTitle);
|
||||||
|
|
||||||
DataResultTopComponent.initInstance(pathText, tableFilterWithDescendantsNode, 0/*totalNodes*/, component);
|
DataResultTopComponent.initInstance(pathText, tableFilterWithDescendantsNode, 0/*totalNodes*/, component);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
@ -496,7 +504,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
|||||||
}//GEN-LAST:event_withinDataSourceRadioButtonActionPerformed
|
}//GEN-LAST:event_withinDataSourceRadioButtonActionPerformed
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
||||||
SwingUtilities.windowForComponent(this).dispose();
|
SwingUtilities.windowForComponent(this).dispose();
|
||||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||||
|
|
||||||
private void withinDataSourceSelected(boolean selected) {
|
private void withinDataSourceSelected(boolean selected) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user