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.List;
32 import java.util.logging.Level;
33 import javax.swing.AbstractAction;
34 import javax.swing.Action;
35 import javax.swing.JCheckBox;
36 import javax.swing.JOptionPane;
37 import org.openide.nodes.ChildFactory;
38 import org.openide.nodes.Children;
39 import org.openide.nodes.Node;
40 import org.openide.nodes.Sheet;
41 import org.openide.util.NbBundle;
42 import org.openide.util.Utilities;
43 import org.openide.util.lookup.Lookups;
56 private static final SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
61 return visitor.
visit(
this);
71 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
75 setName(DISPLAY_NAME);
76 setDisplayName(DISPLAY_NAME);
77 this.setIconBaseWithExtension(ICON_PATH);
91 return visitor.
visit(
this);
96 return getClass().getName();
108 String eventType = evt.getPropertyName();
119 }
catch (IllegalStateException notUsed) {
150 private static final long serialVersionUID = 1L;
151 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
155 super(Children.LEAF, Lookups.fixed(report));
157 super.setName(this.report.getSourceModuleName());
158 super.setDisplayName(this.report.getSourceModuleName());
159 this.setIconBaseWithExtension(ICON_PATH);
173 return visitor.
visit(
this);
178 Sheet sheet = super.createSheet();
179 Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
180 if (propertiesSet == null) {
181 propertiesSet = Sheet.createPropertiesSet();
182 sheet.put(propertiesSet);
184 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.name"),
185 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.displayName"),
186 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.desc"),
188 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.name"),
189 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.displayName"),
190 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.desc"),
192 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.name"),
193 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.displayName"),
194 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.desc"),
195 dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
196 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.name"),
197 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.displayName"),
198 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.desc"),
205 List<Action> actions =
new ArrayList<>();
206 actions.addAll(Arrays.asList(super.getActions(
true)));
209 return actions.toArray(
new Action[actions.size()]);
219 return getClass().getName();
224 private static final long serialVersionUID = 1L;
232 if (instance == null) {
235 if (Utilities.actionsGlobalContext().lookupAll(
Report.class).size() == 1) {
236 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.singleReport"));
238 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.multipleReports"));
251 "DeleteReportAction.showConfirmDialog.single.explanation=The report will remain on disk.",
252 "DeleteReportAction.showConfirmDialog.multiple.explanation=The reports will remain on disk.",
253 "DeleteReportAction.showConfirmDialog.errorMsg=An error occurred while deleting the reports."})
256 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(
Report.class);
257 String message = selectedReportsCollection.size() > 1
258 ? NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
259 : NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
260 String explanation = selectedReportsCollection.size() > 1
261 ? Bundle.DeleteReportAction_showConfirmDialog_multiple_explanation()
262 : Bundle.DeleteReportAction_showConfirmDialog_single_explanation();
263 Object[] jOptionPaneContent = {message, explanation};
264 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, jOptionPaneContent,
265 NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
266 JOptionPane.YES_NO_OPTION)) {
279 private static final long serialVersionUID = 1L;
282 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
288 String extension =
"";
289 int extPosition = reportPath.lastIndexOf(
'.');
291 if (extPosition != -1) {
292 extension = reportPath.substring(extPosition, reportPath.length()).toLowerCase();
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 void addPropertyChangeListener(PropertyChangeListener listener)
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)
String getSourceModuleName()
void actionPerformed(ActionEvent e)
static DeleteReportAction instance
static void error(String message)