19 package org.sleuthkit.autopsy.datamodel;
 
   21 import java.awt.event.ActionEvent;
 
   22 import java.beans.PropertyChangeEvent;
 
   24 import java.text.SimpleDateFormat;
 
   25 import java.util.ArrayList;
 
   26 import java.util.Arrays;
 
   27 import java.util.Collection;
 
   28 import java.util.EnumSet;
 
   29 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.Utilities;
 
   41 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);
 
   95             return getClass().getName();
 
  109                 String eventType = evt.getPropertyName();
 
  151         private static final long serialVersionUID = 1L;
 
  152         private static final String ICON_PATH = 
"org/sleuthkit/autopsy/images/report_16.png"; 
 
  156             super(Children.LEAF, Lookups.fixed(report));
 
  158             super.setName(this.report.getSourceModuleName());
 
  159             super.setDisplayName(this.report.getSourceModuleName());
 
  160             this.setIconBaseWithExtension(ICON_PATH);
 
  174             return visitor.
visit(
this);
 
  179             Sheet sheet = super.createSheet();
 
  180             Sheet.Set propertiesSet = sheet.get(Sheet.PROPERTIES);
 
  181             if (propertiesSet == null) {
 
  182                 propertiesSet = Sheet.createPropertiesSet();
 
  183                 sheet.put(propertiesSet);
 
  185             propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(), 
"ReportNode.sourceModuleNameProperty.name"),
 
  186                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.sourceModuleNameProperty.displayName"),
 
  187                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.sourceModuleNameProperty.desc"),
 
  189             propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(), 
"ReportNode.reportNameProperty.name"),
 
  190                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.reportNameProperty.displayName"),
 
  191                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.reportNameProperty.desc"),
 
  193             propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(), 
"ReportNode.createdTimeProperty.name"),
 
  194                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.createdTimeProperty.displayName"),
 
  195                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.createdTimeProperty.desc"),
 
  196                     dateFormatter.format(
new java.util.Date(
this.report.getCreatedTime() * 1000))));
 
  197             propertiesSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(), 
"ReportNode.pathProperty.name"),
 
  198                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.pathProperty.displayName"),
 
  199                     NbBundle.getMessage(
this.getClass(), 
"ReportNode.pathProperty.desc"),
 
  206             List<Action> actions = 
new ArrayList<>();
 
  210             actions.addAll(Arrays.asList(super.getActions(
true)));
 
  211             return actions.toArray(
new Action[actions.size()]); 
 
  221             return getClass().getName();
 
  226             private static final long serialVersionUID = 1L;
 
  234                 if (instance == null) {
 
  237                 if (Utilities.actionsGlobalContext().lookupAll(
Report.class).size() == 1) {
 
  238                     instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class, 
"DeleteReportAction.actionDisplayName.singleReport"));
 
  240                     instance.putValue(Action.NAME, NbBundle.getMessage(
Reports.class, 
"DeleteReportAction.actionDisplayName.multipleReports"));
 
  253                 "DeleteReportAction.showConfirmDialog.single.explanation=The report will remain on disk.",
 
  254                 "DeleteReportAction.showConfirmDialog.multiple.explanation=The reports will remain on disk.",
 
  255                 "DeleteReportAction.showConfirmDialog.errorMsg=An error occurred while deleting the reports."})
 
  258                 Collection<? extends Report> selectedReportsCollection = Utilities.actionsGlobalContext().lookupAll(
Report.class);
 
  259                 String message = selectedReportsCollection.size() > 1
 
  260                         ? NbBundle.getMessage(
Reports.class, 
"DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg", selectedReportsCollection.size())
 
  261                         : NbBundle.getMessage(
Reports.class, 
"DeleteReportAction.actionPerformed.showConfirmDialog.single.msg");
 
  262                 String explanation = selectedReportsCollection.size() > 1
 
  263                         ? Bundle.DeleteReportAction_showConfirmDialog_multiple_explanation()
 
  264                         : Bundle.DeleteReportAction_showConfirmDialog_single_explanation();
 
  265                 Object[] jOptionPaneContent = {message, explanation};
 
  266                 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, jOptionPaneContent,
 
  267                         NbBundle.getMessage(
Reports.class, 
"DeleteReportAction.actionPerformed.showConfirmDialog.title"),
 
  268                         JOptionPane.YES_NO_OPTION)) {
 
  281             private static final long serialVersionUID = 1L;
 
  284                 super(NbBundle.getMessage(
OpenReportAction.class, 
"OpenReportAction.actionDisplayName"));
 
  291                 if (reportPath.toLowerCase().startsWith(
"http")) {
 
  295                     String extension = 
"";
 
  296                     int extPosition = reportPath.lastIndexOf(
'.');
 
  297                     if (extPosition != -1) {
 
  298                         extension = reportPath.substring(extPosition, reportPath.length()).toLowerCase();
 
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
static void openURL(String path)
static final String DISPLAY_NAME
void actionPerformed(ActionEvent e)
AbstractAction getPreferredAction()
List< Report > getAllReports()
Node createNodeForKey(Report key)
boolean createKeys(List< Report > keys)
static final String ICON_PATH
static DeleteReportAction getInstance()
T visit(DataSourceFilesNode in)
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)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
String getSourceModuleName()
void actionPerformed(ActionEvent e)
static DeleteReportAction instance
static void error(String message)