Autopsy  4.14.0
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  */
19 package org.sleuthkit.autopsy.actions;
20 
21 import java.awt.Desktop;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.io.File;
25 import java.io.IOException;
26 import java.util.logging.Level;
27 import org.openide.DialogDisplayer;
28 import org.openide.NotifyDescriptor;
29 import org.openide.awt.ActionID;
30 import org.openide.awt.ActionReference;
31 import org.openide.awt.ActionRegistration;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.actions.SystemAction;
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)
41 public final class OpenPythonModulesFolderAction extends SystemAction implements ActionListener {
42 
43  private static final Logger logger = Logger.getLogger(OpenPythonModulesFolderAction.class.getName());
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-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.