KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Utilities;
23 import java.net.URL JavaDoc;
24
25 /**
26  * @author snajper
27  */

28 public class DelegatingWebBrowserImpl extends ExtBrowserImpl {
29
30     private NbDdeBrowserImpl ddeImpl;
31     private UnixBrowserImpl unixImpl;
32     private SimpleExtBrowserImpl simpleImpl;
33
34     /** Creates a new instance of DelegatingWebBrowserImpl */
35     public DelegatingWebBrowserImpl() {
36     }
37
38     /** Creates a new instance of DelegatingWebBrowserImpl */
39     public DelegatingWebBrowserImpl(ExtWebBrowser extBrowserFactory) {
40         this.extBrowserFactory = extBrowserFactory;
41     }
42
43     public ExtBrowserImpl getImplementation() {
44         String JavaDoc pName = extBrowserFactory.getBrowserExecutable().getProcessName().toUpperCase();
45                 
46         if (pName != null) {
47             
48             // Windows -> DDE browser if it is Mozilla, or Netscape 4.x or Netscape 7.x or Internet Explorer
49
// Netscape6 is also simple command-line
50
if (Utilities.isWindows()) {
51                 if (pName.indexOf("IEXPLORE.EXE") > -1 || // NOI18N
52
pName.indexOf("NETSCP.EXE") > -1 || // NOI18N
53
pName.indexOf("MOZILLA.EXE") > -1 || // NOI18N
54
pName.indexOf("FIREFOX.EXE") > -1 || // NOI18N
55
pName.indexOf("NETSCAPE.EXE") > -1) { // NOI18N
56
if (ddeImpl == null) {
57                             ddeImpl = new NbDdeBrowserImpl(extBrowserFactory);
58                         }
59                         return ddeImpl;
60                 }
61
62             // Unix (but not MacOSX) -> if Netscape or Mozilla, create Unix browser
63
} else if (Utilities.isUnix() && !Utilities.isMac()) {
64                 if (pName.indexOf("MOZILLA") > -1 || // NOI18N
65
pName.indexOf("NETSCAPE") > -1 ||
66                     pName.indexOf("FIREFOX") > -1) { // NOI18N
67
if (unixImpl == null) {
68                             unixImpl = new UnixBrowserImpl(extBrowserFactory);
69                         }
70                         return unixImpl;
71                 }
72             }
73         }
74         
75         // otherwise simple command-line browser
76
if (simpleImpl == null) {
77             simpleImpl = new SimpleExtBrowserImpl(extBrowserFactory);
78         }
79         return simpleImpl;
80     }
81
82     /**
83      * Sets current URL.
84      * @param url URL to show in the browser.
85      */

86     public void setURL(URL JavaDoc url) {
87         getImplementation().setURL(url);
88     }
89         
90 }
91
Popular Tags