Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenOutputFolderAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.actions;
20 
21 import java.awt.Desktop;
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.logging.Level;
25 import javax.swing.JOptionPane;
26 import org.openide.DialogDisplayer;
27 import org.openide.NotifyDescriptor;
28 import org.openide.awt.ActionID;
29 import org.openide.awt.ActionReference;
30 import org.openide.awt.ActionRegistration;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.CallableSystemAction;
36 
46 @ActionRegistration(displayName = "#CTL_OpenOutputFolder", iconInMenu = true, lazy = false)
47 @ActionReference(path = "Menu/Tools", position = 1850, separatorBefore = 1849)
48 @ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help")
49 public final class OpenOutputFolderAction extends CallableSystemAction {
50 
51  private static final long serialVersionUID = 1L;
52  private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName());
53 
54  @Override
55  public void performAction() {
56  File outputDir;
57  try {
58  Case currentCase = Case.getCurrentCase();
59  outputDir = new File(currentCase.getOutputDirectory());
60  if (outputDir.exists()) {
61  try {
62  Desktop.getDesktop().open(outputDir);
63  } catch (IOException ex) {
64  logger.log(Level.SEVERE, String.format("Failed to open output folder %s", outputDir), ex); //NON-NLS
65  NotifyDescriptor descriptor = new NotifyDescriptor.Message(
66  NbBundle.getMessage(this.getClass(), "OpenOutputFolder.CouldNotOpenOutputFolder", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE);
67  DialogDisplayer.getDefault().notify(descriptor);
68  }
69  } else {
70  NotifyDescriptor descriptor = new NotifyDescriptor.Message(
71  NbBundle.getMessage(this.getClass(), "OpenOutputFolder.error1", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE);
72  DialogDisplayer.getDefault().notify(descriptor);
73  }
74  } catch (IllegalStateException ex) {
75  logger.log(Level.SEVERE, "OpenOutputFolderAction enabled with no current case", ex); //NON-NLS
76  JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(), "OpenOutputFolder.noCaseOpen"));
77  }
78  }
79 
80  @Override
81  public boolean isEnabled() {
82  return Case.isCaseOpen();
83  }
84 
85  @Override
86  public HelpCtx getHelpCtx() {
87  return HelpCtx.DEFAULT_HELP;
88  }
89 
90  @Override
91  public boolean asynchronous() {
92  return false;
93  }
94 
95  @Override
96  public String getName() {
97  return NbBundle.getMessage(OpenOutputFolderAction.class, "CTL_OpenOutputFolder");
98  }
99 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
void open(Path caseMetadataFilePath)
Definition: Case.java:1777

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.