From 851099cee297341a207350940b69676d390c5963 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Wed, 27 Mar 2019 11:29:19 -0400 Subject: [PATCH] Changes per Jonathan's review comments --- .../communications/AccountsBrowser.java | 17 +++++++++++++++ .../autopsy/communications/CVTEvents.java | 15 +++++++++++++ .../autopsy/communications/FiltersPanel.java | 7 +++---- .../autopsy/communications/StateManager.java | 21 ++++++++++++++++++- .../communications/VisualizationPanel.java | 16 +------------- .../autopsy/timeline/actions/Back.java | 2 +- .../autopsy/timeline/actions/Forward.java | 2 +- 7 files changed, 58 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java index 006fbd846f..3fa68948a6 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.communications; +import com.google.common.collect.ImmutableSet; import com.google.common.eventbus.Subscribe; import java.awt.Component; import java.util.logging.Level; @@ -36,7 +37,10 @@ import org.openide.util.lookup.ProxyLookup; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.datamodel.CommunicationsManager; +import static org.sleuthkit.datamodel.Relationship.Type.CALL_LOG; +import static org.sleuthkit.datamodel.Relationship.Type.MESSAGE; import org.sleuthkit.datamodel.TskCoreException; /** @@ -130,6 +134,19 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro //Case is closed, do nothig. } } + + @Subscribe + void historyChange(CVTEvents.StateEvent event) { + try { + final CommunicationsManager commsManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager(); + accountsTableEM.setRootContext(new AbstractNode(Children.create(new AccountDeviceInstanceNodeFactory(commsManager, event.getCommunicationsState().getCommunicationsFilter()), true))); + } catch (TskCoreException ex) { + logger.log(Level.SEVERE, "There was an error getting the CommunicationsManager for the current case.", ex); + } catch (NoCurrentCaseException ex) { //NOPMD empty catch clause + //Case is closed, do nothig. + } + + } /** * This method is called from within the constructor to initialize the form. diff --git a/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java b/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java index 2a12a79c4a..051ff2b193 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java +++ b/Core/src/org/sleuthkit/autopsy/communications/CVTEvents.java @@ -38,6 +38,9 @@ final class CVTEvents { private CVTEvents() { } + /** + * Invoked when a ComminucationsFilter change occures. + */ static final class FilterChangeEvent { private final CommunicationsFilter newFilter; @@ -52,6 +55,9 @@ final class CVTEvents { } + /** + * Invoked when a change in the pinned accounts occures. + */ static final class PinAccountsEvent { private final ImmutableSet accountDeviceInstances; @@ -71,6 +77,9 @@ final class CVTEvents { } } + /** + * Invoked when a change in the unpinned accounts occures. + */ static final class UnpinAccountsEvent { private final ImmutableSet accountDeviceInstances; @@ -84,6 +93,9 @@ final class CVTEvents { } } + /** + * Invoked when there is a change in the state of the window. + */ static final class StateEvent { private final CommunicationsState newState; @@ -96,6 +108,9 @@ final class CVTEvents { } } + /** + * Invoked when change in the link analysis graph scale occures. + */ static final class ZoomEvent { private final double zoomValue; diff --git a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java index 7d39b5d372..a6ed7e5aef 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java @@ -305,12 +305,12 @@ final public class FiltersPanel extends JPanel { private void setDateRangeFilter(DateRangeFilter dateFilter) { ZonedDateTime zoneDate = ZonedDateTime.ofInstant(Instant.ofEpochSecond(dateFilter.getStartDate()), Utils.getUserPreferredZoneId()); startDatePicker.setEnabled(dateFilter.isStartDateEnabled()); - startCheckBox.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.setEnabled(dateFilter.isEndDateEnabled()); + endCheckBox.setSelected(dateFilter.isEndDateEnabled()); endDatePicker.setDate(zoneDate.toLocalDate()); } @@ -320,8 +320,7 @@ final public class FiltersPanel extends JPanel { * @param typeFilter Account Types to be selected */ private void setAccountTypeFilter(AccountTypeFilter typeFilter){ - - Collection typeSet = typeFilter.getAccountTypes(); + accountTypeMap.forEach((type, cb) -> { cb.setSelected(typeFilter.getAccountTypes().contains(type)); }); diff --git a/Core/src/org/sleuthkit/autopsy/communications/StateManager.java b/Core/src/org/sleuthkit/autopsy/communications/StateManager.java index 4eddbc06cb..9e7d78da93 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/StateManager.java +++ b/Core/src/org/sleuthkit/autopsy/communications/StateManager.java @@ -18,6 +18,7 @@ */ 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; @@ -25,6 +26,8 @@ import java.util.Set; 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 @@ -133,7 +136,7 @@ final class StateManager { final class CommunicationsState{ private final List communcationFilters; private final Set pinnedList; - private double zoomValue = -1; + private final double zoomValue; /** * Stores all the properties of the current state of the Communications @@ -176,6 +179,22 @@ final class StateManager { return communcationFilters; } + /** + * Return a new CommunicationsFilter object based on the list of + * SubFilters + * + * @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 the value for the % zoom. * diff --git a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java index 13c80c1056..e2be740602 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java @@ -663,15 +663,6 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider get(); } catch (InterruptedException | ExecutionException ex) { logger.log(Level.WARNING, "CVT graph layout failed.", ex); - String message = (lockedVertexModel.isEmpty()) - ? Bundle.VisualizationPanel_layoutFail_text(layout.getDisplayName()) - : Bundle.VisualizationPanel_layoutFailWithLockedVertices_text(layout.getDisplayName()); - - Platform.runLater(() - -> Notifications.create().owner(notificationsJFXPanel.getScene().getWindow()) - .text(message) - .showWarning() - ); } } }.execute(); @@ -718,12 +709,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider pinnedAccountModel.clear(); } - currentFilter = new CommunicationsFilter(); - currentFilter.addAndFilter(new CommunicationsFilter.RelationshipTypeFilter( - ImmutableSet.of(CALL_LOG, MESSAGE))); - newState.getCommunicationsFilters().forEach(filter -> { - currentFilter.addAndFilter(filter); - }); + currentFilter = newState.getCommunicationsFilter(); rebuildGraph(); // Updates the display diff --git a/Core/src/org/sleuthkit/autopsy/timeline/actions/Back.java b/Core/src/org/sleuthkit/autopsy/timeline/actions/Back.java index 8ee6aa3cd2..43c1a62933 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/actions/Back.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/actions/Back.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.timeline.TimeLineController; //TODO: This and the corresponding imageanalyzer action are identical except for the type of the controller... abstract something! -jm public class Back extends Action { - private static final Image BACK_IMAGE = new Image("/org/sleuthkit/autopsy/timeline/images/arrow-180.png", 16, 16, true, true, true); // NON-NLS + private static final Image BACK_IMAGE = new Image("/org/sleuthkit/autopsy/images/resultset_previous.png", 16, 16, true, true, true); // NON-NLS private final TimeLineController controller; diff --git a/Core/src/org/sleuthkit/autopsy/timeline/actions/Forward.java b/Core/src/org/sleuthkit/autopsy/timeline/actions/Forward.java index 851731528b..9f1d265d60 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/actions/Forward.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/actions/Forward.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.timeline.TimeLineController; //TODO: This and the corresponding imageanalyzer action are identical except for the type of the controller... abstract something! -jm public class Forward extends Action { - private static final Image FORWARD_IMAGE = new Image("/org/sleuthkit/autopsy/timeline/images/arrow.png", 16, 16, true, true, true); // NON-NLS + private static final Image FORWARD_IMAGE = new Image("/org/sleuthkit/autopsy/images/resultset_next.png", 16, 16, true, true, true); // NON-NLS private final TimeLineController controller;