Autopsy  4.6.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-18 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 javax.swing.JPanel;
34 import org.openide.util.NbBundle;
44 import org.sleuthkit.datamodel.Account;
45 import org.sleuthkit.datamodel.BlackboardArtifact;
46 import org.sleuthkit.datamodel.CommunicationsFilter;
47 import org.sleuthkit.datamodel.CommunicationsFilter.AccountTypeFilter;
48 import org.sleuthkit.datamodel.CommunicationsFilter.DateRangeFilter;
49 import org.sleuthkit.datamodel.CommunicationsFilter.DeviceFilter;
50 import org.sleuthkit.datamodel.DataSource;
51 import static org.sleuthkit.datamodel.Relationship.Type.CALL_LOG;
52 import static org.sleuthkit.datamodel.Relationship.Type.MESSAGE;
53 import org.sleuthkit.datamodel.SleuthkitCase;
54 import org.sleuthkit.datamodel.TskCoreException;
55 
60 final public class FiltersPanel extends JPanel {
61 
62  private static final long serialVersionUID = 1L;
63  private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName());
64 
69  private final Map<Account.Type, JCheckBox> accountTypeMap = new HashMap<>();
70 
74  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
75  private final Map<String, JCheckBox> devicesMap = new HashMap<>();
76 
80  private final PropertyChangeListener ingestListener;
81 
86  private boolean needsRefresh;
87 
93  private final ItemListener validationListener;
94 
101  private boolean deviceAccountTypeEnabled;
102 
103  @NbBundle.Messages({"refreshText=Refresh Results", "applyText=Apply"})
104  public FiltersPanel() {
105  initComponents();
106  deviceRequiredLabel.setVisible(false);
107  accountTypeRequiredLabel.setVisible(false);
108  startDatePicker.setDate(LocalDate.now().minusWeeks(3));
109  endDatePicker.setDateToToday();
110  startDatePicker.getSettings().setVetoPolicy(
111  //no end date, or start is before end
112  startDate -> endCheckBox.isSelected() == false
113  || startDate.compareTo(endDatePicker.getDate()) <= 0
114  );
115  endDatePicker.getSettings().setVetoPolicy(
116  //no start date, or end is after start
117  endDate -> startCheckBox.isSelected() == false
118  || endDate.compareTo(startDatePicker.getDate()) >= 0
119  );
120 
121  updateTimeZone();
122  validationListener = itemEvent -> validateFilters();
123 
124  updateFilters(true);
125  UserPreferences.addChangeListener(preferenceChangeEvent -> {
126  if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)) {
127  updateTimeZone();
128  }
129  });
130 
131  this.ingestListener = pce -> {
132  String eventType = pce.getPropertyName();
133  if (eventType.equals(DATA_ADDED.toString())) {
134  // Indicate that a refresh may be needed, unless the data added is Keyword or Hashset hits
135  ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue();
136  if (null != eventData
137  && eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()
138  && eventData.getBlackboardArtifactType().getTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
139  updateFilters(false);
140  needsRefresh = true;
141  validateFilters();
142  }
143  }
144  };
145 
146  applyFiltersButton.addActionListener(e -> applyFilters());
147  refreshButton.addActionListener(e -> applyFilters());
148  }
149 
156  private void validateFilters() {
157  boolean someDevice = devicesMap.values().stream().anyMatch(JCheckBox::isSelected);
158  boolean someAccountType = accountTypeMap.values().stream().anyMatch(JCheckBox::isSelected);
159 
160  deviceRequiredLabel.setVisible(someDevice == false);
161  accountTypeRequiredLabel.setVisible(someAccountType == false);
162 
163  applyFiltersButton.setEnabled(someDevice && someAccountType);
164  refreshButton.setEnabled(someDevice && someAccountType && needsRefresh);
165  needsRefreshLabel.setVisible(needsRefresh);
166  }
167 
171  void updateAndApplyFilters(boolean initialState) {
172  updateFilters(initialState);
173  applyFilters();
174  }
175 
176  private void updateTimeZone() {
177  dateRangeLabel.setText("Date Range ( " + Utils.getUserPreferredZoneId().toString() + "):");
178  }
179 
183  private void updateFilters(boolean initialState) {
185  updateDeviceFilter(initialState);
186  }
187 
188  @Override
189  public void addNotify() {
190  super.addNotify();
192  Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), evt -> {
193  //clear the device filter widget when the case changes.
194  devicesMap.clear();
195  devicesPane.removeAll();
196  });
197  }
198 
199  @Override
200  public void removeNotify() {
201  super.removeNotify();
203  }
204 
208  private void updateAccountTypeFilter() {
209 
210  //TODO: something like this commented code could be used to show only
211  //the account types that are found:
212  //final CommunicationsManager communicationsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager();
213  //List<Account.Type> accountTypesInUse = communicationsManager.getAccountTypesInUse();
214  //accountTypesInUSe.forEach(...)
215  Account.Type.PREDEFINED_ACCOUNT_TYPES.forEach(type -> {
216  if (type.equals(Account.Type.CREDIT_CARD)) {
217  //don't show a check box for credit cards
218  } else {
219  accountTypeMap.computeIfAbsent(type, t -> {
220  final JCheckBox jCheckBox = new JCheckBox(
221  "<html><table cellpadding=0><tr><td><img src=\""
222  + FiltersPanel.class.getResource(Utils.getIconFilePath(type))
223  + "\"/></td><td width=" + 3 + "><td>" + type.getDisplayName() + "</td></tr></table></html>",
224  true
225  );
226  jCheckBox.addItemListener(validationListener);
227  accountTypePane.add(jCheckBox);
228  if (t.equals(Account.Type.DEVICE)) {
229  //Deveice type filter is enabled based on whether we are in table or graph view.
230  jCheckBox.setEnabled(deviceAccountTypeEnabled);
231  }
232  return jCheckBox;
233  });
234  }
235  });
236  }
237 
241  private void updateDeviceFilter(boolean initialState) {
242  try {
243  final SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase();
244 
245  for (DataSource dataSource : sleuthkitCase.getDataSources()) {
246  String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName();
247  //store the device id in the map, but display a datasource name in the UI.
248  devicesMap.computeIfAbsent(dataSource.getDeviceId(), ds -> {
249  final JCheckBox jCheckBox = new JCheckBox(dsName, initialState);
250  jCheckBox.addItemListener(validationListener);
251  devicesPane.add(jCheckBox);
252  return jCheckBox;
253  });
254  }
255  } catch (NoCurrentCaseException ex) {
256  logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex);
257  } catch (TskCoreException tskCoreException) {
258  logger.log(Level.SEVERE, "There was a error loading the datasources for the case.", tskCoreException);
259  }
260  }
261 
267  @SuppressWarnings("unchecked")
268  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
269  private void initComponents() {
270 
271  applyFiltersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/tick.png"))); // NOI18N
272  applyFiltersButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.applyFiltersButton.text")); // NOI18N
273  applyFiltersButton.setPreferredSize(null);
274 
275  filtersTitleLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/funnel.png"))); // NOI18N
276  filtersTitleLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.filtersTitleLabel.text")); // NOI18N
277 
278  unCheckAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllAccountTypesButton.text")); // NOI18N
279  unCheckAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
280  public void actionPerformed(java.awt.event.ActionEvent evt) {
282  }
283  });
284 
285  accountTypesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/accounts.png"))); // NOI18N
286  accountTypesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypesLabel.text")); // NOI18N
287 
288  checkAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllAccountTypesButton.text")); // NOI18N
289  checkAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
290  public void actionPerformed(java.awt.event.ActionEvent evt) {
292  }
293  });
294 
295  accountTypePane.setLayout(new javax.swing.BoxLayout(accountTypePane, javax.swing.BoxLayout.Y_AXIS));
296  jScrollPane3.setViewportView(accountTypePane);
297 
298  accountTypeRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
299  accountTypeRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypeRequiredLabel.text")); // NOI18N
300  accountTypeRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
301  accountTypeRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
302 
303  javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
304  jPanel2.setLayout(jPanel2Layout);
305  jPanel2Layout.setHorizontalGroup(
306  jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
307  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
308  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
309  .addGroup(jPanel2Layout.createSequentialGroup()
310  .addComponent(accountTypesLabel)
311  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
312  .addComponent(accountTypeRequiredLabel))
313  .addGroup(jPanel2Layout.createSequentialGroup()
314  .addContainerGap()
315  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
316  .addComponent(jScrollPane3)
317  .addGroup(jPanel2Layout.createSequentialGroup()
318  .addGap(0, 0, Short.MAX_VALUE)
319  .addComponent(unCheckAllAccountTypesButton)
320  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
321  .addComponent(checkAllAccountTypesButton)))))
322  .addGap(0, 0, 0))
323  );
324  jPanel2Layout.setVerticalGroup(
325  jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326  .addGroup(jPanel2Layout.createSequentialGroup()
327  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
328  .addComponent(accountTypesLabel)
329  .addComponent(accountTypeRequiredLabel))
330  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
331  .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
332  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
333  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
334  .addComponent(checkAllAccountTypesButton)
335  .addComponent(unCheckAllAccountTypesButton)))
336  );
337 
338  unCheckAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllDevicesButton.text")); // NOI18N
339  unCheckAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
340  public void actionPerformed(java.awt.event.ActionEvent evt) {
342  }
343  });
344 
345  devicesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/image.png"))); // NOI18N
346  devicesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.devicesLabel.text")); // NOI18N
347 
348  checkAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllDevicesButton.text")); // NOI18N
349  checkAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
350  public void actionPerformed(java.awt.event.ActionEvent evt) {
352  }
353  });
354 
355  jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
356  jScrollPane2.setMinimumSize(new java.awt.Dimension(27, 75));
357 
358  devicesPane.setMinimumSize(new java.awt.Dimension(4, 100));
359  devicesPane.setLayout(new javax.swing.BoxLayout(devicesPane, javax.swing.BoxLayout.Y_AXIS));
360  jScrollPane2.setViewportView(devicesPane);
361 
362  deviceRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
363  deviceRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.deviceRequiredLabel.text")); // NOI18N
364  deviceRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
365  deviceRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
366 
367  javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
368  jPanel3.setLayout(jPanel3Layout);
369  jPanel3Layout.setHorizontalGroup(
370  jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
371  .addGroup(jPanel3Layout.createSequentialGroup()
372  .addComponent(devicesLabel)
373  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
374  .addComponent(deviceRequiredLabel))
375  .addGroup(jPanel3Layout.createSequentialGroup()
376  .addContainerGap()
377  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378  .addGroup(jPanel3Layout.createSequentialGroup()
379  .addGap(0, 0, Short.MAX_VALUE)
380  .addComponent(unCheckAllDevicesButton)
381  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
382  .addComponent(checkAllDevicesButton))
383  .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
384  );
385  jPanel3Layout.setVerticalGroup(
386  jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
387  .addGroup(jPanel3Layout.createSequentialGroup()
388  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
389  .addComponent(devicesLabel)
390  .addComponent(deviceRequiredLabel))
391  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
392  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
393  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
394  .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
395  .addComponent(checkAllDevicesButton)
396  .addComponent(unCheckAllDevicesButton))
397  .addGap(5, 5, 5))
398  );
399 
400  startDatePicker.setEnabled(false);
401 
402  dateRangeLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/calendar.png"))); // NOI18N
403  dateRangeLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.dateRangeLabel.text")); // NOI18N
404 
405  startCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.startCheckBox.text")); // NOI18N
406  startCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
407  public void stateChanged(javax.swing.event.ChangeEvent evt) {
409  }
410  });
411 
412  endCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.endCheckBox.text")); // NOI18N
413  endCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
414  public void stateChanged(javax.swing.event.ChangeEvent evt) {
416  }
417  });
418 
419  endDatePicker.setEnabled(false);
420 
421  javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
422  jPanel4.setLayout(jPanel4Layout);
423  jPanel4Layout.setHorizontalGroup(
424  jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
425  .addGroup(jPanel4Layout.createSequentialGroup()
426  .addComponent(dateRangeLabel)
427  .addGap(0, 0, Short.MAX_VALUE))
428  .addGroup(jPanel4Layout.createSequentialGroup()
429  .addContainerGap()
430  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
431  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
432  .addComponent(endCheckBox)
433  .addGap(12, 12, 12)
434  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
435  .addGroup(jPanel4Layout.createSequentialGroup()
436  .addComponent(startCheckBox)
437  .addGap(12, 12, 12)
438  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
439  );
440 
441  jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {endCheckBox, startCheckBox});
442 
443  jPanel4Layout.setVerticalGroup(
444  jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
445  .addGroup(jPanel4Layout.createSequentialGroup()
446  .addComponent(dateRangeLabel)
447  .addGap(6, 6, 6)
448  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
449  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
450  .addComponent(startCheckBox))
451  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
452  .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
453  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
454  .addComponent(endCheckBox)))
455  );
456 
457  refreshButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-circle-double-135.png"))); // NOI18N
458  refreshButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.refreshButton.text")); // NOI18N
459 
460  needsRefreshLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.needsRefreshLabel.text")); // NOI18N
461  needsRefreshLabel.setForeground(new java.awt.Color(255, 0, 0));
462 
463  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
464  this.setLayout(layout);
465  layout.setHorizontalGroup(
466  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
467  .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
468  .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
469  .addGroup(layout.createSequentialGroup()
470  .addComponent(filtersTitleLabel)
471  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
472  .addComponent(applyFiltersButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
473  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
474  .addComponent(refreshButton))
475  .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
476  .addGroup(layout.createSequentialGroup()
477  .addContainerGap()
478  .addComponent(needsRefreshLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
479  );
480  layout.setVerticalGroup(
481  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
482  .addGroup(layout.createSequentialGroup()
483  .addGap(0, 0, 0)
484  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
485  .addComponent(filtersTitleLabel)
486  .addComponent(applyFiltersButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
487  .addComponent(refreshButton))
488  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
489  .addComponent(needsRefreshLabel)
490  .addGap(4, 4, 4)
491  .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
492  .addGap(18, 18, 18)
493  .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
494  .addGap(18, 18, 18)
495  .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
496  .addContainerGap(19, Short.MAX_VALUE))
497  );
498  }// </editor-fold>//GEN-END:initComponents
499 
503  private void applyFilters() {
504  CVTEvents.getCVTEventBus().post(new CVTEvents.FilterChangeEvent(getFilter()));
505  needsRefresh = false;
506  validateFilters();
507  }
508 
509  private CommunicationsFilter getFilter() {
510  CommunicationsFilter commsFilter = new CommunicationsFilter();
511  commsFilter.addAndFilter(getDeviceFilter());
512  commsFilter.addAndFilter(getAccountTypeFilter());
513  commsFilter.addAndFilter(getDateRangeFilter());
514  commsFilter.addAndFilter(new CommunicationsFilter.RelationshipTypeFilter(
515  ImmutableSet.of(CALL_LOG, MESSAGE)));
516  return commsFilter;
517  }
518 
524  private DeviceFilter getDeviceFilter() {
525  DeviceFilter deviceFilter = new DeviceFilter(
526  devicesMap.entrySet().stream()
527  .filter(entry -> entry.getValue().isSelected())
528  .map(Entry::getKey)
529  .collect(Collectors.toSet()));
530  return deviceFilter;
531  }
532 
538  private AccountTypeFilter getAccountTypeFilter() {
539  AccountTypeFilter accountTypeFilter = new AccountTypeFilter(
540  accountTypeMap.entrySet().stream()
541  .filter(entry -> entry.getValue().isSelected())
542  .map(entry -> entry.getKey())
543  .collect(Collectors.toSet()));
544  return accountTypeFilter;
545  }
546 
552  private DateRangeFilter getDateRangeFilter() {
553  ZoneId zone = Utils.getUserPreferredZoneId();
554  long start = startDatePicker.isEnabled() ? startDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0;
555  long end = endDatePicker.isEnabled() ? endDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0;
556  return new DateRangeFilter(start, end);
557  }
558 
566  void setDeviceAccountTypeEnabled(boolean enable) {
567  deviceAccountTypeEnabled = enable;
568  JCheckBox deviceCheckbox = accountTypeMap.get(Account.Type.DEVICE);
569  if (deviceCheckbox != null) {
570  deviceCheckbox.setEnabled(deviceAccountTypeEnabled);
571  }
572  }
573 
579  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
580  private void setAllAccountTypesSelected(boolean selected) {
581  setAllSelected(accountTypeMap, selected);
582  }
583 
590  private void setAllDevicesSelected(boolean selected) {
591  setAllSelected(devicesMap, selected);
592  }
593 
602  private void setAllSelected(Map<?, JCheckBox> map, boolean selected) {
603  map.values().forEach(box -> box.setSelected(selected));
604  }
605 
606  private void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllAccountTypesButtonActionPerformed
608  }//GEN-LAST:event_unCheckAllAccountTypesButtonActionPerformed
609 
610  private void checkAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllAccountTypesButtonActionPerformed
612  }//GEN-LAST:event_checkAllAccountTypesButtonActionPerformed
613 
614  private void unCheckAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllDevicesButtonActionPerformed
615  setAllDevicesSelected(false);
616  }//GEN-LAST:event_unCheckAllDevicesButtonActionPerformed
617 
618  private void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllDevicesButtonActionPerformed
619  setAllDevicesSelected(true);
620  }//GEN-LAST:event_checkAllDevicesButtonActionPerformed
621 
622  private void startCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_startCheckBoxStateChanged
623  startDatePicker.setEnabled(startCheckBox.isSelected());
624  }//GEN-LAST:event_startCheckBoxStateChanged
625 
626  private void endCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_endCheckBoxStateChanged
627  endDatePicker.setEnabled(endCheckBox.isSelected());
628  }//GEN-LAST:event_endCheckBoxStateChanged
629 
630 
631  // Variables declaration - do not modify//GEN-BEGIN:variables
632  private final javax.swing.JPanel accountTypePane = new javax.swing.JPanel();
633  private final javax.swing.JLabel accountTypeRequiredLabel = new javax.swing.JLabel();
634  private final javax.swing.JLabel accountTypesLabel = new javax.swing.JLabel();
635  private final javax.swing.JButton applyFiltersButton = new javax.swing.JButton();
636  private final javax.swing.JButton checkAllAccountTypesButton = new javax.swing.JButton();
637  private final javax.swing.JButton checkAllDevicesButton = new javax.swing.JButton();
638  private final javax.swing.JLabel dateRangeLabel = new javax.swing.JLabel();
639  private final javax.swing.JLabel deviceRequiredLabel = new javax.swing.JLabel();
640  private final javax.swing.JLabel devicesLabel = new javax.swing.JLabel();
641  private final javax.swing.JPanel devicesPane = new javax.swing.JPanel();
642  private final javax.swing.JCheckBox endCheckBox = new javax.swing.JCheckBox();
643  private final com.github.lgooddatepicker.components.DatePicker endDatePicker = new com.github.lgooddatepicker.components.DatePicker();
644  private final javax.swing.JLabel filtersTitleLabel = new javax.swing.JLabel();
645  private final javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
646  private final javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
647  private final javax.swing.JPanel jPanel4 = new javax.swing.JPanel();
648  private final javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
649  private final javax.swing.JScrollPane jScrollPane3 = new javax.swing.JScrollPane();
650  private final javax.swing.JLabel needsRefreshLabel = new javax.swing.JLabel();
651  private final javax.swing.JButton refreshButton = new javax.swing.JButton();
652  private final javax.swing.JCheckBox startCheckBox = new javax.swing.JCheckBox();
653  private final com.github.lgooddatepicker.components.DatePicker startDatePicker = new com.github.lgooddatepicker.components.DatePicker();
654  private final javax.swing.JButton unCheckAllAccountTypesButton = new javax.swing.JButton();
655  private final javax.swing.JButton unCheckAllDevicesButton = new javax.swing.JButton();
656  // End of variables declaration//GEN-END:variables
657 }
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:420
static void addChangeListener(PreferenceChangeListener listener)
void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt)
final javax.swing.JButton unCheckAllAccountTypesButton

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