From f6a2bf16c503be95a307f98a0cebce850e3493b7 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Fri, 5 Apr 2019 15:26:04 -0400 Subject: [PATCH] refactored how the date control state was saved --- .../communications/AccountsBrowser.java | 4 +- .../autopsy/communications/CVTEvents.java | 31 +++-- .../autopsy/communications/FiltersPanel.java | 115 +++++++++++++----- .../autopsy/communications/StateManager.java | 77 ++++++------ .../communications/VisualizationPanel.java | 11 +- .../keywordsearch/Bundle.properties-MERGED | 2 +- .../recentactivity/Bundle.properties-MERGED | 2 +- 7 files changed, 157 insertions(+), 85 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java index 1d23a7f9fc..6abd4a70d0 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java @@ -120,7 +120,7 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro } @Subscribe - public void handleFilterEvent(CVTEvents.FilterChangeEvent filterChangeEvent) { + void handleFilterEvent(CVTEvents.FilterChangeEvent filterChangeEvent) { try { final CommunicationsManager commsManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager(); accountsTableEM.setRootContext(new AbstractNode(Children.create(new AccountDeviceInstanceNodeFactory(commsManager, filterChangeEvent.getNewFilter()), true))); @@ -132,7 +132,7 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro } @Subscribe - void historyChange(CVTEvents.StateEvent event) { + void historyChange(CVTEvents.StateChangeEvent event) { try { final CommunicationsManager commsManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager(); accountsTableEM.setRootContext(new AbstractNode(Children.create(new AccountDeviceInstanceNodeFactory(commsManager, event.getCommunicationsState().getCommunicationsFilter()), true))); diff --git a/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java b/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java index 051ff2b193..ee7224b673 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java +++ b/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java @@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.communications; import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.EventBus; import java.util.Collection; +import org.sleuthkit.autopsy.communications.FiltersPanel.DateControlState; import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.autopsy.communications.StateManager.CommunicationsState; @@ -39,18 +40,30 @@ final class CVTEvents { } /** - * Invoked when a ComminucationsFilter change occures. + * Invoked when a change from the FiltersPanel occures. */ static final class FilterChangeEvent { private final CommunicationsFilter newFilter; + private final DateControlState startControlState; + private final DateControlState endControlState; CommunicationsFilter getNewFilter() { return newFilter; } + + DateControlState getStartControlState() { + return startControlState; + } + + DateControlState getEndControlState() { + return endControlState; + } - FilterChangeEvent(CommunicationsFilter newFilter) { + FilterChangeEvent(CommunicationsFilter newFilter, DateControlState startControlState, DateControlState endControlState) { this.newFilter = newFilter; + this.startControlState = startControlState; + this.endControlState = endControlState; } } @@ -96,10 +109,10 @@ final class CVTEvents { /** * Invoked when there is a change in the state of the window. */ - static final class StateEvent { + static final class StateChangeEvent { private final CommunicationsState newState; - StateEvent(CommunicationsState newState) { + StateChangeEvent(CommunicationsState newState) { this.newState = newState; } @@ -111,15 +124,15 @@ final class CVTEvents { /** * Invoked when change in the link analysis graph scale occures. */ - static final class ZoomEvent { - private final double zoomValue; + static final class ScaleChangeEvent { + private final double scaleValue; - ZoomEvent(double zoomValue) { - this.zoomValue = zoomValue; + ScaleChangeEvent(double scaleValue) { + this.scaleValue = scaleValue; } public double getZoomValue(){ - return zoomValue; + return scaleValue; } } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java index a6ed7e5aef..56c8be50a7 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java @@ -22,10 +22,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.Subscribe; import java.awt.event.ItemListener; import java.beans.PropertyChangeListener; -import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; -import java.time.ZonedDateTime; import java.util.Collection; import java.util.EnumSet; import java.util.HashMap; @@ -272,13 +270,11 @@ final public class FiltersPanel extends JPanel { * * @param subFilters A list of subFilters */ - public void setFilters(List subFilters) { - + public void setFilters(CommunicationsFilter commFilter) { + List subFilters = commFilter.getAndFilters(); subFilters.forEach(subFilter -> { if( subFilter instanceof DeviceFilter ) { setDeviceFilter((DeviceFilter)subFilter); - } else if (subFilter instanceof DateRangeFilter) { - setDateRangeFilter( (DateRangeFilter) subFilter); } else if( subFilter instanceof AccountTypeFilter) { setAccountTypeFilter((AccountTypeFilter) subFilter); } @@ -297,23 +293,6 @@ final public class FiltersPanel extends JPanel { }); } - /** - * Sets the value of the DateRangeFilters. - * - * @param dateFilter - */ - private void setDateRangeFilter(DateRangeFilter dateFilter) { - ZonedDateTime zoneDate = ZonedDateTime.ofInstant(Instant.ofEpochSecond(dateFilter.getStartDate()), Utils.getUserPreferredZoneId()); - startDatePicker.setEnabled(dateFilter.isStartDateEnabled()); - startCheckBox.setSelected(dateFilter.isStartDateEnabled()); - startDatePicker.setDate(zoneDate.toLocalDate()); - - zoneDate = ZonedDateTime.ofInstant(Instant.ofEpochSecond(dateFilter.getEndDate()), Utils.getUserPreferredZoneId()); - endDatePicker.setEnabled(dateFilter.isEndDateEnabled()); - endCheckBox.setSelected(dateFilter.isEndDateEnabled()); - endDatePicker.setDate(zoneDate.toLocalDate()); - } - /** * Set the state of the account type checkboxes to match the passed in filter * @@ -326,10 +305,36 @@ final public class FiltersPanel extends JPanel { }); } + /** + * Set up the startDatePicker and startCheckBox based on the passed in + * DateControlState. + * + * @param state new control state + */ + private void setStartDateControlState(DateControlState state) { + startDatePicker.setDate(state.getDate()); + startCheckBox.setSelected(state.isEnabled()); + startDatePicker.setEnabled(state.isEnabled()); + } + + /** + * Set up the endDatePicker and endCheckBox based on the passed in + * DateControlState. + * + * @param state new control state + */ + private void setEndDateControlState(DateControlState state) { + endDatePicker.setDate(state.getDate()); + endCheckBox.setSelected(state.isEnabled()); + endDatePicker.setEnabled(state.isEnabled()); + } + @Subscribe - void filtersBack(CVTEvents.StateEvent event) { - if(event.getCommunicationsState().getCommunicationsFilters() != null){ - setFilters(event.getCommunicationsState().getCommunicationsFilters()); + void filtersBack(CVTEvents.StateChangeEvent event) { + if(event.getCommunicationsState().getCommunicationsFilter() != null){ + setFilters(event.getCommunicationsState().getCommunicationsFilter()); + setStartDateControlState(event.getCommunicationsState().getStartControlState()); + setEndDateControlState(event.getCommunicationsState().getEndControlState()); needsRefresh = false; validateFilters(); } @@ -577,7 +582,7 @@ final public class FiltersPanel extends JPanel { * Post an event with the new filters. */ private void applyFilters() { - CVTEvents.getCVTEventBus().post(new CVTEvents.FilterChangeEvent(getFilter())); + CVTEvents.getCVTEventBus().post(new CVTEvents.FilterChangeEvent(getFilter(), getStartControlState(), getEndControlState())); needsRefresh = false; validateFilters(); } @@ -633,10 +638,16 @@ final public class FiltersPanel extends JPanel { private DateRangeFilter getDateRangeFilter() { ZoneId zone = Utils.getUserPreferredZoneId(); - return new DateRangeFilter(startDatePicker.isEnabled(), - startDatePicker.getDate().atStartOfDay(zone).toEpochSecond(), - endDatePicker.isEnabled(), - endDatePicker.getDate().atStartOfDay(zone).toEpochSecond()); + return new DateRangeFilter( startCheckBox.isSelected() ? startDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0, + endCheckBox.isSelected() ? endDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0); + } + + private DateControlState getStartControlState() { + return new DateControlState (startDatePicker.getDate(), startCheckBox.isSelected()); + } + + private DateControlState getEndControlState() { + return new DateControlState (endDatePicker.getDate(), endCheckBox.isSelected()); } /** @@ -710,7 +721,47 @@ final public class FiltersPanel extends JPanel { endDatePicker.setEnabled(endCheckBox.isSelected()); }//GEN-LAST:event_endCheckBoxStateChanged - + /** + * A class to wrap the state of the date controls that consist of a date picker + * and a checkbox. + * + */ + final class DateControlState { + private final LocalDate date; + private final boolean enabled; + + /** + * Wraps the state of the date controls that consist of a date picker + * and checkbox + * + * @param date LocalDate value of the datepicker + * @param enabled State of the checkbox + */ + protected DateControlState(LocalDate date, boolean enabled) { + this.date = date; + this.enabled = enabled; + } + + /** + * Returns the given LocalDate from the datepicker + * + * @return Current state LocalDate + */ + public LocalDate getDate(){ + return date; + } + + /** + * Returns the given state of the datepicker checkbox + * + * @return boolean, whether or not the datepicker was enabled + */ + public boolean isEnabled() { + return enabled; + } + + } + // Variables declaration - do not modify//GEN-BEGIN:variables private final javax.swing.JPanel accountTypePane = new javax.swing.JPanel(); private final javax.swing.JLabel accountTypeRequiredLabel = new javax.swing.JLabel(); diff --git a/Core/src/org/sleuthkit/autopsy/communications/StateManager.java b/Core/src/org/sleuthkit/autopsy/communications/StateManager.java index 9e7d78da93..c84a5beb79 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/StateManager.java +++ b/Core/src/org/sleuthkit/autopsy/communications/StateManager.java @@ -18,16 +18,12 @@ */ package org.sleuthkit.autopsy.communications; -import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.Subscribe; import java.util.HashSet; -import java.util.List; import java.util.Set; +import org.sleuthkit.autopsy.communications.FiltersPanel.DateControlState; import org.sleuthkit.autopsy.coreutils.History; import org.sleuthkit.datamodel.CommunicationsFilter; -import org.sleuthkit.datamodel.CommunicationsFilter.SubFilter; -import static org.sleuthkit.datamodel.Relationship.Type.CALL_LOG; -import static org.sleuthkit.datamodel.Relationship.Type.MESSAGE; /** * Manages the state history for the Communications window. History is currently @@ -39,6 +35,8 @@ final class StateManager { private final History historyManager = new History<>(); private CommunicationsFilter comFilter; private final PinnedAccountModel pinModel; + private DateControlState currentStartState; + private DateControlState currentEndState; /** * Manages the state history for the Communications window. @@ -55,20 +53,22 @@ final class StateManager { if(pinEvent.isReplace()){ HashSet pinnedList = new HashSet<>(); pinnedList.addAll(pinEvent.getAccountDeviceInstances()); - historyManager.advance(new CommunicationsState(comFilter.getAndFilters(), pinnedList, -1)); + historyManager.advance(new CommunicationsState(comFilter, pinnedList, -1, currentStartState, currentEndState)); } else { HashSet pinnedList = new HashSet<>(); pinnedList.addAll(pinEvent.getAccountDeviceInstances()); pinnedList.addAll(pinModel.getPinnedAccounts()); - historyManager.advance(new CommunicationsState( comFilter.getAndFilters(), pinnedList, -1)); + historyManager.advance(new CommunicationsState( comFilter, pinnedList, -1, currentStartState, currentEndState)); } } @Subscribe - void filterChange(CVTEvents.FilterChangeEvent fileterEvent) { - comFilter = fileterEvent.getNewFilter(); - historyManager.advance(new CommunicationsState(comFilter.getAndFilters(), pinModel.getPinnedAccounts(), -1)); + void filterChange(CVTEvents.FilterChangeEvent filterEvent) { + comFilter = filterEvent.getNewFilter(); + currentStartState = filterEvent.getStartControlState(); + currentEndState = filterEvent.getEndControlState(); + historyManager.advance(new CommunicationsState(comFilter, pinModel.getPinnedAccounts(), -1, currentStartState, currentEndState)); } @Subscribe @@ -78,12 +78,12 @@ final class StateManager { pinnedList.addAll(pinModel.getPinnedAccounts()); pinnedList.removeAll(pinEvent.getAccountDeviceInstances()); - historyManager.advance(new CommunicationsState(comFilter.getAndFilters(), pinnedList, -1)); + historyManager.advance(new CommunicationsState(comFilter, pinnedList, -1, currentStartState, currentEndState)); } @Subscribe - void zoomedGraph(CVTEvents.ZoomEvent zoomEvent) { - historyManager.advance(new CommunicationsState(comFilter.getAndFilters(), pinModel.getPinnedAccounts(), zoomEvent.getZoomValue())); + void zoomedGraph(CVTEvents.ScaleChangeEvent zoomEvent) { + historyManager.advance(new CommunicationsState(comFilter, pinModel.getPinnedAccounts(), zoomEvent.getZoomValue(), currentStartState, currentEndState)); } /** @@ -134,22 +134,28 @@ final class StateManager { * Object to store one instance of the state of the Communications window. */ final class CommunicationsState{ - private final List communcationFilters; + private final CommunicationsFilter communcationFilter; private final Set pinnedList; private final double zoomValue; + private final DateControlState startDateState; + private final DateControlState endDateState; /** * Stores all the properties of the current state of the Communications * window. * - * @param communcationFilters List of the SubFilters from the FiltersPanel + * @param communcationFilter Instance of CommunicationsFilter * @param pinnedList Set of AccountDeviceInstanceKey * @param zoomValue Double value of the current graph scale */ - protected CommunicationsState(List communcationFilters, Set pinnedList, double zoomValue){ + protected CommunicationsState(CommunicationsFilter communcationFilter, + Set pinnedList, double zoomValue, + DateControlState startDateState, DateControlState endDateState){ this.pinnedList = pinnedList; - this.communcationFilters = communcationFilters; + this.communcationFilter = communcationFilter; this.zoomValue = zoomValue; + this.startDateState = startDateState; + this.endDateState = endDateState; } /** @@ -169,16 +175,7 @@ final class StateManager { public Set getPinnedList(){ return pinnedList; } - - /** - * Returns a list of communication SubFilters. - * - * @return List of SubFilter - */ - public List getCommunicationsFilters(){ - return communcationFilters; - } - + /** * Return a new CommunicationsFilter object based on the list of * SubFilters @@ -186,13 +183,7 @@ final class StateManager { * @return CommunicationsFilter */ public CommunicationsFilter getCommunicationsFilter() { - CommunicationsFilter newFilters = new CommunicationsFilter(); - newFilters.addAndFilter(new CommunicationsFilter.RelationshipTypeFilter(ImmutableSet.of(CALL_LOG, MESSAGE))); - communcationFilters.forEach(filter -> { - newFilters.addAndFilter(filter); - }); - - return newFilters; + return communcationFilter; } /** @@ -203,5 +194,23 @@ final class StateManager { public double getZoomValue() { return zoomValue; } + + /** + * Returns the state for the start date picker. + * + * @return Start DateControlState + */ + public DateControlState getStartControlState() { + return startDateState; + } + + /** + * Returns the state for the end date picker. + * + * @return Etart DateControlState + */ + public DateControlState getEndControlState() { + return endDateState; + } } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java index dd6826570b..a0f63348ee 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.communications; -import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.Subscribe; import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; import com.mxgraph.layout.mxCircleLayout; @@ -609,17 +608,17 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider private void zoomActualButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_zoomActualButtonActionPerformed graphComponent.zoomActual(); - CVTEvents.getCVTEventBus().post(new CVTEvents.ZoomEvent(graph.getView().getScale())); + CVTEvents.getCVTEventBus().post(new CVTEvents.ScaleChangeEvent(graph.getView().getScale())); }//GEN-LAST:event_zoomActualButtonActionPerformed private void zoomInButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_zoomInButtonActionPerformed graphComponent.zoomIn(); - CVTEvents.getCVTEventBus().post(new CVTEvents.ZoomEvent(graph.getView().getScale())); + CVTEvents.getCVTEventBus().post(new CVTEvents.ScaleChangeEvent(graph.getView().getScale())); }//GEN-LAST:event_zoomInButtonActionPerformed private void zoomOutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_zoomOutButtonActionPerformed graphComponent.zoomOut(); - CVTEvents.getCVTEventBus().post(new CVTEvents.ZoomEvent(graph.getView().getScale())); + CVTEvents.getCVTEventBus().post(new CVTEvents.ScaleChangeEvent(graph.getView().getScale())); }//GEN-LAST:event_zoomOutButtonActionPerformed /** @@ -695,7 +694,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider } // This will cause the FilterPane to update its controls - CVTEvents.getCVTEventBus().post(new CVTEvents.StateEvent(newState)); + CVTEvents.getCVTEventBus().post(new CVTEvents.StateChangeEvent(newState)); setStateButtonsEnabled(); graph.getModel().beginUpdate(); @@ -1133,7 +1132,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider graphComponent.zoomOut(); } - CVTEvents.getCVTEventBus().post(new CVTEvents.ZoomEvent(graph.getView().getScale())); + CVTEvents.getCVTEventBus().post(new CVTEvents.ScaleChangeEvent(graph.getView().getScale())); } /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED index 6f95dfc82f..ab7e11a07f 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED @@ -35,7 +35,7 @@ KeywordSearchResultFactory.createNodeForKey.noResultsFound.text=No results found KeywordSearchResultFactory.query.exception.msg=Could not perform the query OpenIDE-Module-Display-Category=Ingest Module -OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\nThe module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found. +OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\n\The module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found. OpenIDE-Module-Name=KeywordSearch OptionsCategory_Name_KeywordSearchOptions=Keyword Search OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Bundle.properties-MERGED b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Bundle.properties-MERGED index 17d744eee1..7da2ebca7b 100755 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Bundle.properties-MERGED +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Bundle.properties-MERGED @@ -64,7 +64,7 @@ ExtractZone_progress_Msg=Extracting :Zone.Identifer files ExtractZone_Restricted=Restricted Sites Zone ExtractZone_Trusted=Trusted Sites Zone OpenIDE-Module-Display-Category=Ingest Module -OpenIDE-Module-Long-Description=Recent Activity ingest module.\n\nThe module extracts useful information about the recent user activity on the disk image being ingested, such as:\n\n- Recently open documents,\n- Web activity (sites visited, stored cookies, book marked sites, search engine queries, file downloads),\n- Recently attached devices,\n- Installed programs.\n\nThe module currently supports Windows only disk images.\nThe plugin is also fully functional when deployed on Windows version of Autopsy. +OpenIDE-Module-Long-Description=Recent Activity ingest module.\n\n\The module extracts useful information about the recent user activity on the disk image being ingested, such as:\n\n- Recently open documents,\n- Web activity (sites visited, stored cookies, book marked sites, search engine queries, file downloads),\n- Recently attached devices,\n- Installed programs.\n\nThe module currently supports Windows only disk images.\nThe plugin is also fully functional when deployed on Windows version of Autopsy. OpenIDE-Module-Name=RecentActivity OpenIDE-Module-Short-Description=Recent Activity finder ingest module Chrome.moduleName=Chrome