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;
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";
74 setName(DISPLAY_NAME);
75 setDisplayName(DISPLAY_NAME);
76 this.setIconBaseWithExtension(ICON_PATH);
90 return visitor.
visit(
this);
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()]);
232 private static final long serialVersionUID = 1L;
240 if (instance == null) {
243 if (Utilities.actionsGlobalContext().lookupAll(Report.class).size() == 1) {
244 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.singleReport"));
246 instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionDisplayName.multipleReports"));
259 "DeleteReportAction.showConfirmDialog.single.explanation=The report will remain on disk.",
260 "DeleteReportAction.showConfirmDialog.multiple.explanation=The reports will remain on disk.",
261 "DeleteReportAction.showConfirmDialog.errorMsg=An error occurred while deleting the reports."})
264 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(Report.class);
265 String message = selectedReportsCollection.size() > 1
266 ? NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
267 : NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
268 String explanation = selectedReportsCollection.size() > 1
269 ? Bundle.DeleteReportAction_showConfirmDialog_multiple_explanation()
270 : Bundle.DeleteReportAction_showConfirmDialog_single_explanation();
271 Object[] jOptionPaneContent = {message, explanation};
272 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, jOptionPaneContent,
273 NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
274 JOptionPane.YES_NO_OPTION)) {
277 }
catch (TskCoreException | IllegalStateException ex) {
287 private static final long serialVersionUID = 1L;
290 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
297 Desktop.getDesktop().open(file);
298 }
catch (IOException ex) {
299 JOptionPane.showMessageDialog(null,
300 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoAssociatedEditorMessage"),
301 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
302 JOptionPane.ERROR_MESSAGE);
303 }
catch (UnsupportedOperationException ex) {
304 JOptionPane.showMessageDialog(null,
305 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoOpenInEditorSupportMessage"),
306 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
307 JOptionPane.ERROR_MESSAGE);
308 }
catch (IllegalArgumentException ex) {
309 JOptionPane.showMessageDialog(null,
310 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MissingReportFileMessage"),
311 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
312 JOptionPane.ERROR_MESSAGE);
313 }
catch (SecurityException ex) {
314 JOptionPane.showMessageDialog(null,
315 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.ReportFileOpenPermissionDeniedMessage"),
316 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
317 JOptionPane.ERROR_MESSAGE);
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 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)
void actionPerformed(ActionEvent e)
static DeleteReportAction instance
static void error(String message)