19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.eventbus.Subscribe;
22 import java.util.HashSet;
34 final class StateManager {
36 private final History<CommunicationsState> historyManager =
new History<>();
37 private CommunicationsFilter comFilter;
38 private final PinnedAccountModel pinModel;
39 private DateControlState currentStartState;
40 private DateControlState currentEndState;
47 public StateManager(PinnedAccountModel pinModel){
48 this.pinModel = pinModel;
49 CVTEvents.getCVTEventBus().register(
this);
53 void pinAccount(CVTEvents.PinAccountsEvent pinEvent) {
54 if(pinEvent.isReplace()){
55 HashSet<AccountDeviceInstance> pinnedList =
new HashSet<>();
56 pinnedList.addAll(pinEvent.getAccountDeviceInstances());
57 historyManager.advance(
new CommunicationsState(comFilter, pinnedList, -1, currentStartState, currentEndState));
59 HashSet<AccountDeviceInstance> pinnedList =
new HashSet<>();
60 pinnedList.addAll(pinEvent.getAccountDeviceInstances());
61 pinnedList.addAll(pinModel.getPinnedAccounts());
63 historyManager.advance(
new CommunicationsState( comFilter, pinnedList, -1, currentStartState, currentEndState));
68 void filterChange(CVTEvents.FilterChangeEvent filterEvent) {
69 comFilter = filterEvent.getNewFilter();
70 currentStartState = filterEvent.getStartControlState();
71 currentEndState = filterEvent.getEndControlState();
72 historyManager.advance(
new CommunicationsState(comFilter, pinModel.getPinnedAccounts(), -1, currentStartState, currentEndState));
76 void unpinAccounts(CVTEvents.UnpinAccountsEvent pinEvent) {
78 HashSet<AccountDeviceInstance> pinnedList =
new HashSet<>();
79 pinnedList.addAll(pinModel.getPinnedAccounts());
80 pinnedList.removeAll(pinEvent.getAccountDeviceInstances());
82 historyManager.advance(
new CommunicationsState(comFilter, pinnedList, -1, currentStartState, currentEndState));
86 void zoomedGraph(CVTEvents.ScaleChangeEvent zoomEvent) {
87 historyManager.advance(
new CommunicationsState(comFilter, pinModel.getPinnedAccounts(), zoomEvent.getZoomValue(), currentStartState, currentEndState));
95 public CommunicationsState retreat(){
97 return historyManager.retreat();
108 public CommunicationsState advance() {
110 return historyManager.advance();
121 public boolean canRetreat() {
122 return historyManager.canRetreat();
130 public boolean canAdvance(){
131 return historyManager.canAdvance();
137 final class CommunicationsState{
138 private final CommunicationsFilter communcationFilter;
139 private final Set<AccountDeviceInstance> pinnedList;
140 private final double zoomValue;
141 private final DateControlState startDateState;
142 private final DateControlState endDateState;
152 protected CommunicationsState(CommunicationsFilter communcationFilter,
153 Set<AccountDeviceInstance> pinnedList,
double zoomValue,
154 DateControlState startDateState, DateControlState endDateState){
155 this.pinnedList = pinnedList;
156 this.communcationFilter = communcationFilter;
157 this.zoomValue = zoomValue;
158 this.startDateState = startDateState;
159 this.endDateState = endDateState;
167 public boolean isZoomChange() {
168 return (zoomValue != -1);
176 public Set<AccountDeviceInstance> getPinnedList(){
186 public CommunicationsFilter getCommunicationsFilter() {
187 return communcationFilter;
195 public double getZoomValue() {
204 public DateControlState getStartControlState() {
205 return startDateState;
213 public DateControlState getEndControlState() {