Autopsy  3.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-2015 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;
36 import java.util.logging.Logger;
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 URI uri;
56  private static final Logger Logger =
58 
59  @Override
60  public void actionPerformed(ActionEvent e) {
61  viewOfflineHelp();
62  }
63 
71  private void viewOfflineHelp() {
72  String fileForHelp = "";
73  String indexForHelp = "";
74  String currentDirectory = "";
75 
76  try {
77  // Match the form: file:///C:/some/directory/AutopsyXYZ/docs/index.html
78  fileForHelp = NbBundle.getMessage(OfflineHelpAction.class, "FILE_FOR_LOCAL_HELP");
79  indexForHelp = NbBundle.getMessage(OfflineHelpAction.class, "INDEX_FOR_LOCAL_HELP");
80  currentDirectory = System.getProperty("user.dir").replace("\\", "/").replace(" ", "%20"); //NON-NLS
81  uri = new URI(fileForHelp + currentDirectory + indexForHelp);
82  } catch (Exception ex) {
83  Logger.log(Level.SEVERE, "Unable to load Offline Documentation: "
84  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
85  }
86  if (uri != null) {
87  // Display URL in the System browser
88  if (Desktop.isDesktopSupported()) {
89  Desktop desktop = Desktop.getDesktop();
90  try {
91  desktop.browse(uri);
92  } catch (IOException ex) {
93  Logger.log(Level.SEVERE, "Unable to launch the system browser: "
94  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
95  }
96  } else {
97  org.openide.awt.StatusDisplayer.getDefault().setStatusText(
98  NbBundle.getMessage(HTMLViewAction.class, "CTL_OpeningBrowser")); //NON-NLS
99  try {
100  HtmlBrowser.URLDisplayer.getDefault().showURL(uri.toURL());
101  } catch (MalformedURLException ex) {
102  Logger.log(Level.SEVERE, "Unable to launch the built-in browser: "
103  + fileForHelp + currentDirectory + indexForHelp, ex); //NON-NLS
104  }
105  }
106  }
107  }
108 }
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.