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;
53 public final class Reports implements AutopsyVisitableItem {
55 private static final SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
58 public <T> T accept(AutopsyItemVisitor<T> visitor) {
60 return visitor.visit(
this);
69 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
73 setName(DISPLAY_NAME);
74 setDisplayName(DISPLAY_NAME);
75 this.setIconBaseWithExtension(ICON_PATH);
89 return visitor.
visit(
this);
112 public void propertyChange(PropertyChangeEvent evt) {
113 String eventType = evt.getPropertyName();
124 }
catch (IllegalStateException notUsed) {
138 }
catch (TskCoreException ex) {
156 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
160 super(Children.LEAF, Lookups.fixed(report));
162 super.setName(this.report.getSourceModuleName());
163 super.setDisplayName(this.report.getSourceModuleName());
164 this.setIconBaseWithExtension(ICON_PATH);
178 return visitor.
visit(
this);
183 Sheet sheet = super.createSheet();
184 Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
185 if (propertiesSet == null) {
186 propertiesSet = Sheet.createPropertiesSet();
187 sheet.put(propertiesSet);
189 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.name"),
190 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.displayName"),
191 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.desc"),
192 this.report.getSourceModuleName()));
193 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.name"),
194 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.displayName"),
195 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.desc"),
196 this.report.getReportName()));
197 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.name"),
198 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.displayName"),
199 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.desc"),
200 dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
201 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.name"),
202 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.displayName"),
203 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.desc"),
204 this.report.getPath()));
210 List<Action> actions =
new ArrayList<>();
211 actions.addAll(Arrays.asList(super.getActions(
true)));
214 return actions.toArray(
new Action[actions.size()]);
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"));
260 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(Report.class);
262 String jOptionPaneMessage = selectedReportsCollection.size() > 1
263 ? NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
264 : NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
265 JCheckBox checkbox =
new JCheckBox(NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.checkbox.msg"));
266 checkbox.setSelected(
false);
268 Object[] jOptionPaneContent = {jOptionPaneMessage, checkbox};
270 if (JOptionPane.showConfirmDialog(null, jOptionPaneContent,
271 NbBundle.getMessage(
Reports.class,
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
272 JOptionPane.YES_NO_OPTION) == 0) {
276 }
catch (TskCoreException | IllegalStateException ex) {
286 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
293 Desktop.getDesktop().open(file);
294 }
catch (IOException ex) {
295 JOptionPane.showMessageDialog(null,
296 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoAssociatedEditorMessage"),
297 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
298 JOptionPane.ERROR_MESSAGE);
299 }
catch (UnsupportedOperationException ex) {
300 JOptionPane.showMessageDialog(null,
301 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoOpenInEditorSupportMessage"),
302 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
303 JOptionPane.ERROR_MESSAGE);
304 }
catch (IllegalArgumentException ex) {
305 JOptionPane.showMessageDialog(null,
306 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MissingReportFileMessage"),
307 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
308 JOptionPane.ERROR_MESSAGE);
309 }
catch (SecurityException ex) {
310 JOptionPane.showMessageDialog(null,
311 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.ReportFileOpenPermissionDeniedMessage"),
312 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
313 JOptionPane.ERROR_MESSAGE);
static final String DISPLAY_NAME
void actionPerformed(ActionEvent e)
AbstractAction getPreferredAction()
T visit(DataSourcesNode in)
void deleteReports(Collection<?extends Report > reports, boolean deleteFromDisk)
static synchronized DataContentTopComponent findInstance()
List< Report > getAllReports()
Node createNodeForKey(Report key)
boolean createKeys(List< Report > keys)
static final String ICON_PATH
static DeleteReportAction getInstance()
static final SimpleDateFormat dateFormatter
static synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Action[] getActions(boolean popup)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
void actionPerformed(ActionEvent e)
static DeleteReportAction instance