Autopsy 4.22.1
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 */
19package org.sleuthkit.autopsy.corecomponents;
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.net.MalformedURLException;
27import java.nio.file.Paths;
28import org.netbeans.core.actions.HTMLViewAction;
29import org.openide.awt.ActionID;
30import org.openide.awt.ActionReference;
31import org.openide.awt.ActionReferences;
32import org.openide.awt.ActionRegistration;
33import org.openide.awt.HtmlBrowser;
34import org.openide.util.NbBundle;
35import org.openide.util.NbBundle.Messages;
36import java.util.logging.Level;
37import org.openide.modules.InstalledFileLocator;
38import org.sleuthkit.autopsy.coreutils.Logger;
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")
55public 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
62 = org.sleuthkit.autopsy.coreutils.Logger.getLogger(AboutWindowPanel.class.getName());
63
64 @Override
65 public void actionPerformed(ActionEvent e) {
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(
111 OfflineHelpAction.class.getPackage().getName(),
112 false);
113 }
114}

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