KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > actions > HTMLViewAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core.actions;
21
22 import org.openide.awt.HtmlBrowser;
23 import org.openide.windows.*;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26 import org.openide.util.actions.CallableSystemAction;
27
28 import org.openide.util.Exceptions;
29
30 /** Activates last opened HTML browser or opens a HTML Browser on the home URL
31  * specified in IDESettings using HtmlBrowser.URLDisplayer.showURL().
32 *
33 * @author Ian Formanek
34 */

35 public class HTMLViewAction extends CallableSystemAction {
36
37     public HTMLViewAction() {
38         putValue("noIconInMenu", Boolean.TRUE); //NOI18N
39
}
40     
41     protected String JavaDoc iconResource () {
42         return "org/netbeans/core/resources/actions/htmlView.gif"; // NOI18N
43
}
44
45     public void performAction() {
46         org.openide.awt.StatusDisplayer.getDefault().setStatusText(
47             NbBundle.getBundle(HTMLViewAction.class).getString("CTL_OpeningBrowser"));
48         try {
49             HtmlBrowser.URLDisplayer.getDefault().showURL(
50                     new java.net.URL JavaDoc(HtmlBrowser.getHomePage ()
51                     ));
52         } catch (java.net.MalformedURLException JavaDoc e) {
53             String JavaDoc home = HtmlBrowser.getHomePage ();
54             if (!home.startsWith ("http://")) { // NOI18N
55
home = "http://" + home; // NOI18N
56
}
57             try {
58                 HtmlBrowser.URLDisplayer.getDefault().showURL(
59                     new java.net.URL JavaDoc(home));
60             } catch (java.net.MalformedURLException JavaDoc e1) {
61                 Exceptions.printStackTrace(e1);
62             }
63         }
64     }
65     
66     protected boolean asynchronous() {
67         return false;
68     }
69
70     public String JavaDoc getName() {
71         return NbBundle.getBundle(HTMLViewAction.class).getString("HTMLView");
72     }
73
74     public HelpCtx getHelpCtx() {
75         return new HelpCtx(HTMLViewAction.class);
76     }
77
78 }
79
Popular Tags