19package org.sleuthkit.autopsy.datamodel;
21import java.awt.event.ActionEvent;
22import java.beans.PropertyChangeEvent;
24import java.text.SimpleDateFormat;
25import java.util.ArrayList;
26import java.util.Arrays;
27import java.util.Collection;
28import java.util.EnumSet;
31import java.util.logging.Level;
32import javax.swing.AbstractAction;
33import javax.swing.Action;
34import javax.swing.JOptionPane;
35import org.openide.nodes.ChildFactory;
36import org.openide.nodes.Children;
37import org.openide.nodes.Node;
38import org.openide.nodes.Sheet;
39import org.openide.util.NbBundle;
40import org.openide.util.Utilities;
41import org.openide.util.lookup.Lookups;
42import org.sleuthkit.autopsy.casemodule.Case;
43import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
44import org.sleuthkit.autopsy.coreutils.Logger;
45import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
46import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
47import org.sleuthkit.datamodel.Report;
48import org.sleuthkit.datamodel.TskCoreException;
55 private static final SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
60 return visitor.
visit(
this);
70 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
90 return visitor.
visit(
this);
95 return getClass().getName();
103 private static final class ReportNodeFactory
extends ChildFactory<Report> {
107 ReportNodeFactory() {
109 String eventType = evt.getPropertyName();
119 ReportNodeFactory.this.refresh(
true);
152 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
155 ReportNode(Report
report) {
156 super(Children.LEAF, Lookups.fixed(
report));
158 super.setName(this.report.getSourceModuleName());
159 super.setDisplayName(this.report.getSourceModuleName());
160 this.setIconBaseWithExtension(
ICON_PATH);
174 return visitor.
visit(
this);
179 Sheet sheet = super.createSheet();
180 Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
181 if (propertiesSet ==
null) {
182 propertiesSet = Sheet.createPropertiesSet();
183 sheet.put(propertiesSet);
185 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.name"),
186 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.displayName"),
187 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.desc"),
188 this.report.getSourceModuleName()));
189 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.name"),
190 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.displayName"),
191 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.desc"),
192 this.report.getReportName()));
193 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.name"),
194 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.displayName"),
195 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.desc"),
196 dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
197 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.name"),
198 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.displayName"),
199 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.desc"),
200 this.report.getPath()));
206 List<Action>
actions =
new ArrayList<>();
210 actions.addAll(Arrays.asList(super.getActions(
true)));
221 return getClass().getName();
237 if (Utilities.actionsGlobalContext().lookupAll(Report.class).size() == 1) {
238 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.singleReport"));
240 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.multipleReports"));
253 "DeleteReportAction.showConfirmDialog.single.explanation=The report will remain on disk.",
254 "DeleteReportAction.showConfirmDialog.multiple.explanation=The reports will remain on disk.",
255 "DeleteReportAction.showConfirmDialog.errorMsg=An error occurred while deleting the reports."})
258 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(Report.class);
259 String message = selectedReportsCollection.size() > 1
260 ? NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
261 : NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
262 String explanation = selectedReportsCollection.size() > 1
263 ? Bundle.DeleteReportAction_showConfirmDialog_multiple_explanation()
264 : Bundle.DeleteReportAction_showConfirmDialog_single_explanation();
265 Object[] jOptionPaneContent = {message, explanation};
266 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
null, jOptionPaneContent,
267 NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
268 JOptionPane.YES_NO_OPTION)) {
284 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
289 String reportPath = ReportNode.this.report.getPath();
291 if (reportPath.toLowerCase().startsWith(
"http")) {
295 String extension =
"";
296 int extPosition = reportPath.lastIndexOf(
'.');
297 if (extPosition != -1) {
298 extension = reportPath.substring(extPosition, reportPath.length()).toLowerCase();
List< Report > getAllReports()
static Case getCurrentCaseThrows()
void deleteReports(Collection<? extends Report > reports)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
synchronized static Logger getLogger(String name)
static void error(String message)
DisplayableItemNode(Children children)
static final long serialVersionUID
static DeleteReportAction getInstance()
void actionPerformed(ActionEvent e)
static DeleteReportAction instance
void actionPerformed(ActionEvent e)
static final long serialVersionUID
Node createNodeForKey(Report key)
boolean createKeys(List< Report > keys)
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
Action[] getActions(boolean popup)
static final long serialVersionUID
static final String ICON_PATH
AbstractAction getPreferredAction()
static final String DISPLAY_NAME
static final long serialVersionUID
static final String ICON_PATH
static final SimpleDateFormat dateFormatter
static void openURL(String path)
static void openFile(String mimeType, String ext, File file)
T visit(DataSourceFilesNode in)