Autopsy  4.15.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-2019 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 com.google.common.eventbus.Subscribe;
23 import java.awt.event.ItemListener;
24 import java.beans.PropertyChangeListener;
25 import java.sql.ResultSet;
26 import java.sql.SQLException;
27 import java.time.Instant;
28 import java.time.LocalDate;
29 import java.time.LocalDateTime;
30 import java.time.ZoneId;
31 import java.util.Collection;
32 import java.util.EnumSet;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Map.Entry;
37 import java.util.Set;
38 import java.util.concurrent.ExecutionException;
39 import java.util.logging.Level;
40 import java.util.stream.Collectors;
41 import javax.swing.Box;
42 import javax.swing.BoxLayout;
43 import javax.swing.Icon;
44 import javax.swing.ImageIcon;
45 import javax.swing.JCheckBox;
46 import javax.swing.JLabel;
47 import javax.swing.JPanel;
48 import javax.swing.SwingWorker;
49 import org.openide.util.NbBundle;
60 import org.sleuthkit.datamodel.Account;
61 import org.sleuthkit.datamodel.BlackboardArtifact;
62 import org.sleuthkit.datamodel.CaseDbAccessManager.CaseDbAccessQueryCallback;
63 import org.sleuthkit.datamodel.CommunicationsFilter;
64 import org.sleuthkit.datamodel.CommunicationsFilter.AccountTypeFilter;
65 import org.sleuthkit.datamodel.CommunicationsFilter.DateRangeFilter;
66 import org.sleuthkit.datamodel.CommunicationsFilter.DeviceFilter;
67 import org.sleuthkit.datamodel.CommunicationsFilter.MostRecentFilter;
68 import org.sleuthkit.datamodel.DataSource;
69 import static org.sleuthkit.datamodel.Relationship.Type.CALL_LOG;
70 import static org.sleuthkit.datamodel.Relationship.Type.CONTACT;
71 import static org.sleuthkit.datamodel.Relationship.Type.MESSAGE;
72 import org.sleuthkit.datamodel.SleuthkitCase;
73 import org.sleuthkit.datamodel.TskCoreException;
74 
79 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
80 final public class FiltersPanel extends JPanel {
81 
82  private static final long serialVersionUID = 1L;
83  private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName());
84  private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.COMPLETED);
85  private static final Set<IngestManager.IngestModuleEvent> INGEST_MODULE_EVENTS_OF_INTEREST = EnumSet.of(DATA_ADDED);
90  private final Map<Account.Type, JCheckBox> accountTypeMap = new HashMap<>();
91 
95  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
96  private final Map<String, JCheckBox> devicesMap = new HashMap<>();
97 
101  private final PropertyChangeListener ingestListener;
102  private final PropertyChangeListener ingestJobListener;
103 
108  private boolean needsRefresh;
109 
115  private final ItemListener validationListener;
116 
123  private boolean deviceAccountTypeEnabled;
124 
125  private Case openCase = null;
126 
127  @NbBundle.Messages({"refreshText=Refresh Results", "applyText=Apply"})
128  public FiltersPanel() {
129  initComponents();
130 
131  initalizeDeviceAccountType();
132 
133  deviceRequiredLabel.setVisible(false);
134  accountTypeRequiredLabel.setVisible(false);
135  startDatePicker.setDate(LocalDate.now().minusWeeks(3));
136  endDatePicker.setDateToToday();
137  startDatePicker.getSettings().setVetoPolicy(
138  //no end date, or start is before end
139  startDate -> endCheckBox.isSelected() == false
140  || startDate.compareTo(endDatePicker.getDate()) <= 0
141  );
142  endDatePicker.getSettings().setVetoPolicy(
143  //no start date, or end is after start
144  endDate -> startCheckBox.isSelected() == false
145  || endDate.compareTo(startDatePicker.getDate()) >= 0
146  );
147 
148  updateTimeZone();
149  validationListener = itemEvent -> validateFilters();
150 
151  UserPreferences.addChangeListener(preferenceChangeEvent -> {
152  if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)
153  || preferenceChangeEvent.getKey().equals(UserPreferences.TIME_ZONE_FOR_DISPLAYS)) {
154  updateTimeZone();
155  }
156  });
157 
158  this.ingestListener = pce -> {
159  String eventType = pce.getPropertyName();
160  if (eventType.equals(DATA_ADDED.toString())) {
161  // Indicate that a refresh may be needed, unless the data added is Keyword or Hashset hits
162  ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue();
163  if (null != eventData
164  && (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()
165  || eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT.getTypeID()
166  || eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG.getTypeID()
167  || eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())) {
168  updateFilters(true);
169  needsRefresh = true;
170  validateFilters();
171  }
172  }
173  };
174 
175  this.ingestJobListener = pce -> {
176  String eventType = pce.getPropertyName();
177  if (eventType.equals(COMPLETED.toString())
178  && updateFilters(true)) {
179 
180  needsRefresh = true;
181  validateFilters();
182  }
183  };
184 
185  applyFiltersButton.addActionListener(e -> applyFilters());
186  refreshButton.addActionListener(e -> applyFilters());
187  }
188 
195  private void validateFilters() {
196  boolean someDevice = devicesMap.values().stream().anyMatch(JCheckBox::isSelected);
197  boolean someAccountType = accountTypeMap.values().stream().anyMatch(JCheckBox::isSelected);
198  boolean validLimit = validateLimitValue();
199 
200  deviceRequiredLabel.setVisible(someDevice == false);
201  accountTypeRequiredLabel.setVisible(someAccountType == false);
202  limitErrorMsgLabel.setVisible(!validLimit);
203 
204  applyFiltersButton.setEnabled(someDevice && someAccountType && validLimit);
205  refreshButton.setEnabled(someDevice && someAccountType && needsRefresh && validLimit);
206  needsRefreshLabel.setVisible(needsRefresh);
207  }
208 
209  private boolean validateLimitValue() {
210  String selectedValue = (String) limitComboBox.getSelectedItem();
211  if (selectedValue.trim().equalsIgnoreCase("all")) {
212  return true;
213  } else {
214  try {
215  int value = Integer.parseInt(selectedValue);
216  return value > 0;
217  } catch (NumberFormatException ex) {
218  return false;
219  }
220  }
221  }
222 
226  void updateAndApplyFilters(boolean initialState) {
227  updateFilters(initialState);
228  applyFilters();
229  initalizeDateTimeFilters();
230  }
231 
232  private void updateTimeZone() {
233  dateRangeLabel.setText("Date Range (" + Utils.getUserPreferredZoneId().toString() + "):");
234  }
235 
239  private boolean updateFilters(boolean initialState) {
240  final SleuthkitCase sleuthkitCase;
241  try {
242  sleuthkitCase = Case.getCurrentCaseThrows().getSleuthkitCase();
243  } catch (NoCurrentCaseException ex) {
244  logger.log(Level.WARNING, "Unable to perform filter update, update has been cancelled. Case is closed.", ex);
245  return false;
246  }
247  boolean newAccountType = updateAccountTypeFilter(initialState, sleuthkitCase);
248  boolean newDeviceFilter = updateDeviceFilter(initialState, sleuthkitCase);
249  // both or either are true, return true;
250  return newAccountType || newDeviceFilter;
251  }
252 
253  @Override
254  public void addNotify() {
255  super.addNotify();
256  IngestManager.getInstance().addIngestModuleEventListener(INGEST_MODULE_EVENTS_OF_INTEREST, ingestListener);
257  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestJobListener);
258  Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), evt -> {
259  //clear the device filter widget when the case changes.
260  devicesMap.clear();
261  devicesListPane.removeAll();
262 
263  accountTypeMap.clear();
264  accountTypeListPane.removeAll();
265 
266  initalizeDeviceAccountType();
267  });
268  }
269 
270  @Override
271  public void removeNotify() {
272  super.removeNotify();
275  }
276 
277  private void initalizeDeviceAccountType() {
278  CheckBoxIconPanel panel = createAccoutTypeCheckBoxPanel(Account.Type.DEVICE, true);
279  accountTypeMap.put(Account.Type.DEVICE, panel.getCheckBox());
280  accountTypeListPane.add(panel);
281  }
282 
292  private boolean updateAccountTypeFilter(boolean selected, SleuthkitCase sleuthkitCase) {
293  boolean newOneFound = false;
294  try {
295  List<Account.Type> accountTypesInUse = sleuthkitCase.getCommunicationsManager().getAccountTypesInUse();
296 
297  for (Account.Type type : accountTypesInUse) {
298 
299  if (!accountTypeMap.containsKey(type) && !type.equals(Account.Type.CREDIT_CARD)) {
300  CheckBoxIconPanel panel = createAccoutTypeCheckBoxPanel(type, selected);
301  accountTypeMap.put(type, panel.getCheckBox());
302  accountTypeListPane.add(panel);
303 
304  newOneFound = true;
305  }
306  }
307 
308  } catch (TskCoreException ex) {
309  logger.log(Level.WARNING, "Unable to update to update Account Types Filter", ex);
310  }
311  if (newOneFound) {
312  accountTypeListPane.revalidate();
313  }
314 
315  return newOneFound;
316  }
317 
327  private CheckBoxIconPanel createAccoutTypeCheckBoxPanel(Account.Type type, boolean initalState) {
328  CheckBoxIconPanel panel = new CheckBoxIconPanel(
329  type.getDisplayName(),
330  new ImageIcon(FiltersPanel.class.getResource(Utils.getIconFilePath(type))));
331 
332  panel.setSelected(initalState);
333  panel.addItemListener(validationListener);
334  return panel;
335  }
336 
346  private boolean updateDeviceFilter(boolean selected, SleuthkitCase sleuthkitCase) {
347  boolean newOneFound = false;
348  try {
349  for (DataSource dataSource : sleuthkitCase.getDataSources()) {
350  String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName();
351  if (devicesMap.containsKey(dataSource.getDeviceId())) {
352  continue;
353  }
354 
355  final JCheckBox jCheckBox = new JCheckBox(dsName, selected);
356  jCheckBox.addItemListener(validationListener);
357  devicesListPane.add(jCheckBox);
358  devicesMap.put(dataSource.getDeviceId(), jCheckBox);
359 
360  newOneFound = true;
361 
362  }
363  } catch (TskCoreException tskCoreException) {
364  logger.log(Level.SEVERE, "There was a error loading the datasources for the case.", tskCoreException);
365  }
366 
367  if (newOneFound) {
368  devicesListPane.revalidate();
369  }
370 
371  return newOneFound;
372  }
373 
380  public void setFilters(CommunicationsFilter commFilter) {
381  List<CommunicationsFilter.SubFilter> subFilters = commFilter.getAndFilters();
382  subFilters.forEach(subFilter -> {
383  if (subFilter instanceof DeviceFilter) {
384  setDeviceFilter((DeviceFilter) subFilter);
385  } else if (subFilter instanceof AccountTypeFilter) {
386  setAccountTypeFilter((AccountTypeFilter) subFilter);
387  } else if (subFilter instanceof MostRecentFilter) {
388  setMostRecentFilter((MostRecentFilter) subFilter);
389  }
390  });
391  }
392 
398  private void setDeviceFilter(DeviceFilter deviceFilter) {
399  Collection<String> deviceIDs = deviceFilter.getDevices();
400  devicesMap.forEach((type, cb) -> {
401  cb.setSelected(deviceIDs.contains(type));
402  });
403  }
404 
411  private void setAccountTypeFilter(AccountTypeFilter typeFilter) {
412 
413  accountTypeMap.forEach((type, cb) -> {
414  cb.setSelected(typeFilter.getAccountTypes().contains(type));
415  });
416  }
417 
424  private void setStartDateControlState(DateControlState state) {
425  startDatePicker.setDate(state.getDate());
426  startCheckBox.setSelected(state.isEnabled());
427  startDatePicker.setEnabled(state.isEnabled());
428  }
429 
436  private void setEndDateControlState(DateControlState state) {
437  endDatePicker.setDate(state.getDate());
438  endCheckBox.setSelected(state.isEnabled());
439  endDatePicker.setEnabled(state.isEnabled());
440  }
441 
448  private void setMostRecentFilter(MostRecentFilter filter) {
449  int limit = filter.getLimit();
450  if (limit > 0) {
451  limitComboBox.setSelectedItem(filter.getLimit());
452  } else {
453  limitComboBox.setSelectedItem("All");
454  }
455  }
456 
457  @Subscribe
458  void filtersBack(CVTEvents.StateChangeEvent event) {
459  if (event.getCommunicationsState().getCommunicationsFilter() != null) {
460  setFilters(event.getCommunicationsState().getCommunicationsFilter());
461  setStartDateControlState(event.getCommunicationsState().getStartControlState());
462  setEndDateControlState(event.getCommunicationsState().getEndControlState());
463  needsRefresh = false;
464  validateFilters();
465  }
466  }
467 
473  @SuppressWarnings("unchecked")
474  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
475  private void initComponents() {
476  java.awt.GridBagConstraints gridBagConstraints;
477 
478  setLayout(new java.awt.GridBagLayout());
479 
480  scrollPane.setBorder(null);
481  scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
482  scrollPane.setAutoscrolls(true);
483 
484  mainPanel.setLayout(new java.awt.GridBagLayout());
485 
486  limitPane.setLayout(new java.awt.GridBagLayout());
487 
488  mostRecentLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.mostRecentLabel.text")); // NOI18N
489  gridBagConstraints = new java.awt.GridBagConstraints();
490  gridBagConstraints.gridx = 0;
491  gridBagConstraints.gridy = 1;
492  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
493  gridBagConstraints.insets = new java.awt.Insets(0, 9, 0, 9);
494  limitPane.add(mostRecentLabel, gridBagConstraints);
495 
496  limitComboBox.setEditable(true);
497  limitComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "All", "10000", "5000", "1000", "500", "100" }));
498  limitComboBox.addActionListener(new java.awt.event.ActionListener() {
499  public void actionPerformed(java.awt.event.ActionEvent evt) {
500  limitComboBoxActionPerformed(evt);
501  }
502  });
503  gridBagConstraints = new java.awt.GridBagConstraints();
504  gridBagConstraints.gridx = 1;
505  gridBagConstraints.gridy = 1;
506  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
507  limitPane.add(limitComboBox, gridBagConstraints);
508 
509  limitTitlePanel.setLayout(new java.awt.GridBagLayout());
510 
511  limitHeaderLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.limitHeaderLabel.text")); // NOI18N
512  gridBagConstraints = new java.awt.GridBagConstraints();
513  gridBagConstraints.gridx = 0;
514  gridBagConstraints.gridy = 0;
515  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
516  gridBagConstraints.weightx = 1.0;
517  limitTitlePanel.add(limitHeaderLabel, gridBagConstraints);
518 
519  limitErrorMsgLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
520  limitErrorMsgLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.limitErrorMsgLabel.text")); // NOI18N
521  limitErrorMsgLabel.setForeground(new java.awt.Color(255, 0, 0));
522  limitErrorMsgLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
523  gridBagConstraints = new java.awt.GridBagConstraints();
524  gridBagConstraints.gridx = 1;
525  gridBagConstraints.gridy = 0;
526  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
527  limitTitlePanel.add(limitErrorMsgLabel, gridBagConstraints);
528 
529  gridBagConstraints = new java.awt.GridBagConstraints();
530  gridBagConstraints.gridx = 0;
531  gridBagConstraints.gridy = 0;
532  gridBagConstraints.gridwidth = 2;
533  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
534  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
535  gridBagConstraints.weightx = 1.0;
536  gridBagConstraints.insets = new java.awt.Insets(0, 0, 9, 0);
537  limitPane.add(limitTitlePanel, gridBagConstraints);
538 
539  gridBagConstraints = new java.awt.GridBagConstraints();
540  gridBagConstraints.gridx = 0;
541  gridBagConstraints.gridy = 4;
542  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
543  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
544  gridBagConstraints.weightx = 1.0;
545  gridBagConstraints.weighty = 1.0;
546  gridBagConstraints.insets = new java.awt.Insets(15, 0, 15, 25);
547  mainPanel.add(limitPane, gridBagConstraints);
548 
549  startDatePicker.setEnabled(false);
550 
551  dateRangeLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/calendar.png"))); // NOI18N
552  dateRangeLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.dateRangeLabel.text")); // NOI18N
553 
554  startCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.startCheckBox.text")); // NOI18N
555  startCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
556  public void stateChanged(javax.swing.event.ChangeEvent evt) {
557  startCheckBoxStateChanged(evt);
558  }
559  });
560 
561  endCheckBox.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.endCheckBox.text")); // NOI18N
562  endCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
563  public void stateChanged(javax.swing.event.ChangeEvent evt) {
564  endCheckBoxStateChanged(evt);
565  }
566  });
567 
568  endDatePicker.setEnabled(false);
569 
570  javax.swing.GroupLayout dateRangePaneLayout = new javax.swing.GroupLayout(dateRangePane);
571  dateRangePane.setLayout(dateRangePaneLayout);
572  dateRangePaneLayout.setHorizontalGroup(
573  dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
574  .addGroup(dateRangePaneLayout.createSequentialGroup()
575  .addGroup(dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
576  .addComponent(dateRangeLabel)
577  .addGroup(dateRangePaneLayout.createSequentialGroup()
578  .addContainerGap()
579  .addGroup(dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
580  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dateRangePaneLayout.createSequentialGroup()
581  .addComponent(endCheckBox)
582  .addGap(12, 12, 12)
583  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
584  .addGroup(dateRangePaneLayout.createSequentialGroup()
585  .addComponent(startCheckBox)
586  .addGap(12, 12, 12)
587  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
588  .addGap(0, 0, Short.MAX_VALUE))
589  );
590 
591  dateRangePaneLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {endCheckBox, startCheckBox});
592 
593  dateRangePaneLayout.setVerticalGroup(
594  dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
595  .addGroup(dateRangePaneLayout.createSequentialGroup()
596  .addComponent(dateRangeLabel)
597  .addGap(6, 6, 6)
598  .addGroup(dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
599  .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
600  .addComponent(startCheckBox))
601  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
602  .addGroup(dateRangePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
603  .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
604  .addComponent(endCheckBox)))
605  );
606 
607  gridBagConstraints = new java.awt.GridBagConstraints();
608  gridBagConstraints.gridx = 0;
609  gridBagConstraints.gridy = 3;
610  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
611  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
612  gridBagConstraints.weightx = 1.0;
613  gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 25);
614  mainPanel.add(dateRangePane, gridBagConstraints);
615 
616  devicesPane.setLayout(new java.awt.GridBagLayout());
617 
618  unCheckAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllDevicesButton.text")); // NOI18N
619  unCheckAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
620  public void actionPerformed(java.awt.event.ActionEvent evt) {
621  unCheckAllDevicesButtonActionPerformed(evt);
622  }
623  });
624  gridBagConstraints = new java.awt.GridBagConstraints();
625  gridBagConstraints.gridx = 0;
626  gridBagConstraints.gridy = 2;
627  gridBagConstraints.gridwidth = 2;
628  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
629  gridBagConstraints.weightx = 1.0;
630  gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 9);
631  devicesPane.add(unCheckAllDevicesButton, gridBagConstraints);
632 
633  devicesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/image.png"))); // NOI18N
634  devicesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.devicesLabel.text")); // NOI18N
635  gridBagConstraints = new java.awt.GridBagConstraints();
636  gridBagConstraints.gridx = 0;
637  gridBagConstraints.gridy = 0;
638  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
639  gridBagConstraints.insets = new java.awt.Insets(0, 0, 9, 0);
640  devicesPane.add(devicesLabel, gridBagConstraints);
641 
642  checkAllDevicesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllDevicesButton.text")); // NOI18N
643  checkAllDevicesButton.addActionListener(new java.awt.event.ActionListener() {
644  public void actionPerformed(java.awt.event.ActionEvent evt) {
645  checkAllDevicesButtonActionPerformed(evt);
646  }
647  });
648  gridBagConstraints = new java.awt.GridBagConstraints();
649  gridBagConstraints.gridx = 2;
650  gridBagConstraints.gridy = 2;
651  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
652  gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 0);
653  devicesPane.add(checkAllDevicesButton, gridBagConstraints);
654 
655  devicesScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
656  devicesScrollPane.setMaximumSize(new java.awt.Dimension(32767, 30));
657  devicesScrollPane.setMinimumSize(new java.awt.Dimension(27, 30));
658  devicesScrollPane.setPreferredSize(new java.awt.Dimension(3, 30));
659 
660  devicesListPane.setMinimumSize(new java.awt.Dimension(4, 100));
661  devicesListPane.setLayout(new javax.swing.BoxLayout(devicesListPane, javax.swing.BoxLayout.Y_AXIS));
662  devicesScrollPane.setViewportView(devicesListPane);
663 
664  gridBagConstraints = new java.awt.GridBagConstraints();
665  gridBagConstraints.gridx = 0;
666  gridBagConstraints.gridy = 1;
667  gridBagConstraints.gridwidth = 3;
668  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
669  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
670  gridBagConstraints.weightx = 1.0;
671  gridBagConstraints.weighty = 1.0;
672  devicesPane.add(devicesScrollPane, gridBagConstraints);
673 
674  deviceRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
675  deviceRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.deviceRequiredLabel.text")); // NOI18N
676  deviceRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
677  deviceRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
678  gridBagConstraints = new java.awt.GridBagConstraints();
679  gridBagConstraints.gridx = 1;
680  gridBagConstraints.gridy = 0;
681  gridBagConstraints.gridwidth = 2;
682  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
683  gridBagConstraints.insets = new java.awt.Insets(0, 0, 9, 0);
684  devicesPane.add(deviceRequiredLabel, gridBagConstraints);
685 
686  gridBagConstraints = new java.awt.GridBagConstraints();
687  gridBagConstraints.gridx = 0;
688  gridBagConstraints.gridy = 2;
689  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
690  gridBagConstraints.ipady = 100;
691  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
692  gridBagConstraints.weightx = 1.0;
693  gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 25);
694  mainPanel.add(devicesPane, gridBagConstraints);
695 
696  accountTypesPane.setLayout(new java.awt.GridBagLayout());
697 
698  unCheckAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.unCheckAllAccountTypesButton.text")); // NOI18N
699  unCheckAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
700  public void actionPerformed(java.awt.event.ActionEvent evt) {
701  unCheckAllAccountTypesButtonActionPerformed(evt);
702  }
703  });
704  gridBagConstraints = new java.awt.GridBagConstraints();
705  gridBagConstraints.gridx = 0;
706  gridBagConstraints.gridy = 2;
707  gridBagConstraints.gridwidth = 2;
708  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
709  gridBagConstraints.weightx = 1.0;
710  gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 9);
711  accountTypesPane.add(unCheckAllAccountTypesButton, gridBagConstraints);
712 
713  accountTypesLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/accounts.png"))); // NOI18N
714  accountTypesLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypesLabel.text")); // NOI18N
715  gridBagConstraints = new java.awt.GridBagConstraints();
716  gridBagConstraints.gridx = 0;
717  gridBagConstraints.gridy = 0;
718  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
719  accountTypesPane.add(accountTypesLabel, gridBagConstraints);
720 
721  checkAllAccountTypesButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.checkAllAccountTypesButton.text")); // NOI18N
722  checkAllAccountTypesButton.addActionListener(new java.awt.event.ActionListener() {
723  public void actionPerformed(java.awt.event.ActionEvent evt) {
724  checkAllAccountTypesButtonActionPerformed(evt);
725  }
726  });
727  gridBagConstraints = new java.awt.GridBagConstraints();
728  gridBagConstraints.gridx = 2;
729  gridBagConstraints.gridy = 2;
730  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
731  gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 0);
732  accountTypesPane.add(checkAllAccountTypesButton, gridBagConstraints);
733 
734  accountTypesScrollPane.setMaximumSize(new java.awt.Dimension(32767, 210));
735  accountTypesScrollPane.setMinimumSize(new java.awt.Dimension(20, 210));
736  accountTypesScrollPane.setName(""); // NOI18N
737  accountTypesScrollPane.setPreferredSize(new java.awt.Dimension(2, 210));
738 
739  accountTypeListPane.setLayout(new javax.swing.BoxLayout(accountTypeListPane, javax.swing.BoxLayout.PAGE_AXIS));
740  accountTypesScrollPane.setViewportView(accountTypeListPane);
741 
742  gridBagConstraints = new java.awt.GridBagConstraints();
743  gridBagConstraints.gridx = 0;
744  gridBagConstraints.gridy = 1;
745  gridBagConstraints.gridwidth = 3;
746  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
747  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
748  gridBagConstraints.weightx = 1.0;
749  gridBagConstraints.weighty = 1.0;
750  gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 0);
751  accountTypesPane.add(accountTypesScrollPane, gridBagConstraints);
752 
753  accountTypeRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/error-icon-16.png"))); // NOI18N
754  accountTypeRequiredLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.accountTypeRequiredLabel.text")); // NOI18N
755  accountTypeRequiredLabel.setForeground(new java.awt.Color(255, 0, 0));
756  accountTypeRequiredLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
757  gridBagConstraints = new java.awt.GridBagConstraints();
758  gridBagConstraints.gridx = 1;
759  gridBagConstraints.gridy = 0;
760  gridBagConstraints.gridwidth = 2;
761  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
762  accountTypesPane.add(accountTypeRequiredLabel, gridBagConstraints);
763 
764  gridBagConstraints = new java.awt.GridBagConstraints();
765  gridBagConstraints.gridx = 0;
766  gridBagConstraints.gridy = 1;
767  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
768  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
769  gridBagConstraints.weightx = 1.0;
770  gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 25);
771  mainPanel.add(accountTypesPane, gridBagConstraints);
772 
773  topPane.setLayout(new java.awt.GridBagLayout());
774 
775  filtersTitleLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/funnel.png"))); // NOI18N
776  filtersTitleLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.filtersTitleLabel.text")); // NOI18N
777  gridBagConstraints = new java.awt.GridBagConstraints();
778  gridBagConstraints.gridx = 0;
779  gridBagConstraints.gridy = 0;
780  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
781  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
782  gridBagConstraints.weightx = 1.0;
783  topPane.add(filtersTitleLabel, gridBagConstraints);
784 
785  refreshButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/arrow-circle-double-135.png"))); // NOI18N
786  refreshButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.refreshButton.text")); // NOI18N
787  gridBagConstraints = new java.awt.GridBagConstraints();
788  gridBagConstraints.gridx = 2;
789  gridBagConstraints.gridy = 0;
790  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
791  topPane.add(refreshButton, gridBagConstraints);
792 
793  applyFiltersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/tick.png"))); // NOI18N
794  applyFiltersButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.applyFiltersButton.text")); // NOI18N
795  gridBagConstraints = new java.awt.GridBagConstraints();
796  gridBagConstraints.gridx = 1;
797  gridBagConstraints.gridy = 0;
798  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
799  gridBagConstraints.weightx = 1.0;
800  gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
801  topPane.add(applyFiltersButton, gridBagConstraints);
802 
803  needsRefreshLabel.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.needsRefreshLabel.text")); // NOI18N
804  needsRefreshLabel.setForeground(new java.awt.Color(255, 0, 0));
805  gridBagConstraints = new java.awt.GridBagConstraints();
806  gridBagConstraints.gridx = 0;
807  gridBagConstraints.gridy = 1;
808  gridBagConstraints.gridwidth = 3;
809  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
810  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
811  gridBagConstraints.weightx = 1.0;
812  topPane.add(needsRefreshLabel, gridBagConstraints);
813 
814  gridBagConstraints = new java.awt.GridBagConstraints();
815  gridBagConstraints.gridx = 0;
816  gridBagConstraints.gridy = 0;
817  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
818  gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END;
819  gridBagConstraints.weightx = 1.0;
820  gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 25);
821  mainPanel.add(topPane, gridBagConstraints);
822 
823  scrollPane.setViewportView(mainPanel);
824 
825  gridBagConstraints = new java.awt.GridBagConstraints();
826  gridBagConstraints.gridx = 0;
827  gridBagConstraints.gridy = 0;
828  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
829  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
830  gridBagConstraints.weightx = 1.0;
831  gridBagConstraints.weighty = 1.0;
832  gridBagConstraints.insets = new java.awt.Insets(9, 15, 0, 0);
833  add(scrollPane, gridBagConstraints);
834  }// </editor-fold>//GEN-END:initComponents
835 
839  private void applyFilters() {
840  CVTEvents.getCVTEventBus().post(new CVTEvents.FilterChangeEvent(getFilter(), getStartControlState(), getEndControlState()));
841  needsRefresh = false;
842  validateFilters();
843  }
844 
850  private CommunicationsFilter getFilter() {
851  CommunicationsFilter commsFilter = new CommunicationsFilter();
852  commsFilter.addAndFilter(getDeviceFilter());
853  commsFilter.addAndFilter(getAccountTypeFilter());
854  commsFilter.addAndFilter(getDateRangeFilter());
855  commsFilter.addAndFilter(new CommunicationsFilter.RelationshipTypeFilter(
856  ImmutableSet.of(CALL_LOG, MESSAGE, CONTACT)));
857  commsFilter.addAndFilter(getMostRecentFilter());
858  return commsFilter;
859  }
860 
866  private DeviceFilter getDeviceFilter() {
867  DeviceFilter deviceFilter = new DeviceFilter(
868  devicesMap.entrySet().stream()
869  .filter(entry -> entry.getValue().isSelected())
870  .map(Entry::getKey)
871  .collect(Collectors.toSet()));
872  return deviceFilter;
873  }
874 
880  private AccountTypeFilter getAccountTypeFilter() {
881  AccountTypeFilter accountTypeFilter = new AccountTypeFilter(
882  accountTypeMap.entrySet().stream()
883  .filter(entry -> entry.getValue().isSelected())
884  .map(entry -> entry.getKey())
885  .collect(Collectors.toSet()));
886  return accountTypeFilter;
887  }
888 
894  private DateRangeFilter getDateRangeFilter() {
895  ZoneId zone = Utils.getUserPreferredZoneId();
896 
897  return new DateRangeFilter(startCheckBox.isSelected() ? startDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0,
898  endCheckBox.isSelected() ? endDatePicker.getDate().atStartOfDay(zone).toEpochSecond() : 0);
899  }
900 
907  private MostRecentFilter getMostRecentFilter() {
908  String value = (String) limitComboBox.getSelectedItem();
909  if (value.trim().equalsIgnoreCase("all")) {
910  return new MostRecentFilter(-1);
911  } else {
912  try {
913  int count = Integer.parseInt(value);
914  return new MostRecentFilter(count);
915  } catch (NumberFormatException ex) {
916  return null;
917  }
918  }
919  }
920 
921  private DateControlState getStartControlState() {
922  return new DateControlState(startDatePicker.getDate(), startCheckBox.isSelected());
923  }
924 
925  private DateControlState getEndControlState() {
926  return new DateControlState(endDatePicker.getDate(), endCheckBox.isSelected());
927  }
928 
935  private void setAllAccountTypesSelected(boolean selected) {
936  setAllSelected(accountTypeMap, selected);
937  }
938 
945  private void setAllDevicesSelected(boolean selected) {
946  setAllSelected(devicesMap, selected);
947  }
948 
957  private void setAllSelected(Map<?, JCheckBox> map, boolean selected) {
958  map.values().forEach(box -> box.setSelected(selected));
959  }
960 
965  private void initalizeDateTimeFilters() {
966  Case currentCase = null;
967  try {
968  currentCase = Case.getCurrentCaseThrows();
969  } catch (NoCurrentCaseException ex) {
970  logger.log(Level.INFO, "Tried to intialize communication filters date range filters without an open case, using default values");
971  }
972 
973  if (currentCase == null) {
974  setDateTimeFiltersToDefault();
975  openCase = null;
976  return;
977  }
978 
979  if (!currentCase.equals(openCase)) {
980  setDateTimeFiltersToDefault();
981  openCase = currentCase;
982  (new DatePickerWorker()).execute();
983  }
984  }
985 
987  startDatePicker.setDate(LocalDate.now().minusWeeks(3));
988  endDatePicker.setDate(LocalDate.now());
989  }
990 
991  private void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllAccountTypesButtonActionPerformed
992  setAllAccountTypesSelected(false);
993  }//GEN-LAST:event_unCheckAllAccountTypesButtonActionPerformed
994 
995  private void checkAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllAccountTypesButtonActionPerformed
996  setAllAccountTypesSelected(true);
997  }//GEN-LAST:event_checkAllAccountTypesButtonActionPerformed
998 
999  private void unCheckAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unCheckAllDevicesButtonActionPerformed
1000  setAllDevicesSelected(false);
1001  }//GEN-LAST:event_unCheckAllDevicesButtonActionPerformed
1002 
1003  private void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAllDevicesButtonActionPerformed
1004  setAllDevicesSelected(true);
1005  }//GEN-LAST:event_checkAllDevicesButtonActionPerformed
1006 
1007  private void startCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_startCheckBoxStateChanged
1008  startDatePicker.setEnabled(startCheckBox.isSelected());
1009  validateFilters();
1010  }//GEN-LAST:event_startCheckBoxStateChanged
1011 
1012  private void endCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_endCheckBoxStateChanged
1013  endDatePicker.setEnabled(endCheckBox.isSelected());
1014  validateFilters();
1015  }//GEN-LAST:event_endCheckBoxStateChanged
1016 
1017  private void limitComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limitComboBoxActionPerformed
1018  validateFilters();
1019  }//GEN-LAST:event_limitComboBoxActionPerformed
1020 
1026  final class DateControlState {
1027 
1028  private final LocalDate date;
1029  private final boolean enabled;
1030 
1038  protected DateControlState(LocalDate date, boolean enabled) {
1039  this.date = date;
1040  this.enabled = enabled;
1041  }
1042 
1048  public LocalDate getDate() {
1049  return date;
1050  }
1051 
1057  public boolean isEnabled() {
1058  return enabled;
1059  }
1060 
1061  }
1062 
1063  // Variables declaration - do not modify//GEN-BEGIN:variables
1064  private final javax.swing.JPanel accountTypeListPane = new javax.swing.JPanel();
1065  private final javax.swing.JLabel accountTypeRequiredLabel = new javax.swing.JLabel();
1066  private final javax.swing.JLabel accountTypesLabel = new javax.swing.JLabel();
1067  private final javax.swing.JPanel accountTypesPane = new javax.swing.JPanel();
1068  private final javax.swing.JScrollPane accountTypesScrollPane = new javax.swing.JScrollPane();
1069  private final javax.swing.JButton applyFiltersButton = new javax.swing.JButton();
1070  private final javax.swing.JButton checkAllAccountTypesButton = new javax.swing.JButton();
1071  private final javax.swing.JButton checkAllDevicesButton = new javax.swing.JButton();
1072  private final javax.swing.JLabel dateRangeLabel = new javax.swing.JLabel();
1073  private final javax.swing.JPanel dateRangePane = new javax.swing.JPanel();
1074  private final javax.swing.JLabel deviceRequiredLabel = new javax.swing.JLabel();
1075  private final javax.swing.JLabel devicesLabel = new javax.swing.JLabel();
1076  private final javax.swing.JPanel devicesListPane = new javax.swing.JPanel();
1077  private final javax.swing.JPanel devicesPane = new javax.swing.JPanel();
1078  private final javax.swing.JScrollPane devicesScrollPane = new javax.swing.JScrollPane();
1079  private final javax.swing.JCheckBox endCheckBox = new javax.swing.JCheckBox();
1080  private final com.github.lgooddatepicker.components.DatePicker endDatePicker = new com.github.lgooddatepicker.components.DatePicker();
1081  private final javax.swing.JLabel filtersTitleLabel = new javax.swing.JLabel();
1082  private final javax.swing.JComboBox<String> limitComboBox = new javax.swing.JComboBox<>();
1083  private final javax.swing.JLabel limitErrorMsgLabel = new javax.swing.JLabel();
1084  private final javax.swing.JLabel limitHeaderLabel = new javax.swing.JLabel();
1085  private final javax.swing.JPanel limitPane = new javax.swing.JPanel();
1086  private final javax.swing.JPanel limitTitlePanel = new javax.swing.JPanel();
1087  private final javax.swing.JPanel mainPanel = new javax.swing.JPanel();
1088  private final javax.swing.JLabel mostRecentLabel = new javax.swing.JLabel();
1089  private final javax.swing.JLabel needsRefreshLabel = new javax.swing.JLabel();
1090  private final javax.swing.JButton refreshButton = new javax.swing.JButton();
1091  private final javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
1092  private final javax.swing.JCheckBox startCheckBox = new javax.swing.JCheckBox();
1093  private final com.github.lgooddatepicker.components.DatePicker startDatePicker = new com.github.lgooddatepicker.components.DatePicker();
1094  private final javax.swing.JPanel topPane = new javax.swing.JPanel();
1095  private final javax.swing.JButton unCheckAllAccountTypesButton = new javax.swing.JButton();
1096  private final javax.swing.JButton unCheckAllDevicesButton = new javax.swing.JButton();
1097  // End of variables declaration//GEN-END:variables
1098 
1104  final class CheckBoxIconPanel extends JPanel {
1105 
1106  private static final long serialVersionUID = 1L;
1107 
1108  private final JCheckBox checkbox;
1109  private final JLabel label;
1110 
1117  private CheckBoxIconPanel(String labelText, Icon image) {
1118  checkbox = new JCheckBox();
1119  label = new JLabel(labelText);
1120  label.setIcon(image);
1121  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
1122 
1123  add(checkbox);
1124  add(label);
1125  add(Box.createHorizontalGlue());
1126  }
1127 
1133  void setSelected(boolean selected) {
1134  checkbox.setSelected(selected);
1135  }
1136 
1137  @Override
1138  public void setEnabled(boolean enabled) {
1139  checkbox.setEnabled(enabled);
1140  }
1141 
1147  JCheckBox getCheckBox() {
1148  return checkbox;
1149  }
1150 
1156  void addItemListener(ItemListener l) {
1157  checkbox.addItemListener(l);
1158  }
1159  }
1160 
1165  class FilterPanelQueryCallback implements CaseDbAccessQueryCallback {
1166 
1167  @Override
1168  public void process(ResultSet rs) {
1169  // Subclasses can implement their own process function.
1170  }
1171  }
1172 
1173  final class DatePickerWorker extends SwingWorker<Map<String, Integer>, Void> {
1174 
1175  @Override
1176  protected Map<String, Integer> doInBackground() throws Exception {
1177  if (openCase == null) {
1178  return null;
1179  }
1180 
1181  Map<String, Integer> resultMap = new HashMap<>();
1182  String queryString = "max(date_time) as end, min(date_time) as start from account_relationships"; // NON-NLS
1183 
1184  openCase.getSleuthkitCase().getCaseDbAccessManager().select(queryString, new FilterPanelQueryCallback() {
1185  @Override
1186  public void process(ResultSet rs) {
1187  try {
1188  if (rs.next()) {
1189  int startDate = rs.getInt("start"); // NON-NLS
1190  int endDate = rs.getInt("end"); // NON-NLS
1191 
1192  resultMap.put("start", startDate); // NON-NLS
1193  resultMap.put("end", endDate); // NON-NLS
1194  }
1195  } catch (SQLException ex) {
1196  // Not the end of the world if this fails.
1197  logger.log(Level.WARNING, String.format("SQL Exception thrown from Query: %s", queryString), ex);
1198  }
1199  }
1200  });
1201 
1202  return resultMap;
1203  }
1204 
1205  @Override
1206  protected void done() {
1207  try {
1208  Map<String, Integer> resultMap = get();
1209  if (resultMap != null) {
1210  Integer start = resultMap.get("start");
1211  Integer end = resultMap.get("end");
1212 
1213  if (start != null && start != 0) {
1214  startDatePicker.setDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(start), Utils.getUserPreferredZoneId()).toLocalDate());
1215  }
1216 
1217  if (end != null && end != 0) {
1218  endDatePicker.setDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(end), Utils.getUserPreferredZoneId()).toLocalDate());
1219  }
1220  }
1221  } catch (InterruptedException | ExecutionException ex) {
1222  logger.log(Level.WARNING, "Exception occured after date time sql query", ex);
1223  }
1224  }
1225  }
1226 
1227 }
BlackboardArtifact.Type getBlackboardArtifactType()
void unCheckAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt)
void removeIngestModuleEventListener(final PropertyChangeListener listener)
void setEndDateControlState(DateControlState state)
static synchronized IngestManager getInstance()
void setMostRecentFilter(MostRecentFilter filter)
void setDeviceFilter(DeviceFilter deviceFilter)
void unCheckAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt)
void endCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)
void startCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)
void removeIngestJobEventListener(final PropertyChangeListener listener)
CheckBoxIconPanel createAccoutTypeCheckBoxPanel(Account.Type type, boolean initalState)
void setStartDateControlState(DateControlState state)
void limitComboBoxActionPerformed(java.awt.event.ActionEvent evt)
void addIngestJobEventListener(final PropertyChangeListener listener)
void setAccountTypeFilter(AccountTypeFilter typeFilter)
void setFilters(CommunicationsFilter commFilter)
void checkAllAccountTypesButtonActionPerformed(java.awt.event.ActionEvent evt)
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:491
static void addChangeListener(PreferenceChangeListener listener)
void checkAllDevicesButtonActionPerformed(java.awt.event.ActionEvent evt)
static final String getIconFilePath(Account.Type type)
Definition: Utils.java:47
boolean updateAccountTypeFilter(boolean selected, SleuthkitCase sleuthkitCase)
boolean updateDeviceFilter(boolean selected, SleuthkitCase sleuthkitCase)

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.