reset state of data source filters when case is opened.

This commit is contained in:
millmanorama 2018-02-27 15:24:44 +01:00
parent 14a55af19c
commit 3f5619933d
3 changed files with 48 additions and 24 deletions

View File

@ -142,7 +142,7 @@ public final class CVTTopComponent extends TopComponent {
* *
* Re-applying the filters means we will lose the selection... * Re-applying the filters means we will lose the selection...
*/ */
filtersPane.updateAndApplyFilters(); filtersPane.updateAndApplyFilters(true);
} }
@Override @Override

View File

@ -310,7 +310,7 @@ final class CommunicationsGraph extends mxGraph {
Set<Long> accountIDs = relatedAccounts.keySet(); Set<Long> accountIDs = relatedAccounts.keySet();
Map<Relationship.RelationshipKey, Long> relationshipCounts = commsManager.getRelationshipCounts(accountIDs, currentFilter); Map<Relationship.RelationshipKey, Long> relationshipCounts = commsManager.getRelationshipCountsBetween(accountIDs, currentFilter);
int total = relationshipCounts.size(); int total = relationshipCounts.size();
int k = 0; int k = 0;

View File

@ -61,8 +61,15 @@ final public class FiltersPanel extends JPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName()); private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName());
/**
* Map from Account.Type to the checkbox for that account type's filter.
*/
@ThreadConfined(type = ThreadConfined.ThreadType.AWT) @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
private final Map<Account.Type, JCheckBox> accountTypeMap = new HashMap<>(); private final Map<Account.Type, JCheckBox> accountTypeMap = new HashMap<>();
/**
* Map from datasource device id to the checkbox for that datasource.
*/
@ThreadConfined(type = ThreadConfined.ThreadType.AWT) @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
private final Map<String, JCheckBox> devicesMap = new HashMap<>(); private final Map<String, JCheckBox> devicesMap = new HashMap<>();
@ -70,6 +77,11 @@ final public class FiltersPanel extends JPanel {
* Listens to ingest events to enable refresh button * Listens to ingest events to enable refresh button
*/ */
private final PropertyChangeListener ingestListener; private final PropertyChangeListener ingestListener;
/**
* Flag that indicates the UI is not up-sto-date with respect to the case DB
* and it should be refreshed (by reapplying the filters).
*/
private boolean needsRefresh; private boolean needsRefresh;
/** /**
@ -78,10 +90,16 @@ final public class FiltersPanel extends JPanel {
* results) * results)
*/ */
private final ItemListener validationListener; private final ItemListener validationListener;
private boolean deviceAccountTypeEnabled = false;
@NbBundle.Messages({"refreshText=Refresh Results", /**
"applyText=Apply"}) * Is the device account type filter enabled or not. It should be enabled
* when the Table/Brows mode is active and disabled when the visualization
* is active. Initially false since the browse/table mode is active
* initially.
*/
private boolean deviceAccountTypeEnabled;
@NbBundle.Messages({"refreshText=Refresh Results", "applyText=Apply"})
public FiltersPanel() { public FiltersPanel() {
initComponents(); initComponents();
deviceRequiredLabel.setVisible(false); deviceRequiredLabel.setVisible(false);
@ -102,8 +120,7 @@ final public class FiltersPanel extends JPanel {
updateTimeZone(); updateTimeZone();
validationListener = itemEvent -> validateFilters(); validationListener = itemEvent -> validateFilters();
updateFilters(); updateFilters(true);
setAllDevicesSelected(true);
UserPreferences.addChangeListener(preferenceChangeEvent -> { UserPreferences.addChangeListener(preferenceChangeEvent -> {
if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)) { if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)) {
updateTimeZone(); updateTimeZone();
@ -118,7 +135,7 @@ final public class FiltersPanel extends JPanel {
if (null != eventData if (null != eventData
&& eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID() && eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()
&& eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) { && eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
updateFilters(); updateFilters(false);
needsRefresh = true; needsRefresh = true;
validateFilters(); validateFilters();
} }
@ -150,8 +167,8 @@ final public class FiltersPanel extends JPanel {
/** /**
* Update the filter widgets, and apply them. * Update the filter widgets, and apply them.
*/ */
void updateAndApplyFilters() { void updateAndApplyFilters(boolean initialState) {
updateFilters(); updateFilters(initialState);
applyFilters(); applyFilters();
} }
@ -162,9 +179,9 @@ final public class FiltersPanel extends JPanel {
/** /**
* Updates the filter widgets to reflect he data sources/types in the case. * Updates the filter widgets to reflect he data sources/types in the case.
*/ */
private void updateFilters() { private void updateFilters(boolean initialState) {
updateAccountTypeFilter(); updateAccountTypeFilter();
updateDeviceFilter(); updateDeviceFilter(initialState);
} }
@Override @Override
@ -221,7 +238,7 @@ final public class FiltersPanel extends JPanel {
/** /**
* Populate the devices filter widgets * Populate the devices filter widgets
*/ */
private void updateDeviceFilter() { private void updateDeviceFilter(boolean initialState) {
try { try {
final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase(); final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
@ -229,13 +246,12 @@ final public class FiltersPanel extends JPanel {
String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName(); String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName();
//store the device id in the map, but display a datasource name in the UI. //store the device id in the map, but display a datasource name in the UI.
devicesMap.computeIfAbsent(dataSource.getDeviceId(), ds -> { devicesMap.computeIfAbsent(dataSource.getDeviceId(), ds -> {
final JCheckBox jCheckBox = new JCheckBox(dsName, false); final JCheckBox jCheckBox = new JCheckBox(dsName, initialState);
jCheckBox.addItemListener(validationListener); jCheckBox.addItemListener(validationListener);
devicesPane.add(jCheckBox); devicesPane.add(jCheckBox);
return jCheckBox; return jCheckBox;
}); });
}; }
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex); logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex);
} catch (TskCoreException tskCoreException) { } catch (TskCoreException tskCoreException) {
@ -538,6 +554,21 @@ final public class FiltersPanel extends JPanel {
return new DateRangeFilter(start, end); return new DateRangeFilter(start, end);
} }
/**
* Enable or disable the device account type filter. The filter should be
* disabled for the browse/table mode and enabled for the visualization.
*
* @param enable True to enable the device account type filter, False to
* disable it.
*/
void setDeviceAccountTypeEnabled(boolean enable) {
deviceAccountTypeEnabled = enable;
JCheckBox deviceCheckbox = accountTypeMap.get(Account.Type.DEVICE);
if (deviceCheckbox != null) {
deviceCheckbox.setEnabled(deviceAccountTypeEnabled);
}
}
/** /**
* Set the selection state of all the account type check boxes * Set the selection state of all the account type check boxes
* *
@ -569,6 +600,7 @@ final public class FiltersPanel extends JPanel {
private void setAllSelected(Map<?, JCheckBox> map, boolean selected) { private void setAllSelected(Map<?, JCheckBox> map, boolean selected) {
map.values().forEach(box -> box.setSelected(selected)); map.values().forEach(box -> box.setSelected(selected));
} }
private void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllAccountTypesButtonActionPerformed private void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllAccountTypesButtonActionPerformed
setAllAccountTypesSelected(false); setAllAccountTypesSelected(false);
}//GEN-LAST:event_unCheckAllAccountTypesButtonActionPerformed }//GEN-LAST:event_unCheckAllAccountTypesButtonActionPerformed
@ -620,12 +652,4 @@ final public class FiltersPanel extends JPanel {
private final javax.swing.JButton unCheckAllAccountTypesButton = new javax.swing.JButton(); private final javax.swing.JButton unCheckAllAccountTypesButton = new javax.swing.JButton();
private final javax.swing.JButton unCheckAllDevicesButton = new javax.swing.JButton(); private final javax.swing.JButton unCheckAllDevicesButton = new javax.swing.JButton();
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
void setDeviceAccountTypeEnabled(boolean enableDeviceAccountType) {
deviceAccountTypeEnabled = enableDeviceAccountType;
JCheckBox deviceCheckbox = accountTypeMap.get(Account.Type.DEVICE);
if (deviceCheckbox != null) {
deviceCheckbox.setEnabled(deviceAccountTypeEnabled);
}
}
} }