KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > browser > browsers > MozillaFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.browser.browsers;
12
13 import org.eclipse.ui.browser.BrowserFactory;
14 import org.eclipse.ui.browser.IWebBrowser;
15
16 public class MozillaFactory extends BrowserFactory {
17     private MozillaBrowser browserInstance = null;
18     
19     /**
20      * Constructor.
21      */

22     public MozillaFactory() {
23         super();
24     }
25     
26     /*
27      * @see BrowserFactory#isAvailable()
28      */

29     /*public boolean isAvailable() {
30         try {
31             Process pr = Runtime.getRuntime().exec("which " + executable); //$NON-NLS-1$
32             StreamConsumer outputs = new StreamConsumer(pr.getInputStream());
33             (outputs).start();
34             StreamConsumer errors = new StreamConsumer(pr.getErrorStream());
35             (errors).start();
36             pr.waitFor();
37             
38             int ret = pr.exitValue();
39             if (ret == 0)
40                 return !errorsInOutput(outputs, errors);
41             return false;
42         } catch (InterruptedException e) {
43             return false;
44         } catch (IOException e) {
45             // launching which failed, assume browser executable is present
46             return true;
47         }
48     }*/

49     
50     /**
51      * On some OSes 0 is always returned by "which" command it is necessary to
52      * examine ouput to find out failure.
53      *
54      * @param outputs
55      * @param errors
56      * @return @throws
57      * InterruptedException
58      */

59     /*private boolean errorsInOutput(StreamConsumer outputs, StreamConsumer errors) {
60         try {
61             outputs.join(1000);
62             if (outputs.getLastLine() != null
63                 && outputs.getLastLine()
64                     .indexOf("no " + executable + " in") //$NON-NLS-1$ //$NON-NLS-2$
65                     >= 0) {
66                 return true;
67             }
68             errors.join(1000);
69             if (errors.getLastLine() != null
70                     && errors.getLastLine().indexOf("no " + executable + " in") //$NON-NLS-1$ //$NON-NLS-2$
71                     >= 0) {
72                 return true;
73             }
74         } catch (InterruptedException ie) {
75             // ignore
76         }
77         return false;
78     }*/

79
80     /*
81      * @see BrowserFactory#createBrowser()
82      */

83     public IWebBrowser createBrowser(String JavaDoc id, String JavaDoc location, String JavaDoc parameters) {
84         // Create single browser for all clients
85
if (browserInstance == null) {
86             browserInstance = new MozillaBrowser(id, location);
87         }
88         return browserInstance;
89     }
90 }
Popular Tags