Autopsy  4.10.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), true));
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 type;
113  private final long filesCount;
114  private final long resultsCount;
115  private final long tagsCount;
116 
124  DataSourceSummaryEntryNode(DataSourceSummary dataSourceSummary) {
125  super(Children.LEAF);
126  dataSource = dataSourceSummary.getDataSource();
127  type = dataSourceSummary.getType();
128  filesCount = dataSourceSummary.getFilesCount();
129  resultsCount = dataSourceSummary.getResultsCount();
130  tagsCount = dataSourceSummary.getTagsCount();
131  super.setName(dataSource.getName());
132  setName(dataSource.getName());
133  setDisplayName(dataSource.getName());
134  }
135 
141  DataSource getDataSource() {
142  return dataSource;
143  }
144 
145  @Messages({"DataSourceSummaryNode.column.dataSourceName.header=Data Source Name",
146  "DataSourceSummaryNode.column.type.header=Type",
147  "DataSourceSummaryNode.column.files.header=Files",
148  "DataSourceSummaryNode.column.results.header=Results",
149  "DataSourceSummaryNode.column.tags.header=Tags"})
150  @Override
151  protected Sheet createSheet() {
152  Sheet sheet = super.createSheet();
153  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
154  if (sheetSet == null) {
155  sheetSet = Sheet.createPropertiesSet();
156  sheet.put(sheetSet);
157  }
158  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(),
159  dataSource));
160  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(), Bundle.DataSourceSummaryNode_column_type_header(),
161  type));
162  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(),
163  filesCount));
164  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(),
165  resultsCount));
166  sheetSet.put(new NodeProperty<>(Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(),
167  tagsCount));
168  return sheet;
169  }
170 
176  @Override
177  public Action getPreferredAction() {
178  return new ViewDataSourceInContextAction();
179  }
180 
181  @Override
182  public Action[] getActions(boolean context) {
183  List<Action> actions = new ArrayList<>();
184  actions.add(new ViewDataSourceInContextAction());
185  return actions.toArray(new Action[actions.size()]);
186  }
187 
193 
194  private static final long serialVersionUID = 1L;
195 
199  @Messages({"DataSourceSummaryNode.viewDataSourceAction.text=Go to Data Source"})
201  super(Bundle.DataSourceSummaryNode_viewDataSourceAction_text(), dataSource);
202  }
203 
204  @Override
205  public void actionPerformed(ActionEvent e) {
206  closeDialogObservable.notifyObservers();
207  super.actionPerformed(e);
208  }
209  }
210  }
211 
212 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.