Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FiltersPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications;
20 
21 import com.google.common.collect.ImmutableSet;
22 import java.awt.event.ItemListener;
23 import java.beans.PropertyChangeListener;
24 import java.time.LocalDate;
25 import java.time.ZoneId;
26 import java.util.EnumSet;
27 import java.util.HashMap;
28 import java.util.Map;
29 import java.util.Map.Entry;
30 import java.util.logging.Level;
31 import java.util.stream.Collectors;
32 import javax.swing.JCheckBox;
33 import org.openide.explorer.ExplorerManager;
34 import org.openide.nodes.AbstractNode;
35 import org.openide.nodes.Children;
36 import org.openide.util.NbBundle;
45 import org.sleuthkit.datamodel.Account;
46 import org.sleuthkit.datamodel.BlackboardArtifact;
47 import org.sleuthkit.datamodel.CommunicationsFilter;
48 import org.sleuthkit.datamodel.CommunicationsFilter.AccountTypeFilter;
49 import org.sleuthkit.datamodel.CommunicationsFilter.DateRangeFilter;
50 import org.sleuthkit.datamodel.CommunicationsFilter.DeviceFilter;
51 import org.sleuthkit.datamodel.CommunicationsManager;
52 import org.sleuthkit.datamodel.DataSource;
53 import static org.sleuthkit.datamodel.Relationship.Type.CALL_LOG;
54 import static org.sleuthkit.datamodel.Relationship.Type.MESSAGE;
55 import org.sleuthkit.datamodel.SleuthkitCase;
56 import org.sleuthkit.datamodel.TskCoreException;
57 
62 final public class FiltersPanel extends javax.swing.JPanel {
63 
64  private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName());
65  private static final long serialVersionUID = 1L;
66 
67  private ExplorerManager em;
68 
70  private final Map<Account.Type, JCheckBox> accountTypeMap = new HashMap<>();
71  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
72  private final Map<String, JCheckBox> devicesMap = new HashMap<>();
73 
77  private final PropertyChangeListener ingestListener;
78  private boolean needsRefresh;
79 
85  private final ItemListener validationListener;
86 
87  @NbBundle.Messages({"refreshText=Refresh Results",
88  "applyText=Apply"})
89  public FiltersPanel() {
91  deviceRequiredLabel.setVisible(false);
92  accountTypeRequiredLabel.setVisible(false);
93  startDatePicker.setDate(LocalDate.now().minusWeeks(3));
94  endDatePicker.setDateToToday();
95  startDatePicker.getSettings().setVetoPolicy(
96  //no end date, or start is before end
97  startDate -> endCheckBox.isSelected() == false
98  || startDate.compareTo(endDatePicker.getDate()) <= 0
99  );
100  endDatePicker.getSettings().setVetoPolicy(
101  //no start date, or end is after start
102  endDate -> startCheckBox.isSelected() == false
103  || endDate.compareTo(startDatePicker.getDate()) >= 0
104  );
105 
106  updateTimeZone();
107  validationListener = itemEvent -> validateFilters();
108 
109  updateFilters();
110  setAllDevicesSelected(true);
111  UserPreferences.addChangeListener(preferenceChangeEvent -> {
112  if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)) {
113  updateTimeZone();
114  }
115  });
116 
117  this.ingestListener = pce -> {
118  String eventType = pce.getPropertyName();
119  if (eventType.equals(DATA_ADDED.toString())) {
120  // Indicate that a refresh may be needed, unless the data added is Keyword or Hashset hits
121  ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue();
122  if (null != eventData &&
123  eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID() &&
124  eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
125  updateFilters();
126  needsRefresh = true;
127  validateFilters();
128  }
129  }
130  };
131 
132  applyFiltersButton.addActionListener(e -> applyFilters());
133  refreshButton.addActionListener(e -> applyFilters());
134  }
135 
142  private void validateFilters() {
143  boolean someDevice = devicesMap.values().stream().anyMatch(JCheckBox::isSelected);
144  boolean someAccountType = accountTypeMap.values().stream().anyMatch(JCheckBox::isSelected);
145 
146  deviceRequiredLabel.setVisible(someDevice == false);
147  accountTypeRequiredLabel.setVisible(someAccountType == false);
148 
149  applyFiltersButton.setEnabled(someDevice && someAccountType);
150  refreshButton.setEnabled(someDevice && someAccountType && needsRefresh);
151  needsRefreshLabel.setVisible(needsRefresh);
152  }
153 
157  void updateAndApplyFilters() {
158  updateFilters();
159  if (em != null) {
160  applyFilters();
161  }
162  }
163 
164  private void updateTimeZone() {
165  dateRangeLabel.setText("Date Range ( " + Utils.getUserPreferredZoneId().toString() + "):");
166  }
167 
168  private void updateFilters() {
171  }
172 
173  @Override
174  public void addNotify() {
175  super.addNotify();
176  /*
177  * Since we get the exploreremanager from the parent JComponenet, wait
178  * till this FiltersPanel is actaully added to a parent.
179  */
180  em = ExplorerManager.find(this);
182  Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), evt -> {
183  devicesMap.clear();
184  devicesPane.removeAll();
185  });
186  }
187 
188  @Override
189  public void removeNotify() {
190  super.removeNotify();
192  }
193 
197  private void updateAccountTypeFilter() {
198 
199  //TODO: something like this commented code could be used to show only
200  //the account types that are found:
201  //final CommunicationsManager communicationsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
202  //List<Account.Type> accountTypesInUse = communicationsManager.getAccountTypesInUse();
203  //accountTypesInUSe.forEach(...)
204  Account.Type.PREDEFINED_ACCOUNT_TYPES.forEach(type -> {
205  if (type.equals(Account.Type.CREDIT_CARD)) {
206  //don't show a check box for credit cards
207  } else if (type.equals(Account.Type.DEVICE)) {
208  //don't show a check box fro device
209  } else {
210  accountTypeMap.computeIfAbsent(type, t -> {
211  final JCheckBox jCheckBox = new JCheckBox(
212  "<html><table cellpadding=0><tr><td><img src=\""
213  + FiltersPanel.class.getResource("/org/sleuthkit/autopsy/communications/images/"
214  + Utils.getIconFileName(type))
215  + "\"/></td><td width=" + 3 + "><td>" + type.getDisplayName() + "</td></tr></table></html>",
216  true
217  );
218  jCheckBox.addItemListener(validationListener);
219  accountTypePane.add(jCheckBox);
220  return jCheckBox;
221  });
222  }
223  }
224  );
225  }
226 
230  private void updateDeviceFilter() {
231  try {
232  final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
233 
234  for (DataSource dataSource : sleuthkitCase.getDataSources()) {
235  String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName();
236  //store the device id in the map, but display a datasource name in the UI.
237  devicesMap.computeIfAbsent(dataSource.getDeviceId(), ds -> {
238  final JCheckBox jCheckBox = new JCheckBox(dsName, false);
239  jCheckBox.addItemListener(validationListener);
240  devicesPane.add(jCheckBox);
241  return jCheckBox;
242  });
243  };
244 
245  } catch (IllegalStateException ex) {
246  logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex);
247  } catch (TskCoreException tskCoreException) {
248  logger.log(Level.SEVERE, "There was a error loading the datasources for the case.", tskCoreException);
249  }
250  }
251 
257  @SuppressWarnings("unchecked")
258  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
259  private void initComponents() {
260 
261  applyFiltersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/tick.png"))); // NOI18N
262  applyFiltersButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.applyFiltersButton.text")); // NOI18N
263  applyFiltersButton.setPreferredSize(null);
264 
265  filtersTitleLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/funnel.png"))); // NOI18N
266  filtersTitleLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.filtersTitleLabel.text")); // NOI18N
267  filtersTitleLabel.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
268 
269  unCheckAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllAccountTypesButton.text")); // NOI18N
270  unCheckAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
271  public void actionPerformed(java.awt.event.ActionEvent evt) {
273  }
274  });
275 
276  accountTypesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/accounts.png"))); // NOI18N
277  accountTypesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypesLabel.text")); // NOI18N
278 
279  checkAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllAccountTypesButton.text")); // NOI18N
280  checkAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
281  public void actionPerformed(java.awt.event.ActionEvent evt) {
283  }
284  });
285 
286  accountTypePane.setLayout(new javax.swing.BoxLayout(accountTypePane, javax.swing.BoxLayout.Y_AXIS));
287  jScrollPane3.setViewportView(accountTypePane);
288 
289  accountTypeRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
290  accountTypeRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypeRequiredLabel.text")); // NOI18N
291  accountTypeRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
292  accountTypeRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
293 
294  javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
295  jPanel2.setLayout(jPanel2Layout);
296  jPanel2Layout.setHorizontalGroup(
297  jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
298  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
299  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
300  .addGroup(jPanel2Layout.createSequentialGroup()
301  .addComponent(accountTypesLabel)
302  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
303  .addComponent(accountTypeRequiredLabel))
304  .addGroup(jPanel2Layout.createSequentialGroup()
305  .addContainerGap()
306  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
307  .addComponent(jScrollPane3)
308  .addGroup(jPanel2Layout.createSequentialGroup()
309  .addGap(0, 0, Short.MAX_VALUE)
310  .addComponent(unCheckAllAccountTypesButton)
311  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
312  .addComponent(checkAllAccountTypesButton)))))
313  .addGap(0, 0, 0))
314  );
315  jPanel2Layout.setVerticalGroup(
316  jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
317  .addGroup(jPanel2Layout.createSequentialGroup()
318  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
319  .addComponent(accountTypesLabel)
320  .addComponent(accountTypeRequiredLabel))
321  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
322  .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
323  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
324  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
325  .addComponent(checkAllAccountTypesButton)
326  .addComponent(unCheckAllAccountTypesButton)))
327  );
328 
329  unCheckAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllDevicesButton.text")); // NOI18N
330  unCheckAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
331  public void actionPerformed(java.awt.event.ActionEvent evt) {
333  }
334  });
335 
336  devicesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/image.png"))); // NOI18N
337  devicesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.devicesLabel.text")); // NOI18N
338 
339  checkAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllDevicesButton.text")); // NOI18N
340  checkAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
341  public void actionPerformed(java.awt.event.ActionEvent evt) {
343  }
344  });
345 
346  jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
347  jScrollPane2.setMinimumSize(new java.awt.Dimension(27, 75));
348 
349  devicesPane.setMinimumSize(new java.awt.Dimension(4, 100));
350  devicesPane.setLayout(new javax.swing.BoxLayout(devicesPane, javax.swing.BoxLayout.Y_AXIS));
351  jScrollPane2.setViewportView(devicesPane);
352 
353  deviceRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
354  deviceRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.deviceRequiredLabel.text")); // NOI18N
355  deviceRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
356  deviceRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
357 
358  javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
359  jPanel3.setLayout(jPanel3Layout);
360  jPanel3Layout.setHorizontalGroup(
361  jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
362  .addGroup(jPanel3Layout.createSequentialGroup()
363  .addComponent(devicesLabel)
364  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
365  .addComponent(deviceRequiredLabel))
366  .addGroup(jPanel3Layout.createSequentialGroup()
367  .addContainerGap()
368  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
369  .addGroup(jPanel3Layout.createSequentialGroup()
370  .addGap(0, 0, Short.MAX_VALUE)
371  .addComponent(unCheckAllDevicesButton)
372  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
373  .addComponent(checkAllDevicesButton))
374  .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
375  );
376  jPanel3Layout.setVerticalGroup(
377  jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378  .addGroup(jPanel3Layout.createSequentialGroup()
379  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
380  .addComponent(devicesLabel)
381  .addComponent(deviceRequiredLabel))
382  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
383  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
384  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
385  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
386  .addComponent(checkAllDevicesButton)
387  .addComponent(unCheckAllDevicesButton))
388  .addGap(5, 5, 5))
389  );
390 
391  startDatePicker.setEnabled(false);
392 
393  dateRangeLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/calendar.png"))); // NOI18N
394  dateRangeLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.dateRangeLabel.text")); // NOI18N
395 
396  startCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.startCheckBox.text")); // NOI18N
397  startCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
398  public void stateChanged(javax.swing.event.ChangeEvent evt) {
400  }
401  });
402 
403  endCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.endCheckBox.text")); // NOI18N
404  endCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
405  public void stateChanged(javax.swing.event.ChangeEvent evt) {
407  }
408  });
409 
410  endDatePicker.setEnabled(false);
411 
412  javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
413  jPanel4.setLayout(jPanel4Layout);
414  jPanel4Layout.setHorizontalGroup(
415  jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
416  .addGroup(jPanel4Layout.createSequentialGroup()
417  .addComponent(dateRangeLabel)
418  .addGap(0, 0, Short.MAX_VALUE))
419  .addGroup(jPanel4Layout.createSequentialGroup()
420  .addContainerGap()
421  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
422  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
423  .addComponent(endCheckBox)
424  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
425  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
426  .addGroup(jPanel4Layout.createSequentialGroup()
427  .addComponent(startCheckBox)
428  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
429  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))))
430  );
431  jPanel4Layout.setVerticalGroup(
432  jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
433  .addGroup(jPanel4Layout.createSequentialGroup()
434  .addComponent(dateRangeLabel)
435  .addGap(6, 6, 6)
436  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
437  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
438  .addComponent(startCheckBox))
439  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
440  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
441  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
442  .addComponent(endCheckBox)))
443  );
444 
445  refreshButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-circle-double-135.png"))); // NOI18N
446  refreshButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.refreshButton.text")); // NOI18N
447 
448  needsRefreshLabel.setForeground(new java.awt.Color(255, 0, 0));
449  needsRefreshLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.needsRefreshLabel.text")); // NOI18N
450 
451  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
452  this.setLayout(layout);
453  layout.setHorizontalGroup(
454  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
455  .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
456  .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
457  .addGroup(layout.createSequentialGroup()
458  .addComponent(filtersTitleLabel)
459  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
460  .addComponent(applyFiltersButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
461  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
462  .addComponent(refreshButton))
463  .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
464  .addGroup(layout.createSequentialGroup()
465  .addContainerGap()
466  .addComponent(needsRefreshLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
467  );
468  layout.setVerticalGroup(
469  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
470  .addGroup(layout.createSequentialGroup()
471  .addGap(0, 0, 0)
472  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
473  .addComponent(filtersTitleLabel)
474  .addComponent(applyFiltersButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
475  .addComponent(refreshButton))
476  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
477  .addComponent(needsRefreshLabel)
478  .addGap(4, 4, 4)
479  .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
480  .addGap(18, 18, 18)
481  .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
482  .addGap(18, 18, 18)
483  .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
484  .addContainerGap(19, Short.MAX_VALUE))
485  );
486  }// </editor-fold>//GEN-END:initComponents
487 
492  private void applyFilters() {
493  CommunicationsFilter commsFilter = new CommunicationsFilter();
494  commsFilter.addAndFilter(getDeviceFilter());
495  commsFilter.addAndFilter(getAccountTypeFilter());
496  commsFilter.addAndFilter(getDateRangeFilter());
497  commsFilter.addAndFilter(new CommunicationsFilter.RelationshipTypeFilter(
498  ImmutableSet.of(CALL_LOG, MESSAGE)));
499 
500  try {
501  final CommunicationsManager commsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
502  em.setRootContext(new AbstractNode(Children.create(new AccountsRootChildren(commsManager, commsFilter), true)));
503  } catch (TskCoreException ex) {
504  logger.log(Level.SEVERE, "There was an error getting the CommunicationsManager for the current case.", ex);
505  }
506 
507  needsRefresh = false;
508  validateFilters();
509  }
510 
516  private DeviceFilter getDeviceFilter() {
517  DeviceFilter deviceFilter = new DeviceFilter(
518  devicesMap.entrySet().stream()
519  .filter(entry -> entry.getValue().isSelected())
520  .map(Entry::getKey)
521  .collect(Collectors.toSet()));
522  return deviceFilter;
523  }
524 
530  private AccountTypeFilter getAccountTypeFilter() {
531  AccountTypeFilter accountTypeFilter = new AccountTypeFilter(
532  accountTypeMap.entrySet().stream()
533  .filter(entry -> entry.getValue().isSelected())
534  .map(entry -> entry.getKey())
535  .collect(Collectors.toSet()));
536  return accountTypeFilter;
537  }
538 
539  private DateRangeFilter getDateRangeFilter() {
540  ZoneId zone = Utils.getUserPreferredZoneId();
541  long start = startDatePicker.isEnabled() ? startDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0;
542  long end = endDatePicker.isEnabled() ? endDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0;
543  return new DateRangeFilter(start, end);
544  }
545 
552  private void setAllAccountTypesSelected(boolean selected) {
553  setAllSelected(accountTypeMap, selected);
554  }
555 
562  private void setAllDevicesSelected(boolean selected) {
563  setAllSelected(devicesMap, selected);
564  }
565 
574  private void setAllSelected(Map<?, JCheckBox> map, boolean selected) {
575  map.values().forEach(box -> box.setSelected(selected));
576  }
577  private void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllAccountTypesButtonActionPerformed
579  }//GEN-LAST:event_unCheckAllAccountTypesButtonActionPerformed
580 
581  private void checkAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllAccountTypesButtonActionPerformed
583  }//GEN-LAST:event_checkAllAccountTypesButtonActionPerformed
584 
585  private void unCheckAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllDevicesButtonActionPerformed
586  setAllDevicesSelected(false);
587  }//GEN-LAST:event_unCheckAllDevicesButtonActionPerformed
588 
589  private void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllDevicesButtonActionPerformed
590  setAllDevicesSelected(true);
591  }//GEN-LAST:event_checkAllDevicesButtonActionPerformed
592 
593  private void startCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_startCheckBoxStateChanged
594  startDatePicker.setEnabled(startCheckBox.isSelected());
595  }//GEN-LAST:event_startCheckBoxStateChanged
596 
597  private void endCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_endCheckBoxStateChanged
598  endDatePicker.setEnabled(endCheckBox.isSelected());
599  }//GEN-LAST:event_endCheckBoxStateChanged
600 
601 
602  // Variables declaration - do not modify//GEN-BEGIN:variables
603  private final javax.swing.JPanel accountTypePane = new javax.swing.JPanel();
604  private final javax.swing.JLabel accountTypeRequiredLabel = new javax.swing.JLabel();
605  private final javax.swing.JLabel accountTypesLabel = new javax.swing.JLabel();
606  private final javax.swing.JButton applyFiltersButton = new javax.swing.JButton();
607  private final javax.swing.JButton checkAllAccountTypesButton = new javax.swing.JButton();
608  private final javax.swing.JButton checkAllDevicesButton = new javax.swing.JButton();
609  private final javax.swing.JLabel dateRangeLabel = new javax.swing.JLabel();
610  private final javax.swing.JLabel deviceRequiredLabel = new javax.swing.JLabel();
611  private final javax.swing.JLabel devicesLabel = new javax.swing.JLabel();
612  private final javax.swing.JPanel devicesPane = new javax.swing.JPanel();
613  private final javax.swing.JCheckBox endCheckBox = new javax.swing.JCheckBox();
614  private final com.github.lgooddatepicker.components.DatePicker endDatePicker = new com.github.lgooddatepicker.components.DatePicker();
615  private final javax.swing.JLabel filtersTitleLabel = new javax.swing.JLabel();
616  private final javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
617  private final javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
618  private final javax.swing.JPanel jPanel4 = new javax.swing.JPanel();
619  private final javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
620  private final javax.swing.JScrollPane jScrollPane3 = new javax.swing.JScrollPane();
621  private final javax.swing.JLabel needsRefreshLabel = new javax.swing.JLabel();
622  private final javax.swing.JButton refreshButton = new javax.swing.JButton();
623  private final javax.swing.JCheckBox startCheckBox = new javax.swing.JCheckBox();
624  private final com.github.lgooddatepicker.components.DatePicker startDatePicker = new com.github.lgooddatepicker.components.DatePicker();
625  private final javax.swing.JButton unCheckAllAccountTypesButton = new javax.swing.JButton();
626  private final javax.swing.JButton unCheckAllDevicesButton = new javax.swing.JButton();
627  // End of variables declaration//GEN-END:variables
628 }
BlackboardArtifact.Type getBlackboardArtifactType()
void unCheckAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt)
void removeIngestModuleEventListener(final PropertyChangeListener listener)
final com.github.lgooddatepicker.components.DatePicker endDatePicker
static synchronized IngestManager getInstance()
void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt)
final com.github.lgooddatepicker.components.DatePicker startDatePicker
void endCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)
void startCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)
void setAllSelected(Map<?, JCheckBox > map, boolean selected)
void checkAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt)
final Map< Account.Type, JCheckBox > accountTypeMap
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:419
static void addChangeListener(PreferenceChangeListener listener)
void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt)
final javax.swing.JButton unCheckAllAccountTypesButton

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.