KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > extbrowser > IExplorerBrowser


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.modules.extbrowser;
21
22 import org.openide.ErrorManager;
23 import org.openide.awt.HtmlBrowser;
24 import org.openide.execution.NbProcessDescriptor;
25 import org.openide.util.NbBundle;
26 import org.openide.util.Utilities;
27
28 /**
29  * @author Martin Grebac
30  */

31 public class IExplorerBrowser extends ExtWebBrowser {
32
33 // /** storage for starting browser timeout property */
34
// protected int browserStartTimeout = 5000;
35

36     /** Determines whether the browser should be visible or not
37      * @return true when OS is Windows.
38      * false in all other cases.
39      */

40     public static Boolean JavaDoc isHidden () {
41         return (Utilities.isWindows()) ? Boolean.FALSE : Boolean.TRUE;
42     }
43             
44     private static final long serialVersionUID = 6433332055280422486L;
45     
46     /** Creates new ExtWebBrowser */
47     public IExplorerBrowser() {
48         ddeServer = ExtWebBrowser.IEXPLORE;
49     }
50
51     /** Getter for browser name
52      * @return name of browser
53      */

54     public String JavaDoc getName () {
55         if (name == null) {
56             this.name = NbBundle.getMessage(IExplorerBrowser.class, "CTL_IExplorerBrowserName");
57         }
58         return name;
59     }
60     
61     /**
62      * Returns a new instance of BrowserImpl implementation.
63      * @throws UnsupportedOperationException when method is called and OS is not Windows.
64      * @return browserImpl implementation of browser.
65      */

66     public HtmlBrowser.Impl createHtmlBrowserImpl() {
67         ExtBrowserImpl impl = null;
68
69         if (org.openide.util.Utilities.isWindows ()) {
70             impl = new NbDdeBrowserImpl (this);
71         } else {
72             throw new UnsupportedOperationException JavaDoc (NbBundle.getMessage (IExplorerBrowser.class, "MSG_CannotUseBrowser"));
73         }
74         
75         return impl;
76     }
77         
78     /** Default command for browser execution.
79      * Can be overriden to return browser that suits to platform and settings.
80      *
81      * @return process descriptor that allows to start browser.
82      */

83     protected NbProcessDescriptor defaultBrowserExecutable () {
84         String JavaDoc b;
85         String JavaDoc params = "-nohome "; // NOI18N
86

87         params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}";
88         try {
89             b = NbDdeBrowserImpl.getBrowserPath(getDDEServer ());
90         } catch (NbBrowserException e) {
91             b = "C:\\Program Files\\Internet Explorer\\iexplore.exe"; // NOI18N
92
} catch (UnsatisfiedLinkError JavaDoc e) {
93             // someone is customizing this on non-Win platform
94
b = "iexplore"; // NOI18N
95
}
96         if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) {
97             ExtWebBrowser.getEM().log(ErrorManager.INFORMATIONAL, "" + System.currentTimeMillis() + " IE: defaultBrowserExecutable: " + params + ", " + b);
98         }
99         return new NbProcessDescriptor (b, params);
100     }
101     
102     private void readObject (java.io.ObjectInputStream JavaDoc ois) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc {
103         ois.defaultReadObject();
104     }
105     
106     
107 }
108
Popular Tags