Autopsy 4.22.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 */
19package org.sleuthkit.autopsy.actions;
20
21import org.sleuthkit.autopsy.coreutils.Desktop;
22import java.io.File;
23import java.io.IOException;
24import java.util.logging.Level;
25import javax.swing.JOptionPane;
26import org.openide.DialogDisplayer;
27import org.openide.NotifyDescriptor;
28import org.openide.awt.ActionID;
29import org.openide.awt.ActionReference;
30import org.openide.awt.ActionRegistration;
31import org.openide.util.HelpCtx;
32import org.openide.util.NbBundle;
33import org.openide.util.actions.CallableSystemAction;
34import org.openide.windows.WindowManager;
35import org.sleuthkit.autopsy.casemodule.Case;
36import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
37import org.sleuthkit.autopsy.coreutils.Logger;
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")
51public final class OpenOutputFolderAction extends CallableSystemAction {
52
53 private static final long serialVersionUID = 1L;
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}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.