KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.beans.*;
23 import java.io.IOException JavaDoc;
24 import java.net.URL JavaDoc;
25
26 import org.openide.NotifyDescriptor;
27 import org.openide.util.NbBundle;
28 import org.openide.execution.NbProcessDescriptor;
29 import org.openide.ErrorManager;
30
31 /** Class that implements browsing.
32  * It starts new process whenever it is asked to display URL.
33  */

34 public class SimpleExtBrowserImpl extends ExtBrowserImpl {
35
36     public SimpleExtBrowserImpl(ExtWebBrowser extBrowserFactory) {
37         super();
38         this.extBrowserFactory = extBrowserFactory;
39         if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) {
40             ExtWebBrowser.getEM().log("SimpleExtBrowserImpl created from factory: " + extBrowserFactory); // NOI18N
41
}
42     }
43
44     /** Given URL is displayed.
45       * Configured process is started to satisfy this request.
46       */

47     public void setURL(URL JavaDoc url) {
48         if (url == null) {
49             return;
50         }
51         
52         try {
53             url = URLUtil.createExternalURL(url, false);
54             NbProcessDescriptor np = extBrowserFactory.getBrowserExecutable();
55             if (np != null) {
56                 np.exec(new SimpleExtBrowser.BrowserFormat((url == null)? "": url.toString())); // NOI18N
57
}
58             this.url = url;
59         } catch (IOException JavaDoc ex) {
60             org.openide.DialogDisplayer.getDefault().notify(
61                 new NotifyDescriptor.Confirmation(
62                     NbBundle.getMessage(SimpleExtBrowserImpl.class, "EXC_Invalid_Processor"),
63                     NotifyDescriptor.DEFAULT_OPTION, NotifyDescriptor.WARNING_MESSAGE
64                 )
65             );
66         }
67     }
68
69 }
Popular Tags