Autopsy  4.17.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.datasourcesummary.ui;
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;
36 import org.sleuthkit.datamodel.DataSource;
37 
43 final class DataSourceSummaryNode extends AbstractNode {
44 
45  private final static Observable closeDialogObservable = new Observable() {
46  @Override
47  public void notifyObservers() {
48  //set changed before notify observers
49  //we want this observerable to always cause the observer to update when notified
50  this.setChanged();
51  super.notifyObservers();
52  }
53  };
54 
61  DataSourceSummaryNode(List<DataSourceSummary> dataSourceList) {
62  super(Children.create(new DataSourceSummaryChildren(dataSourceList), false));
63  }
64 
70  void addObserver(Observer observer) {
71  closeDialogObservable.addObserver(observer);
72  }
73 
78  static final class DataSourceSummaryChildren extends ChildFactory<DataSourceSummary> {
79 
80  private final List<DataSourceSummary> dataSourceList;
81 
89  DataSourceSummaryChildren(List<DataSourceSummary> dataSourceList) {
90  this.dataSourceList = dataSourceList;
91  }
92 
93  @Override
94  protected boolean createKeys(List<DataSourceSummary> list) {
95  if (dataSourceList != null && !dataSourceList.isEmpty()) {
96  list.addAll(dataSourceList);
97  }
98  return true;
99  }
100 
101  @Override
102  protected Node createNodeForKey(DataSourceSummary key) {
103  return new DataSourceSummaryEntryNode(key);
104  }
105  }
106 
110  static final class DataSourceSummaryEntryNode extends AbstractNode {
111 
112  private final DataSource dataSource;
113  private final String status;
114  private final String type;
115  private final long filesCount;
116  private final long resultsCount;
117  private final long tagsCount;
118 
126  DataSourceSummaryEntryNode(DataSourceSummary dataSourceSummary) {
127  super(Children.LEAF);
128  dataSource = dataSourceSummary.getDataSource();
129  status = dataSourceSummary.getIngestStatus() == null ? "" : dataSourceSummary.getIngestStatus().getDisplayName();
130  type = dataSourceSummary.getType();
131  filesCount = dataSourceSummary.getFilesCount();
132  resultsCount = dataSourceSummary.getResultsCount();
133  tagsCount = dataSourceSummary.getTagsCount();
134  super.setName(dataSource.getName());
135  setName(dataSource.getName());
136  setDisplayName(dataSource.getName());
137  }
138 
144  DataSource getDataSource() {
145  return dataSource;
146  }
147 
148  @Messages({"DataSourceSummaryNode.column.dataSourceName.header=Data Source Name",
149  "DataSourceSummaryNode.column.status.header=Ingest Status",
150  "DataSourceSummaryNode.column.type.header=Type",
151  "DataSourceSummaryNode.column.files.header=Files",
152  "DataSourceSummaryNode.column.results.header=Results",
153  "DataSourceSummaryNode.column.tags.header=Tags"})
154  @Override
155  protected Sheet createSheet() {
156  Sheet sheet = super.createSheet();
157  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
158  if (sheetSet == null) {
159  sheetSet = Sheet.createPropertiesSet();
160  sheet.put(sheetSet);
161  }
162  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(),
163  dataSource));
164  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_status_header(), Bundle.DataSourceSummaryNode_column_status_header(), Bundle.DataSourceSummaryNode_column_status_header(), status));
165  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(),
166  type));
167  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(),
168  filesCount));
169  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(),
170  resultsCount));
171  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(),
172  tagsCount));
173  return sheet;
174  }
175 
181  @Override
182  public Action getPreferredAction() {
183  return new ViewDataSourceInContextAction();
184  }
185 
186  @Override
187  public Action[] getActions(boolean context) {
188  List<Action> actions = new ArrayList<>();
189  actions.add(new ViewDataSourceInContextAction());
190  return actions.toArray(new Action[actions.size()]);
191  }
192 
198 
199  private static final long serialVersionUID = 1L;
200 
204  @Messages({"DataSourceSummaryNode.viewDataSourceAction.text=Go to Data Source"})
206  super(Bundle.DataSourceSummaryNode_viewDataSourceAction_text(), dataSource);
207  }
208 
209  @Override
210  public void actionPerformed(ActionEvent e) {
211  closeDialogObservable.notifyObservers();
212  super.actionPerformed(e);
213  }
214  }
215  }
216 
217 }

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.