19 package org.sleuthkit.autopsy.casemodule.datasourcesummary;
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;
42 final class DataSourceSummaryNode
extends AbstractNode {
44 private final static Observable closeDialogObservable =
new Observable() {
46 public void notifyObservers() {
50 super.notifyObservers();
60 DataSourceSummaryNode(List<DataSourceSummary> dataSourceList) {
61 super(Children.create(
new DataSourceSummaryChildren(dataSourceList),
false));
69 void addObserver(Observer observer) {
70 closeDialogObservable.addObserver(observer);
77 static final class DataSourceSummaryChildren
extends ChildFactory<DataSourceSummary> {
79 private final List<DataSourceSummary> dataSourceList;
88 DataSourceSummaryChildren(List<DataSourceSummary> dataSourceList) {
89 this.dataSourceList = dataSourceList;
93 protected boolean createKeys(List<DataSourceSummary> list) {
94 if (dataSourceList != null && !dataSourceList.isEmpty()) {
95 list.addAll(dataSourceList);
101 protected Node createNodeForKey(DataSourceSummary key) {
102 return new DataSourceSummaryEntryNode(key);
109 static final class DataSourceSummaryEntryNode
extends AbstractNode {
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;
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());
143 DataSource getDataSource() {
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"})
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();
161 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(),
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(),
166 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(),
168 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(),
170 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(),
181 public Action getPreferredAction() {
182 return new ViewDataSourceInContextAction();
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()]);
203 @Messages({
"DataSourceSummaryNode.viewDataSourceAction.text=Go to Data Source"})
205 super(Bundle.DataSourceSummaryNode_viewDataSourceAction_text(), dataSource);
210 closeDialogObservable.notifyObservers();
211 super.actionPerformed(e);
static final long serialVersionUID
void actionPerformed(ActionEvent e)