Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenPythonModulesFolderAction.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2014 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.awt.event.ActionEvent;
23import java.awt.event.ActionListener;
24import java.io.File;
25import java.io.IOException;
26import java.util.logging.Level;
27import org.openide.DialogDisplayer;
28import org.openide.NotifyDescriptor;
29import org.openide.awt.ActionID;
30import org.openide.awt.ActionReference;
31import org.openide.awt.ActionRegistration;
32import org.openide.util.HelpCtx;
33import org.openide.util.NbBundle;
34import org.openide.util.actions.SystemAction;
35import org.sleuthkit.autopsy.coreutils.Logger;
36import org.sleuthkit.autopsy.coreutils.PlatformUtil;
37
38@ActionID(category = "Tools", id = "org.sleuthkit.autopsy.actions.OpenPythonModulesFolderAction")
39@ActionRegistration(displayName = "#CTL_OpenPythonModulesFolderAction", lazy = false)
40@ActionReference(path = "Menu/Tools", position = 1400)
41public final class OpenPythonModulesFolderAction extends SystemAction implements ActionListener {
42
44 private static final String ACTION_NAME = NbBundle.getMessage(OpenPythonModulesFolderAction.class, "OpenPythonModulesFolderAction.actionName.text");
45
46 @Override
47 public void actionPerformed(ActionEvent e) {
48 String pythonModulesDirPath = PlatformUtil.getUserPythonModulesPath();
49 try {
50 File directory = new File(pythonModulesDirPath);
51 if (directory.exists()) {
52 Desktop.getDesktop().open(directory);
53 } else {
54 throw new IOException(String.format("%s does not exist", pythonModulesDirPath)); //NON-NLS
55 }
56 } catch (IOException ex) {
57 String msg = String.format("Error creating File object for %s", pythonModulesDirPath); //NON-NLS
58 logger.log(Level.SEVERE, msg, ex);
59 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
60 NbBundle.getMessage(OpenPythonModulesFolderAction.class, "OpenPythonModulesFolderAction.errorMsg.folderNotFound", pythonModulesDirPath),
61 NotifyDescriptor.ERROR_MESSAGE));
62 }
63 }
64
65 @Override
66 public String getName() {
67 return ACTION_NAME;
68 }
69
70 @Override
71 public HelpCtx getHelpCtx() {
72 return HelpCtx.DEFAULT_HELP;
73 }
74}
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.