1 19 20 package org.netbeans.modules.extbrowser; 21 22 import org.openide.awt.HtmlBrowser; 23 import org.openide.execution.NbProcessDescriptor; 24 import org.openide.util.NbBundle; 25 import org.openide.util.Utilities; 26 import java.beans.PropertyChangeListener ; 27 import org.openide.ErrorManager; 28 29 32 public class NetscapeBrowser extends ExtWebBrowser implements PropertyChangeListener { 33 34 private static final long serialVersionUID = -2097024098026706995L; 35 36 37 39 40 public NetscapeBrowser() { 41 init(); 42 } 43 44 public void init() { 45 if (Utilities.isWindows()) { 47 ddeServer = ExtWebBrowser.NETSCAPE6; 48 pcs.addPropertyChangeListener(this); 49 } 51 } 52 53 57 public static Boolean isHidden () { 58 String detectedPath = null; 59 if (Utilities.isWindows()) { 60 try { 61 detectedPath = NbDdeBrowserImpl.getBrowserPath("NETSCP"); } catch (NbBrowserException e) { 63 ExtWebBrowser.getEM().log("Cannot detect Netscape 7 : " + e); } 65 if ((detectedPath != null) && (detectedPath.trim().length() > 0)) { 66 return Boolean.FALSE; 67 } 68 69 try { 70 detectedPath = NbDdeBrowserImpl.getBrowserPath("NETSCP6"); } catch (NbBrowserException e) { 72 ExtWebBrowser.getEM().log("Cannot detect Netscape 6 : " + e); } 74 if ((detectedPath != null) && (detectedPath.trim().length() > 0)) { 75 return Boolean.FALSE; 76 } 77 78 try { 79 detectedPath = NbDdeBrowserImpl.getBrowserPath("NETSCAPE"); } catch (NbBrowserException e) { 81 ExtWebBrowser.getEM().log("Cannot detect Netscape 4 : " + e); } 83 if ((detectedPath != null) && (detectedPath.trim().length() > 0)) { 84 return Boolean.FALSE; 85 } 86 87 return Boolean.TRUE; 88 } 89 90 return (Utilities.isUnix() && !Utilities.isMac()) ? Boolean.FALSE : Boolean.TRUE; 91 } 92 93 96 public String getName () { 97 if (name == null) { 98 this.name = NbBundle.getMessage(NetscapeBrowser.class, "CTL_NetscapeBrowserName"); 99 } 100 return name; 101 } 102 103 108 public HtmlBrowser.Impl createHtmlBrowserImpl() { 109 ExtBrowserImpl impl = null; 110 111 if (org.openide.util.Utilities.isWindows ()) { 112 impl = new NbDdeBrowserImpl (this); 113 } else if (Utilities.isUnix() && !Utilities.isMac()) { 114 impl = new UnixBrowserImpl(this); 115 } else { 116 throw new UnsupportedOperationException (NbBundle.getMessage (NetscapeBrowser.class, "MSG_CannotUseBrowser")); 117 } 118 119 return impl; 120 } 121 122 127 protected NbProcessDescriptor defaultBrowserExecutable() { 128 String b = ""; 129 String params = ""; NbProcessDescriptor retValue; 131 132 if (Utilities.isWindows()) { 134 params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; 135 try { 136 try { 137 b = NbDdeBrowserImpl.getBrowserPath("Netscp"); if ((b != null) && (b.trim().length() > 0)) { 139 setDDEServer(ExtWebBrowser.NETSCAPE6); 140 return new NbProcessDescriptor(b, params); 141 } 142 } catch (NbBrowserException e) { 143 if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) { 144 ExtWebBrowser.getEM().log("Cannot get Path for Netscape 7: " + e); } 146 } 147 148 try { 149 b = NbDdeBrowserImpl.getBrowserPath("Netscp6"); if ((b != null) && (b.trim().length() > 0)) { 151 setDDEServer(ExtWebBrowser.NETSCAPE6); 152 return new NbProcessDescriptor(b, params); 153 } 154 } catch (NbBrowserException e) { 155 if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) { 156 ExtWebBrowser.getEM().log("Cannot get Path for Netscape 6: " + e); } 158 } 159 160 try { 161 b = NbDdeBrowserImpl.getBrowserPath("Netscape"); if ((b != null) && (b.trim().length() > 0)) { 163 setDDEServer(ExtWebBrowser.NETSCAPE); 164 return new NbProcessDescriptor(b, params); 165 } 166 } catch (NbBrowserException e) { 167 if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) { 168 ExtWebBrowser.getEM().log("Cannot get Path for Netscape 4: " + e); } 170 } 171 172 } catch (UnsatisfiedLinkError e) { 173 if (ExtWebBrowser.getEM().isLoggable(ErrorManager.INFORMATIONAL)) { 174 ExtWebBrowser.getEM().log("Some problem here:" + e); } 176 } 177 178 b = "C:\\PROGRA~1\\Netscape\\NETSCA~1\\netscp.exe"; setDDEServer(ExtWebBrowser.NETSCAPE6); 180 181 retValue = new NbProcessDescriptor (b, params); 182 183 } else { 185 186 b = "netscape"; if (Utilities.getOperatingSystem() == Utilities.OS_SOLARIS) { 188 java.io.File f = new java.io.File ("/usr/dt/bin/sun_netscape"); if (f.exists()) { 190 b = f.getAbsolutePath(); 191 } 192 } 193 retValue = new NbProcessDescriptor ( 194 b, "-remote \"openURL({" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "})\"", NbBundle.getMessage (NetscapeBrowser.class, "MSG_BrowserExecutorHint") 196 ); 197 } 198 199 return retValue; 200 } 201 202 } 203 | Popular Tags |