Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OfflineHelpAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.corecomponents;
20 
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.net.MalformedURLException;
27 import java.nio.file.Paths;
28 import org.netbeans.core.actions.HTMLViewAction;
29 import org.openide.awt.ActionID;
30 import org.openide.awt.ActionReference;
31 import org.openide.awt.ActionReferences;
32 import org.openide.awt.ActionRegistration;
33 import org.openide.awt.HtmlBrowser;
34 import org.openide.util.NbBundle;
35 import org.openide.util.NbBundle.Messages;
36 import java.util.logging.Level;
37 import org.openide.modules.InstalledFileLocator;
39 
43 @ActionID(
44  category = "Help",
45  id = "org.sleuthkit.autopsy.corecomponents.OfflineHelpAction"
46 )
47 @ActionRegistration(
48  displayName = "#CTL_OfflineHelpAction"
49 )
50 @ActionReferences({
51  @ActionReference(path = "Menu/Help", position = 1),
52  @ActionReference(path = "Shortcuts", name = "F2")
53 })
54 @Messages("CTL_OfflineHelpAction=Offline Autopsy Documentation")
55 public final class OfflineHelpAction implements ActionListener {
56 
57  private static final String DOCS_FOLDER = "docs";
58  private static final String HELP_HTML_FILE = "index.html";
59  private static final String HELP_REL_PATH = Paths.get("..", DOCS_FOLDER, HELP_HTML_FILE).toString();
60 
61  private static final Logger logger
63 
64  @Override
65  public void actionPerformed(ActionEvent e) {
66  viewOfflineHelp();
67  }
68 
75  private void viewOfflineHelp() {
76 
77  File systemHelpFile = getOfflineHelpFile();
78  if (systemHelpFile == null) {
79  logger.log(Level.SEVERE, "Unable to load Offline Documentation file at relative path: " + HELP_REL_PATH);
80  return;
81  }
82 
83  // Display URL in the System browser
85  Desktop desktop = Desktop.getDesktop();
86  try {
87  desktop.open(systemHelpFile);
88  return;
89  } catch (IOException ex) {
90  logger.log(Level.SEVERE, "Unable to launch the system browser: "
91  + systemHelpFile, ex); //NON-NLS
92  }
93  }
94 
95  org.openide.awt.StatusDisplayer.getDefault().setStatusText(
96  NbBundle.getMessage(HTMLViewAction.class, "CTL_OpeningBrowser")); //NON-NLS
97  try {
98  HtmlBrowser.URLDisplayer.getDefault().showURL(systemHelpFile.toURI().toURL());
99  } catch (MalformedURLException ex) {
100  logger.log(Level.SEVERE, "Unable to launch the built-in browser: "
101  + systemHelpFile, ex); //NON-NLS
102  }
103 
104  }
105 
106 
107 
108  private File getOfflineHelpFile() {
109  return InstalledFileLocator.getDefault().locate(
110  HELP_REL_PATH,
111  OfflineHelpAction.class.getPackage().getName(),
112  false);
113  }
114 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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