19 package org.sleuthkit.autopsy.datasourcesummary.ui;
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;
43 final class DataSourceSummaryNode
extends AbstractNode {
45 private final static Observable closeDialogObservable =
new Observable() {
47 public void notifyObservers() {
51 super.notifyObservers();
61 DataSourceSummaryNode(List<DataSourceSummary> dataSourceList) {
62 super(Children.create(
new DataSourceSummaryChildren(dataSourceList),
false));
70 void addObserver(Observer observer) {
71 closeDialogObservable.addObserver(observer);
78 static final class DataSourceSummaryChildren
extends ChildFactory<DataSourceSummary> {
80 private final List<DataSourceSummary> dataSourceList;
89 DataSourceSummaryChildren(List<DataSourceSummary> dataSourceList) {
90 this.dataSourceList = dataSourceList;
94 protected boolean createKeys(List<DataSourceSummary> list) {
95 if (dataSourceList != null && !dataSourceList.isEmpty()) {
96 list.addAll(dataSourceList);
102 protected Node createNodeForKey(DataSourceSummary key) {
103 return new DataSourceSummaryEntryNode(key);
110 static final class DataSourceSummaryEntryNode
extends AbstractNode {
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;
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());
144 DataSource getDataSource() {
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"})
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();
162 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(), Bundle.DataSourceSummaryNode_column_dataSourceName_header(),
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(),
167 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(), Bundle.DataSourceSummaryNode_column_files_header(),
169 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(), Bundle.DataSourceSummaryNode_column_results_header(),
171 sheetSet.put(
new NodeProperty<>(Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(), Bundle.DataSourceSummaryNode_column_tags_header(),
182 public Action getPreferredAction() {
183 return new ViewDataSourceInContextAction();
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()]);
204 @Messages({
"DataSourceSummaryNode.viewDataSourceAction.text=Go to Data Source"})
206 super(Bundle.DataSourceSummaryNode_viewDataSourceAction_text(), dataSource);
211 closeDialogObservable.notifyObservers();
212 super.actionPerformed(e);
static final long serialVersionUID
void actionPerformed(ActionEvent e)