19 package org.sleuthkit.autopsy.datamodel;
21 import java.awt.Desktop;
22 import java.awt.event.ActionEvent;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
26 import java.io.IOException;
27 import java.text.SimpleDateFormat;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collection;
31 import java.util.EnumSet;
32 import java.util.List;
34 import java.util.logging.Level;
35 import javax.swing.AbstractAction;
36 import javax.swing.Action;
37 import javax.swing.JCheckBox;
38 import javax.swing.JOptionPane;
39 import org.openide.nodes.ChildFactory;
40 import org.openide.nodes.Children;
41 import org.openide.nodes.Node;
42 import org.openide.nodes.Sheet;
43 import org.openide.util.NbBundle;
44 import org.openide.util.Utilities;
45 import org.openide.util.lookup.Lookups;
58 private static final SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
63 return visitor.
visit(
this);
73 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
77 setName(DISPLAY_NAME);
78 setDisplayName(DISPLAY_NAME);
79 this.setIconBaseWithExtension(ICON_PATH);
93 return visitor.
visit(
this);
98 return getClass().getName();
112 String eventType = evt.getPropertyName();
123 }
catch (IllegalStateException notUsed) {
136 }
catch (TskCoreException ex) {
154 private static final long serialVersionUID = 1L;
155 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
159 super(Children.LEAF, Lookups.fixed(report));
161 super.setName(this.report.getSourceModuleName());
162 super.setDisplayName(this.report.getSourceModuleName());
163 this.setIconBaseWithExtension(ICON_PATH);
177 return visitor.
visit(
this);
182 Sheet sheet = super.createSheet();
183 Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
184 if (propertiesSet == null) {
185 propertiesSet = Sheet.createPropertiesSet();
186 sheet.put(propertiesSet);
188 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.name"),
189 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.displayName"),
190 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.desc"),
191 this.report.getSourceModuleName()));
192 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.name"),
193 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.displayName"),
194 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.desc"),
195 this.report.getReportName()));
196 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.name"),
197 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.displayName"),
198 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.desc"),
199 dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
200 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.name"),
201 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.displayName"),
202 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.desc"),
203 this.report.getPath()));
209 List<Action> actions =
new ArrayList<>();
210 actions.addAll(Arrays.asList(super.getActions(
true)));
213 return actions.toArray(
new Action[actions.size()]);
223 return getClass().getName();
228 private static final long serialVersionUID = 1L;
236 if (instance == null) {
239 if (Utilities.actionsGlobalContext().lookupAll(Report.class).size() == 1) {
240 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.singleReport"));
242 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.multipleReports"));
255 "DeleteReportAction.showConfirmDialog.single.explanation=The report will remain on disk.",
256 "DeleteReportAction.showConfirmDialog.multiple.explanation=The reports will remain on disk.",
257 "DeleteReportAction.showConfirmDialog.errorMsg=An error occurred while deleting the reports."})
260 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(Report.class);
261 String message = selectedReportsCollection.size() > 1
262 ? NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
263 : NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
264 String explanation = selectedReportsCollection.size() > 1
265 ? Bundle.DeleteReportAction_showConfirmDialog_multiple_explanation()
266 : Bundle.DeleteReportAction_showConfirmDialog_single_explanation();
267 Object[] jOptionPaneContent = {message, explanation};
268 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, jOptionPaneContent,
269 NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
270 JOptionPane.YES_NO_OPTION)) {
273 }
catch (TskCoreException | IllegalStateException ex) {
283 private static final long serialVersionUID = 1L;
286 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
292 String extension =
"";
293 int extPosition = reportPath.lastIndexOf(
'.');
295 if (extPosition != -1) {
296 extension = reportPath.substring(extPosition, reportPath.length()).toLowerCase();
299 File file =
new File(reportPath);
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
static final String DISPLAY_NAME
void actionPerformed(ActionEvent e)
AbstractAction getPreferredAction()
T visit(DataSourcesNode in)
List< Report > getAllReports()
Node createNodeForKey(Report key)
boolean createKeys(List< Report > keys)
static final String ICON_PATH
static DeleteReportAction getInstance()
static void openFile(String mimeType, String ext, File file)
static final long serialVersionUID
void deleteReports(Collection<?extends Report > reports)
static final SimpleDateFormat dateFormatter
Action[] getActions(boolean popup)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
void actionPerformed(ActionEvent e)
static DeleteReportAction instance
static void error(String message)