Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceSummaryNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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.casemodule.datasourcesummary;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Observable;
25 import java.util.Observer;
26 import javax.swing.Action;
27 import org.openide.nodes.AbstractNode;
28 import org.openide.nodes.ChildFactory;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Sheet;
32 import org.openide.util.NbBundle.Messages;
35 import org.sleuthkit.datamodel.DataSource;
36 
42 final class DataSourceSummaryNode extends AbstractNode {
43 
44  private final static Observable closeDialogObservable = new Observable() {
45  @Override
46  public void notifyObservers() {
47  //set changed before notify observers
48  //we want this observerable to always cause the observer to update when notified
49  this.setChanged();
50  super.notifyObservers();
51  }
52  };
53 
60  DataSourceSummaryNode(List<DataSourceSummary> dataSourceList) {
61  super(Children.create(new DataSourceSummaryChildren(dataSourceList), false));
62  }
63 
69  void addObserver(Observer observer) {
70  closeDialogObservable.addObserver(observer);
71  }
72 
77  static final class DataSourceSummaryChildren extends ChildFactory<DataSourceSummary> {
78 
79  private final List<DataSourceSummary> dataSourceList;
80 
88  DataSourceSummaryChildren(List<DataSourceSummary> dataSourceList) {
89  this.dataSourceList = dataSourceList;
90  }
91 
92  @Override
93  protected boolean createKeys(List<DataSourceSummary> list) {
94  if (dataSourceList != null && !dataSourceList.isEmpty()) {
95  list.addAll(dataSourceList);
96  }
97  return true;
98  }
99 
100  @Override
101  protected Node createNodeForKey(DataSourceSummary key) {
102  return new DataSourceSummaryEntryNode(key);
103  }
104  }
105 
109  static final class DataSourceSummaryEntryNode extends AbstractNode {
110 
111  private final DataSource dataSource;
112  private final String status;
113  private final String type;
114  private final long filesCount;
115  private final long resultsCount;
116  private final long tagsCount;
117 
125  DataSourceSummaryEntryNode(DataSourceSummary dataSourceSummary) {
126  super(Children.LEAF);
127  dataSource = dataSourceSummary.getDataSource();
128  status = dataSourceSummary.getIngestStatus() == null ? "" : dataSourceSummary.getIngestStatus().getDisplayName();
129  type = dataSourceSummary.getType();
130  filesCount = dataSourceSummary.getFilesCount();
131  resultsCount = dataSourceSummary.getResultsCount();
132  tagsCount = dataSourceSummary.getTagsCount();
133  super.setName(dataSource.getName());
134  setName(dataSource.getName());
135  setDisplayName(dataSource.getName());
136  }
137 
143  DataSource getDataSource() {
144  return dataSource;
145  }
146 
147  @Messages({"DataSourceSummaryNode.column.dataSourceName.header=Data Source Name",
148  "DataSourceSummaryNode.column.status.header=Ingest Status",
149  "DataSourceSummaryNode.column.type.header=Type",
150  "DataSourceSummaryNode.column.files.header=Files",
151  "DataSourceSummaryNode.column.results.header=Results",
152  "DataSourceSummaryNode.column.tags.header=Tags"})
153  @Override
154  protected Sheet createSheet() {
155  Sheet sheet = super.createSheet();
156  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
157  if (sheetSet == null) {
158  sheetSet = Sheet.createPropertiesSet();
159  sheet.put(sheetSet);
160  }
161  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(),
162  dataSource));
163  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_status_header(), Bundle.DataSourceSummaryNode_column_status_header(), Bundle.DataSourceSummaryNode_column_status_header(), status));
164  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(),
165  type));
166  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(),
167  filesCount));
168  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(),
169  resultsCount));
170  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(),
171  tagsCount));
172  return sheet;
173  }
174 
180  @Override
181  public Action getPreferredAction() {
182  return new ViewDataSourceInContextAction();
183  }
184 
185  @Override
186  public Action[] getActions(boolean context) {
187  List<Action> actions = new ArrayList<>();
188  actions.add(new ViewDataSourceInContextAction());
189  return actions.toArray(new Action[actions.size()]);
190  }
191 
197 
198  private static final long serialVersionUID = 1L;
199 
203  @Messages({"DataSourceSummaryNode.viewDataSourceAction.text=Go to Data Source"})
205  super(Bundle.DataSourceSummaryNode_viewDataSourceAction_text(), dataSource);
206  }
207 
208  @Override
209  public void actionPerformed(ActionEvent e) {
210  closeDialogObservable.notifyObservers();
211  super.actionPerformed(e);
212  }
213  }
214  }
215 
216 }

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