Autopsy  4.10.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 
21 import java.awt.Desktop;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.io.IOException;
25 import java.net.MalformedURLException;
26 import java.net.URI;
27 import org.netbeans.core.actions.HTMLViewAction;
28 import org.openide.awt.ActionID;
29 import org.openide.awt.ActionReference;
30 import org.openide.awt.ActionReferences;
31 import org.openide.awt.ActionRegistration;
32 import org.openide.awt.HtmlBrowser;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
35 import java.util.logging.Level;
37 
41 @ActionID(
42  category = "Help",
43  id = "org.sleuthkit.autopsy.corecomponents.OfflineHelpAction"
44 )
45 @ActionRegistration(
46  displayName = "#CTL_OfflineHelpAction"
47 )
48 @ActionReferences({
49  @ActionReference(path = "Menu/Help", position = 1),
50  @ActionReference(path = "Shortcuts", name = "F2")
51 })
52 @Messages("CTL_OfflineHelpAction=Offline Autopsy Documentation")
53 public final class OfflineHelpAction implements ActionListener {
54 
55  private static final Logger logger
57 
58  @Override
59  public void actionPerformed(ActionEvent e) {
60  viewOfflineHelp();
61  }
62 
69  private void viewOfflineHelp() {
70  String fileForHelp = "";
71  String indexForHelp = "";
72  String currentDirectory = "";
73  URI uri = null;
74 
75  try {
76  // Match the form: file:///C:/some/directory/AutopsyXYZ/docs/index.html
77  fileForHelp = NbBundle.getMessage(OfflineHelpAction.class, "FILE_FOR_LOCAL_HELP");
78  indexForHelp = NbBundle.getMessage(OfflineHelpAction.class, "INDEX_FOR_LOCAL_HELP");
79  currentDirectory = System.getProperty("user.dir").replace("\\", "/").replace(" ", "%20"); //NON-NLS
80  uri = new URI(fileForHelp + currentDirectory + indexForHelp);
81  } catch (Exception ex) {
82  logger.log(Level.SEVERE, "Unable to load Offline Documentation: "
83  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
84  }
85  if (uri != null) {
86  // Display URL in the System browser
87  if (Desktop.isDesktopSupported()) {
88  Desktop desktop = Desktop.getDesktop();
89  try {
90  desktop.browse(uri);
91  } catch (IOException ex) {
92  logger.log(Level.SEVERE, "Unable to launch the system browser: "
93  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
94  }
95  } else {
96  org.openide.awt.StatusDisplayer.getDefault().setStatusText(
97  NbBundle.getMessage(HTMLViewAction.class, "CTL_OpeningBrowser")); //NON-NLS
98  try {
99  HtmlBrowser.URLDisplayer.getDefault().showURL(uri.toURL());
100  } catch (MalformedURLException ex) {
101  logger.log(Level.SEVERE, "Unable to launch the built-in browser: "
102  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
103  }
104  }
105  }
106  }
107 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.