Autopsy  4.14.0
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;
34 import org.openide.windows.WindowManager;
38 
48 @ActionRegistration(displayName = "#CTL_OpenOutputFolder", iconInMenu = true, lazy = false)
49 @ActionReference(path = "Menu/Tools", position = 1900, separatorBefore = 1899)
50 @ActionID(id = "org.sleuthkit.autopsy.actions.OpenOutputFolderAction", category = "Help")
51 public final class OpenOutputFolderAction extends CallableSystemAction {
52 
53  private static final long serialVersionUID = 1L;
54  private static final Logger logger = Logger.getLogger(OpenOutputFolderAction.class.getName());
55 
56  @Override
57  public void performAction() {
58  File outputDir;
59  try {
60  Case currentCase = Case.getCurrentCaseThrows();
61  outputDir = new File(currentCase.getOutputDirectory());
62  if (outputDir.exists()) {
63  try {
64  Desktop.getDesktop().open(outputDir);
65  } catch (IOException ex) {
66  logger.log(Level.SEVERE, String.format("Failed to open output folder %s", outputDir), ex); //NON-NLS
67  NotifyDescriptor descriptor = new NotifyDescriptor.Message(
68  NbBundle.getMessage(this.getClass(), "OpenOutputFolder.CouldNotOpenOutputFolder", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE);
69  DialogDisplayer.getDefault().notify(descriptor);
70  }
71  } else {
72  NotifyDescriptor descriptor = new NotifyDescriptor.Message(
73  NbBundle.getMessage(this.getClass(), "OpenOutputFolder.error1", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE);
74  DialogDisplayer.getDefault().notify(descriptor);
75  }
76  } catch (NoCurrentCaseException ex) {
77  logger.log(Level.SEVERE, "OpenOutputFolderAction enabled with no current case", ex); //NON-NLS
78  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(this.getClass(), "OpenOutputFolder.noCaseOpen"));
79  }
80  }
81 
82  @Override
83  public boolean isEnabled() {
84  return Case.isCaseOpen();
85  }
86 
87  @Override
88  public HelpCtx getHelpCtx() {
89  return HelpCtx.DEFAULT_HELP;
90  }
91 
92  @Override
93  public boolean asynchronous() {
94  return false;
95  }
96 
97  @Override
98  public String getName() {
99  return NbBundle.getMessage(OpenOutputFolderAction.class, "CTL_OpenOutputFolder");
100  }
101 }
Void open(ProgressIndicator progressIndicator, Object additionalParams)
Definition: Case.java:1965
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.