Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDorian Birsan2003-02-15 22:06:15 +0000
committerDorian Birsan2003-02-15 22:06:15 +0000
commitb8e9fdb92a9510bb11536bbece9f086233d42856 (patch)
tree3214e68398c9daaf34ab15c747301ec2e5fe2b11 /org.eclipse.help.ui
parentb94ebab6349f96e7b75271c788a0fc7870a615fb (diff)
downloadeclipse.platform.ua-b8e9fdb92a9510bb11536bbece9f086233d42856.tar.gz
eclipse.platform.ua-b8e9fdb92a9510bb11536bbece9f086233d42856.tar.xz
eclipse.platform.ua-b8e9fdb92a9510bb11536bbece9f086233d42856.zip
Refactor the browsers to move them to core help
Diffstat (limited to 'org.eclipse.help.ui')
-rw-r--r--org.eclipse.help.ui/doc/org_eclipse_help_ui_browser.html6
-rw-r--r--org.eclipse.help.ui/plugin.properties6
-rw-r--r--org.eclipse.help.ui/plugin.xml97
-rw-r--r--org.eclipse.help.ui/schema/browser.mxsd123
-rw-r--r--org.eclipse.help.ui/src/helpworkbench.properties6
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowser.java126
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowserFactory.java48
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java18
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelp.java36
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/WorkbenchHelpPlugin.java6
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserDescriptor.java31
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserManager.java206
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java15
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowser.java87
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowserFactory.java28
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/DefaultBrowser.java129
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaBrowserAdapter.java197
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaFactory.java84
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserAdapter.java2
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserFactory.java2
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserAdapter.java81
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserFactory.java35
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeBrowserAdapter.java122
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeFactory.java32
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/BrowserLog.java82
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/ErrorUtil.java18
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/StreamConsumer.java30
27 files changed, 152 insertions, 1501 deletions
diff --git a/org.eclipse.help.ui/doc/org_eclipse_help_ui_browser.html b/org.eclipse.help.ui/doc/org_eclipse_help_ui_browser.html
index 2c7f61b4b..f3a56855d 100644
--- a/org.eclipse.help.ui/doc/org_eclipse_help_ui_browser.html
+++ b/org.eclipse.help.ui/doc/org_eclipse_help_ui_browser.html
@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
- <title>org.eclipse.help.ui.browser</title>
+ <title>org.eclipse.help.browser</title>
</head>
<body link="#0000FF" vlink="#800080">
&nbsp;
@@ -20,7 +20,7 @@ ways.</b></td>
<center>
<h1>
Browser</h1></center>
-<b><i>Identifier: </i></b>org.eclipse.help.ui.browser
+<b><i>Identifier: </i></b>org.eclipse.help.browser
<p><b><i>Description:</i></b> For providing web browsers capable of displaying
html documents at given URL<br>This extension point was added in 2.0.
<p><b><i>Configuration Markup:</i></b>
@@ -47,7 +47,7 @@ interface.</li>
<b><i>Examples:</i></b>
<p>The following is a sample usage of the browser extension point:
<p>(in file <tt>plugin.xml</tt>)
-<p><tt>&nbsp;&lt;extension point="org.eclipse.help.ui.browser"></tt>
+<p><tt>&nbsp;&lt;extension point="org.eclipse.help.browser"></tt>
<br><tt>&nbsp;&nbsp; &lt;browser id="org.eclipse.myPlugin.myBrowserID"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; factoryclass="org.eclipse.myPlugin.myPackage.MyFactoryClass"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; name="My Browser" /></tt>
diff --git a/org.eclipse.help.ui/plugin.properties b/org.eclipse.help.ui/plugin.properties
index 6ac6bad9a..8ae44c2ca 100644
--- a/org.eclipse.help.ui/plugin.properties
+++ b/org.eclipse.help.ui/plugin.properties
@@ -8,7 +8,6 @@ help_view = Help
help_perspective = Help
openhelpcontents = Open Help Contents
related_view = Related Contexts
-browser_extention_point_name = Web Browser
browsers_preferences_page_name = Web Browsers
help_search_page = Help Search
helpsearchhitname = Help Search Hit
@@ -19,13 +18,8 @@ searchMenu.label = Se&arch
# Browser adapters
internet_explorer = Embedded Internet Explorer Adapter
-mozilla = Mozilla
-mozilla_adapter = Mozilla Adapter
-netscape = Netscape
-netscape_adapter = Netscape Adapter
defaultBrowser = Default Web Browser (Change in System Preferences)
system_browser = Default System Browser
-custom_browser = Custom Browser (user defined program)
# Application Server
appserver_preferences_page_name= Help Server
diff --git a/org.eclipse.help.ui/plugin.xml b/org.eclipse.help.ui/plugin.xml
index dc9af302d..d84677d4f 100644
--- a/org.eclipse.help.ui/plugin.xml
+++ b/org.eclipse.help.ui/plugin.xml
@@ -20,10 +20,6 @@
<import plugin="org.eclipse.ui"/>
</requires>
-
-<!-- Extension points -->
- <extension-point id="browser" name="%browser_extention_point_name" schema="schema/browser.mxsd"/>
-
<!-- Default Help UI -->
<extension
point="org.eclipse.help.support">
@@ -97,103 +93,12 @@
</extension>
<!-- Web Browsers -->
<extension
- point="org.eclipse.help.ui.browser">
- <browser
- name="%mozilla_adapter"
- id="org.eclipse.help.ui.mozillaLinux">
- <factoryclass
- class="org.eclipse.help.ui.internal.browser.MozillaFactory">
- <parameter
- name="executable"
- value="mozilla">
- </parameter>
- <parameter
- name="executableName"
- value="%mozilla">
- </parameter>
- <parameter
- name="os"
- value="Linux">
- </parameter>
- </factoryclass>
- </browser>
- <browser
- name="%netscape_adapter"
- id="org.eclipse.help.ui.netscapeLinux">
- <factoryclass
- class="org.eclipse.help.ui.internal.browser.MozillaFactory">
- <parameter
- name="executable"
- value="netscape">
- </parameter>
- <parameter
- name="executableName"
- value="%netscape">
- </parameter>
- <parameter
- name="os"
- value="Linux">
- </parameter>
- </factoryclass>
- </browser>
- <browser
- name="%netscape_adapter"
- id="org.eclipse.help.ui.netscapeAIX">
- <factoryclass
- class="org.eclipse.help.ui.internal.browser.MozillaFactory">
- <parameter
- name="executable"
- value="netscape">
- </parameter>
- <parameter
- name="executableName"
- value="%netscape">
- </parameter>
- <parameter
- name="os"
- value="AIX">
- </parameter>
- </factoryclass>
- </browser>
- <browser
- name="%netscape_adapter"
- id="org.eclipse.help.ui.netscapeHPUX">
- <factoryclass
- class="org.eclipse.help.ui.internal.browser.MozillaFactory">
- <parameter
- name="executable"
- value="netscape">
- </parameter>
- <parameter
- name="executableName"
- value="%netscape">
- </parameter>
- <parameter
- name="os"
- value="HP">
- </parameter>
- </factoryclass>
- </browser>
- <browser
- factoryclass="org.eclipse.help.ui.internal.browser.solaris.NetscapeFactory"
- name="%netscape_adapter"
- id="org.eclipse.help.ui.netscapeSolaris">
- </browser>
- <browser
- factoryclass="org.eclipse.help.ui.internal.browser.macosx.DefaultBrowserFactory"
- name="%defaultBrowser"
- id="org.eclipse.help.ui.defaultBrowserMacOSX">
- </browser>
+ point="org.eclipse.help.browser">
<browser
factoryclass="org.eclipse.help.ui.internal.browser.SystemBrowserFactory"
name="%system_browser"
id="org.eclipse.help.ui.systembrowser">
</browser>
- <browser
- factoryclass="org.eclipse.help.ui.internal.browser.CustomBrowserFactory"
- name="%custom_browser"
- id="org.eclipse.help.ui.custombrowser">
- </browser>
</extension>
<!-- Search Page -->
<extension
diff --git a/org.eclipse.help.ui/schema/browser.mxsd b/org.eclipse.help.ui/schema/browser.mxsd
deleted file mode 100644
index ff1e5ce91..000000000
--- a/org.eclipse.help.ui/schema/browser.mxsd
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.help.ui">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.help.ui" id="browser" name="Browser"/>
- </appInfo>
- <documentation>
- For providing web browsers capable of displaying html documents at a given URL.
- </documentation>
-</annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="browser" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="browser">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- the unique ID of the browser.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="factoryClass" type="string" use="required">
- <annotation>
- <documentation>
- the implementation class for the browser factory. This class must implement the &lt;samp&gt;org.eclipse.help.ui.IBrowserFactory&lt;/samp&gt; interface.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.help.ui.IBrowserFactory"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- the name of the browser (translatable).
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is a sample usage of the browser extension point:
-
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension point="org.eclipse.help.ui.browser"&gt;
- &lt;browser
- id="org.eclipse.myPlugin.myBrowserID"
- factoryClass="org.eclipse.myPlugin.myPackage.MyFactoryClass"
- name="My Browser"&gt;
- &lt;/browser&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- The supplied factory class must implement the &lt;samp&gt;org.eclipse.help.ui.IBrowserFactory&lt;/samp&gt; interface.
-Methods in that interface determine whether the factory is available on the given system, i.e. is capable
-of supplying browser instances, and create browser instances that implement IBrowser interface.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The &lt;samp&gt;org.eclipse.help.ui&lt;/samp&gt; plug-in contains implementation of a browser on common platforms.
-Other plug-ins can provide different implementations. In the preferences, the user can select the default
-browser from among available browsers.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.help.ui/src/helpworkbench.properties b/org.eclipse.help.ui/src/helpworkbench.properties
index 9fa5017a6..a4035e449 100644
--- a/org.eclipse.help.ui/src/helpworkbench.properties
+++ b/org.eclipse.help.ui/src/helpworkbench.properties
@@ -35,10 +35,6 @@ SystemBrowser.noProgramForHTML= A program associated with ".html" extension coul
CustomBrowserPreferencePage.Program = Custom Browser &program:
CustomBrowserPreferencePage.Browse = &Browse...
CustomBrowserPreferencePage.Details = Select a browser program
-CustomBrowser.errorLaunching = Launching url "{0}" using browser program "{1}" has failed. Specify another browser in help preferences.
-MozillaFactory.dataMissing = Initialization data required by Mozilla adapter is missing.
-MozillaBrowserAdapter.executeFailed = Launching {0} has failed. Ensure that the executable program is available on your system path.
-NetscapeBrowserAdapter.executeFailed = Launching Netscape has failed. Ensure that the executable program is available on your system path.
AppserverPreferencePage.description = Internal Application Server configuration. The server is used internally\n\
by help system.
AppserverPreferencePage.hostDescription = &Host name or IP address of local machine. Leave blank, to be automatically\n\
@@ -66,7 +62,7 @@ WE021 = Exception occured executing help search
WE022 = Exception occured trying to obtain install location of Internet Explorer adapter.
WE023 = Internet Explorer adapter interrupted before Internet Explorer process has finished.
WE024 = Exception occured launching Internet Explorer help browser. Executed command: {0}
-WE025 = Exception occured reading from web browser.
+
WE026 = The following exception occured when reading commands: {0}
WE027 = Exception occured while creating browser control: {0}
WE028 = Unrecognized command: {0}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowser.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowser.java
index be93a2950..73ca7d3bf 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowser.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowser.java
@@ -1,63 +1,63 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.browser;
-/**
- * Represents a web browser that can be used
- * by clients to display documents for the given URLs.
- * @since 2.0
- */
-public interface IBrowser {
- /**
- * Closes the browser.
- */
- public void close();
- /**
- * Queries the browser if close
- * method is supported.
- * @return true if the method is fully implemented
- */
- public boolean isCloseSupported();
- /**
- * Displays document with the given URL,
- * and makes the browser visible.
- * This method starts the browser if necessary.
- * @param url the URL to display in the browser
- */
- public void displayURL(String url);
- /**
- * Queries the browser if setLocation
- * method is supported.
- * @return true if the method is fully implemented
- */
- public boolean isSetLocationSupported();
- /**
- * Queries the browser if setSize
- * method is supported.
- * @return true if the method is fully implemented
- */
- public boolean isSetSizeSupported();
- /**
- * Causes browser to be moved to the specified
- * location. If the actual browser is not visible,
- * the next time it becomes visible, it will be shown
- * at the give location
- * @param x horizontal coordinates of the left-top
- * external corner
- * @param y vertical coordinates of the left-top
- * external corner
- */
- public void setLocation(int x, int y);
- /**
- * Causes browser to be resized to the specified
- * size. If the actual browser is not visible,
- * the next time it becomes visible, it will be shown
- * with the give size.
- * @param width width in pixels
- * @param height height in pixels
- * external corner
- */
- public void setSize(int width, int height);
-}
-
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.help.ui.browser;
+/**
+ * Represents a web browser that can be used
+ * by clients to display documents for the given URLs.
+ * @deprecated Use the org.eclipse.help.browser.IBrowser instead.
+ */
+public interface IBrowser {
+ /**
+ * Closes the browser.
+ */
+ public void close();
+ /**
+ * Queries the browser if close
+ * method is supported.
+ * @return true if the method is fully implemented
+ */
+ public boolean isCloseSupported();
+ /**
+ * Displays document with the given URL,
+ * and makes the browser visible.
+ * This method starts the browser if necessary.
+ * @param url the URL to display in the browser
+ */
+ public void displayURL(String url);
+ /**
+ * Queries the browser if setLocation
+ * method is supported.
+ * @return true if the method is fully implemented
+ */
+ public boolean isSetLocationSupported();
+ /**
+ * Queries the browser if setSize
+ * method is supported.
+ * @return true if the method is fully implemented
+ */
+ public boolean isSetSizeSupported();
+ /**
+ * Causes browser to be moved to the specified
+ * location. If the actual browser is not visible,
+ * the next time it becomes visible, it will be shown
+ * at the give location
+ * @param x horizontal coordinates of the left-top
+ * external corner
+ * @param y vertical coordinates of the left-top
+ * external corner
+ */
+ public void setLocation(int x, int y);
+ /**
+ * Causes browser to be resized to the specified
+ * size. If the actual browser is not visible,
+ * the next time it becomes visible, it will be shown
+ * with the give size.
+ * @param width width in pixels
+ * @param height height in pixels
+ * external corner
+ */
+ public void setSize(int width, int height);
+}
+
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowserFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowserFactory.java
index 3d53aa6fb..a666e7b7f 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowserFactory.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/IBrowserFactory.java
@@ -1,25 +1,25 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.browser;
-/**
- * Implementators of org.eclipse.help.ui.browsers
- * extension points must provide implementation of this
- * interface.
- * @since 2.0
- */
-public interface IBrowserFactory {
- /**
- * Checks whether the factory can work on the user system.
- * @return false if the factory cannot work on this system;
- * for example the required native browser required
- * by browser adapters that it creates is not installed.
- */
- public boolean isAvailable();
- /**
- * Obtains a new instance of a web browser.
- * @return instance of IBrowser
- */
- public IBrowser createBrowser();
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.help.ui.browser;
+/**
+ * Implementators of org.eclipse.help.ui.browsers
+ * extension points must provide implementation of this
+ * interface.
+ * @deprecated Use the org.eclipse.help.browser.IBrowserFactory instead.
+ */
+public interface IBrowserFactory {
+ /**
+ * Checks whether the factory can work on the user system.
+ * @return false if the factory cannot work on this system;
+ * for example the required native browser required
+ * by browser adapters that it creates is not installed.
+ */
+ public boolean isAvailable();
+ /**
+ * Obtains a new instance of a web browser.
+ * @return instance of IBrowser
+ */
+ public IBrowser createBrowser();
} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java
index 9e125143d..7dd37a203 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/browser/LaunchURL.java
@@ -5,11 +5,13 @@
package org.eclipse.help.ui.browser;
import org.eclipse.core.runtime.*;
-import org.eclipse.help.ui.internal.browser.BrowserManager;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.program.Program;
+import org.eclipse.help.browser.IBrowser;
+import org.eclipse.help.internal.browser.*;
+import org.eclipse.help.ui.internal.util.*;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.program.*;
import org.eclipse.ui.*;
/**
@@ -71,7 +73,11 @@ public class LaunchURL
Program.launch(url);
} else {
IBrowser browser = BrowserManager.getInstance().createBrowser();
- browser.displayURL(url);
+ try{
+ browser.displayURL(url);
+ } catch(Exception e) {
+ ErrorUtil.displayErrorDialog(e.getMessage());
+ }
}
}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelp.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelp.java
index 29e424e2c..e62a8b926 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelp.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelp.java
@@ -108,10 +108,7 @@ public class DefaultHelp implements IHelp {
*/
public void displayHelpResource(String href) {
// check if this is a toc
- IToc toc =
- HelpSystem.getTocManager().getToc(
- href,
- BootLoader.getNL());
+ IToc toc = HelpSystem.getTocManager().getToc(href, BootLoader.getNL());
if (toc != null)
displayHelpResource(toc);
else if (
@@ -212,20 +209,23 @@ public class DefaultHelp implements IHelp {
if (!HelpSystem.ensureWebappRunning())
return;
- // may want to display an error message
- if (helpURL == null || helpURL.length() == 0) {
- WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
- getBaseURL());
- } else if (
- helpURL.startsWith("tab=")
- || helpURL.startsWith("toc=")
- || helpURL.startsWith("topic=")
- || helpURL.startsWith("contextId=")) {
- WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
- getBaseURL() + "?" + helpURL);
- } else {
- WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
- helpURL);
+ try {
+ if (helpURL == null || helpURL.length() == 0) {
+ WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
+ getBaseURL());
+ } else if (
+ helpURL.startsWith("tab=")
+ || helpURL.startsWith("toc=")
+ || helpURL.startsWith("topic=")
+ || helpURL.startsWith("contextId=")) {
+ WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
+ getBaseURL() + "?" + helpURL);
+ } else {
+ WorkbenchHelpPlugin.getDefault().getHelpBrowser().displayURL(
+ helpURL);
+ }
+ } catch (Exception e) {
+ ErrorUtil.displayErrorDialog(e.getMessage());
}
}
/**
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/WorkbenchHelpPlugin.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/WorkbenchHelpPlugin.java
index e105c225d..6d6d04fbd 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/WorkbenchHelpPlugin.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/WorkbenchHelpPlugin.java
@@ -6,8 +6,9 @@ package org.eclipse.help.ui.internal;
import org.eclipse.core.runtime.*;
import org.eclipse.help.internal.HelpSystem;
import org.eclipse.help.internal.appserver.WebappManager;
-import org.eclipse.help.ui.browser.IBrowser;
-import org.eclipse.help.ui.internal.browser.BrowserManager;
+import org.eclipse.help.browser.IBrowser;
+import org.eclipse.help.internal.browser.BrowserManager;
+import org.eclipse.help.ui.internal.util.*;
import org.eclipse.help.ui.internal.workingset.HelpWorkingSetSynchronizer;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -59,6 +60,7 @@ public class WorkbenchHelpPlugin extends AbstractUIPlugin {
* Called by Platform after loading the plugin
*/
public void startup() {
+ HelpSystem.setDefaultErrorUtil(new ErrorUtil());
if (HelpSystem.getMode() == HelpSystem.MODE_WORKBENCH) {
// register the working set listener to keep the ui and the help working sets in sych
workingSetListener = new HelpWorkingSetSynchronizer();
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserDescriptor.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserDescriptor.java
deleted file mode 100644
index 4ec83fc68..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserDescriptor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-import org.eclipse.help.ui.browser.IBrowserFactory;
-class BrowserDescriptor {
- private String browserID;
- private String browserLabel;
- private IBrowserFactory factory;
- /**
- * @param id ID of a browser as specified in plugin.xml
- * @param label name of the browser
- * @param factory the factory that creates instances
- * of this browser
- */
- public BrowserDescriptor(String id, String label, IBrowserFactory factory) {
- this.browserID = id;
- this.browserLabel = label;
- this.factory = factory;
- }
- public String getID() {
- return browserID;
- }
- public String getLabel() {
- return browserLabel;
- }
- public IBrowserFactory getFactory() {
- return factory;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserManager.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserManager.java
deleted file mode 100644
index d94871730..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowserManager.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.help.internal.util.Logger;
-import org.eclipse.help.ui.browser.*;
-import org.eclipse.help.ui.internal.WorkbenchHelpPlugin;
-import org.eclipse.help.ui.internal.util.*;
-
-/**
- * Creates browser by delegating
- * to appropriate browser adapter
- */
-public class BrowserManager {
- public static final String DEFAULT_BROWSER_ID_KEY = "default_browser";
- private static BrowserManager instance;
- private BrowserDescriptor defaultBrowserDesc;
- private BrowserDescriptor[] browsersDescriptors;
- private Collection browsers = new ArrayList();
- /**
- * Private Constructor
- */
- private BrowserManager() {
- // Find all available browsers
- browsersDescriptors = createBrowserDescriptors();
- // 1. set default browser from preferences
- String defBrowserID =
- WorkbenchHelpPlugin.getDefault().getPluginPreferences().getString(
- DEFAULT_BROWSER_ID_KEY);
- if (defBrowserID != null && (!"".equals(defBrowserID)))
- setDefaultBrowserID(defBrowserID);
- if (defaultBrowserDesc == null) {
- // No default browser in properties!
- // Set default browser to prefered implementation
- if (System.getProperty("os.name").startsWith("Win")) {
- setDefaultBrowserID("org.eclipse.help.ui.iexplorer");
- } else if (System.getProperty("os.name").startsWith("Linux")) {
- setDefaultBrowserID("org.eclipse.help.ui.mozillaLinux");
- } else if (System.getProperty("os.name").startsWith("SunOS")) {
- setDefaultBrowserID("org.eclipse.help.ui.netscapeSolaris");
- } else if (System.getProperty("os.name").startsWith("AIX")) {
- setDefaultBrowserID("org.eclipse.help.ui.netscapeAIX");
- } else if (
- System.getProperty("os.name").toLowerCase().startsWith("hp")) {
- setDefaultBrowserID("org.eclipse.help.ui.netscapeAIX");
- } else {
- setDefaultBrowserID("org.eclipse.help.ui.mozillaLinux");
- }
- }
- if (defaultBrowserDesc == null) {
- // No default browser in properties!
- // Set default browser to one of the available
- if (browsersDescriptors.length > 0)
- defaultBrowserDesc = browsersDescriptors[0];
- }
- if (defaultBrowserDesc == null) {
- // If no browsers at all, use the Null Browser Adapter
- defaultBrowserDesc =
- new BrowserDescriptor(
- "",
- "Null Browser",
- new IBrowserFactory() {
- public boolean isAvailable() {
- return true;
- }
- public IBrowser createBrowser() {
- return new IBrowser() {
- public void close() {
- }
- public void displayURL(String url) {
- Logger.logError(
- WorkbenchResources.getString(
- "no_browsers",
- url),
- null);
- ErrorUtil.displayErrorDialog(
- WorkbenchResources.getString(
- "no_browsers",
- url));
- }
- public boolean isCloseSupported() {
- return false;
- }
- public boolean isSetLocationSupported() {
- return false;
- }
- public boolean isSetSizeSupported() {
- return false;
- }
- public void setLocation(int width, int height) {
- }
- public void setSize(int x, int y) {
- }
- };
- }
- });
- }
- }
- /**
- * Obtains singleton instance.
- */
- public static BrowserManager getInstance() {
- if (instance == null)
- instance = new BrowserManager();
- return instance;
- }
- /**
- * Creates all adapters, and returns
- * available ones.
- */
- private BrowserDescriptor[] createBrowserDescriptors() {
- if (this.browsersDescriptors != null)
- return this.browsersDescriptors;
- Collection bDescriptors = new ArrayList();
- IConfigurationElement configElements[] =
- Platform.getPluginRegistry().getConfigurationElementsFor(
- "org.eclipse.help.ui",
- "browser");
- for (int i = 0; i < configElements.length; i++) {
- if (!configElements[i].getName().equals("browser"))
- continue;
- String id = configElements[i].getAttribute("id");
- if (id == null)
- continue;
- String label = configElements[i].getAttribute("name");
- if (label == null)
- continue;
- try {
- Object adapter =
- configElements[i].createExecutableExtension("factoryclass");
- if (!(adapter instanceof IBrowserFactory))
- continue;
- if (((IBrowserFactory) adapter).isAvailable()) {
- bDescriptors.add(
- new BrowserDescriptor(
- id,
- label,
- (IBrowserFactory) adapter));
- }
- } catch (CoreException ce) {
- }
- }
- this.browsersDescriptors =
- (BrowserDescriptor[]) bDescriptors.toArray(
- new BrowserDescriptor[bDescriptors.size()]);
- return this.browsersDescriptors;
- }
- /**
- * Obtains browsers descriptors.
- */
- protected BrowserDescriptor[] getBrowserDescriptors() {
- return this.browsersDescriptors;
- }
- /**
- * Gets the defaultBrowserID.
- * @return Returns a String or null if not set
- */
- protected String getDefaultBrowserID() {
- if (defaultBrowserDesc == null)
- return null;
- return defaultBrowserDesc.getID();
- }
- /**
- * Sets the defaultBrowserID.
- * If browser of given ID does not exists,
- * the method does nothing
- * @param defaultBrowserID The defaultAdapterID to set
- */
- protected void setDefaultBrowserID(String defaultAdapterID) {
- for (int i = 0; i < browsersDescriptors.length; i++) {
- if (browsersDescriptors[i].getID().equals(defaultAdapterID)) {
- defaultBrowserDesc = browsersDescriptors[i];
- return;
- }
- }
- }
- /**
- * Creates web browser
- */
- public IBrowser createBrowser() {
- return new DefaultBrowser(
- createBrowserAdapter(),
- getDefaultBrowserID());
- }
- /**
- * Creates web browser
- */
- IBrowser createBrowserAdapter() {
- IBrowser browser = defaultBrowserDesc.getFactory().createBrowser();
- browsers.add(browser);
- return browser;
- }
- /**
- * Closes all browsers created
- */
- public void closeAll() {
- for (Iterator it = browsers.iterator(); it.hasNext();) {
- IBrowser browser = (IBrowser) it.next();
- browser.close();
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java
index 44f238b5c..aeafec070 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java
@@ -3,18 +3,19 @@ package org.eclipse.help.ui.internal.browser;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.*;
+import org.eclipse.help.internal.browser.*;
import org.eclipse.help.ui.internal.*;
-import org.eclipse.help.ui.internal.util.WorkbenchResources;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
+import org.eclipse.help.ui.internal.util.*;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.preference.*;
+import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.help.*;
/**
* Preference page for selecting default web browser.
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowser.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowser.java
deleted file mode 100644
index 5ecb4179c..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowser.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-
-import org.eclipse.help.internal.util.Logger;
-import org.eclipse.help.ui.browser.IBrowser;
-import org.eclipse.help.ui.internal.WorkbenchHelpPlugin;
-import org.eclipse.help.ui.internal.util.*;
-
-/**
- *
- */
-public class CustomBrowser implements IBrowser {
- public static final String CUSTOM_BROWSER_PATH_KEY = "custom_browser_path";
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#close()
- */
- public void close() {
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isCloseSupported()
- */
- public boolean isCloseSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#displayURL(java.lang.String)
- */
- public void displayURL(String url) {
- String path =
- WorkbenchHelpPlugin.getDefault().getPluginPreferences().getString(
- CustomBrowser.CUSTOM_BROWSER_PATH_KEY);
- try {
- Process pr = Runtime.getRuntime().exec(new String[] { path, url });
- Thread outConsumer = new StreamConsumer(pr.getInputStream());
- outConsumer.setName("Custom browser adapter output reader");
- outConsumer.start();
- Thread errConsumer = new StreamConsumer(pr.getErrorStream());
- errConsumer.setName("Custom browser adapter error reader");
- errConsumer.start();
- } catch (Exception e) {
- Logger.logError(
- WorkbenchResources.getString(
- "CustomBrowser.errorLaunching",
- url,
- path),
- e);
- ErrorUtil.displayErrorDialog(
- WorkbenchResources.getString(
- "CustomBrowser.errorLaunching",
- url,
- path));
- }
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetLocationSupported()
- */
- public boolean isSetLocationSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetSizeSupported()
- */
- public boolean isSetSizeSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setLocation(int, int)
- */
- public void setLocation(int x, int y) {
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setSize(int, int)
- */
- public void setSize(int width, int height) {
- }
-
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowserFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowserFactory.java
deleted file mode 100644
index cbbee7915..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/CustomBrowserFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-
-import org.eclipse.help.ui.browser.*;
-
-/**
- * Produces Custom Browser
- */
-public class CustomBrowserFactory implements IBrowserFactory {
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowserFactory#isAvailable()
- */
- public boolean isAvailable() {
- return true;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowserFactory#createBrowser()
- */
- public IBrowser createBrowser() {
- return new CustomBrowser();
- }
-
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/DefaultBrowser.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/DefaultBrowser.java
deleted file mode 100644
index 2dc394708..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/DefaultBrowser.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-
-import org.eclipse.help.ui.browser.IBrowser;
-
-/**
- * Wrapper for individual browsers
- * contributed through extension point.
- */
-public class DefaultBrowser implements IBrowser {
- private IBrowser browserAdapter;
- private String browserAdapterId;
- /**
- * new adapter selected in preferences but not yet shown
- */
- private IBrowser newBrowserAdapter = null;
- private String newBrowserAdapterId = null;
- private boolean locationSet = false;
- private boolean sizeSet = false;
- private int x;
- private int y;
- private int width;
- private int height;
-
- public DefaultBrowser(IBrowser browserImpl, String browserAdapterId) {
- this.browserAdapter = browserImpl;
- this.browserAdapterId = browserAdapterId;
- }
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#close()
- */
- public void close() {
- browserAdapter.close();
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isCloseSupported()
- */
- public boolean isCloseSupported() {
- return browserAdapter.isCloseSupported();
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#displayURL(java.lang.String)
- */
- public void displayURL(String url) {
- checkDefaultAdapter();
- if (newBrowserAdapter != null) {
- browserAdapter.close();
-
- browserAdapter = newBrowserAdapter;
- newBrowserAdapter = null;
- browserAdapterId = newBrowserAdapterId;
- newBrowserAdapterId = null;
-
- if (locationSet) {
- browserAdapter.setLocation(x, y);
- }
- if (sizeSet) {
- browserAdapter.setSize(width, height);
- }
- }
- browserAdapter.displayURL(url);
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetLocationSupported()
- */
- public boolean isSetLocationSupported() {
- checkDefaultAdapter();
- if (newBrowserAdapterId == null) {
- return browserAdapter.isSetLocationSupported();
- } else {
- return browserAdapter.isSetLocationSupported()
- || newBrowserAdapter.isSetLocationSupported();
- }
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetSizeSupported()
- */
- public boolean isSetSizeSupported() {
- checkDefaultAdapter();
- if (newBrowserAdapterId == null) {
- return browserAdapter.isSetSizeSupported();
- } else {
- return browserAdapter.isSetSizeSupported()
- || newBrowserAdapter.isSetSizeSupported();
- }
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setLocation(int, int)
- */
- public void setLocation(int x, int y) {
- checkDefaultAdapter();
- browserAdapter.setLocation(x, y);
- locationSet = true;
- this.x = x;
- this.y = y;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setSize(int, int)
- */
- public void setSize(int width, int height) {
- checkDefaultAdapter();
- browserAdapter.setSize(width, height);
- sizeSet = true;
- this.width = width;
- this.height = height;
- }
- /*
- * Checks wheter default adapter has changed.
- * If yes, sets the newBrowserAdapter field
- */
- private void checkDefaultAdapter() {
- if (browserAdapterId
- != BrowserManager.getInstance().getDefaultBrowserID()) {
- newBrowserAdapter = BrowserManager.getInstance().createBrowser();
- newBrowserAdapterId =
- BrowserManager.getInstance().getDefaultBrowserID();
- }
- }
-
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaBrowserAdapter.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaBrowserAdapter.java
deleted file mode 100644
index 04366f949..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaBrowserAdapter.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-import java.io.*;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.help.internal.util.Logger;
-import org.eclipse.help.ui.browser.IBrowser;
-import org.eclipse.help.ui.internal.WorkbenchHelpPlugin;
-import org.eclipse.help.ui.internal.util.*;
-import org.eclipse.swt.widgets.Display;
-/**
- * Browser adapter for browsers supporting
- * -remote openURL command line option
- * i.e. Mozilla and Netscape.
- */
-public class MozillaBrowserAdapter implements IBrowser {
- // delay that it takes mozilla to start responding
- // to remote command after mozilla has been called
- private static final int DELAY = 5000;
- private long browserFullyOpenedAt = 0;
- private BrowserThread lastBrowserThread = null;
- private int x, y;
- private int width, height;
- private boolean setLocationPending = false;
- private boolean setSizePending = false;
- private String executable;
- private String executableName;
- private Thread uiThread;
- /**
- * Constructor
- * @executable executable filename to launch
- * @executableName name of the program to display when error occurs
- */
- MozillaBrowserAdapter(String executable, String executableName) {
- this.uiThread = Thread.currentThread();
- this.executable = executable;
- this.executableName = executableName;
- }
- /*
- * @see IBrowser#close()
- */
- public void close() {
- }
- /*
- * @see IBrowser#displayURL(String)
- */
- public void displayURL(String url) {
- if (lastBrowserThread != null)
- lastBrowserThread.exitRequested = true;
- if (setLocationPending || setSizePending) {
- url = createPositioningURL(url);
- }
- lastBrowserThread = new BrowserThread(url);
- lastBrowserThread.start();
- setLocationPending = false;
- setSizePending = false;
- }
- /*
- * @see IBrowser#isCloseSupported()
- */
- public boolean isCloseSupported() {
- return false;
- }
- /*
- * @see IBrowser#isSetLocationSupported()
- */
- public boolean isSetLocationSupported() {
- return true;
- }
- /*
- * @see IBrowser#isSetSizeSupported()
- */
- public boolean isSetSizeSupported() {
- return true;
- }
- /*
- * @see IBrowser#setLocation(int, int)
- */
- public void setLocation(int x, int y) {
- this.x = x;
- this.y = y;
- setLocationPending = true;
- }
- /*
- * @see IBrowser#setSize(int, int)
- */
- public void setSize(int width, int height) {
- this.width = width;
- this.height = height;
- setSizePending = true;
- }
- private synchronized String createPositioningURL(String url) {
- IPath pluginPath = WorkbenchHelpPlugin.getDefault().getStateLocation();
- File outFile =
- pluginPath
- .append("mozillaPositon")
- .append("position.html")
- .toFile();
- try {
- outFile.getParentFile().mkdirs();
- PrintWriter writer =
- new PrintWriter(
- new BufferedWriter(
- new OutputStreamWriter(
- new FileOutputStream(outFile),
- "UTF8")),
- false);
- writer.println(
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
- writer.println("<html><head>");
- writer.println(
- "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
- writer.print("<title></title><script language=\"JavaScript\">");
- if (setSizePending)
- writer.print("window.resizeTo(" + width + "," + height + ");");
- if (setLocationPending)
- writer.print("window.moveTo(" + x + "," + y + ");");
- writer.print("location.replace(\"" + url + "\");");
- writer.print("</script></head><body>");
- writer.print("<a href=\"" + url + "\">--&gt;</a>");
- writer.print("</body></html>");
- writer.close();
- return "file://" + outFile.getAbsolutePath();
- } catch (IOException ioe) {
- // return the original url
- return url;
- }
- }
- private class BrowserThread extends Thread {
- public boolean exitRequested = false;
- private String url;
- public BrowserThread(String urlName) {
- this.url = urlName;
- }
- private int openBrowser(String browserCmd) {
- try {
- Process pr = Runtime.getRuntime().exec(browserCmd);
- (new StreamConsumer(pr.getInputStream())).start();
- (new StreamConsumer(pr.getErrorStream())).start();
- pr.waitFor();
- return pr.exitValue();
- } catch (InterruptedException e) {
- } catch (IOException e) {
- Logger.logError(
- WorkbenchResources.getString(
- "MozillaBrowserAdapter.executeFailed",
- executableName),
- e);
- try {
- Display.findDisplay(uiThread).asyncExec(new Runnable() {
- public void run() {
- ErrorUtil.displayErrorDialog(
- WorkbenchResources.getString(
- "MozillaBrowserAdapter.executeFailed",
- executableName));
- }
- });
- } catch (Exception e2) {
- }
- // return success so second command does not execute
- return 0;
- }
- return -1;
- }
- public void run() {
- // If browser is opening, wait until it fully opens,
- waitForBrowser();
- if (exitRequested)
- return;
- //workaround for bug 23750, mozilla bug 159092
- // instead of simply -remote openURL(" + url + ")", call a javascript
- if (openBrowser(executable
- + " -remote openURL(javascript:window.focus();window.location=\'"
- + url
- + "\')")
- == 0) {
- return;
- }
- if (exitRequested)
- return;
- browserFullyOpenedAt = System.currentTimeMillis() + DELAY;
- openBrowser(executable + " " + url);
- }
- private void waitForBrowser() {
- while (System.currentTimeMillis() < browserFullyOpenedAt)
- try {
- if (exitRequested)
- return;
- Thread.sleep(100);
- } catch (InterruptedException ie) {
- }
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaFactory.java
deleted file mode 100644
index d5e7eaf2b..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/MozillaFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser;
-import java.io.IOException;
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.help.ui.browser.*;
-import org.eclipse.help.ui.internal.util.StreamConsumer;
-public class MozillaFactory implements IBrowserFactory, IExecutableExtension {
- private String executable;
- private String executableName;
- private String os;
- private MozillaBrowserAdapter browserInstance = null;
- /**
- * Constructor.
- */
- public MozillaFactory() {
- super();
- }
- /*
- * @see IBrowserFactory#isAvailable()
- */
- public boolean isAvailable() {
- if (!System
- .getProperty("os.name")
- .toLowerCase()
- .startsWith(os.toLowerCase())) {
- return false;
- }
- try {
- Process pr = Runtime.getRuntime().exec("which " + executable);
- (new StreamConsumer(pr.getInputStream())).start();
- (new StreamConsumer(pr.getErrorStream())).start();
- pr.waitFor();
- int ret = pr.exitValue();
- if (ret == 0) {
- return true;
- }
- } catch (InterruptedException e) {
- } catch (IOException e) {
- // launching which failed, assume executable is present
- return true;
- }
- return false;
-
- }
- /*
- * @see IBrowserFactory#createBrowser()
- */
- public IBrowser createBrowser() {
- // Create single browser for all clients
- if (browserInstance == null) {
- browserInstance =
- new MozillaBrowserAdapter(executable, executableName);
- }
- return browserInstance;
- }
- /**
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- public void setInitializationData(
- IConfigurationElement config,
- String propertyName,
- Object data)
- throws CoreException {
- try {
- Hashtable params = (Hashtable) data;
- executable = (String) params.get("executable");
- executableName = (String) params.get("executableName");
- os = (String) params.get("os");
- } catch (Exception e) {
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- "org.eclipse.help.ui",
- IStatus.OK,
- "MozillaFactory.dataMissing",
- e));
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserAdapter.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserAdapter.java
index be6dce890..43415edcb 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserAdapter.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserAdapter.java
@@ -3,7 +3,7 @@
* All Rights Reserved.
*/
package org.eclipse.help.ui.internal.browser;
-import org.eclipse.help.ui.browser.IBrowser;
+import org.eclipse.help.browser.IBrowser;
import org.eclipse.help.ui.internal.util.*;
import org.eclipse.swt.program.Program;
/**
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserFactory.java
index 1c7df12a9..44cc5212e 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserFactory.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/SystemBrowserFactory.java
@@ -3,7 +3,7 @@
* All Rights Reserved.
*/
package org.eclipse.help.ui.internal.browser;
-import org.eclipse.help.ui.browser.*;
+import org.eclipse.help.browser.*;
public class SystemBrowserFactory implements IBrowserFactory {
/**
* Constructor.
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserAdapter.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserAdapter.java
deleted file mode 100644
index 43d9b95cf..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- *
- * Andre Weinand, OTI - Initial version
- */
-package org.eclipse.help.ui.internal.browser.macosx;
-
-import java.io.IOException;
-
-import org.eclipse.help.ui.browser.IBrowser;
-
-public class DefaultBrowserAdapter implements IBrowser {
-
- private static DefaultBrowserAdapter fgInstance;
-
- static DefaultBrowserAdapter getInstance() {
- if (fgInstance == null)
- fgInstance= new DefaultBrowserAdapter();
- return fgInstance;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#close()
- */
- public void close() {
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#displayURL(String)
- */
- public void displayURL(String url) {
- /*
- * Code from Marc-Antoine Parent
- */
- try {
- Runtime.getRuntime().exec(
- new String[] {
- "/usr/bin/osascript",
- "-e",
- "open location \"" + url +"\""
- }
- );
- } catch (IOException e) {
- // ignore silently
- }
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isCloseSupported()
- */
- public boolean isCloseSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetLocationSupported()
- */
- public boolean isSetLocationSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#isSetSizeSupported()
- */
- public boolean isSetSizeSupported() {
- return false;
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setLocation(int, int)
- */
- public void setLocation(int x, int y) {
- }
-
- /**
- * @see org.eclipse.help.ui.browser.IBrowser#setSize(int, int)
- */
- public void setSize(int width, int height) {
- }
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserFactory.java
deleted file mode 100644
index 5404a680d..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/macosx/DefaultBrowserFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- *
- * Andre Weinand, OTI - Initial version
- */
-package org.eclipse.help.ui.internal.browser.macosx;
-
-import org.eclipse.help.ui.browser.*;
-
-
-public class DefaultBrowserFactory implements IBrowserFactory {
-
- public DefaultBrowserFactory() {
- super();
- }
-
- /*
- * @see IBrowserFactory#isAvailable()
- */
- public boolean isAvailable() {
- return System.getProperty("os.name").equals("Mac OS X");
- /*
- * we assume that every Mac OS X has an "/usr/bin/osascript"
- * so we don't test any further
- */
- }
-
- /*
- * @see IBrowserFactory#createBrowser()
- */
- public IBrowser createBrowser() {
- return DefaultBrowserAdapter.getInstance();
- }
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeBrowserAdapter.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeBrowserAdapter.java
deleted file mode 100644
index 98749d309..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeBrowserAdapter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser.solaris;
-import java.io.IOException;
-
-import org.eclipse.help.internal.util.Logger;
-import org.eclipse.help.ui.browser.IBrowser;
-import org.eclipse.help.ui.internal.util.*;
-import org.eclipse.swt.widgets.Display;
-public class NetscapeBrowserAdapter implements IBrowser {
- // delay that it takes the browser to start responding
- // to remote command after browser command has been called
- private static final int DELAY = 5000;
- private static long browserFullyOpenedAt = 0;
- private static boolean opened = false;
- private static NetscapeBrowserAdapter instance;
- private static Thread uiThread;
- /**
- * Constructor
- */
- NetscapeBrowserAdapter() {
- uiThread = Thread.currentThread();
- }
- /*
- * @see IBrowser#close()
- */
- public void close() {
- }
- /*
- * @see IBrowser#displayURL(String)
- */
- public synchronized void displayURL(String url) {
- new BrowserThread(url).start();
- }
- /*
- * @see IBrowser#isCloseSupported()
- */
- public boolean isCloseSupported() {
- return false;
- }
- /*
- * @see IBrowser#isSetLocationSupported()
- */
- public boolean isSetLocationSupported() {
- return false;
- }
- /*
- * @see IBrowser#isSetSizeSupported()
- */
- public boolean isSetSizeSupported() {
- return false;
- }
- /*
- * @see IBrowser#setLocation(int, int)
- */
- public void setLocation(int width, int height) {
- }
- /*
- * @see IBrowser#setSize(int, int)
- */
- public void setSize(int x, int y) {
- }
- private class BrowserThread extends Thread {
- private String url;
- public BrowserThread(String urlName) {
- this.url = urlName;
- }
- private void reuseBrowser(String browserCmd) {
- try {
- // If browser is opening, wait until it fully opens,
- while (System.currentTimeMillis() < browserFullyOpenedAt)
- try {
- Thread.sleep(100);
- } catch (InterruptedException ie) {
- }
- Process pr = Runtime.getRuntime().exec(browserCmd);
- (new StreamConsumer(pr.getInputStream())).start();
- (new StreamConsumer(pr.getErrorStream())).start();
- pr.waitFor();
- } catch (InterruptedException e) {
- } catch (IOException e) {
- }
- }
- public void run() {
- if (!opened) {
- openBrowser("netscape " + url);
- } else {
- reuseBrowser("netscape -remote openURL(" + url + ")");
- }
- }
- }
- public static synchronized void openBrowser(String browserCmd) {
- opened = true;
- browserFullyOpenedAt = System.currentTimeMillis() + DELAY;
- try {
- Process pr = Runtime.getRuntime().exec(browserCmd);
- (new StreamConsumer(pr.getInputStream())).start();
- (new StreamConsumer(pr.getErrorStream())).start();
- pr.waitFor();
- } catch (InterruptedException e) {
- } catch (IOException e) {
- Logger.logError(
- WorkbenchResources.getString(
- "NetscapeBrowserAdapter.executeFailed"),
- e);
- try {
- Display.findDisplay(uiThread).asyncExec(new Runnable() {
- public void run() {
- ErrorUtil.displayErrorDialog(
- WorkbenchResources.getString(
- "NetscapeBrowserAdapter.executeFailed"));
- }
- });
- } catch (Exception e2) {
- }
- } finally {
- opened = false;
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeFactory.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeFactory.java
deleted file mode 100644
index c874b9729..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/solaris/NetscapeFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.browser.solaris;
-import org.eclipse.help.ui.browser.*;
-public class NetscapeFactory implements IBrowserFactory {
- private NetscapeBrowserAdapter browserInstance = null;
- /**
- * Constructor.
- */
- public NetscapeFactory() {
- super();
- }
- /*
- * @see IBrowserFactory#isAvailable()
- */
- public boolean isAvailable() {
- return System.getProperty("os.name").toLowerCase().startsWith(
- "SunOS".toLowerCase());
- }
- /*
- * @see IBrowserFactory#createBrowser()
- */
- public IBrowser createBrowser() {
- // Create single browser for all clients
- if (browserInstance == null) {
- browserInstance = new NetscapeBrowserAdapter();
- }
- return browserInstance;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/BrowserLog.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/BrowserLog.java
deleted file mode 100644
index ff2cea95a..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/BrowserLog.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-package org.eclipse.help.ui.internal.util;
-
-import java.io.*;
-import java.text.*;
-import java.util.Date;
-
-import org.eclipse.help.ui.internal.WorkbenchHelpPlugin;
-
-/**
- * Log for messages output by external browser processes.
- */
-public class BrowserLog {
- private static BrowserLog instance;
- private String logFileName;
- private boolean newSession;
- DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy kk:mm:ss.SS");
- String LN=System.getProperty("line.separator");
- /**
- * Constructor
- */
- private BrowserLog() {
- try {
- newSession = true;
- logFileName =
- WorkbenchHelpPlugin
- .getDefault()
- .getStateLocation()
- .append("browser.log")
- .toOSString();
- } catch (Exception e) {
- // can get here if platform is shutting down
- }
- }
- /**
- * Obtains singleton
- */
- private static BrowserLog getInstance() {
- if (instance == null) {
- instance = new BrowserLog();
- }
- return instance;
- }
- /**
- * Appends a line to the browser.log
- */
- public static synchronized void log(String message) {
- getInstance().append(message);
- }
- private void append(String message) {
- if (logFileName == null) {
- return;
- }
- Writer outWriter = null;
- try {
- outWriter =
- new BufferedWriter(
- new OutputStreamWriter(
- new FileOutputStream(logFileName, true),
- "UTF-8"));
- if (newSession) {
- newSession = false;
- outWriter.write(
- LN + formatter.format(new Date()) + " NEW SESSION"+LN);
- }
- outWriter.write(
- formatter.format(new Date()) + " " + message + LN);
- outWriter.flush();
- outWriter.close();
- } catch (Exception e) {
- if (outWriter != null) {
- try {
- outWriter.close();
- } catch (IOException ioe) {
- }
- }
- }
- }
-}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/ErrorUtil.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/ErrorUtil.java
index 7762381a8..39142c64f 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/ErrorUtil.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/ErrorUtil.java
@@ -5,12 +5,26 @@ package org.eclipse.help.ui.internal.util;
*/
import org.eclipse.help.internal.util.*;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
/**
* Utiliy class for common error displaying tasks.
*/
-public class ErrorUtil {
+public class ErrorUtil implements IErrorUtil {
+ public void displayError(String msg) {
+ displayErrorDialog(msg);
+ }
+
+ public void displayError(final String msg, Thread uiThread) {
+ try {
+ Display.findDisplay(uiThread).asyncExec(new Runnable() {
+ public void run() {
+ displayErrorDialog(msg);
+ }
+ });
+ } catch (Exception e2) {
+ }
+ }
/**
* Immidiately displays error dialog with a given string,
* also logs the error using Logger.logError().
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/StreamConsumer.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/StreamConsumer.java
deleted file mode 100644
index 95c122f48..000000000
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/StreamConsumer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.eclipse.help.ui.internal.util;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.*;
-
-import org.eclipse.help.internal.util.Logger;
-/**
- * Used to receive output from processes
- */
-public class StreamConsumer extends Thread {
- BufferedReader bReader;
- public StreamConsumer(InputStream inputStream) {
- super();
- setDaemon(true);
- bReader = new BufferedReader(new InputStreamReader(inputStream));
- }
- public void run() {
- try {
- String line;
- while (null != (line = bReader.readLine())) {
- BrowserLog.log(line);
- }
- bReader.close();
- } catch (IOException ioe) {
- Logger.logError(WorkbenchResources.getString("WE025"), ioe);
- }
- }
-} \ No newline at end of file

Back to the top