Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018-2021 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.filesearch;
20 
21 import java.awt.event.ActionListener;
22 import java.beans.PropertyChangeEvent;
23 import java.util.EnumSet;
24 import org.openide.util.NbBundle.Messages;
26 
30 class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
31 
37  DataSourceFilter(DataSourcePanel component) {
38  super(component);
39  }
40 
45  DataSourceFilter() {
46  this(new DataSourcePanel());
47  }
48 
49  @Override
50  public boolean isEnabled() {
51  return this.getComponent().isSelected();
52  }
53 
59  void setSelectedDataSource(long dataSourceId) {
60  this.getComponent().setDataSourceSelected(dataSourceId);
61  }
62 
66  void resetDataSourceFilter() {
67  this.getComponent().resetDataSourcePanel();
68  }
69 
70  @Override
71  public String getPredicate() throws FilterValidationException {
72  String predicate = "";
73  for (Long dataSourceObjId : this.getComponent().getDataSourcesSelected()) {
74  if (!predicate.isEmpty()) {
75  predicate += " OR ";
76  }
77  predicate += "data_source_obj_id = '" + dataSourceObjId + "'";
78  }
79  return predicate;
80  }
81 
82  @Override
83  public void addActionListener(ActionListener lis) {
84  //Unused by now
85  }
86 
87  @Override
88  @Messages({
89  "DataSourceFilter.errorMessage.emptyDataSource=At least one data source must be selected."
90  })
91  public boolean isValid() {
92  if (this.getComponent().getDataSourcesSelected().isEmpty()) {
93  setLastError(Bundle.DataSourceFilter_errorMessage_emptyDataSource());
94  return false;
95  }
96  return true;
97  }
98 }

Copyright © 2012-2022 Basis Technology. Generated on: Fri Sep 30 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.