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.List;
31 import java.util.logging.Level;
32 import javax.swing.AbstractAction;
33 import javax.swing.Action;
34 import javax.swing.JOptionPane;
35 import org.openide.nodes.ChildFactory;
36 import org.openide.nodes.Children;
37 import org.openide.nodes.Node;
38 import org.openide.nodes.Sheet;
39 import org.openide.util.NbBundle;
40 import org.openide.util.lookup.Lookups;
49 public final class Reports implements AutopsyVisitableItem {
51 private static final SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
54 public <T> T accept(AutopsyItemVisitor<T> visitor) {
56 return visitor.visit(
this);
65 private static final String
ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
69 setName(DISPLAY_NAME);
70 setDisplayName(DISPLAY_NAME);
71 this.setIconBaseWithExtension(ICON_PATH);
85 return visitor.
visit(
this);
98 public void propertyChange(PropertyChangeEvent evt) {
99 String eventType = evt.getPropertyName();
129 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/report_16.png";
133 super(Children.LEAF, Lookups.fixed(report));
135 super.setName(this.report.getSourceModuleName());
136 super.setDisplayName(this.report.getSourceModuleName());
137 this.setIconBaseWithExtension(ICON_PATH);
151 return visitor.
visit(
this);
156 Sheet sheet = super.createSheet();
157 Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
158 if (propertiesSet == null) {
159 propertiesSet = Sheet.createPropertiesSet();
160 sheet.put(propertiesSet);
162 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.name"),
163 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.displayName"),
164 NbBundle.getMessage(
this.getClass(),
"ReportNode.sourceModuleNameProperty.desc"),
166 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.name"),
167 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.displayName"),
168 NbBundle.getMessage(
this.getClass(),
"ReportNode.reportNameProperty.desc"),
170 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.name"),
171 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.displayName"),
172 NbBundle.getMessage(
this.getClass(),
"ReportNode.createdTimeProperty.desc"),
173 dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
174 propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.name"),
175 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.displayName"),
176 NbBundle.getMessage(
this.getClass(),
"ReportNode.pathProperty.desc"),
183 List<Action> actions =
new ArrayList<>();
184 actions.addAll(Arrays.asList(super.getActions(
true)));
186 return actions.toArray(
new Action[actions.size()]);
197 super(NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionDisplayName"));
203 Desktop.getDesktop().open(file);
204 }
catch (IOException ex) {
205 JOptionPane.showMessageDialog(null,
206 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoAssociatedEditorMessage"),
207 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
208 JOptionPane.ERROR_MESSAGE);
209 }
catch (UnsupportedOperationException ex) {
210 JOptionPane.showMessageDialog(null,
211 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.NoOpenInEditorSupportMessage"),
212 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
213 JOptionPane.ERROR_MESSAGE);
214 }
catch (IllegalArgumentException ex) {
215 JOptionPane.showMessageDialog(null,
216 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MissingReportFileMessage"),
217 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
218 JOptionPane.ERROR_MESSAGE);
219 }
catch (SecurityException ex) {
220 JOptionPane.showMessageDialog(null,
221 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.ReportFileOpenPermissionDeniedMessage"),
222 NbBundle.getMessage(
OpenReportAction.class,
"OpenReportAction.actionPerformed.MessageBoxTitle"),
223 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 final SimpleDateFormat dateFormatter
static synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Action[] getActions(boolean popup)
static Case getCurrentCase()
String getSourceModuleName()
static Logger getLogger(String name)