panel update

This commit is contained in:
Greg DiCristofaro 2020-07-20 08:32:09 -04:00
parent 6a274fdcb5
commit 4f97008eb5
2 changed files with 84 additions and 63 deletions

View File

@ -655,7 +655,7 @@ public class HashDbManager implements PropertyChangeListener {
officialHashSets = new ArrayList<HashDbInfo>();
}
final Stream combined = Stream.concat(hashDbInfoList.stream(), officialHashSets.stream());
final Stream<HashDbInfo> combined = Stream.concat(hashDbInfoList.stream(), officialHashSets.stream());
combined.forEach((HashDbInfo hashDbInfo) -> {
try {

View File

@ -25,8 +25,10 @@ import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.logging.Level;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
@ -37,6 +39,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import org.apache.commons.lang3.StringUtils;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
@ -197,25 +200,72 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
if (db instanceof SleuthkitHashSet) {
SleuthkitHashSet hashDb = (SleuthkitHashSet) db;
updateForSleuthkitHashSet(ingestIsRunning, hashDb);
} else {
// Disable the file type fields/buttons
indexPathLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
hashDbIndexStatusLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
hashDbLocationLabel.setText(Bundle.HashLookupSettingsPanel_centralRepo());
indexButton.setEnabled(false);
deleteDatabaseButton.setEnabled(false);
CentralRepoHashSet crDb = (CentralRepoHashSet) db;
hashDbVersionLabel.setText(crDb.getVersion());
hashDbOrgLabel.setText(crDb.getOrgName());
}
// Disable the indexing button if ingest is in progress.
if (ingestIsRunning) {
indexButton.setEnabled(false);
}
// Update ingest option components.
sendIngestMessagesCheckBox.setSelected(db.getSendIngestMessages());
sendIngestMessagesCheckBox.setEnabled(!ingestIsRunning && db.getKnownFilesType().isInboxMessagesAllowed());
// Update database action buttons.
createDatabaseButton.setEnabled(true);
importDatabaseButton.setEnabled(true);
// Update ingest in progress warning label.
ingestWarningLabel.setVisible(ingestIsRunning);
}
private static String getPathString(String path, boolean justFilename) {
if (StringUtils.isBlank(path))
return "";
if (!justFilename)
return path;
return new File(path).getName();
}
private void updateForSleuthkitHashSet(boolean ingestIsRunning, SleuthkitHashSet hashDb) throws MissingResourceException {
// Disable the central repo fields
hashDbVersionLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
hashDbOrgLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
// Enable the delete button if ingest is not running
deleteDatabaseButton.setEnabled(!ingestIsRunning);
// Enable the delete button if ingest is not running and is not an official hashset
deleteDatabaseButton.setEnabled(!ingestIsRunning && !hashDb.isOfficialSet());
try {
hashDbLocationLabel.setText(db.getDatabasePath());
String dbPath = getPathString(hashDb.getDatabasePath(), hashDb.isOfficialSet());
hashDbLocationLabel.setText(dbPath);
} catch (TskCoreException ex) {
Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting hash set path of " + db.getHashSetName() + " hash set", ex); //NON-NLS
Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting hash set path of " + hashDb.getHashSetName() + " hash set", ex); //NON-NLS
hashDbLocationLabel.setText(ERROR_GETTING_PATH_TEXT);
}
try {
indexPathLabel.setText(hashDb.getIndexPath());
String indexPath = getPathString(hashDb.getIndexPath(), hashDb.isOfficialSet());
indexPathLabel.setText(indexPath);
} catch (TskCoreException ex) {
Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index path of " + db.getHashSetName() + " hash set", ex); //NON-NLS
Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index path of " + hashDb.getHashSetName() + " hash set", ex); //NON-NLS
indexPathLabel.setText(ERROR_GETTING_PATH_TEXT);
}
@ -259,37 +309,8 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
indexButton.setEnabled(false);
}
} else {
// Disable the file type fields/buttons
indexPathLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
hashDbIndexStatusLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
hashDbLocationLabel.setText(Bundle.HashLookupSettingsPanel_centralRepo());
indexButton.setEnabled(false);
deleteDatabaseButton.setEnabled(false);
CentralRepoHashSet crDb = (CentralRepoHashSet) db;
hashDbVersionLabel.setText(crDb.getVersion());
hashDbOrgLabel.setText(crDb.getOrgName());
}
// Disable the indexing button if ingest is in progress.
if (ingestIsRunning) {
indexButton.setEnabled(false);
}
// Update ingest option components.
sendIngestMessagesCheckBox.setSelected(db.getSendIngestMessages());
sendIngestMessagesCheckBox.setEnabled(!ingestIsRunning && db.getKnownFilesType().isInboxMessagesAllowed());
// Update database action buttons.
createDatabaseButton.setEnabled(true);
importDatabaseButton.setEnabled(true);
// Update ingest in progress warning label.
ingestWarningLabel.setVisible(ingestIsRunning);
}
private boolean isLocalIngestJobEvent(PropertyChangeEvent evt) {
if (evt instanceof AutopsyEvent) {