diff options
author | Konrad Kolosowski | 2005-04-06 16:08:53 +0000 |
---|---|---|
committer | Konrad Kolosowski | 2005-04-06 16:08:53 +0000 |
commit | 05bee1fb4c2e4360be3fd4621393248e94046efe (patch) | |
tree | 8b8361092af18442eb0971289e8a9dc59e3f5777 | |
parent | 0edc580dffd2c5aa6ccb12d4554cd95993269503 (diff) | |
download | eclipse.platform.ua-perf_301.tar.gz eclipse.platform.ua-perf_301.tar.xz eclipse.platform.ua-perf_301.zip |
*** empty log message ***perf_301
62 files changed, 0 insertions, 5245 deletions
diff --git a/org.eclipse.help/.classpath b/org.eclipse.help/.classpath deleted file mode 100644 index 065ac06e1..000000000 --- a/org.eclipse.help/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/org.eclipse.help/.cvsignore b/org.eclipse.help/.cvsignore deleted file mode 100644 index a05a9c026..000000000 --- a/org.eclipse.help/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -bin -build.xml -help.jar -help.jar.bin.log -org.eclipse.help_*
\ No newline at end of file diff --git a/org.eclipse.help/.options b/org.eclipse.help/.options deleted file mode 100644 index adc49bf89..000000000 --- a/org.eclipse.help/.options +++ /dev/null @@ -1,3 +0,0 @@ -org.eclipse.help/debug = true -org.eclipse.help/debug/context = false -org.eclipse.help/debug/protocols = false diff --git a/org.eclipse.help/.project b/org.eclipse.help/.project deleted file mode 100644 index 6718fa07e..000000000 --- a/org.eclipse.help/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.help</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.pde.PluginNature</nature> - </natures> -</projectDescription> diff --git a/org.eclipse.help/about.html b/org.eclipse.help/about.html deleted file mode 100644 index 9db411aab..000000000 --- a/org.eclipse.help/about.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> -<html> -<head> -<title>About</title> -<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>20th June, 2002</p> -<h3>License</h3> -<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>. -For purposes of the CPL, "Program" will mean the Content.</p> - -<h3>Contributions</h3> - -<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise -made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such -Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p> - -<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or -other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the -host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available -to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also -providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of -the CPL.</p> - -</body> -</html>
\ No newline at end of file diff --git a/org.eclipse.help/build.properties b/org.eclipse.help/build.properties deleted file mode 100644 index 7ba1a6267..000000000 --- a/org.eclipse.help/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -source.help.jar=src/ -src.includes=schema/,about.html -bin.includes=dtd/,livehelp.js,plugin.xml,preferences.ini,*.jar,plugin.properties,about.html,.options - diff --git a/org.eclipse.help/dtd/contexts.dtd b/org.eclipse.help/dtd/contexts.dtd deleted file mode 100644 index e1897422f..000000000 --- a/org.eclipse.help/dtd/contexts.dtd +++ /dev/null @@ -1,13 +0,0 @@ - -<!ELEMENT contexts (context)* > - -<!ELEMENT context (description, topic*) > -<!ATTLIST context id ID #REQUIRED > - -<!ELEMENT description (#PCDATA|b)* > - -<!ELEMENT b (#PCDATA)* > - -<!ELEMENT topic EMPTY > -<!ATTLIST topic label CDATA #REQUIRED > -<!ATTLIST topic href CDATA #IMPLIED > diff --git a/org.eclipse.help/dtd/toc.dtd b/org.eclipse.help/dtd/toc.dtd deleted file mode 100644 index bb251085e..000000000 --- a/org.eclipse.help/dtd/toc.dtd +++ /dev/null @@ -1,14 +0,0 @@ -<!ELEMENT toc (topic | anchor | link)* > -<!ATTLIST toc link_to CDATA #IMPLIED > -<!ATTLIST toc label CDATA #REQUIRED > -<!ATTLIST toc topic CDATA #IMPLIED > - -<!ELEMENT topic (topic | anchor | link )* > -<!ATTLIST topic label CDATA #REQUIRED > -<!ATTLIST topic href CDATA #IMPLIED > - -<!ELEMENT anchor EMPTY > -<!ATTLIST anchor id ID #REQUIRED > - -<!ELEMENT link EMPTY > -<!ATTLIST link toc CDATA #REQUIRED > diff --git a/org.eclipse.help/livehelp.js b/org.eclipse.help/livehelp.js deleted file mode 100644 index 835c217df..000000000 --- a/org.eclipse.help/livehelp.js +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -/** - * Private helper function for use by other (public) functions. - */ -function findHelpTop() { - var helpTop; - for (helpTop=self; helpTop; helpTop = helpTop.parent){ - if (helpTop.liveActionInternal){ - break; - } - if (helpTop==helpTop.parent){ - break; - } - } - return helpTop; -} - -/** - * Call this Javascript method to trigger a specified live help action - * in the workbench. - * The parameters for liveAction are: - * - the id of the plug-in that contains the action - * - the name of the class that implements the action - * - the String that will be passed to the live help action using setInitializationString - */ - -function liveAction(pluginId, className, argument) -{ - // find top help frameset - var helpTop=findHelpTop(); - if (helpTop != null && helpTop.liveActionInternal){ - return helpTop.liveActionInternal(helpTop, pluginId, className, argument); - } -} - -/** - * Show specified topic in the Contents tree. - * The topic must be passed as a URL string. - * Example: - * // include the script first - * <script src="../org.eclipse.help/livehelp.js"></script> - * ...... - * // show specified topic in the tree - * showTopicInContents(window.location.href); - */ -function showTopicInContents(topic) { - var helpTop=findHelpTop(); - if (helpTop != null && helpTop.showTopicInContentsInternal){ - return helpTop.showTopicInContentsInternal(helpTop, topic); - } -} diff --git a/org.eclipse.help/plugin.properties b/org.eclipse.help/plugin.properties deleted file mode 100644 index 6181f1f30..000000000 --- a/org.eclipse.help/plugin.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -help_plugin_name = Help System Core -providerName=Eclipse.org -toc_extension_point_name = Help Table of Contents Contributions -contexts_extension_point_name = Context Help -content_producer_extension_point_name = Help Content Producer diff --git a/org.eclipse.help/plugin.xml b/org.eclipse.help/plugin.xml deleted file mode 100644 index eaec99e42..000000000 --- a/org.eclipse.help/plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="org.eclipse.help" - name="%help_plugin_name" - version="3.0.0" - provider-name="%providerName" - class="org.eclipse.help.internal.HelpPlugin"> - - <runtime> - <library name="help.jar"> - <export name="*"/> - <packages prefixes="org.eclipse.help"/> - </library> - </runtime> - <requires> - <import plugin="org.eclipse.core.runtime"/> - </requires> - - -<!-- Extension points --> - <extension-point id="contexts" name="%contexts_extension_point_name" schema="schema/contexts.exsd"/> - <extension-point id="toc" name="%toc_extension_point_name" schema="schema/toc.exsd"/> - <extension-point id="contentProducer" name="%content_producer_extension_point_name" schema="schema/contentProducer.exsd"/> - -</plugin> diff --git a/org.eclipse.help/preferences.ini b/org.eclipse.help/preferences.ini deleted file mode 100644 index 2c57c6b49..000000000 --- a/org.eclipse.help/preferences.ini +++ /dev/null @@ -1,9 +0,0 @@ -# Toc ordering. Ordered list of help TOC's (books) as they would appear -# on the bookshelf. All the other TOCS will be follow these books. -# Non-present TOC's on this list will be ignored. Use the location of each TOC -# as /pluginId/path/to/toc.xml. -baseTOCS= /org.eclipse.platform.doc.user/toc.xml,\ - /org.eclipse.jdt.doc.user/toc.xml,\ - /org.eclipse.platform.doc.isv/toc.xml,\ - /org.eclipse.jdt.doc.isv/toc.xml,\ - /org.eclipse.pde.doc.user/toc.xml diff --git a/org.eclipse.help/schema/contentProducer.exsd b/org.eclipse.help/schema/contentProducer.exsd deleted file mode 100644 index a3201938c..000000000 --- a/org.eclipse.help/schema/contentProducer.exsd +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.help"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.help" id="contentProducer" name="Help Content Producer"/> - </appInfo> - <documentation> - For providing dynamic, generated at run time, help content. - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="contentProducer" minOccurs="0" maxOccurs="1"/> - </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="contentProducer"> - <complexType> - <sequence> - <element ref="producer"/> - </sequence> - <attribute name="producer" type="string"> - <annotation> - <documentation> - the implementation class for the help content producer. This class must implement the <samp>org.eclipse.help.IHelpContentProducer</samp> interface. This attribute may be omitted, and the nested <samp>producer</samp> element may be provided instead. - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.help.IHelpContentProducer"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="producer"> - <complexType> - <sequence> - <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - the implementation class for the help content producer. This class must implement the <samp>org.eclipse.help.IHelpContentProducer</samp> interface. - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.help.IHelpContentProducer"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="parameter"> - <complexType> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - name of a parameter passed to the implementation class - </documentation> - </annotation> - </attribute> - <attribute name="value" type="string" use="required"> - <annotation> - <documentation> - value of a parameter passed to the implementation class - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - 3.0 - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - The following is a sample usage of the browser extension point: - -<p> -<pre> - <extension point="org.eclipse.help.contentProducer" - id="org.eclipse.myPlugin.myDynamicHelpProducer" - name="My Dynamic Help Content"> - <contentProducer producer="org.eclipse.myPlugin.myPackage.Myproducer" /> - </extension> -</pre> -</p> - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - The supplied content producer class must implement the <samp>org.eclipse.help.IHelpContentProducer</samp> interface. -The producer is responsible for providing content for dynamic help resources from a plug-in. The method of content producer is called by help for every help resource obtained from the plug-in. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - None. If a documentation plug-in does not provide help content producer or a call to it results in null, help system searches doc.zip and file system in the plug-in install location for a static document and displays its content. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - Copyright (c) 2000, 2003 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made -available under the terms of the Common Public License v1.0 which accompanies -this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - </documentation> - </annotation> - -</schema> diff --git a/org.eclipse.help/schema/contexts.exsd b/org.eclipse.help/schema/contexts.exsd deleted file mode 100644 index b96a1e3b5..000000000 --- a/org.eclipse.help/schema/contexts.exsd +++ /dev/null @@ -1,170 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.help"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.help" id="contexts" name="Contexts"/> - </appInfo> - <documentation> - For defining context-sensitive help for an -individual plug-in. - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="contexts" 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="contexts"> - <complexType> - <attribute name="file" type="string" use="required"> - <annotation> - <documentation> - the name of the manifest file which contains the context-sensitive help documentation for this plug-in. -<p> -<i><b>Configuration Markup for what goes into the -contexts manifest file:</b></i> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT contexts (context)* ) ></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT context (description?,topic*) ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST context id ID #REQUIRED ></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT description (#PCDATA)></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT topic EMPTY ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST topic label CDATA #REQUIRED ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST topic href CDATA #IMPLIED ></tt> -<p>The contexts manifest files provide all the information needed when -context-sensitive help is requested by the user. The id is passed by the -platform to identify the currently active context. The context definitions -with matching IDs are then retrieved. The IContext object is then created -by help system that contains descriptions and topics from all context definitions -for a given ID.&nbsp; The description is to be displayed to the user, and -related topics might be useful to the user for understanding the current -context.&nbsp; The related topic are html files packaged in doc.zip, together -with topics that are part of on line help. -</p> - </documentation> - <appInfo> - <meta.attribute kind="resource"/> - </appInfo> - </annotation> - </attribute> - <attribute name="plugin" type="string"> - <annotation> - <documentation> - Plugin to which its context definitions are extended with extra information. -<p>If a plugin defines some context id's, one can extend the description or related links of a context by declaring another context with the same id.</p> - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - The following is an example of using the contexts -extension point: -<br> -(in file <tt>plugin.xml</tt>) -<p> -<pre> - <extension point="org.eclipse.help.contexts"> - <contexts file="xyzContexts.xml"/> - </extension> -</pre> -</p> - -<p>(in file <tt>xyzContexts.xml</tt>) -<p><tt>&nbsp;&nbsp;&nbsp; &lt;contexts></tt> -<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;context&nbsp; id="generalContextId"></tt> -<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description> This -is a sample F1 help string.&lt;/description></tt> -<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;topic href="contexts/RelatedContext1.html"&nbsp; -label="Help Related Topic 1"/></tt> -<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;topic href="contexts/RelatedContext2.html"&nbsp; -label="Help Related Topic 2"/></tt> -<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/context></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;/contexts></tt> -<br>&nbsp; -</p> - -<b><em>Externalizing Strings</em></b> -The Context XML files can be translated and the resulting copy (with translated -descriptions labels) should be placed in nl/&lt;language>/&lt;country> -or nl/&lt;language> directory.&nbsp; The &lt;language> and &lt;country> -stand for two letter language and country codes as used in locale codes.&nbsp; -For example, Traditional Chinese translations should be placed in the nl/zh/TW -directory.&nbsp; The nl/&lt;language>/&lt;country> directory has a higher -priority than nl/&lt;language>.&nbsp; Only if no file is found in the nl/&lt;language>/&lt;country>, -the file residing in nl/&lt;language> will be used.&nbsp; The the root -directory of a plugin will be searched last. -<p>The related topics contained in doc.zip can be localized by creating -a doc.zip file with translated version of documents, and placing doc.zip -in -<br>nl/&lt;language>/&lt;country> or nl/&lt;language> directory. The help -system will look for the files under this directories before defaulting -to plugin directory. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - No code is required to use this extension point. All -that is needed is to supply the appropriate manifest -file(s) mentioned in the plugin.xml file. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - The optional default implementation of the help -system UI supplied with the Eclipse platform -fully supports the <samp>contexts</samp> extension point. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - Copyright (c) 2000, 2003 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made -available under the terms of the Common Public License v1.0 which accompanies -this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - </documentation> - </annotation> - -</schema> diff --git a/org.eclipse.help/schema/toc.exsd b/org.eclipse.help/schema/toc.exsd deleted file mode 100644 index b165f65bf..000000000 --- a/org.eclipse.help/schema/toc.exsd +++ /dev/null @@ -1,294 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.help"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.help" id="toc" name="Table of Contents (TOC)"/> - </appInfo> - <documentation> - For registering an online help contribution for an individual plug-in. - -<p>Each plug-in that contributes help files should in general do the following: -<ul> -<ul> -<li> -author the html files, zip html files into doc.zip, and store the zip file -in the plug-in directory.</li> - -<li> -create TOC files that describe Table of Contents for the help and the necessary -topic interleaving. See the syntax below.</li> - -<li> -the plugin.xml file should extend the <tt>org.eclipse.help.toc</tt> extension -point and specify TOC file(s).</li> -</ul> -</ul> - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="toc" 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="toc"> - <complexType> - <attribute name="file" type="string" use="required"> - <annotation> - <documentation> - the name of the TOC file which contains the table of contents or section for this plug-in's online help. -<p> -<i><b>Configuration Markup for toc file:</b></i> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT toc (topic | anchor | link)* ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST toc link_to CDATA #IMPLIED ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST toc label CDATA #REQUIRED ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST toc topic CDATA #IMPLIED ></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT topic (topic | anchor | link )* -></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST topic label CDATA #REQUIRED ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST topic href CDATA #IMPLIED ></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT anchor EMPTY ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST anchor id ID&nbsp; #REQUIRED ></tt> -<p><tt>&nbsp;&nbsp;&nbsp; &lt;!ELEMENT link EMPTY ></tt> -<br><tt>&nbsp;&nbsp;&nbsp; &lt;!ATTLIST link toc CDATA #REQUIRED ></tt> -<p>In general, a plug-in that needs to provide online help will define -its own TOC files. In the end, the help system is configured to be launched -as some actions, and the path of the TOC file can be used to do so. -<p><b>The topic element</b> -<p>All help topic element are contributed as part of the toc container -element. They can have a hierarchical structure, or can be listed as a -flat list. -<p>The topic element is the workhorse of structure of Table of Contents. -There are two typical uses for the topic element: -<p>1.&nbsp; To provide a link to a documentation file - usually an HTML -file. -<br>2.&nbsp; To act as a container for other toc, either in the same manifest -or another. -<p><b><i>1.&nbsp; Topics as links</i></b> -<br>The simplest use of a topic is as a link to a documentation file. -<p><tt>&lt;topic label="Some concept file" href="concepts/some_file.html" -/></tt> -<p>The href attribute is relative to the plug-in that the manifest file -belongs to.&nbsp; If you need to access a file in another plug-in, you -can use the syntax -<p><tt>&lt;topic label="topic in another plug-in" href="../other.plugin.id/concepts/some_other_file.html" -/></tt> -<p><b><i>2.&nbsp; Topics as containers</i></b> -<br>The next most common use of a topic is to use it as a container for -other toc.&nbsp; The container topic itself can always refer to a particular -file as well. -<p><tt>&lt;topic label="Integrated Development Environment" href="concepts/ciover.htm" -></tt> -<br><tt>&nbsp; &lt;topic label="Starting the IDE" href="concepts/blah.htm" -/></tt> -<br><tt>&nbsp; ...</tt> -<br><tt>&lt;/topic></tt> -<p><b>The link element</b> -<p>The link element allows to link Table of Contents defined in another -toc file.&nbsp; All the topics from the toc file specified in the toc attribute -will appear in the table of contents as if they were defined directly in -place of the link element.&nbsp; To include toc from api.xml file you could -write -<p><tt>&lt;topic label="References" ></tt> -<br><tt>&nbsp; ...</tt> -<br><tt>&nbsp; &lt;link toc="api.xml" /></tt> -<br><tt>&nbsp; ...</tt> -<br><tt>&lt;/topic></tt> -<p><b>The anchor element</b> -<p>The anchor element defines a point that will allow linking other toc -files to this navigation, and extending it, without using the link element -and referencing other toc files from here.&nbsp; To allow inserting Table -of Contents with more topics after the "ZZZ" document you would define -an anchor as follows: -<p><tt>...</tt> -<br><tt>&lt;topic label="zzz" href="zzz.html" /></tt> -<br><tt>&lt;anchor id="moreapi" /></tt> -<br><tt>...</tt> -<p><b>The toc element</b> -<p>The toc element is a Table of Contents that groups topics and other -elements defined in this file.&nbsp; The label identifies the table of -contents to the user, when it is displayed to the user.&nbsp; The optional topic -attribute is the path to a topic file describing the TOC.&nbsp; The optional -link_to attribute allows for linking toc from this file into another toc -file being higher in the navigation hierarchy.&nbsp; The value of the link_to -attribute must specify an anchor in another toc file. To link toc from -myapi.xml to api.xml file, specified in another plugin you would use -the syntax -<p><tt>&lt;toc link_to="../anotherPlugin/api.xml#moreapi" label="My Tool -API"/></tt> -<br><tt>...</tt> -<br><tt>&lt;toc /></tt> -<p>where # character separates toc file name from the anchor identifier. -</p> -<br> - </documentation> - <appInfo> - <meta.attribute kind="resource"/> - </appInfo> - </annotation> - </attribute> - <attribute name="primary" type="boolean" use="default" value="false"> - <annotation> - <documentation> - specifies whether the TOC file is a primary table of contents and is meant to be the master table of contents, -or not primary and intended to be integrated into another table of contents. - </documentation> - </annotation> - </attribute> - <attribute name="extradir" type="string"> - <annotation> - <documentation> - specifies relative directory name of containing additional documents that are associated with the table of contents. -All help documents in this directory, and all subdirectories, will be indexed, and accessible through -the documentation search, even if <samp>topic</samp> elements in the TOC file do not refer to these documents. - </documentation> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - The following is an example of using the <samp>toc</samp> extension point. - -<p>(in file <tt>plugin.xml</tt>) -<pre> - <extension point="org.eclipse.help.toc"> - <toc file="maindocs.html" primary="true"/> - <toc file="task.xml"/> - <toc file="sample.xml" extradir="samples"/> - </extension> -</pre> -</p> - -<p>(in file <tt>maindocs.xml</tt>) -<blockquote><tt>&lt;toc label="Help System Example"></tt> -<br><tt>&nbsp;&lt;topic label="Introduction" href="intro.html"/></tt> -<br><tt>&nbsp;&lt;topic label="Tasks"></tt> -<br><tt>&nbsp; &lt;topic label="Creating a Project" href="tasks/task1.html"></tt> -<br><tt>&nbsp;&nbsp; &lt;topic label="Creating a Web Project" href="tasks/task11.html"/></tt> -<br><tt>&nbsp;&nbsp; &lt;topic label="Creating a Java Project" href="tasks/task12.html"/></tt> -<br><tt>&nbsp; &lt;/topic></tt> -<br><tt>&nbsp; &lt;link toc="task.xml" /></tt> -<br><tt>&nbsp; &lt;topic label="Testing a Project" href="tasks/taskn.html"/></tt> -<br><tt>&nbsp;&lt;/topic></tt> -<br><tt>&nbsp;&lt;topic label="Samples"></tt> -<br><tt>&nbsp; &lt;topic label="Creating Java Project" href="samples/sample1.html"></tt> -<br><tt>&nbsp;&nbsp; &lt;topic label="Launch a Wizard" href="samples/sample11.html"/></tt> -<br><tt>&nbsp;&nbsp; &lt;topic label="Set Options" href="samples/sample12.html"/></tt> -<br><tt>&nbsp;&nbsp; &lt;topic label="Finish Creating Project" href="samples/sample13.html"/></tt> -<br><tt>&nbsp; &lt;/topic></tt> -<br><tt>&nbsp; &lt;anchor id="samples" /></tt> -<br><tt>&nbsp;&lt;/topic></tt> -<br><tt>&lt;/toc></tt></blockquote> - -<p><br>(in file <tt>tasks.xml</tt>) -<blockquote><tt>&lt;toc label="Building a Project"></tt> -<br><tt>&nbsp;&lt;topic label="Building a Project" href="build/building.html"></tt> -<br><tt>&nbsp; &lt;topic label="Building a Web Project" href="build/web.html"/></tt> -<br><tt>&nbsp; &lt;topic label="Building a Java Project" href="build/java.html"/></tt> -<br><tt>&nbsp;&lt;/topic></tt> -<br><tt>&lt;/toc></tt></blockquote> - -<p><br>(in file <tt>samples.xml</tt>) -<blockquote><tt>&lt;toc link_to="maindocs.xml#samples" label="Using The -Compile Tool"></tt> -<br><tt>&nbsp;&lt;topic label="The Compile Tool Sample" href="compilesample/example.html"></tt> -<br><tt>&nbsp; &lt;topic label="Step 1" href="compilesample/step1.html"/></tt> -<br><tt>&nbsp; &lt;topic label="Step 2" href="compilesample/step2.html"/></tt> -<br><tt>&nbsp; &lt;topic label="Step 3" href="compilesample/step3.html"/></tt> -<br><tt>&nbsp; &lt;topic label="Step 4" href="compilesample/step4.html"/></tt> -<br><tt>&nbsp;&lt;/topic></tt> -<br><tt>&lt;/toc></tt></blockquote> - - -<p>Assuming more documents exists with the path starting with "samples", -they will not be displayed in the navigation tree, but be accessible using -search.&nbsp; It is due to the presence of "extradir" attribute in the -element <tt>&lt;toc file="sample.xml" extradir="samples" /> </tt>inside<tt> -plugin.xml </tt>file. For example searching for "Creating Java Project" -could return a document "Other Ways of Creating Java Project", which path -is <tt>samples/sample2.html.</tt> - -<p> -<b><em>Internationalization</em></b> -The TOC XML files can be translated and the resulting copy (with translated -labels) should be placed in nl/&lt;language>/&lt;country> or nl/&lt;language> -directory.&nbsp; The &lt;language> and &lt;country> stand for two letter -language and country codes as used in locale codes.&nbsp; For example, -Traditional Chinese translations should be placed in the nl/zh/TW directory.&nbsp; -The nl/&lt;language>/&lt;country> directory has a higher priority than -nl/&lt;language>.&nbsp; Only if no file is found in the nl/&lt;language>/&lt;country>, -the file residing in nl/&lt;language> will be used.&nbsp; The the root -directory of a plugin will be searched last. -<p>The documentation contained in doc.zip can be localized by creating -a doc.zip file with translated version of documents, and placing doc.zip -in -<br>nl/&lt;language>/&lt;country> or nl/&lt;language> directory. The help -system will look for the files under this directories before defaulting -to plugin directory. -<br>&nbsp; -</p> - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - No code is required to use this extension point. All that is needed is to supply the appropriate manifest -files mentioned in the plugin.xml file. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - The default implementation of the help system UI supplied with the Eclipse platform fully supports the <samp>toc</samp> extension point. - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - Copyright (c) 2000, 2003 IBM Corporation and others.<br> -All rights reserved. This program and the accompanying materials are made -available under the terms of the Common Public License v1.0 which accompanies -this distribution, and is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a> - </documentation> - </annotation> - -</schema> diff --git a/org.eclipse.help/src/org/eclipse/help/HelpSystem.java b/org.eclipse.help/src/org/eclipse/help/HelpSystem.java deleted file mode 100644 index 48f4dba4e..000000000 --- a/org.eclipse.help/src/org/eclipse/help/HelpSystem.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; - -import java.io.*; -import java.net.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.internal.*; -import org.eclipse.help.internal.protocols.*; - -/** - * This class provides general access to help content contributed to the - * <code>"org.eclipse.help.toc"</code> and - * <code>"org.eclipse.help.contexts"</code> extension points. - * <p> - * This class provides static methods only; it is not intended to be - * instantiated or subclassed. - * </p> - * - * @since 3.0 - */ -public final class HelpSystem { - - /** - * This class is not intended to be instantiated. - */ - private HelpSystem() { - // do nothing - } - - /** - * Computes and returns context information for the given context id. - * - * @param contextId - * the context id - * @return the context, or <code>null</code> if none - */ - public static IContext getContext(String contextId) { - return HelpPlugin.getContextManager().getContext(contextId); - } - - /** - * Returns the list of all integrated tables of contents available. Each - * entry corresponds of a different help "book". - * - * @return an array of TOC's - */ - public static IToc[] getTocs() { - return HelpPlugin.getTocManager().getTocs(Platform.getNL()); - } - - /** - * Returns an open input stream on the contents of the specified help - * resource. The client is responsible for closing the stream when finished. - * - * @param href - * the URL (as a string) of the help resource - * <p> - * Valid href are as described in - * {@link org.eclipse.help.IHelpResource#getHref IHelpResource.getHref} - * </p> - * @return an input stream containing the contents of the help resource, or - * <code>null</code> if the help resource could not be found and - * opened - */ - public static InputStream getHelpContent(String href) { - try { - // URL helpURL = new URL("help:" + href); - URL helpURL = new URL("help", //$NON-NLS-1$ - null, -1, href, HelpURLStreamHandler.getDefault()); - - return helpURL.openStream(); - } catch (IOException ioe) { - return null; - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/IContext.java b/org.eclipse.help/src/org/eclipse/help/IContext.java deleted file mode 100644 index a9cb03d78..000000000 --- a/org.eclipse.help/src/org/eclipse/help/IContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; -/** - * A context registered for context-sensitive help. - * <p> - * This interface models the context-sensitive help that can be associated with - * SWT menus, menu items, and controls, and with JFace actions. A help context - * provides the text description of the object with which it is associated with, - * as well as topic links that contain more related information. This - * information would be displayed to the user when context sensitive help (F1) - * is requested. - * </p> - * <p> - * In the current implementation of the Help system, valid contexts can be - * contributed through the <code>contexts</code> element of the - * <code>"org.eclipse.help.contexts"</code> extension point. The - * <code>IHelp.findContext(String)</code> method is used at runtime to create - * or fetch IContext objects using there fully qualified contextIds. If there is - * a need to override this behavior, then this IContext interface could be - * implemented by a client and registered with the SWT control or JFace action. - * </p> - */ -public interface IContext { - /** - * Returns a list of related topics for this help context. - * - * @return a list of related help topics - * @since 2.0 - */ - public IHelpResource[] getRelatedTopics(); - /** - * Returns the text description for this context. - * - * @return the text description - */ - public String getText(); -} diff --git a/org.eclipse.help/src/org/eclipse/help/IHelp.java b/org.eclipse.help/src/org/eclipse/help/IHelp.java deleted file mode 100644 index 647f8a3c3..000000000 --- a/org.eclipse.help/src/org/eclipse/help/IHelp.java +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; -/** - * Former interface to the help system UI. - * - * @deprecated This interface became obsolete in 3.0, along with the extension - * point that it was associated with. The functionality provided by - * this interface is available elsewhere. Use - * {@link org.eclipse.help.HelpSystem#getTocs HelpSystem.getTocs()} - * and - * {@link org.eclipse.help.HelpSystem#getContext HelpSystem.getContext(String)} - * to obtain help resources. Use various display methods of - * {@link org.eclipse.ui.help.WorkbenchHelp WorkbenchHelp}to - * display help resources. - */ -public interface IHelp { - - /** - * Displays the entire help bookshelf. - * <p> - * This method is called by the platform to launch the help system UI - * </p> - * - * @since 2.0 - * @deprecated Use WorkbenchHelp.displayHelp() instead. - */ - public void displayHelp(); - - /** - * Displays context-sensitive help for the given context. - * <p> - * (x,y) coordinates specify the location where the context sensitive help - * UI will be presented. These coordinates are screen-relative (ie: (0,0) is - * the top left-most screen corner). The platform is responsible for calling - * this method and supplying the appropriate location. - * </p> - * - * - * @param context - * the context to display - * @param x - * horizontal position - * @param y - * verifical position - * @since 2.0 - * @deprecated Use WorkbenchHelp.displayContext(context,x,y) instead. - */ - public void displayContext(IContext context, int x, int y); - - /** - * Displays context-sensitive help for context with the given context id. - * <p> - * (x,y) coordinates specify the location where the context sensitive help - * UI will be presented. These coordinates are screen-relative (ie: (0,0) is - * the top left-most screen corner). The platform is responsible for calling - * this method and supplying the appropriate location. - * </p> - * - * @param contextId - * the help context identifier; the parameter needs to have a - * form pluginID.pluginContextId, where pluginID is ID of plug-in - * contributing a context, and pluginContextID is ID of context - * contributed in a plug-in. - * @param x - * horizontal position - * @param y - * verifical position - * @see #getContext(String) - * @since 2.0 - * @deprecated Use - * WorkbenchHelp.displayContext(HelpSystem.getContext(contextId),x,y) - * instead. - */ - public void displayContext(String contextId, int x, int y); - - /** - * Displays help content for the help resource with the given URL. - * <p> - * This method is called by the platform to launch the help system UI, - * displaying the documentation identified by the <code>href</code> - * parameter. - * </p> - * <p> - * The help system makes no guarantee that all the help resources can be - * displayed or how they are displayed. - * </p> - * - * @param href - * the URL of the help resource. - * <p> - * Valid href are as described in - * {@link org.eclipse.help.IHelpResource#getHref() IHelpResource.getHref()} - * </p> - * @since 2.0 - * @deprecated Use WorkbenchHelp.displayHelpResource(href) instead. - */ - public void displayHelpResource(String href); - - /** - * Displays help content for the help resource. - * <p> - * This method is called by the platform to launch the help system UI, - * displaying the documentation identified by the <code>helpResource</code> - * parameter. - * <p> - * The help system makes no guarantee that all the help resources can be - * displayed or how they are displayed. - * </p> - * - * @see IHelp#displayHelpResource(String) - * @param helpResource - * the help resource to display. - * @since 2.0 - * @deprecated Use WorkbenchHelp.displayHelpResource(helpResource.getHref()) - * instead. - */ - public void displayHelpResource(IHelpResource helpResource); - - /** - * Displays help content for the toc with the given URL. - * <p> - * This method is called by the platform to launch the help system UI, - * displaying the documentation identified by the <code>toc</code> - * parameter. - * </p> - * <p> - * Valid toc are contributed through the <code>toc</code> element of the - * <code>"org.eclipse.help.toc"</code> extension point. - * </p> - * - * @param toc - * the URL of the toc as specified in the - * <code>"org.eclipse.help.toc"</code> extenstion point - * @deprecated Use WorkbenchHelp.displayHelpResource(toc) instead. - */ - public void displayHelp(String toc); - - /** - * This method is an extension to the <a - * href="#displayHelp(java.lang.String)">displayHelp(String toc) </a> - * method, providing the ability to open the specified help topic. - * <p> - * <code>selectedTopic</code> should be a valid help topic url contained - * in the specified <code>toc</code> and have the following format: - * <em>/pluginID/path_to_document</em><br> - * where - * <dl> - * <dt><em>pluginID</em> is the unique identifier of the plugin - * containing the help topic,</dt> - * <dt><em>path_to_document</em> is the help topic path, relative to the - * plugin directory</dt> - * </dl> - * </p> - * - * @param toc - * the URL of the toc - * @param selectedTopic - * the help topic url. - * @see #displayHelp(java.lang.String) - * @deprecated Use WorkbenchHelp.displayHelpResource(selectedTopic) instead. - */ - public void displayHelp(String toc, String selectedTopic); - - /** - * Displays context-sensitive help for context with the given context id. - * <p> - * (x,y) coordinates specify the location where the context sensitive help - * UI will be presented. These coordinates are screen-relative (ie: (0,0) is - * the top left-most screen corner). The platform is responsible for calling - * this method and supplying the appropriate location. - * </p> - * - * @param contextId - * the help context identifier - * @param x - * horizontal position - * @param y - * verifical position - * @see #getContext(String) - * @deprecated Use - * WorkbenchHelp.displayContext(HelpSystem.getContext(contextId),x,y) - * instead. - */ - public void displayHelp(String contextId, int x, int y); - - /** - * Displays context-sensitive help for the given context. - * <p> - * (x,y) coordinates specify the location where the context sensitive help - * UI will be presented. These coordinates are screen-relative (ie: (0,0) is - * the top left-most screen corner). The platform is responsible for calling - * this method and supplying the appropriate location. - * </p> - * - * - * @param context - * the context to display - * @param x - * horizontal position - * @param y - * verifical position - * @deprecated Use WorkbenchHelp.displayContext(context,x,y) instead. - */ - public void displayHelp(IContext context, int x, int y); - - /** - * Computes and returns context information for the given context id. - * - * @param contextId - * the context id - * @return the context, or <code>null</code> if none - * @deprecated Use HelpSystem.getContext(contextId) instead. - */ - public IContext getContext(String contextId); - - /** - * Returns the list of all integrated tables of contents available. - * - * @return an array of TOC's - * @since 2.0 - * @deprecated Use HelpSystem.getTocs() instead. - */ - public IToc[] getTocs(); - - /** - * Returns <code>true</code> if the context-sensitive help window is - * currently being displayed, <code>false</code> if not. - * - * @deprecated Use WorkbenchHelp.isContextHelpDisplayed() instead. - */ - public boolean isContextHelpDisplayed(); -} diff --git a/org.eclipse.help/src/org/eclipse/help/IHelpContentProducer.java b/org.eclipse.help/src/org/eclipse/help/IHelpContentProducer.java deleted file mode 100644 index 29fb4eb51..000000000 --- a/org.eclipse.help/src/org/eclipse/help/IHelpContentProducer.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; - -import java.io.*; -import java.util.*; - -/** - * Producer capable of generating or otherwise obtaining contents for help - * resources. A plug-in can contribute instance of IHelpContentProducer to - * <code>"org.eclipse.help.contentProducer"</code> extension point. When - * content for a resource is needed from a plug-in is needed, help tries to - * obtain content from instance of this class contributed by the plugin. If - * IHelpContentProvider does not return the content, help system searches - * doc.zip and plug-in install location for the file and reads its content. - * - * @since 3.0 - */ -public interface IHelpContentProducer { - /** - * Obtains content of a specified help resource. If resource for a given - * path does not exist, a null should be returned. If topic content is - * static, and corresponding file exist in a plug-in directory or doc.zip - * file, null might be return as help system can read the file content - * itself. - * - * @param pluginID - * unique identifier of a plug-in containing the resource - * @param href - * path of the resource in a plug-in. - * <p> - * An href has a format <em>path/to/resource</em> or - * <em>path/to/resource?parameter=value1¶meter2=value2...</em> - * For example, <em>references/myclass.html</em> may be passed. - * </p> - * @param locale - * used by the client. In most cases, content in a user language - * should be produced. - * @return InputStream or null if specified resource is not dynamic and - * should be read from doc.zip or plug-in install location. - */ - public InputStream getInputStream(String pluginID, String href, - Locale locale); -} diff --git a/org.eclipse.help/src/org/eclipse/help/IHelpResource.java b/org.eclipse.help/src/org/eclipse/help/IHelpResource.java deleted file mode 100644 index 3b41461fc..000000000 --- a/org.eclipse.help/src/org/eclipse/help/IHelpResource.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; -/** - * A help resource, usually a help topic. - * <p> - * This interface models a help resource. In general, help resources are either - * html help files, or table of contents XML files. - * </p> - * - * @since 2.0 - */ -public interface IHelpResource { - - /** - * This is attribute name used for href in XML files. - */ - public final static String HREF = "href"; //$NON-NLS-1$ - /** - * This is attribute name used for label in XML files. - */ - public final static String LABEL = "label"; //$NON-NLS-1$ - - /** - * Returns the URL (as a string) associated with this help resource. - * - * @return the URL (as a string) associated with the resource - * <p> - * Valid URL of a help resource is: - * <ul> - * <li>a <em>/pluginID/path/to/resource</em>, where - * <ul> - * <li><em>pluginID</em> is the unique identifier of the plugin - * containing the help resource, - * <li><em>path/to/document</em> is the help resource path, - * relative to the plugin directory. - * </ul> - * For example. <em>/myplugin/mytoc.xml</em> or - * <em>/myplugin/references/myclass.html</em> are vaild. - * <li>string representation of URI to an external document. In - * this case, all special characters have to be enoded such that the - * URI is appropriate to be opened with a web browser. - * <em>http://eclipse.org/documents/my%20file.html</em> and - * <em>jar:file:/c:/my%20sources/src.zip!/mypackage/MyClass.html</em> - * are examples of valid URIs. - * </ul> - * </p> - */ - public String getHref(); - /** - * Returns the label of this help resource. - * - * @return the label - */ - public String getLabel(); -} diff --git a/org.eclipse.help/src/org/eclipse/help/ILiveHelpAction.java b/org.eclipse.help/src/org/eclipse/help/ILiveHelpAction.java deleted file mode 100644 index e98fa69c1..000000000 --- a/org.eclipse.help/src/org/eclipse/help/ILiveHelpAction.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; -/** - * Live Help Extension. Classes that implement this interface can be used as - * live help extensions. When user clicks a live help link in a help document, - * the class will be loaded and run. - * - * @since 2.0 - */ -public interface ILiveHelpAction extends Runnable { - /** - * This method will be called upon instantiation of the live help extension. - * The data will be passed as specified in the help document live help link. - * - * @param data - - * initialization data as a String - */ - public void setInitializationString(String data); -} diff --git a/org.eclipse.help/src/org/eclipse/help/IToc.java b/org.eclipse.help/src/org/eclipse/help/IToc.java deleted file mode 100644 index a8c049197..000000000 --- a/org.eclipse.help/src/org/eclipse/help/IToc.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; - -/** - * IToc is the table of contents. It contains help topics. - * - * @since 2.0 - */ -public interface IToc extends IHelpResource { - /** - * This is element name used for TOC in XML files. - */ - public final static String TOC = "toc"; //$NON-NLS-1$ - /** - * This is the attribute used for description topic in XML files. - */ - public final static String TOPIC = "topic"; //$NON-NLS-1$ - - /** - * Obtains the topics directly contained by a toc. - * - * @return Array of ITopic - */ - public ITopic[] getTopics(); - - /** - * Returns a topic with the specified href defined by this TOC. <br> - * If the TOC contains multiple topics with the same href only of them - * (arbitrarily chosen) will be returned. - * <p> - * If no topic is specified, then the TOC description topic is returned, or - * null if there is no description topic for the TOC. - * </p> - * - * @param href - * the topic's URL or null - * @return ITopic or null - */ - public ITopic getTopic(String href); -} - diff --git a/org.eclipse.help/src/org/eclipse/help/ITopic.java b/org.eclipse.help/src/org/eclipse/help/ITopic.java deleted file mode 100644 index 305cdf670..000000000 --- a/org.eclipse.help/src/org/eclipse/help/ITopic.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help; - -/** - * ITopic is one topic in a hierarchy of topics. - * - * @since 2.0 - */ -public interface ITopic extends IHelpResource { - /** - * This is element name used for topic in XML files. - */ - public final static String TOPIC = "topic"; //$NON-NLS-1$ - - /** - * Obtains the topics contained in this node. - * - * @return Array of ITopic - */ - public ITopic[] getSubtopics(); -} - diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java deleted file mode 100644 index a593bcc96..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.internal.context.*; -import org.eclipse.help.internal.toc.*; -import org.eclipse.help.internal.util.*; -import org.osgi.framework.*; -/** - * Help System Core plug-in - */ -public class HelpPlugin extends Plugin - implements - IRegistryChangeListener, - BundleListener { - public final static String PLUGIN_ID = "org.eclipse.help"; //$NON-NLS-1$ - // debug options - public static boolean DEBUG = false; - public static boolean DEBUG_CONTEXT = false; - public static boolean DEBUG_PROTOCOLS = false; - protected static HelpPlugin plugin; - private static BundleContext bundleContext; - private List tocsChangedListeners = new Vector(); - - public final static String BASE_TOCS_KEY = "baseTOCS"; //$NON-NLS-1$ - - protected TocManager tocManager; - protected static Object tocManagerCreateLock = new Object(); - protected ContextManager contextManager; - - /** - * Logs an Error message with an exception. Note that the message should - * already be localized to proper locale. ie: Resources.getString() should - * already have been called - */ - public static synchronized void logError(String message, Throwable ex) { - if (message == null) - message = ""; //$NON-NLS-1$ - Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, - message, ex); - HelpPlugin.getDefault().getLog().log(errorStatus); - } - /** - * Logs a Warning message with an exception. Note that the message should - * already be localized to proper local. ie: Resources.getString() should - * already have been called - */ - public static synchronized void logWarning(String message) { - if (HelpPlugin.DEBUG) { - if (message == null) - message = ""; //$NON-NLS-1$ - Status warningStatus = new Status(IStatus.WARNING, PLUGIN_ID, - IStatus.OK, message, null); - HelpPlugin.getDefault().getLog().log(warningStatus); - } - } - - /** - * @return the singleton instance of the plugin - */ - public static HelpPlugin getDefault() { - return plugin; - } - /* - * (non-Javadoc) - * - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - Platform.getExtensionRegistry().removeRegistryChangeListener(this); - context.removeBundleListener(this); - plugin = null; - bundleContext = null; - super.stop(context); - } - - /* - * (non-Javadoc) - * - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - bundleContext = context; - context.addBundleListener(this); - Platform.getExtensionRegistry().addRegistryChangeListener(this, - HelpPlugin.PLUGIN_ID); - // Setup debugging options - DEBUG = isDebugging(); - if (DEBUG) { - DEBUG_CONTEXT = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/debug/context")); //$NON-NLS-1$ //$NON-NLS-2$ - DEBUG_PROTOCOLS = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/debug/protocols")); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - /** - * Used to obtain Toc Naviagiont Manager - * - * @return instance of TocManager - */ - public static TocManager getTocManager() { - if (getDefault().tocManager == null) { - synchronized (tocManagerCreateLock) { - if (getDefault().tocManager == null) { - getDefault().tocManager = new TocManager(); - } - } - } - return getDefault().tocManager; - } - /** - * Used to obtain Context Manager returns an instance of ContextManager - */ - public static ContextManager getContextManager() { - if (getDefault().contextManager == null) - getDefault().contextManager = new ContextManager(); - return getDefault().contextManager; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent) - */ - public void registryChanged(IRegistryChangeEvent event) { - IExtensionDelta[] deltas = event.getExtensionDeltas( - HelpPlugin.PLUGIN_ID, TocManager.TOC_XP_NAME); - if (deltas.length > 0) { - tocManager = null; - } - // notifiy listeners - if (deltas.length > 0) { - for (Iterator it = tocsChangedListeners.iterator(); it.hasNext();) { - ((ITocsChangedListener) it.next()).tocsChanged(); - } - } - } - public void addTocsChangedListener(ITocsChangedListener listener) { - if (!tocsChangedListeners.contains(listener)) { - tocsChangedListeners.add(listener); - } - } - public void removeTocsChangedListener(ITocsChangedListener listener) { - tocsChangedListeners.remove(listener); - } - - public void bundleChanged(BundleEvent event) { - int type = event.getType(); - if (type == BundleEvent.RESOLVED || type == BundleEvent.UNRESOLVED) { - ResourceLocator.clearZipCache(); - } - } - -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.java deleted file mode 100644 index 455d39510..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal; - -import java.text.*; -import java.util.*; - -import org.eclipse.core.runtime.*; - -/** - * Uses a resource bundle to load images and strings from a property file. - */ -public class HelpResources { - private static ResourceBundle resBundle; - static { - resBundle = ResourceBundle.getBundle(HelpResources.class.getName()); - } - /** - * Resources constructor. - */ - public HelpResources() { - super(); - } - /** - * Returns a string from a property file - */ - public static String getString(String name) { - try { - return resBundle.getString(name); - } catch (Exception e) { - return name; - } - - } - /** - * Returns a string from a property file - */ - public static String getString(String name, String replace0) { - try { - String stringFromPropertiesFile = resBundle.getString(name); - stringFromPropertiesFile = MessageFormat.format( - stringFromPropertiesFile, new Object[]{replace0}); - return stringFromPropertiesFile; - } catch (Exception e) { - return name; - } - } - - /** - * Returns a string from a property file - */ - public static String getString(String name, String replace0, String replace1) { - try { - String stringFromPropertiesFile = resBundle.getString(name); - stringFromPropertiesFile = MessageFormat.format( - stringFromPropertiesFile, new Object[]{replace0, replace1}); - return stringFromPropertiesFile; - } catch (Exception e) { - return name; - } - } - - private static Locale getDefaultLocale() { - String nl = Platform.getNL(); - // sanity test - if (nl == null) - return Locale.getDefault(); - - // break the string into tokens to get the Locale object - StringTokenizer locales = new StringTokenizer(nl, "_"); //$NON-NLS-1$ - if (locales.countTokens() == 1) - return new Locale(locales.nextToken(), ""); //$NON-NLS-1$ - else if (locales.countTokens() == 2) - return new Locale(locales.nextToken(), locales.nextToken()); - else if (locales.countTokens() == 3) - return new Locale(locales.nextToken(), locales.nextToken(), locales - .nextToken()); - else - return Locale.getDefault(); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.properties b/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.properties deleted file mode 100644 index 1107da1ea..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/HelpResources.properties +++ /dev/null @@ -1,36 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Common Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/cpl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# ==================================== -# Eclipse Help System Properties File -# ==================================== - - -# Error Messages -# -------------- -E001 = Error parsing URL: {0} at line: {1,number,integer}, column: {2,number,integer}.\n{3} -E002 = Failed to parse URL: {0} at line: {1,number,integer}, column: {2,number,integer}.\n{3} -E003 = Warning parsing URL: {0} at line: {1,number,integer}, column: {2,number,integer}.\n{3} -E006 = The following errors occurred:\n -E007 = The following contribution files were ignored because of errors:\n -E008 = Parser Errors:\n -E009 = Error loading file {0}. -E024 = Error parsing Table of Contents file, URL: {0} at line: {1,number,integer}, column: {2,number,integer}.\n{3} -E025 = Failed to parse Table of Contents file, URL: {0} at line: {1,number,integer}, column: {2,number,integer}.\n{3} -E026 = Error loading Table of Contents file {0}. -E033 = Error occurred processing file {0}. -E036 = IOException occurred, when resolving URL {0}. -E037 = IOException occurred, when accessing Zip file {0}. File might not be locally available. -E038 = IOException occurred, when resolving URL {0}. -E039 = Problems occurred reading plug-in preferences. -E044 = Exception occurred creating help content producer for plug-in{0}. -TocFileParser.PCE = SAXParser implementation could not be loaded. -ContextsFileParser.PCE = SAXParser implementation could not be loaded. -ContextManager.FileAttribute = "context" element in extension of {0}, contributed in plug-in {1}, is missing required "file" attribute. diff --git a/org.eclipse.help/src/org/eclipse/help/internal/ITocsChangedListener.java b/org.eclipse.help/src/org/eclipse/help/internal/ITocsChangedListener.java deleted file mode 100644 index 18f28c308..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/ITocsChangedListener.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal; - -public interface ITocsChangedListener { - public void tocsChanged(); -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/RuntimeHelpStatus.java b/org.eclipse.help/src/org/eclipse/help/internal/RuntimeHelpStatus.java deleted file mode 100644 index 490e86c2f..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/RuntimeHelpStatus.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal; - -import java.util.*; - -import org.eclipse.core.runtime.*; - -/** - * This class is intended to capture all runtime exception happening during the - * execution of the Help System. - */ - -public class RuntimeHelpStatus { - private static RuntimeHelpStatus inst = null; - - // contains Status objects of errors occurred - private ArrayList errorList = new ArrayList(); - - // contains File names (Strings) of invalid contribution files. - private ArrayList badFilesList = new ArrayList(); - - // contains the error messages (Strings) from the parser - private ArrayList parserErrorMessagesList = new ArrayList(); - - /** - * RuntimeHelpStatus constructor comment. - */ - public RuntimeHelpStatus() { - super(); - } - public synchronized void addParseError(String message, - String invalidFileName) { - // add the Exception to the files list only once. These exceptions will - // be used to - // produce the list of files with errors. - if (!badFilesList.contains(invalidFileName)) - badFilesList.add(invalidFileName); - - // now add the message. All parser messages are added - parserErrorMessagesList.add(message); - - } - public boolean errorsExist() { - if (errorList.isEmpty() && parserErrorMessagesList.isEmpty() - && badFilesList.isEmpty()) - return false; - else - return true; - } - public static synchronized RuntimeHelpStatus getInstance() { - if (inst == null) // create instance - inst = new RuntimeHelpStatus(); - return inst; - } - /** - * clears RuntimeHelpStatus object. - */ - public void reset() { - errorList.clear(); - badFilesList.clear(); - parserErrorMessagesList.clear(); - } - public synchronized String toString() { - StringBuffer fullText = new StringBuffer(); - if (!errorList.isEmpty()) { - fullText.append(HelpResources.getString("E006")); //$NON-NLS-1$ - fullText.append("******************** \n"); //$NON-NLS-1$ - for (int i = 0; i < errorList.size(); i++) { - fullText.append(((Status) (errorList.get(i))).getMessage()); - fullText.append("\n"); //$NON-NLS-1$ - } - } - - if (fullText.length() > 0) - fullText.append("\n"); //$NON-NLS-1$ - - if (!parserErrorMessagesList.isEmpty()) { - // display the files that failed to parse - fullText.append(HelpResources.getString("E007")); //$NON-NLS-1$ - fullText.append("******************** \n"); //$NON-NLS-1$ - for (int i = 0; i < badFilesList.size(); i++) { - fullText.append(((String) (badFilesList.get(i)))); - fullText.append("\n"); //$NON-NLS-1$ - } - - fullText.append("\n"); //$NON-NLS-1$ - - // and the parse error message - fullText.append(HelpResources.getString("E008")); //$NON-NLS-1$ - fullText.append("******************** \n"); //$NON-NLS-1$ - for (int i = 0; i < parserErrorMessagesList.size(); i++) { - fullText.append(((String) (parserErrorMessagesList.get(i)))); - fullText.append("\n"); //$NON-NLS-1$ - } - } - - if (fullText.length() > 0) - return fullText.toString(); - else - return ""; //$NON-NLS-1$ - - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java b/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java deleted file mode 100644 index b816e3939..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; - -import org.eclipse.help.*; -import org.xml.sax.*; -/** - * Context object, as defined in the map.xml - */ -public class Context extends ContextsNode implements IStyledContext { - private String text; - protected String pluginID; - protected String shortID; - /** - * Context constructor. - */ - public Context(Attributes attrs) { - super(attrs); - if (attrs == null) - return; - shortID = attrs.getValue("id"); //$NON-NLS-1$ - } - /** - * @return plain text (without <@#$b>or </@#$b> bug 59541) - */ - public String getText() { - return text - // if there are spaces on any or both side of bold they need to be - // collapsed to one - .replaceAll("(\\s+</?@#\\$b>\\s*)|(\\s*</?@#\\$b>\\s+)", " ") //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll("</?@#\\$b>", ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - /** - * @return styled text with <@#$b>and </@#$b> to mark bold range - */ - public String getStyledText() { - return text; - } - public IHelpResource[] getRelatedTopics() { - if (children.size() > 0) { - IHelpResource[] related = new IHelpResource[children.size()]; - children.toArray(related); - return related; - } else { - // signal empty toc. handled by calling class. - return null; - } - } - public void setStyledText(String s) { - text = s; - } - /** - * Obtains short id (without plugin) - */ - public String getShortId() { - return shortID; - } - public String getID() { - return pluginID + "." + shortID; //$NON-NLS-1$ - } - /** - * Sets the pluginID. - * - * @param pluginID - * The pluginID to set - */ - public void setPluginID(String pluginID) { - this.pluginID = pluginID; - } - /** - * @see ContextsNode#build(ContextsBuilder) - */ - public void build(ContextsBuilder builder) { - builder.build(this); - } - /** - * Replaces children list - */ - public void setChildren(List children) { - this.children = children; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java deleted file mode 100644 index 92e8aff8f..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.*; -import org.eclipse.help.internal.*; -/** - * Maintains the list of contexts and performs look-ups. - */ -public class ContextManager implements IRegistryChangeListener { - public static final String CONTEXTS_XP_NAME = "contexts"; //$NON-NLS-1$ - public static final String CONTEXTS_XP_FULLNAME = HelpPlugin.PLUGIN_ID - + "." + CONTEXTS_XP_NAME; //$NON-NLS-1$ - PluginsContexts pluginsContexts = new PluginsContexts(); - /** - * Context contributions - */ - Map contextsFiles = new HashMap(/* - * of List ContextsFile indexed by plugin ID - * the context apply to - */ - ); - // Dynamic context IDs (generated by help) - // indexed by dynamic context objects (not read from files) - Map dynamicContextIDs = new HashMap(); - private int idCounter = 0; - /** - * HelpContextManager constructor. - */ - public ContextManager() { - super(); - createContextsFiles(); - Platform.getExtensionRegistry().addRegistryChangeListener(this, - HelpPlugin.PLUGIN_ID); - } - /** - * Finds the context, given context ID. - */ - public IContext getContext(String contextId) { - if (HelpPlugin.DEBUG_CONTEXT) { - System.out.println("ContextManager.getContext(" + contextId + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - } - if (contextId == null) - return null; - String plugin = contextId; - String id = contextId; - int dot = contextId.lastIndexOf('.'); - if (dot <= 0 || dot >= contextId.length() - 1) { - // no dot in the middle of context ID - return null; - } - plugin = contextId.substring(0, dot); - id = contextId.substring(dot + 1); - PluginContexts contexts = pluginsContexts.get(plugin); - if (contexts == null) { - contexts = loadPluginContexts(plugin); - } - return contexts.get(id); - } - /** - * Loads context.xml with context for a specified plugin, creates context - * nodes and adds to pluginContext map. - */ - private synchronized PluginContexts loadPluginContexts(String plugin) { - PluginContexts contexts = pluginsContexts.get(plugin); - if (contexts == null) { - contexts = new PluginContexts(); - // read the context info from the XML contributions - List pluginContextsFiles = (List) contextsFiles.get(plugin); - if (pluginContextsFiles == null) { - pluginContextsFiles = new ArrayList(); - } - ContextsBuilder builder = new ContextsBuilder(contexts); - builder.build(pluginContextsFiles); - pluginsContexts.put(plugin, contexts); - } - return contexts; - } - /** - * Creates a list of context files. - */ - private void createContextsFiles() { - // read extension point and retrieve all context contributions - IExtensionPoint xpt = Platform.getExtensionRegistry() - .getExtensionPoint(CONTEXTS_XP_FULLNAME); - if (xpt == null) - return; // no contributions... - IExtension[] extensions = xpt.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - createContextFile(extensions[i]); - } - } - /** - * @param extension - * @return Collection of String (plugin IDs that have new contexts - * contributed) - */ - private Collection createContextFile(IExtension extension) { - Collection plugins = new HashSet(); - String definingPlugin = extension.getNamespace(); - IConfigurationElement[] contextContributions = extension - .getConfigurationElements(); - for (int j = 0; j < contextContributions.length; j++) { - if ("contexts".equals(contextContributions[j].getName())) { //$NON-NLS-1$ - String plugin = contextContributions[j].getAttribute("plugin"); //$NON-NLS-1$ - if (plugin == null || "".equals(plugin)) //$NON-NLS-1$ - plugin = definingPlugin; - String fileName = contextContributions[j].getAttribute("file"); //$NON-NLS-1$ - // in v1 file attribute was called name - if (fileName == null) - fileName = contextContributions[j].getAttribute("name"); //$NON-NLS-1$ - if (fileName == null) { - String msg = HelpResources.getString( - "ContextManager.FileAttribute", //$NON-NLS-1$ - CONTEXTS_XP_FULLNAME, definingPlugin); - HelpPlugin.logError(msg, null); - continue; - } - List pluginContextsFiles = (List) contextsFiles.get(plugin); - if (pluginContextsFiles == null) { - pluginContextsFiles = new ArrayList(); - contextsFiles.put(plugin, pluginContextsFiles); - } - pluginContextsFiles.add(new ContextsFile(definingPlugin, - fileName, plugin)); - plugins.add(plugin); - } - } - return plugins; - } - /** - * Registers context in the manager. - * - * @return context ID assigned to the context - */ - public String addContext(IContext context) { - String plugin = HelpPlugin.PLUGIN_ID; - String id = (String) dynamicContextIDs.get(context); - if (id != null) { - // context already registered - } else { - // generate ID and register the context - id = "ID" + idCounter++; //$NON-NLS-1$ - dynamicContextIDs.put(context, id); - PluginContexts contexts = pluginsContexts.get(plugin); - if (contexts == null) { - contexts = loadPluginContexts(plugin); - } - contexts.put(id, context); - } - return plugin + "." + id; //$NON-NLS-1$ - } - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent) - */ - public synchronized void registryChanged(IRegistryChangeEvent event) { - IExtensionDelta[] deltas = event.getExtensionDeltas( - HelpPlugin.PLUGIN_ID, CONTEXTS_XP_NAME); - for (int i = 0; i < deltas.length; i++) { - if (deltas[i].getKind() == IExtensionDelta.ADDED) { - IExtension extension = deltas[i].getExtension(); - Collection affectedPlugins = createContextFile(extension); - // reset contexts for affected plugins, - // they will be recreated on demand - for (Iterator it = affectedPlugins.iterator(); it.hasNext();) { - String pluginId = (String) it.next(); - pluginsContexts.remove(pluginId); - } - } - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/Contexts.java b/org.eclipse.help/src/org/eclipse/help/internal/context/Contexts.java deleted file mode 100644 index b70e54f15..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/Contexts.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import org.xml.sax.*; -/** - * Context - */ -public class Contexts extends ContextsNode { - /** - * Contexts constructor. - */ - public Contexts(Attributes attrs) { - super(attrs); - } - public void build(ContextsBuilder builder) { - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsBuilder.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsBuilder.java deleted file mode 100644 index 1ded72c48..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsBuilder.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; - -import org.eclipse.help.*; -public class ContextsBuilder { - protected PluginContexts contexts; - private String definingPluginID; - private String pluginID; - /** - * Contexts Builder Constructor. - */ - public ContextsBuilder(PluginContexts pluginContexts) { - this.contexts = pluginContexts; - } - public void build(RelatedTopic relatedTopic) { - // set the href on the related topic - String href = relatedTopic.getHref(); - if (href == null) - relatedTopic.setHref(""); //$NON-NLS-1$ - else { - if (!href.equals("") // no empty link //$NON-NLS-1$ - && !href.startsWith("/") // no help url //$NON-NLS-1$ - && href.indexOf(':') == -1) // no other protocols - { - relatedTopic.setHref("/" + definingPluginID + "/" + href); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - public void build(Context context) { - context.setPluginID(pluginID); - // if context with same Id exists, merge them - Context existingContext = (Context) contexts.get(context.getShortId()); - if (existingContext != null) { - mergeContexts(existingContext, context); - } else { - contexts.put(context.getShortId(), context); - } - } - public void build(ContextsFile contextsFile) { - this.pluginID = contextsFile.getPluginID(); - this.definingPluginID = contextsFile.getDefiningPluginID(); - ContextsFileParser parser = new ContextsFileParser(this); - parser.parse(contextsFile); - } - public void build(List pluginContextsFiles) { - for (Iterator contextFilesIt = pluginContextsFiles.iterator(); contextFilesIt - .hasNext();) { - ContextsFile contextsFile = (ContextsFile) contextFilesIt.next(); - contextsFile.build(this); - } - } - /** - * Merges Text and Links from new Context into an existing Context - */ - private void mergeContexts(Context existingContext, Context newContext) { - // Merge Text - if (newContext.getStyledText() != null) { - if (existingContext.getStyledText() != null) { - existingContext.setStyledText(existingContext.getStyledText() - + "\n" //$NON-NLS-1$ - + newContext.getStyledText()); - } else { - existingContext.setStyledText(newContext.getStyledText()); - } - } - // Merge Related Links - existingContext.getChildren().addAll(newContext.getChildren()); - removeDuplicateLinks(existingContext); - } - /** - * Filters out the duplicate related topics in a Context - */ - private void removeDuplicateLinks(Context context) { - List links = context.getChildren(); - if (links == null || links.size() <= 0) - return; - List filtered = new ArrayList(); - for (Iterator it = links.iterator(); it.hasNext();) { - IHelpResource topic1 = (IHelpResource) it.next(); - if (!isValidTopic(topic1)) - continue; - boolean dup = false; - for (int j = 0; j < filtered.size(); j++) { - IHelpResource topic2 = (IHelpResource) filtered.get(j); - if (!isValidTopic(topic2)) - continue; - if (equalTopics(topic1, topic2)) { - dup = true; - break; - } - } - if (!dup) - filtered.add(topic1); - } - context.setChildren(filtered); - } - /** - * Checks if topic labels and href are not null and not empty strings - */ - private boolean isValidTopic(IHelpResource topic) { - return topic != null && topic.getHref() != null - && !"".equals(topic.getHref()) && topic.getLabel() != null //$NON-NLS-1$ - && !"".equals(topic.getLabel()); //$NON-NLS-1$ - } - /** - * Check if two context topic are the same. They are considered the same if - * both labels and href are equal - */ - private boolean equalTopics(IHelpResource topic1, IHelpResource topic2) { - return topic1.getHref().equals(topic2.getHref()) - && topic1.getLabel().equals(topic2.getLabel()); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFile.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFile.java deleted file mode 100644 index e35b3c8d4..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFile.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.io.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.internal.util.*; - -public class ContextsFile { - protected String href; - protected String definingPluginID; - protected String pluginID; - /** - * Contexts File Constructor - */ - protected ContextsFile(String definingPlugin, String href, String plugin) { - this.href = href; - this.definingPluginID = definingPlugin; - this.pluginID = plugin; - } - /** - * Gets the href - * - * @return Returns a String - */ - protected String getHref() { - return href; - } - protected InputStream getInputStream() { - InputStream stream = null; - try { - if (definingPluginID != null) - stream = ResourceLocator.openFromPlugin(definingPluginID, href, - Platform.getNL()); - else - stream = new FileInputStream(href); - } catch (IOException e) { - } - return stream; - } - /** - * Gets the definingPluginID. - * - * @return Returns a String - */ - public String getDefiningPluginID() { - return definingPluginID; - } - /** - * Gets the plugin ID. - * - * @return Returns a String - */ - public String getPluginID() { - return pluginID; - } - public void build(ContextsBuilder builder) { - builder.build(this); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFileParser.java deleted file mode 100644 index 19177c598..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsFileParser.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.io.*; -import java.text.*; - -import javax.xml.parsers.*; - -import org.eclipse.help.internal.*; -import org.eclipse.help.internal.util.*; -import org.xml.sax.*; -import org.xml.sax.helpers.*; -/** - * Parser for xml file - */ -public class ContextsFileParser extends DefaultHandler { - protected FastStack stack = new FastStack(); - StringBuffer buffer = new StringBuffer(); - boolean seenDescription = false; - ContextsFile contextsFile; - private ContextsBuilder builder; - private final static SAXParserFactory factory = SAXParserFactory - .newInstance(); - public ContextsFileParser(ContextsBuilder builder) { - super(); - this.builder = builder; - } - /** - * Receive notification of character data. - */ - public void characters(char ch[], int start, int length) - throws SAXException { - if (seenDescription) - buffer.append(ch, start, length); - if (HelpPlugin.DEBUG_CONTEXT) { - System.out - .println("ContextsFileParser.characters(): got char from parser= " //$NON-NLS-1$ - + new StringBuffer().append(ch, start, length) - .toString()); - } - } - /** - * Receive notification of the end of an element. - */ - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - // make sure that no error has already occurred before adding to stack. - if (qName.equals(ContextsNode.DESC_ELEM)) { - seenDescription = false; - ((Context) stack.peek()).setStyledText(buffer.toString()); - buffer.setLength(0); - } else if (qName.equals(ContextsNode.DESC_TXT_BOLD)) { - // pop the starting bold tag - stack.pop(); - if (!(stack.peek()).equals(ContextsNode.BOLD_TAG)) - buffer.append(ContextsNode.BOLD_CLOSE_TAG); - } else { - ContextsNode node = (ContextsNode) stack.pop(); - node.build(builder); - } - } - /** - * @see ErrorHandler#error(SAXParseException) - */ - public void error(SAXParseException ex) { - String message = getMessage("E001", ex); //$NON-NLS-1$ - HelpPlugin.logError(message, null); - RuntimeHelpStatus.getInstance() - .addParseError(message, ex.getSystemId()); - } - /** - * @see ErrorHandler#fatalError(SAXParseException) - */ - public void fatalError(SAXParseException ex) throws SAXException { - String message = getMessage("E002", ex); //$NON-NLS-1$ - HelpPlugin.logError(message, ex); - RuntimeHelpStatus.getInstance() - .addParseError(message, ex.getSystemId()); - } - public String getMessage(String messageID, SAXParseException ex) { - String param0 = ex.getSystemId(); - Integer param1 = new Integer(ex.getLineNumber()); - Integer param2 = new Integer(ex.getColumnNumber()); - String param3 = ex.getMessage(); - String message = MessageFormat.format(HelpResources - .getString(messageID), new Object[]{param0, param1, param2, - param3}); - return message; - } - /** - * Receive notification of the beginning of an element. - */ - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) throws SAXException { - // We don't create a description element - if (qName.equals(ContextsNode.DESC_ELEM)) - seenDescription = true; - else if (qName.equals(ContextsNode.DESC_TXT_BOLD)) { - // peek into stack to findout if a bold tag element already - // exists. If we find one, then we do not add the bold tag to - // the current StringBuffer of description. - // ie: there are many bold start tags in the stack, but we appended - // the tag only once to the description string. - // eg: (b) some text (b) more test (/b) more text (/b) will result - // in all of the sentence being bold. - if (!(stack.peek()).equals(ContextsNode.BOLD_TAG)) - buffer.append(ContextsNode.BOLD_TAG); - stack.push(ContextsNode.BOLD_TAG); - } else { - ContextsNode e = null; - // NOTE: we don't create an element for the description - if (qName.equals(ContextsNode.CONTEXTS_ELEM)) { - e = new Contexts(atts); - } else if (qName.equals(ContextsNode.CONTEXT_ELEM)) { - e = new Context(atts); - } else if (qName.equals(ContextsNode.RELATED_ELEM)) { - e = new RelatedTopic(atts); - } else - return; - if (!stack.empty()) - ((ContextsNode) stack.peek()).addChild(e); - stack.push(e); - } - } - public void warning(SAXParseException ex) { - String message = getMessage("E003", ex); //$NON-NLS-1$ - HelpPlugin.logWarning(message); - } - public void parse(ContextsFile contextsFile) { - this.contextsFile = contextsFile; - InputStream is = contextsFile.getInputStream(); - if (is == null) - return; - InputSource inputSource = new InputSource(is); - String file = "/" + contextsFile.getDefiningPluginID() + "/" //$NON-NLS-1$ //$NON-NLS-2$ - + contextsFile.getHref(); - inputSource.setSystemId(file); - try { - SAXParser parser = factory.newSAXParser(); - parser.parse(inputSource, this); - } catch (ParserConfigurationException pce) { - HelpPlugin.logError(HelpResources - .getString("ContextsFileParser.PCE"), pce); //$NON-NLS-1$ - } catch (SAXException se) { - HelpPlugin.logError("", se); //$NON-NLS-1$ - } catch (IOException ioe) { - String msg = HelpResources.getString("E009", file); //$NON-NLS-1$ - HelpPlugin.logError(msg, ioe); - // now pass it to the RuntimeHelpStatus object explicitly because we - // still need to display errors even if Logging is turned off. - RuntimeHelpStatus.getInstance().addParseError(msg, file); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - } - } - } - } - /** - * @see EntityResolver This method implementation prevents loading external - * entities instead of calling - * org.apache.xerces.parsers.SaxParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false); - */ - public InputSource resolveEntity(String publicId, String systemId) { - InputSource source = new InputSource(new ByteArrayInputStream( - new byte[0])); - source.setPublicId(publicId); - source.setSystemId(systemId); - return source; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsNode.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsNode.java deleted file mode 100644 index a164c72aa..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextsNode.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; - -import org.xml.sax.*; -/** - * Object in hierarchy of context contributions - */ -public abstract class ContextsNode { - public static final String CONTEXTS_ELEM = "contexts"; //$NON-NLS-1$ - public static final String CONTEXT_ELEM = "context"; //$NON-NLS-1$ - public static final String DESC_ELEM = "description"; //$NON-NLS-1$ - public static final String RELATED_ELEM = "topic"; //$NON-NLS-1$ - public static final String RELATED_HREF = "href"; //$NON-NLS-1$ - public static final String RELATED_LABEL = "label"; //$NON-NLS-1$ - /** - * Internal representation of <b> - unlikely to occur in a text - */ - public static final String BOLD_CLOSE_TAG = "</@#$b>"; //$NON-NLS-1$ - /** - * Internal representation of <b> - unlikely to occur in a text - */ - public static final String BOLD_TAG = "<@#$b>"; //$NON-NLS-1$ - public static final String DESC_TXT_BOLD = "b"; //$NON-NLS-1$ - protected List children = new ArrayList(); - /** - * When a builder builds the contexts, each node must "accomodate" the - * builder by responding to the build() command. - */ - public abstract void build(ContextsBuilder builder); - /** - * ContextsNode constructor. - */ - public ContextsNode(Attributes attrs) { - } - /** - * Adds a child - * - * @param child - * IContextsNode - */ - public void addChild(ContextsNode child) { - children.add(children.size(), child); - } - /** - * Obtains children - */ - public List getChildren() { - return children; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/IStyledContext.java b/org.eclipse.help/src/org/eclipse/help/internal/context/IStyledContext.java deleted file mode 100644 index 0f7bc798d..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/IStyledContext.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import org.eclipse.help.*; -/** - * <p> - * An enhanced version of <code>org.eclipse.help.IContext</code> interface - * allowing obtaining a styled text. Used by Intro plug-ing and - * org.eclipse.help.ui.internal.ContextHelpDialog TODO Create interface that - * will return description as XML and make it public - * </p> - * - * @since 3.0 - */ -public interface IStyledContext extends IContext { - /** - * Returns the text description for this context with bold markers - * - * @return String with <@#$b>and </@#$b> to mark bold range (as - * IContext.getText() used to in 2.x) - */ - public String getStyledText(); -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/PluginContexts.java b/org.eclipse.help/src/org/eclipse/help/internal/context/PluginContexts.java deleted file mode 100644 index 3d8d46b33..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/PluginContexts.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; - -import org.eclipse.help.*; -/** - * Holds mapping of short contextId to IContext - */ -class PluginContexts { - private Map map = new HashMap(); - public void put(String shortId, IContext context) { - map.put(shortId, context); - } - public IContext get(String shortId) { - return (IContext) map.get(shortId); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/PluginsContexts.java b/org.eclipse.help/src/org/eclipse/help/internal/context/PluginsContexts.java deleted file mode 100644 index e8f8589bd..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/PluginsContexts.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import java.util.*; -/** - * Holds mapping of short plugin Id to PluginContext - */ -class PluginsContexts { - private Map map = new HashMap(); - public void put(String pluginId, PluginContexts contexts) { - map.put(pluginId, contexts); - } - public PluginContexts get(String pluginId) { - return (PluginContexts) map.get(pluginId); - } - public void remove(String pluginId) { - map.remove(pluginId); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/RelatedTopic.java b/org.eclipse.help/src/org/eclipse/help/internal/context/RelatedTopic.java deleted file mode 100644 index 7a67c2c84..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/RelatedTopic.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.context; -import org.eclipse.help.*; -import org.xml.sax.*; -/** - * Default implementation for a topic contribution - */ -public class RelatedTopic extends ContextsNode implements IHelpResource { - protected String href; - protected String label; - public RelatedTopic(Attributes attrs) { - super(attrs); - if (attrs == null) - return; - href = attrs.getValue(ContextsNode.RELATED_HREF); - this.label = attrs.getValue(ContextsNode.RELATED_LABEL); - if (this.label == null) - this.label = ""; //$NON-NLS-1$ - } - public String getHref() { - return href; - } - public void setHref(String href) { - this.href = href; - } - /** - * Returns the label - */ - public String getLabel() { - return label; - } - /** - * @see ContextsNode#build(ContextsBuilder) - */ - public void build(ContextsBuilder builder) { - builder.build(this); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/model/IAnchorElement.java b/org.eclipse.help/src/org/eclipse/help/internal/model/IAnchorElement.java deleted file mode 100644 index 96f3eea94..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/model/IAnchorElement.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.model; - -/** - * Part of help navigation model corresponding to ANCHOR element. It may contain - * TOC elements. - * - * @since 3.0 - */ -public interface IAnchorElement extends INavigationElement { - -}
\ No newline at end of file diff --git a/org.eclipse.help/src/org/eclipse/help/internal/model/ILinkElement.java b/org.eclipse.help/src/org/eclipse/help/internal/model/ILinkElement.java deleted file mode 100644 index 07fb835c3..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/model/ILinkElement.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.model; - -/** - * Part of help navigation model corresponding to LINK element. It may contain - * TOC elements. - * - * @since 3.0 - */ -public interface ILinkElement extends INavigationElement { - -}
\ No newline at end of file diff --git a/org.eclipse.help/src/org/eclipse/help/internal/model/INavigationElement.java b/org.eclipse.help/src/org/eclipse/help/internal/model/INavigationElement.java deleted file mode 100644 index ffba3bbd5..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/model/INavigationElement.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.model; - -import java.util.*; - -/** - * Part of help navigation model corresponding to any of: TOC, TOPIC, ANCHOR, or - * LINK element. After navigation is built, this may contain TOC, TOPIC, LINK, - * or ANCHOR elements. - * - * @since 3.0 - */ -public interface INavigationElement { - /** - * Returns child elements - * - * @return List of INavigationElement - */ - List getChildren(); - -}
\ No newline at end of file diff --git a/org.eclipse.help/src/org/eclipse/help/internal/model/ITocElement.java b/org.eclipse.help/src/org/eclipse/help/internal/model/ITocElement.java deleted file mode 100644 index 24c273c91..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/model/ITocElement.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.model; - -import java.util.*; - -import org.eclipse.help.*; - -/** - * Part of help navigation model corresponding to TOC element. It may contain - * TOPIC, LINK, or ANCHOR elements. - * - * @since 3.0 - */ -public interface ITocElement extends IToc, INavigationElement { - /** - * @return the URL (as a string) of description topic. - */ - public String getTocTopicHref(); - /** - * Returns a topic with the specified href defined by this TOC, without - * looking in children TOCs <br> - * If the TOC contains multiple topics with the same href only of them - * (arbitrarily chosen) will be returned. TOC Descritpion topic is ignored. - * - * @param href - * the topic's URL. - * @return ITopic or null - */ - public ITopic getOwnedTopic(String href); - /** - * Returns a topic with the specified href found in extra dir defined by - * this TOC, without looking in children TOCs - * - * @param href - * the topic's URL. - * @return ITopic or null - */ - public ITopic getOwnedExtraTopic(String href); - /** - * Gets the childrenTocs. - * - * @return Returns a List of ITocElement - */ - public List getChildrenTocs(); -}
\ No newline at end of file diff --git a/org.eclipse.help/src/org/eclipse/help/internal/model/ITopicElement.java b/org.eclipse.help/src/org/eclipse/help/internal/model/ITopicElement.java deleted file mode 100644 index 79a79e9d2..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/model/ITopicElement.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.model; - -import org.eclipse.help.*; - -/** - * Part of help navigation model corresponding to TOPIC element. It may contain - * TOPIC, LINK, or ANCHOR elements. - * - * @since 3.0 - */ -public interface ITopicElement extends ITopic, INavigationElement { - -}
\ No newline at end of file diff --git a/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLConnection.java b/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLConnection.java deleted file mode 100644 index dd5912bad..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLConnection.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.protocols; -import java.io.*; -import java.net.*; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.internal.*; -import org.eclipse.help.internal.util.*; -import org.osgi.framework.*; -/** - * URLConnection to help documents in plug-ins - */ -public class HelpURLConnection extends URLConnection { - private final static String LANG = "lang"; //$NON-NLS-1$ - // document caching - disabled if running in dev mode - protected static boolean cachingEnabled = true; - static { - String[] args = Platform.getCommandLineArgs(); - for (int i = 0; i < args.length; i++) { - if ("-dev".equals(args[i])) { //$NON-NLS-1$ - cachingEnabled = false; - break; - } - } - } - - protected String pluginAndFile; // plugin/file - protected String query; // after ? - protected HashMap arguments; - protected Bundle plugin; - // file in a plug-in - protected String file; - protected String locale; - private static String appserverImplPluginId; - /** - * Constructor for HelpURLConnection - */ - public HelpURLConnection(URL url) { - super(url); - - String urlFile = url.getFile(); - - // Strip off the leading "/" and the query - if (urlFile.startsWith("/")) //$NON-NLS-1$ - urlFile = urlFile.substring(1); - - int indx = urlFile.indexOf("?"); //$NON-NLS-1$ - if (indx != -1) { - query = urlFile.substring(indx + 1); - urlFile = urlFile.substring(0, indx); - } - this.pluginAndFile = urlFile; - parseQuery(); - - setDefaultUseCaches(isCacheable()); - if (HelpPlugin.DEBUG_PROTOCOLS) { - System.out.println("HelpURLConnection: url=" + url); //$NON-NLS-1$ - } - } - - /** - * @see URLConnection#connect() - */ - public void connect() throws IOException { - } - /** - * see URLConnection#getInputStream(); Note: this method can throw - * IOException, but should never return null - */ - public InputStream getInputStream() throws IOException { - // must override parent implementation, since it does nothing. - Bundle plugin = getPlugin(); - if (plugin == null) { - throw new IOException("Resource not found."); //$NON-NLS-1$ - } - - if (plugin.getSymbolicName().equals(getAppserverImplPluginId())) { - // Do not return documents from app server implementation plug-in - throw new IOException("Resource not found."); //$NON-NLS-1$ - } - - if (getFile() == null || "".equals(getFile())) { //$NON-NLS-1$ - throw new IOException("Resource not found."); //$NON-NLS-1$ - } - - // first try using content provider - // then find the file inside nl tree in doc.zip, - // and then, in the file system - InputStream inputStream = ResourceLocator.openFromProducer(plugin, - query == null ? getFile() : getFile() + "?" + query, //$NON-NLS-1$ - getLocale()); - - if (inputStream == null) { - inputStream = ResourceLocator.openFromZip(plugin, "doc.zip", //$NON-NLS-1$ - getFile(), getLocale()); - } - if (inputStream == null) { - inputStream = ResourceLocator.openFromPlugin(plugin, getFile(), - getLocale()); - } - if (inputStream == null) { - throw new IOException("Resource not found."); //$NON-NLS-1$ - } - return inputStream; - } - - public long getExpiration() { - return isCacheable() ? new Date().getTime() + 10000 : 0; - } - /** - * NOTE: need to add support for multi-valued parameters (like filtering) - * Multiple values are added as vectors - */ - protected void parseQuery() { - if (query != null && !"".equals(query)) { //$NON-NLS-1$ - if (arguments == null) { - arguments = new HashMap(5); - } - - StringTokenizer stok = new StringTokenizer(query, "&"); //$NON-NLS-1$ - while (stok.hasMoreTokens()) { - String aQuery = stok.nextToken(); - int equalsPosition = aQuery.indexOf("="); //$NON-NLS-1$ - if (equalsPosition > -1) { // well formed name/value pair - String arg = aQuery.substring(0, equalsPosition); - String val = aQuery.substring(equalsPosition + 1); - Object existing = arguments.get(arg); - if (existing == null) - arguments.put(arg, val); - else if (existing instanceof Vector) { - ((Vector) existing).add(val); - arguments.put(arg, existing); - } else { - Vector v = new Vector(2); - v.add(existing); - v.add(val); - arguments.put(arg, v); - } - } - } - } - } - - public String getContentType() { - // Check if the file is hypertext or plain text - String file = pluginAndFile.toLowerCase(Locale.US); - if (file.endsWith(".html") || file.endsWith(".htm")) //$NON-NLS-1$ //$NON-NLS-2$ - return "text/html"; //$NON-NLS-1$ - else if (file.endsWith(".css")) //$NON-NLS-1$ - return "text/css"; //$NON-NLS-1$ - else if (file.endsWith(".gif")) //$NON-NLS-1$ - return "image/gif"; //$NON-NLS-1$ - else if (file.endsWith(".jpg")) //$NON-NLS-1$ - return "image/jpeg"; //$NON-NLS-1$ - else if (file.endsWith(".pdf")) //$NON-NLS-1$ - return "application/pdf"; //$NON-NLS-1$ - else if (file.endsWith(".xml")) //$NON-NLS-1$ - return "application/xml"; //$NON-NLS-1$ - else if (file.endsWith(".xsl")) //$NON-NLS-1$ - return "application/xsl"; //$NON-NLS-1$ - return "text/plain"; //$NON-NLS-1$ - } - /** - * - */ - public Vector getMultiValue(String name) { - if (arguments != null) { - Object value = arguments.get(name); - if (value instanceof Vector) - return (Vector) value; - else - return null; - } - return null; - } - /** - * - */ - public String getValue(String name) { - if (arguments == null) - return null; - Object value = arguments.get(name); - String stringValue = null; - if (value instanceof String) - stringValue = (String) value; - else if (value instanceof Vector) - stringValue = (String) ((Vector) value).firstElement(); - else - return null; - try { - return URLCoder.decode(stringValue); - } catch (Exception e) { - return null; - } - - } - - /** - * Returns the locale specified by client. - */ - protected String getLocale() { - if (locale == null) { - locale = getValue(LANG); - if (locale == null) { - locale = Platform.getNL(); - } - } - return locale; - } - - protected String getFile() { - if (file == null) { - // Strip the plugin id - int start = pluginAndFile.indexOf("/") + 1; //$NON-NLS-1$ - // Strip query string or anchor bookmark - int end = pluginAndFile.indexOf("?"); //$NON-NLS-1$ - if (end == -1) - end = pluginAndFile.indexOf("#"); //$NON-NLS-1$ - if (end == -1) - end = pluginAndFile.length(); - file = pluginAndFile.substring(start, end); - file = URLCoder.decode(file); - } - return file; - } - protected Bundle getPlugin() { - if (plugin == null) { - // Assume the url is pluginID/path_to_topic.html - int i = pluginAndFile.indexOf('/'); - String pluginId = i == -1 ? "" : pluginAndFile.substring(0, i); //$NON-NLS-1$ - pluginId = URLCoder.decode(pluginId); - plugin = Platform.getBundle(pluginId); - } - return plugin; - } - public boolean isCacheable() { - if (getValue("resultof") != null) //$NON-NLS-1$ - return false; - else - return cachingEnabled; - } - public String toString() { - return pluginAndFile; - } - - /** - * Obtains ID of plugin that contributes appserver implementation. * - * - * @return plug-in ID or null - */ - private static String getAppserverImplPluginId() { - if (appserverImplPluginId == null) { - - // This part mimics AppserverPlugin.createWebappServer() - - // get the app server extension from the system plugin registry - IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = pluginRegistry - .getExtensionPoint("org.eclipse.help.appserver.server"); //$NON-NLS-1$ - if (point != null) { - IExtension[] extensions = point.getExtensions(); - if (extensions.length != 0) { - // We need to pick up the non-default configuration - IConfigurationElement[] elements = extensions[0] - .getConfigurationElements(); - if (elements.length == 0) - return null; - IConfigurationElement serverElement = null; - for (int i = 0; i < elements.length; i++) { - String defaultValue = elements[i] - .getAttribute("default"); //$NON-NLS-1$ - if (defaultValue == null - || defaultValue.equals("false")) { //$NON-NLS-1$ - serverElement = elements[i]; - break; - } - } - // if all the servers are default, then pick the first one - if (serverElement == null) { - serverElement = elements[0]; - } - // - - appserverImplPluginId = serverElement - .getDeclaringExtension().getNamespace(); - - } - } - } - return appserverImplPluginId; - } - -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLStreamHandler.java b/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLStreamHandler.java deleted file mode 100644 index 9540f6117..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/protocols/HelpURLStreamHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.protocols; -import java.io.*; -import java.net.*; -public class HelpURLStreamHandler extends URLStreamHandler { - private static HelpURLStreamHandler instance; - /** - * Constructor for URLHandler - */ - public HelpURLStreamHandler() { - super(); - } - /** - * @see java.net.URLStreamHandler#openConnection(java.net.URL) - */ - protected URLConnection openConnection(URL url) throws IOException { - String protocol = url.getProtocol(); - if (protocol.equals("help")) { //$NON-NLS-1$ - return new HelpURLConnection(url); - } else { - return null; - } - } - public static URLStreamHandler getDefault() { - if (instance == null) { - instance = new HelpURLStreamHandler(); - } - return instance; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/Anchor.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/Anchor.java deleted file mode 100644 index 1d0b37a98..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/Anchor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.util.*; - -import org.eclipse.help.internal.model.*; -import org.xml.sax.*; -/** - * Anchor. Place holder that Toc objects can atatch to. - */ -class Anchor extends TocNode implements IAnchorElement { - protected Toc parentToc; - protected String id; - protected TocFile tocFile; - /** - * Constructor. - */ - protected Anchor(TocFile tocFile, Attributes attrs) { - this.tocFile = tocFile; - if (attrs == null) - return; - id = attrs.getValue("id"); //$NON-NLS-1$ - id = HrefUtil.normalizeHref(tocFile.getPluginID(), tocFile.getHref() - + "#" + id); //$NON-NLS-1$ - parentToc = tocFile.getToc(); - } - /** - * Implements abstract method. - */ - public void build(TocBuilder builder) { - builder.buildAnchor(this); - } - /** - * Obtains the ID - */ - protected String getID() { - return id; - } - /** - * Returns the toc file - */ - public TocFile getTocFile() { - return tocFile; - } - /** - * Adds another element as child of this element Modifies parents of a child - * as well - */ - public void addChild(ITocNode child) { - super.addChild(child); - if (child instanceof Toc && parentToc != null) { - parentToc.getChildrenTocs().add(child); - } - } - - /** - * @return ITopic list - */ - public List getChildTopics() { - // after build, release TocFile - tocFile = null; - return super.getChildTopics(); - } - -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/DirectoryToc.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/DirectoryToc.java deleted file mode 100644 index 9ec826d2c..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/DirectoryToc.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.zip.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.*; -import org.eclipse.help.internal.*; -import org.osgi.framework.*; -/** - * Toc created from files in a extra directory in a plugin. - */ -public class DirectoryToc { - private String dir; - /** - * Map of ITopic by href String; - */ - private Map extraTopics; - private String locale; - /** - * Constructor. - */ - protected DirectoryToc(TocFile tocFile) { - this(tocFile.getPluginID(), tocFile.getLocale(), tocFile.getExtraDir()); - } - private DirectoryToc(String pluginID, String locale, String directory) { - this.locale = locale; - // Obtain extra search directory if provided - this.dir = HrefUtil.normalizeDirectoryHref(pluginID, directory); - - } - /** - * This public method is to be used after the build of TOCs is finished. - * With assumption that TOC model is not modifiable after the build, this - * method caches topics in an array and releases objects used only during - * build. - * - * @return Map of ITopic - */ - public Map getExtraTopics() { - if (extraTopics == null) { - extraTopics = createExtraTopics(); - // for memory foot print, release TocFile and dir - dir = null; - } - - return extraTopics; - } - /** - * Obtains URLs of all documents inside given directory. - * - * @return Map of ITopic by href - */ - private Map createExtraTopics() { - Map ret = new HashMap(); - String pluginID = HrefUtil.getPluginIDFromHref(dir); - if (pluginID == null) { - return ret; - } - Bundle pluginDesc = Platform.getBundle(pluginID); - if (pluginDesc == null || pluginDesc.getState() == Bundle.INSTALLED - || pluginDesc.getState() == Bundle.UNINSTALLED) - return ret; - String directory = HrefUtil.getResourcePathFromHref(dir); - if (directory == null) { - // the root - all files in a zip should be indexed - directory = ""; //$NON-NLS-1$ - } - // Find doc.zip file - IPath iPath = new Path("$nl$/doc.zip"); //$NON-NLS-1$ - Map override = new HashMap(1); - override.put("$nl$", locale); //$NON-NLS-1$ - URL url = Platform.find(pluginDesc, iPath, override); - if (url == null) { - url = Platform.find(pluginDesc, new Path("doc.zip")); //$NON-NLS-1$ - } - if (url != null) { - // collect topics from doc.zip file - ret.putAll(createExtraTopicsFromZip(pluginID, directory, url)); - } - // Find directory on the filesystem - iPath = new Path("$nl$/" + directory); //$NON-NLS-1$ - url = null; - url = Platform.find(pluginDesc, iPath, override); - if (url == null) { - url = Platform.find(pluginDesc, new Path(directory)); - } - if (url != null) { - // collect topics from directory - ret - .putAll(createExtraTopicsFromDirectory(pluginID, directory, - url)); - } - return ret; - - } - /** - * @param directory - * path in the form "segment1/segment2...", "" will return names - * of all files in a zip - * @return Map of ITopic by href String - */ - private Map createExtraTopicsFromZip(String pluginID, String directory, - URL url) { - Map ret = new HashMap(0); - URL realZipURL; - try { - realZipURL = Platform.asLocalURL(Platform.resolve(url)); - } catch (IOException ioe) { - HelpPlugin.logError( - HelpResources.getString("E036", url.toString()), //$NON-NLS-1$ - ioe); - return new HashMap(0); - } - ZipFile zipFile; - try { - zipFile = new ZipFile(realZipURL.getFile()); - ret = createExtraTopicsFromZipFile(pluginID, zipFile, directory); - zipFile.close(); - } catch (IOException ioe) { - HelpPlugin.logError(HelpResources.getString( - "E037", realZipURL.getFile()), //$NON-NLS-1$ - ioe); - return new HashMap(0); - } - - return ret; - - } - - /** - * Obtains names of files in a zip file that given directory in their path. - * Files in subdirectories are included as well. - * - * @param directory - * path in the form "segment1/segment2...", "" will return names - * of all files in a zip - * @return Map of ITopic by href String - */ - private Map createExtraTopicsFromZipFile(String pluginID, ZipFile zipFile, - String directory) { - String constantHrefSegment = "/" + pluginID + "/"; //$NON-NLS-1$ //$NON-NLS-2$ - Map ret = new HashMap(); - for (Enumeration enum = zipFile.entries(); enum.hasMoreElements();) { - ZipEntry zEntry = (ZipEntry) enum.nextElement(); - if (zEntry.isDirectory()) { - continue; - } - String docName = zEntry.getName(); - int l = directory.length(); - if (l == 0 || docName.length() > l && docName.charAt(l) == '/' - && directory.equals(docName.substring(0, l))) { - String href = constantHrefSegment + docName; - ret.put(href, new ExtraTopic(href)); - } - } - return ret; - } - /** - * @param directory - * path in the form "segment1/segment2...", "" will return names - * of all files in a directory - * @return Map of ITopic by href String - */ - private Map createExtraTopicsFromDirectory(String pluginID, - String directory, URL url) { - Map m = new HashMap(); - URL realURL; - try { - realURL = Platform.asLocalURL(Platform.resolve(url)); - } catch (IOException ioe) { - HelpPlugin.logError( - HelpResources.getString("E038", url.toString()), //$NON-NLS-1$ - ioe); - return m; - } - File dirFile = new File(realURL.getFile()); - if (dirFile.exists() && dirFile.isDirectory()) { - String prefix; - if (directory.length() > 0) { - prefix = "/" + pluginID + "/" + directory; //$NON-NLS-1$ //$NON-NLS-2$ - } else { - prefix = "/" + pluginID; //$NON-NLS-1$ - } - createExtraTopicsFromDirectoryFile(prefix, dirFile, m); - } - return m; - - } - /** - * @prefix /pluginID/segment1/segment2 - * @return Map of ITopic by href String - */ - private Map createExtraTopicsFromDirectoryFile(String prefix, File dir, - Map m) { - File[] files = dir.listFiles(); - for (int i = 0; i < files.length; i++) { - String href = prefix + "/" + files[i].getName(); //$NON-NLS-1$ - if (files[i].isDirectory()) { - createExtraTopicsFromDirectoryFile(href, files[i], m); - } else { - m.put(href, new ExtraTopic(href)); - } - } - return m; - } - class ExtraTopic implements ITopic { - private String topicHref; - public ExtraTopic(String href) { - this.topicHref = href; - } - - public String getHref() { - return topicHref; - } - public String getLabel() { - return topicHref; - } - public ITopic[] getSubtopics() { - return new ITopic[0]; - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java deleted file mode 100644 index a5b8aa8d7..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; - -public class HrefUtil { - /** - * Creates /pluginid/directory from directory name - */ - public static String normalizeDirectoryHref(String pluginID, String dir) { - // "" is treated as if extra directory was not provided - if (dir == null || dir.length() <= 0) - return null; - // "." means all the files in the plugin - if (".".equals(dir)) //$NON-NLS-1$ - dir = ""; //$NON-NLS-1$ - // remove not needed trailing separator - if (dir.length() > 0 && dir.lastIndexOf('/') == dir.length() - 1) { - dir = dir.substring(0, dir.length() - 1); - } - return normalizeHref(pluginID, dir); - } - - /** - * Creates /pluginid/href from href relative to the current plugin - * - * @param pluginID - * id of a plugin to which href is relative - * @param href - * relative href ex: path[#anchorID] ex: - * ../pluginID/path[#anchorID] - * @return String representation of href, formatted as - * /pluginID/path[#anchorID] - */ - public final static String normalizeHref(String pluginID, String href) { - if (href == null) - return null; - if (href.startsWith("/")) //$NON-NLS-1$ - // already normalized - return href; - if (href.startsWith("http:") //$NON-NLS-1$ - || href.startsWith("file:") //$NON-NLS-1$ - || href.startsWith("jar:")) //$NON-NLS-1$ - // external doc - return href; - if (href.startsWith("../")) { //$NON-NLS-1$ - return href.substring(2); - } else { - if (href.length() > 0) - return "/" + pluginID + "/" + href; //$NON-NLS-1$ //$NON-NLS-2$ - else - return "/" + pluginID; //$NON-NLS-1$ - } - } - /** - * Parses href and obtains plugin id - * - * @param href - * String in format /string1[/string2] - * @return plugin ID, or null - */ - public static String getPluginIDFromHref(String href) { - if (href == null || href.length() < 2 || href.charAt(0) != '/') - return null; - int secondSlashIx = href.indexOf("/", 1); //$NON-NLS-1$ - if (secondSlashIx < 0) // href is /pluginID - return href.substring(1); - // href is /pluginID/path[#anchorID] - return href.substring(1, secondSlashIx); - } - - /** - * Parses href and obtains resource path relative to the plugin - * - * @param href - * String in format /string1[/[string2]][#string3] - * @return relative resource path, or null - */ - public static String getResourcePathFromHref(String href) { - if (href == null) - return null; - // drop anchor id - int anchorIx = href.lastIndexOf("#"); //$NON-NLS-1$ - if (anchorIx >= 0) //anchor exists, drop it - href = href.substring(0, anchorIx); - if (href.length() < 2 || href.charAt(0) != '/') - return null; - int secondSlashIx = href.indexOf("/", 1); //$NON-NLS-1$ - if (secondSlashIx < 0) // href is /pluginID - return null; - if (secondSlashIx + 1 < href.length()) // href is /pluginID/path - return href.substring(secondSlashIx + 1); - else - // href is /pluginID/ - return ""; //$NON-NLS-1$ - } - -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/ITocNode.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/ITocNode.java deleted file mode 100644 index 6e92a2efc..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/ITocNode.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; - -import org.eclipse.help.internal.model.*; -/** - * ITocNode interface. - */ -interface ITocNode extends INavigationElement { - - /** - * Adds another element as child of this element Modifies parents of a child - * as well - * - * @param child - * node to add as child - */ - void addChild(ITocNode child); - - /** - * When a builder builds the navigation, each node must "accomodate" the - * builder by responding to the build() command. - */ - void build(TocBuilder builder); -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/Link.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/Link.java deleted file mode 100644 index 425bfe893..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/Link.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import org.eclipse.help.internal.model.*; -import org.xml.sax.*; -/** - * Include. Place holder to link to other Toc objects. - */ -class Link extends TocNode implements ILinkElement { - protected Toc parentToc; - protected String toc; - /** - * Contstructor. Used when parsing help contributions. - */ - protected Link(TocFile tocFile, Attributes attrs) { - if (attrs == null) - return; - toc = attrs.getValue("toc"); //$NON-NLS-1$ - toc = HrefUtil.normalizeHref(tocFile.getPluginID(), toc); - parentToc = tocFile.getToc(); - } - /** - * Implements abstract method. - */ - public void build(TocBuilder builder) { - builder.buildLink(this); - } - /** - * Obtains URL of linked TOC - */ - protected String getToc() { - return toc; - } - /** - * Adds another element as child of this element Modifies parents of a child - * as well - */ - public void addChild(ITocNode child) { - super.addChild(child); - if (child instanceof Toc && parentToc != null) { - parentToc.getChildrenTocs().add(child); - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java deleted file mode 100644 index 0257c33d2..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java +++ /dev/null @@ -1,257 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.util.*; - -import org.eclipse.help.*; -import org.eclipse.help.internal.model.*; -import org.xml.sax.*; -/** - * Root of navigation TocFile Can be linked with other Toc objects. - */ -public class Toc extends TocNode implements IToc, ITocElement { - private static final int SIZE_UNINITIALIZED = -1; - private String link_to; - private String href; - private String label; - private TocFile tocFile; - private ITopic[] topicArray; - private Topic descriptionTopic; - /** - * Collection of Toc - */ - private List childrenTocs; - private DirectoryToc directoryToc; - /** - * Map of all topics contained by this TOC by href. Description topic is not - * in the map. - */ - private Map topicMap = new HashMap(); - private int size = SIZE_UNINITIALIZED; - /** - * Constructor. Used when parsing help contributions. - */ - protected Toc(TocFile tocFile, Attributes attrs) { - if (attrs == null) - return; - this.tocFile = tocFile; - this.label = attrs.getValue("label"); //$NON-NLS-1$ - if (label == null) { - throw new RuntimeException("toc label==null"); //$NON-NLS-1$ - } - this.link_to = attrs.getValue("link_to"); //$NON-NLS-1$ - this.link_to = HrefUtil.normalizeHref(tocFile.getPluginID(), link_to); - this.href = HrefUtil.normalizeHref(tocFile.getPluginID(), tocFile - .getHref()); - - try { - // create the description topic - this.descriptionTopic = new Topic(tocFile, null); - this.descriptionTopic.setLabel(this.label); - String topic = attrs.getValue("topic"); //$NON-NLS-1$ - if (topic != null && topic.trim().length() > 0) - this.descriptionTopic.setHref(HrefUtil.normalizeHref(tocFile - .getPluginID(), topic)); - else - this.descriptionTopic.setHref(""); //$NON-NLS-1$ - } catch (Exception e) { - } - - childrenTocs = new ArrayList(); - directoryToc = new DirectoryToc(tocFile); - } - /** - * Implements abstract method. - */ - public void build(TocBuilder builder) { - builder.buildToc(this); - } - /** - * Returns the toc file. Returns null when the topic is read from a temp - * file. - */ - public TocFile getTocFile() { - return tocFile; - } - /** - * Gets the link_to - * - * @return Returns a String - */ - protected String getLink_to() { - return link_to; - } - /** - * Gets the href - * - * @return Returns a String - */ - public String getHref() { - return href; - } - public String getLabel() { - return label; - } - /** - * Returns a topic with the specified href defined by this TOC. <br> - * If the TOC contains multiple topics with the same href only of them - * (arbitrarily chosen) will be returned. - * <p> - * If no topic is specified, then the TOC description topic is returned, or - * null if there is no description topic for the TOC. - * </p> - * - * @param href - * the topic's URL or null - * @return ITopic or null - */ - public ITopic getTopic(String href) { - if (href == null || href.equals(descriptionTopic.getHref())) { - return descriptionTopic; - } - return getTopicNoDescr(href); - } - /** - * Similar to ITopic getTopic(String) but does not match and return - * description Topic - * - * @param href - * the topic's URL - * @return ITopic or null - */ - private ITopic getTopicNoDescr(String href) { - ITopic result = getOwnedTopic(href); - if (result != null) { - return result; - } - - // check inside children TOCs - for (Iterator it = getChildrenTocs().iterator(); it.hasNext();) { - Toc childToc = (Toc) it.next(); - // must not return description topic from children TOCs - result = childToc.getTopicNoDescr(href); - if (result != null) { - break; - } - } - return result; - } - /** - * This public method is to be used after the build of TOCs is finished. - * With assumption that TOC model is not modifiable after the build, this - * method caches subtopics in an array and releases objects used only during - * build. - * - * @return ITopic[] - */ - public ITopic[] getTopics() { - if (topicArray == null) { - List topics = getChildTopics(); - // create and cache array of children (Topics only) - topicArray = new ITopic[topics.size()]; - topics.toArray(topicArray); - // after TOC is build, TocFile no longer needed - tocFile = null; - } - return topicArray; - } - /** - * @return ITopic or null; - */ - public String getTocTopicHref() { - if (descriptionTopic != null) { - return descriptionTopic.getHref(); - } - return null; - } - /** - * Returns a topic with the specified href defined by this TOC, without - * looking in children TOCs <br> - * If the TOC contains multiple topics with the same href only of them - * (arbitrarily chosen) will be returned. TOC Descritpion topic is ignored. - * - * @param href - * the topic's URL. - * @return ITopic or null - */ - public ITopic getOwnedTopic(String href) { - return (ITopic) topicMap.get(href); - } - /** - * @return ITopic[] - */ - public ITopic[] getExtraTopics() { - Collection dirTopicCollection = directoryToc.getExtraTopics().values(); - ITopic[] dirTopics = (ITopic[]) dirTopicCollection - .toArray(new ITopic[dirTopicCollection.size()]); - - // add extra topics from children TOCs. - for (Iterator it = childrenTocs.iterator(); it.hasNext();) { - IToc toc = (IToc) it.next(); - if (toc instanceof Toc) { - ITopic[] moreDirTopics = ((Toc) toc).getExtraTopics(); - if (moreDirTopics.length > 0) { - ITopic[] newDirTopics = new ITopic[dirTopics.length - + moreDirTopics.length]; - System.arraycopy(dirTopics, 0, newDirTopics, 0, - dirTopics.length); - System.arraycopy(moreDirTopics, 0, newDirTopics, - dirTopics.length, moreDirTopics.length); - dirTopics = newDirTopics; - } - } - } - - return dirTopics; - } - /** - * Returns a topic with the specified href found in extra dir defined by - * this TOC, without looking in children TOCs - * - * @param href - * the topic's URL. - * @return ITopic or null - */ - public ITopic getOwnedExtraTopic(String href) { - return (ITopic) directoryToc.getExtraTopics().get(href); - - } - /** - * Used by debugger - */ - public String toString() { - return href != null ? href : super.toString(); - } - - /** - * Gets the childrenTocs. - * - * @return Returns a Collection of Toc - */ - public List getChildrenTocs() { - return childrenTocs; - } - public int size() { - if (size == SIZE_UNINITIALIZED) { - size = topicMap.size(); - for (Iterator it = childrenTocs.iterator(); it.hasNext();) { - size += ((Toc) it.next()).size(); - } - } - return size; - } - void registerTopic(ITopic topic) { - String topicHref = topic.getHref(); - if (topicHref != null) { - topicMap.put(topicHref, topic); - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocBuilder.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocBuilder.java deleted file mode 100644 index d888a345d..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocBuilder.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; - -import java.util.*; - -import org.eclipse.help.internal.*; - -public class TocBuilder { - // list of all toc files - protected Collection contributedTocFiles; - // list of unprocessed toc files - protected Collection unprocessedTocFiles; - // list of unprocessed toc (the target of attach_to was not available at the - // time) - protected List unprocessedTocs; - /** - * Constructor. - */ - public TocBuilder() { - unprocessedTocFiles = new ArrayList(); - unprocessedTocs = new ArrayList(); - } - public Collection getBuiltTocs() { - // returns the list of root Toc trees - Collection tocCol = new ArrayList(contributedTocFiles.size()); - for (Iterator it = contributedTocFiles.iterator(); it.hasNext();) { - TocFile tocFile = (TocFile) it.next(); - Toc toc = tocFile.getToc(); - if (toc != null && toc.getTocFile().isPrimary() - && !isIntegrated(toc)) - tocCol.add((toc)); - } - return tocCol; - } - /** - */ - public void build(Collection contributedTocFiles) { - this.contributedTocFiles = contributedTocFiles; - unprocessedTocFiles.addAll(contributedTocFiles); - // process all the toc files. - // A side-effect is that linked files are also processed - while (!unprocessedTocFiles.isEmpty()) { - TocFile tocFile = (TocFile) unprocessedTocFiles.iterator().next(); - tocFile.build(this); - } - // At the end, unprocessedTocs may contain TOCs that need be build. - // All these toc could not be attached because the - // target node was not parsed at that time - - // try processing as many toc (link_to) as possible now - int remaining = unprocessedTocs.size(); - for (int i = 0; i < remaining; i++) { - Toc toc = (Toc) unprocessedTocs.get(i); - buildToc(toc); - } - } - public void buildTocFile(TocFile tocFile) { - try { - unprocessedTocFiles.remove(tocFile); - TocFileParser parser = new TocFileParser(this); - parser.parse(tocFile); - } catch (Exception e) { - String msg = HelpResources.getString("E033", tocFile.getHref()); //$NON-NLS-1$ - HelpPlugin.logError(msg, e); - } - } - public void buildAnchor(Anchor anchor) { - // cache the anchor in the toc file - anchor.getTocFile().addAnchor(anchor); - } - public void buildLink(Link link) { - // parse the linked file - String linkedToc = link.getToc(); - TocFile includedTocFile = getTocFile(linkedToc); - if (includedTocFile == null) - return; - Toc toc = includedTocFile.getToc(); - if (toc == null) - return; - // link the two Toc objects - link.addChild(toc); - } - public void buildTopic(Topic topic) { - // nothing to do - } - public void buildToc(Toc toc) { - // link toc if so specified - String href = toc.getLink_to(); - if (href == null || href.equals("")) //$NON-NLS-1$ - return; - TocFile targetTocFile = getTocFile(href); - if (targetTocFile == null) - return; - Anchor anchor = targetTocFile.getAnchor(href); - if (anchor == null) { - unprocessedTocs.add(toc); - return; - } - // link the two toc objects - anchor.addChild(toc); - } - private TocFile getTocFile(String href) { - String plugin = HrefUtil.getPluginIDFromHref(href); - if (plugin == null) - return null; - String path = HrefUtil.getResourcePathFromHref(href); - if (path == null) - return null; - TocFile tocFile = null; - for (Iterator it = contributedTocFiles.iterator(); it.hasNext();) { - tocFile = (TocFile) it.next(); - if (tocFile.getPluginID().equals(plugin) - && tocFile.getHref().equals(path)) - break; - else - tocFile = null; - } - if (tocFile == null) - return null; - if (unprocessedTocFiles.contains(tocFile)) - buildTocFile(tocFile); - return tocFile; - } - /** - * Checks if navigation element has been integrated into another TOC. - */ - private boolean isIntegrated(TocNode element) { - // check if there if there is TOC in ancestor hierarchy (depth first) - for (Iterator it = element.getParents().iterator(); it.hasNext();) { - TocNode parent = (TocNode) it.next(); - if (parent instanceof Toc - && ((Toc) parent).getTocFile().isPrimary()) { - return true; - } else if (isIntegrated(parent)) { - return true; - } - } - // no ancestor is a TOC - return false; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java deleted file mode 100644 index 1a0a1314d..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.io.*; -import java.util.*; - -import org.eclipse.help.internal.util.*; - -public class TocFile { - - protected Toc toc; - - protected String plugin; - protected String href; - protected boolean primary; - protected String locale; - protected String extraDir; - - // used for fast access to anchors - protected Map anchors; - - /** - * Toc File Constructor - */ - public TocFile(String plugin, String href, boolean primary, - String locale, String extraDir) { - this.plugin = plugin; - this.href = href; - this.primary = primary; - this.locale = locale; - this.extraDir = extraDir; - } - - /** - * Gets the href - * - * @return Returns a String - */ - protected String getHref() { - return href; - } - - /** - * Gets the pluginID - * - * @return Returns a String - */ - public final String getPluginID() { - return plugin; - } - - protected InputStream getInputStream() { - InputStream stream = null; - try { - if (plugin != null) - stream = ResourceLocator.openFromPlugin(plugin, href, locale); - else - stream = new FileInputStream(href); - } catch (IOException e) { - } - return stream; - } - - /** - * Parses file and gets the toc - * - * @return Returns a Toc - */ - public Toc getToc() { - return toc; - } - - /** - * Sets the toc on this file. It should happen during parsing - */ - public void setToc(Toc toc) { - this.toc = toc; - } - - /** - * Registers a new anchor. - */ - public void addAnchor(Anchor a) { - if (anchors == null) - anchors = new HashMap(); - - anchors.put(a.getID(), a); - } - - /** - * Returns anchor by id - */ - public Anchor getAnchor(String id) { - if (anchors == null || anchors.get(id) == null) - return null; - else - return (Anchor) anchors.get(id); - } - - /** - * Builds the toc file if needed - */ - public void build(TocBuilder builder) { - builder.buildTocFile(this); - } - - /** - * Used by debugger - */ - public String toString() { - return plugin + "/" + href; //$NON-NLS-1$ - } - /** - * Checks if this file specifies a TOC. - * - * @return Returns a boolean - */ - public boolean isPrimary() { - return primary; - } - - /** - * Gets the extraDir. - * - * @return Returns a String - */ - public String getExtraDir() { - return extraDir; - } - /** - * Gets the locale. - * - * @return Returns a String - */ - public String getLocale() { - return locale; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java deleted file mode 100644 index 57718f6ae..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.io.*; -import java.text.*; -import java.util.*; - -import javax.xml.parsers.*; - -import org.eclipse.help.internal.*; -import org.eclipse.help.internal.util.*; -import org.xml.sax.*; -import org.xml.sax.helpers.*; -/** - * Used to create TocFile's Toc object from contributed toc xml file. - */ -class TocFileParser extends DefaultHandler { - protected TocBuilder builder; - protected FastStack elementStack; - protected TocFile tocFile; - static SAXParserFactory factory = SAXParserFactory.newInstance(); - private static XMLParserPool parserPool = new XMLParserPool(); - /** - * Constructor - */ - public TocFileParser(TocBuilder builder) { - super(); - this.builder = builder; - } - /** - * @see ErrorHandler#error(SAXParseException) - */ - public void error(SAXParseException ex) throws SAXException { - String message = getMessage("E024", ex); //$NON-NLS-1$ - //Error parsing Table of Contents file, URL: %1 at Line:%2 Column:%3 %4 - HelpPlugin.logError(message, null); - RuntimeHelpStatus.getInstance() - .addParseError(message, ex.getSystemId()); - } - /** - * @see ErrorHandler#fatalError(SAXParseException) - */ - public void fatalError(SAXParseException ex) throws SAXException { - // create message string from exception - String message = getMessage("E025", ex); //$NON-NLS-1$ - //Failed to parse Table of Contents file, URL: %1 at Line:%2 Column:%3 - // %4 - HelpPlugin.logError(message, ex); - RuntimeHelpStatus.getInstance() - .addParseError(message, ex.getSystemId()); - } - protected String getMessage(String messageID, SAXParseException ex) { - String param0 = ex.getSystemId(); - Integer param1 = new Integer(ex.getLineNumber()); - Integer param2 = new Integer(ex.getColumnNumber()); - String param3 = ex.getMessage(); - String message = MessageFormat.format(HelpResources - .getString(messageID), new Object[]{param0, param1, param2, - param3}); - return message; - } - /** - * Gets the toc - */ - public void parse(TocFile tocFile) { - this.tocFile = tocFile; - elementStack = new FastStack(); - InputStream is = tocFile.getInputStream(); - if (is == null) - return; - InputSource inputSource = new InputSource(is); - String file = "/" + tocFile.getPluginID() + "/" + tocFile.getHref(); //$NON-NLS-1$ //$NON-NLS-2$ - inputSource.setSystemId(file); - try { - SAXParser parser = parserPool.obtainParser(); - try { - parser.parse(inputSource, this); - is.close(); - } finally { - parserPool.releaseParser(parser); - } - } catch (ParserConfigurationException pce) { - String msg = HelpResources.getString("TocFileParser.PCE"); //$NON-NLS-1$ - //SAXParser implementation could not be loaded. - HelpPlugin.logError(msg, pce); - } catch (SAXException se) { - String msg = HelpResources.getString("E026", file); //$NON-NLS-1$ - //Error loading Table of Contents file %1. - HelpPlugin.logError(msg, se); - } catch (IOException ioe) { - String msg = HelpResources.getString("E026", file); //$NON-NLS-1$ - //Error loading Table of Contents file %1. - HelpPlugin.logError(msg, ioe); - // now pass it to the RuntimeHelpStatus object explicitly because we - // still need to display errors even if Logging is turned off. - RuntimeHelpStatus.getInstance().addParseError(msg, file); - } - } - /** - * @see ContentHandler#startElement(String, String, String, Attributes) - */ - public final void startElement(String namespaceURI, String localName, - String qName, Attributes atts) throws SAXException { - TocNode node = null; - if (qName.equals("toc")) { //$NON-NLS-1$ - node = new Toc(tocFile, atts); - tocFile.setToc((Toc) node); - } else if (qName.equals("topic")) { //$NON-NLS-1$ - node = new Topic(tocFile, atts); - } else if (qName.equals("link")) { //$NON-NLS-1$ - node = new Link(tocFile, atts); - } else if (qName.equals("anchor")) { //$NON-NLS-1$ - node = new Anchor(tocFile, atts); - } else - return; // perhaps throw some exception - if (!elementStack.empty()) - ((TocNode) elementStack.peek()).addChild(node); - elementStack.push(node); - // do any builder specific actions in the node - node.build(builder); - } - /** - * @see ContentHandler#endElement(String, String, String) - */ - public final void endElement(String namespaceURI, String localName, - String qName) throws SAXException { - elementStack.pop(); - } - - /** - * @see EntityResolver This method implementation prevents loading external - * entities instead of calling - * org.apache.xerces.parsers.SaxParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false); - */ - public InputSource resolveEntity(String publicId, String systemId) { - InputSource source = new InputSource(new ByteArrayInputStream( - new byte[0])); - source.setPublicId(publicId); - source.setSystemId(systemId); - return source; - } - - /** - * This class maintain pool of parsers that can be used for parsing TOC - * files. The parsers should be returned to the pool for reuse. - */ - static class XMLParserPool { - private ArrayList pool = new ArrayList(); - SAXParser obtainParser() throws ParserConfigurationException, - SAXException { - SAXParser p; - int free = pool.size(); - if (free > 0) { - p = (SAXParser) pool.remove(free - 1); - } else { - p = factory.newSAXParser(); - } - return p; - } - void releaseParser(SAXParser parser) { - pool.add(parser); - } - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java deleted file mode 100644 index c6adf0b54..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.*; -import org.eclipse.help.internal.*; -import org.eclipse.help.internal.model.*; - -/** - * Manages the navigation model. It keeps track of all the tables of contents. - */ -public class TocManager { - public static final String TOC_XP_NAME = "toc"; //$NON-NLS-1$ - - /** - * Map of ITocNavNode[] by String - */ - private Map tocsByLang; - private Collection contributingPlugins; - - /** - * HelpNavigationManager constructor. - */ - public TocManager() { - super(); - try { - tocsByLang = new HashMap(); - // build TOCs for machine locale at startup - // Note: this can be removed, and build on first invocation... - build(Platform.getNL()); - } catch (Exception e) { - HelpPlugin.logError("", e); //$NON-NLS-1$ - } - } - - /** - * Returns the list of TOC's available in the help system - */ - public ITocElement[] getTocs(String locale) { - - if (locale == null) - return new ITocElement[0]; - - ITocElement[] tocs = (ITocElement[]) tocsByLang.get(locale); - if (tocs == null) { - synchronized (this) { - if (tocs == null) { - build(locale); - } - } - tocs = (ITocElement[]) tocsByLang.get(locale); - // one more sanity test... - if (tocs == null) - tocs = new ITocElement[0]; - } - return tocs; - } - - /** - * Returns the navigation model for specified toc - */ - public ITocElement getToc(String href, String locale) { - if (href == null || href.equals("")) //$NON-NLS-1$ - return null; - ITocElement[] tocs = getTocs(locale); - - for (int i = 0; i < tocs.length; i++) { - if (tocs[i].getHref().equals(href)) - return tocs[i]; - } - return null; - } - - /** - * Returns the list of contributing Bundle IDs - */ - public Collection getContributingPlugins() { - if (contributingPlugins == null) { - getContributedTocFiles(Locale.getDefault().toString()); - } - return contributingPlugins; - } - - /** - * Builds the toc from the contribution files - */ - private void build(String locale) { - IToc[] tocs; - try { - Collection contributedTocFiles = getContributedTocFiles(locale); - TocBuilder builder = new TocBuilder(); - builder.build(contributedTocFiles); - Collection builtTocs = builder.getBuiltTocs(); - tocs = new ITocElement[builtTocs.size()]; - int i = 0; - for (Iterator it = builtTocs.iterator(); it.hasNext();) { - tocs[i++] = (ITocElement) it.next(); - } - List orderedTocs = orderTocs(builtTocs); - tocs = new ITocElement[orderedTocs.size()]; - orderedTocs.toArray(tocs); - } catch (Exception e) { - tocs = new IToc[0]; - HelpPlugin.logError("", e); //$NON-NLS-1$ - } - tocsByLang.put(locale, tocs); - } - - /** - * Orders the TOCs according to a product wide preference. - */ - private List orderTocs(Collection unorderedTocs) { - ArrayList orderedHrefs = getPreferredTocOrder(); - ArrayList orderedTocs = new ArrayList(unorderedTocs.size()); - - // add the tocs from the preferred order... - for (Iterator it = orderedHrefs.iterator(); it.hasNext();) { - String href = (String) it.next(); - ITocElement toc = getToc(unorderedTocs, href); - if (toc != null) - orderedTocs.add(toc); - } - // add the remaining tocs - for (Iterator it = unorderedTocs.iterator(); it.hasNext();) { - ITocElement toc = (ITocElement) it.next(); - if (!orderedTocs.contains(toc)) - orderedTocs.add(toc); - } - return orderedTocs; - } - - /** - * Reads product.ini to determine toc ordering. It works in current drivers, - * but will not if location/name of product.ini change. Return the list of - * href's. - */ - private ArrayList getPreferredTocOrder() { - ArrayList orderedTocs = new ArrayList(); - try { - Preferences pref = HelpPlugin.getDefault().getPluginPreferences(); - String preferredTocs = pref.getString(HelpPlugin.BASE_TOCS_KEY); - if (preferredTocs != null) { - StringTokenizer suggestdOrderedInfosets = new StringTokenizer( - preferredTocs, " ;,"); //$NON-NLS-1$ - - while (suggestdOrderedInfosets.hasMoreElements()) { - orderedTocs.add(suggestdOrderedInfosets.nextElement()); - } - } - } catch (Exception e) { - HelpPlugin.logError(HelpResources.getString("E039"), e); //$NON-NLS-1$ - } - return orderedTocs; - } - - /** - * Returns the toc from a list of IToc by identifying it with its (unique) - * href. - */ - private ITocElement getToc(Collection list, String href) { - for (Iterator it = list.iterator(); it.hasNext();) { - ITocElement toc = (ITocElement) it.next(); - if (toc.getHref().equals(href)) - return toc; - } - return null; - } - - /** - * Returns a collection of TocFile that were not processed. - */ - protected Collection getContributedTocFiles(String locale) { - contributingPlugins = new HashSet(); - Collection contributedTocFiles = new ArrayList(); - // find extension point - IExtensionPoint xpt = Platform.getExtensionRegistry() - .getExtensionPoint(HelpPlugin.PLUGIN_ID, TOC_XP_NAME); - if (xpt == null) - return contributedTocFiles; - // get all extensions - IExtension[] extensions = xpt.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - contributingPlugins.add(extensions[i].getNamespace()); - // add to TopicFiles declared in this extension - IConfigurationElement[] configElements = extensions[i] - .getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) - if (configElements[j].getName().equals(TOC_XP_NAME)) { - String pluginId = configElements[j].getDeclaringExtension() - .getNamespace(); - String href = configElements[j].getAttribute("file"); //$NON-NLS-1$ - boolean isPrimary = "true".equals( //$NON-NLS-1$ - configElements[j].getAttribute("primary")); //$NON-NLS-1$ - String extraDir = configElements[j] - .getAttribute("extradir"); //$NON-NLS-1$ - if (href != null) { - contributedTocFiles.add(new TocFile(pluginId, href, - isPrimary, locale, extraDir)); - } - } - } - return contributedTocFiles; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocNode.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocNode.java deleted file mode 100644 index a490eb3ab..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocNode.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; - -import java.util.*; - -/** - * Navigation Element. Common for all objects definable in toc.xml - */ -abstract class TocNode implements ITocNode { - protected List children; - protected List parents; - - /** - * Adds another element as child of this element Modifies parents of a child - * as well - */ - public void addChild(ITocNode child) { - if (children == null) - children = new ArrayList(); - children.add(child); - if (child instanceof TocNode) - ((TocNode) child).addParent(this); - } - /** - * Adds parent parents of this element called by addChild method - */ - protected void addParent(ITocNode parent) { - if (parents == null) - parents = new ArrayList(); - parents.add(parent); - } - - /** - * Obtains children - * - * @return ITocNode List - */ - public List getChildren() { - if (children == null) - return Collections.EMPTY_LIST; - return children; - } - /** - * Obtains parents - * - * @return ITocNode List - */ - protected List getParents() { - if (parents == null) - return Collections.EMPTY_LIST; - return parents; - } - - /** - * @return ITopic list - */ - public List getChildTopics() { - if (children == null) - return Collections.EMPTY_LIST; - List childTopics = new ArrayList(children.size()); - for (Iterator childrenIt = children.iterator(); childrenIt.hasNext();) { - TocNode c = (TocNode) childrenIt.next(); - if ((c instanceof Topic)) { - childTopics.add(c); - } else { - // it is a Toc, Anchor or Link, - // which may have children attached to it. - childTopics.addAll(c.getChildTopics()); - } - } - return childTopics; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/Topic.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/Topic.java deleted file mode 100644 index 8e6d4ac61..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/Topic.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.toc; -import java.util.*; - -import org.eclipse.help.*; -import org.eclipse.help.internal.model.*; -import org.xml.sax.*; -/** - * Topic. Visible navigation element. Labeled, contains linik to a document. Can - * also act as a container for other documents. - */ -public class Topic extends TocNode implements ITopic, ITopicElement { - private String href; - private String label; - private ITopic[] topicArray; - /** - * Constructor. - */ - protected Topic(TocFile tocFile, Attributes attrs) { - if (attrs == null) - return; - href = attrs.getValue("href"); //$NON-NLS-1$ - if (href != null && href.length() > 0) - href = HrefUtil.normalizeHref(tocFile.getPluginID(), href); - label = attrs.getValue("label"); //$NON-NLS-1$ - if (label == null) { - throw new RuntimeException("topic label==null"); //$NON-NLS-1$ - } - tocFile.getToc().registerTopic(this); - } - /** - * Implements abstract method. - */ - public final void build(TocBuilder builder) { - builder.buildTopic(this); - } - public String getHref() { - return href; - } - public String getLabel() { - return label; - } - /** - * This public method is to be used after the build of TOCs is finished. - * With assumption that TOC model is not modifiable after the build, this - * method caches subtopics in an array and releases objects used only during - * build. - * - * @return ITopic list - */ - public ITopic[] getSubtopics() { - if (topicArray == null) { - List topics = getChildTopics(); - // create and cache array of children (Topics only) - topicArray = new ITopic[topics.size()]; - topics.toArray(topicArray); - } - return topicArray; - } - - void setLabel(String label) { - this.label = label; - } - - void setHref(String href) { - this.href = href; - } - /** - * Obtains shortest path leading to this topic in a given TOC - * - * @param toc - * @return ITopic[] or null, path excludes TOC and includes this topic - */ - public ITopic[] getPathInToc(IToc toc) { - List /* of TocNode */ancestors = getTopicPathInToc(toc, this); - if (ancestors == null) { - return null; - } - return (ITopic[]) ancestors.toArray(new ITopic[ancestors.size()]); - } - - /** - * Obtains List of ancestors (TocNodes) leading to specific topic or null - * - * @param toc - * @param topic - * @return List with TocElements: topic1, topic2, topic - */ - static List getTopicPathInToc(IToc toc, Topic topic) { - List topicParents = new ArrayList(topic.getParents()); - for (ListIterator it = topicParents.listIterator(); it.hasNext();) { - TocNode tocNode = (TocNode) it.next(); - if (!(tocNode instanceof Topic)) { - // Check if any parent is the needed TOC - if (tocNode == toc) { - // success, found the correct TOC - List ancestors = new ArrayList(); - ancestors.add(topic); - return ancestors; - } else { - // substitute real topics for toc, link, and anchor parent - // nodes, because we are looking for the shortest path - List grandParents = tocNode.getParents(); - it.remove(); - for (Iterator it2 = grandParents.iterator(); it2.hasNext();) { - it.add(it2.next()); - it.previous(); - } - } - - } - } - - for (Iterator it = topicParents.iterator(); it.hasNext();) { - // delegate to ancestors first - List a = getTopicPathInToc(toc, (Topic) it.next()); - if (a != null) { - // then add this topic to the path - a.add(topic); - return a; - } - } - - return null; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/FastStack.java b/org.eclipse.help/src/org/eclipse/help/internal/util/FastStack.java deleted file mode 100644 index e1ce846ae..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/util/FastStack.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.util; - -import java.util.*; - -/** - * Fast Stack is similar to java.uiti.Stack, but simplified for speed. It uses - * ArrayList as an underlying collection. The methods in this class are not - * thread safe. - */ -public class FastStack extends ArrayList { - private int last = -1; - - public FastStack() { - super(); - } - - public final Object push(Object item) { - super.add(item); - last++; - return item; - } - - public final Object pop() { - return super.remove(last--); - } - - public final Object peek() { - return super.get(last); - } - - public final boolean empty() { - return last < 0; - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java b/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java deleted file mode 100644 index e2a5ed4c4..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.util; -import java.io.*; -import java.net.*; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.help.*; -import org.eclipse.help.internal.*; -import org.osgi.framework.*; -public class ResourceLocator { - public static final String CONTENTPRODUCER_XP_NAME = "contentProducer"; //$NON-NLS-1$ - public static final String CONTENTPRODUCER_XP_FULLNAME = HelpPlugin.PLUGIN_ID - + "." + CONTENTPRODUCER_XP_NAME; //$NON-NLS-1$ - private static Hashtable zipCache = new Hashtable(); - private static final Object ZIP_NOT_FOUND = new Object(); - // Indicates there is no dynamic content provider for a particular plugin - private static final Object STATIC_DOCS_ONLY = ZIP_NOT_FOUND; - // Map of document content providers by plug-in ID; - private static Map contentProducers = new HashMap(2, 0.5f); - static { - Platform.getExtensionRegistry().addRegistryChangeListener( - new IRegistryChangeListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent) - */ - public void registryChanged(IRegistryChangeEvent event) { - IExtensionDelta[] deltas = event.getExtensionDeltas( - HelpPlugin.PLUGIN_ID, CONTENTPRODUCER_XP_NAME); - for (int i = 0; i < deltas.length; i++) { - IExtension extension = deltas[i].getExtension(); - String affectedPlugin = extension.getNamespace(); - // reset producer for the affected plugin, - // it will be recreated on demand - synchronized (contentProducers) { - contentProducers.remove(affectedPlugin); - } - } - } - }); - } - /** - * Obtains content proivider for a documentation plug-in, creates one if - * necessary. - * - * @param pluginId - * @return ITopicContentProvider or null - */ - private static IHelpContentProducer getContentProducer(String pluginId) { - synchronized (contentProducers) { - Object producer = contentProducers.get(pluginId); - if (producer == null) { - // first time for the plug-in, so attempt to - // find and instantiate provider - producer = createContentProducer(pluginId); - if (producer == null) { - producer = STATIC_DOCS_ONLY; - } - contentProducers.put(pluginId, producer); - } - if (producer == STATIC_DOCS_ONLY) { - return null; - } else { - return (IHelpContentProducer) producer; - } - } - } - /** - * Creates content proivider for a documentation plug-in - * - * @param pluginId - * @return ITopicContentProvider or null - */ - private static IHelpContentProducer createContentProducer(String pluginId) { - IExtensionPoint xp = Platform.getExtensionRegistry().getExtensionPoint( - CONTENTPRODUCER_XP_FULLNAME); - if (xp == null) { - return null; - } - IExtension[] extensions = xp.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - if (!extensions[i].getNamespace().equals(pluginId)) { - continue; - } - IConfigurationElement[] elements = extensions[i] - .getConfigurationElements(); - for (int j = 0; j < elements.length; j++) { - if (!CONTENTPRODUCER_XP_NAME.equals(elements[j].getName())) { - continue; - } - try { - Object o = elements[j] - .createExecutableExtension("producer"); //$NON-NLS-1$ - if (o instanceof IHelpContentProducer) { - return (IHelpContentProducer) o; - } - } catch (CoreException ce) { - HelpPlugin.logError(HelpResources.getString( - "E044", pluginId), ce); //$NON-NLS-1$ - } - } - } - return null; - } - /** - * Opens an input stream to a file contained in a plugin. This includes NL - * lookup. - */ - public static InputStream openFromProducer(Bundle pluginDesc, String file, - String locale) { - IHelpContentProducer producer = getContentProducer(pluginDesc - .getSymbolicName()); - if (producer == null) { - return null; - } - if (locale == null || locale.length() <= 0) { - locale = Platform.getNL(); - } - Locale l; - if (locale.length() >= 5) { - l = new Locale(locale.substring(0, 2), locale.substring(3, 5)); - } else if (locale.length() >= 2) { - l = new Locale(locale.substring(0, 2), ""); //$NON-NLS-1$ - } else { - l = Locale.getDefault(); - } - return producer.getInputStream(pluginDesc.getSymbolicName(), file, l); - } - /** - * Opens an input stream to a file contained in a plugin. This includes NL - * lookup. - */ - public static InputStream openFromPlugin(String pluginId, String file, - String locale) { - Bundle bundle = Platform.getBundle(pluginId); - if (bundle != null) - return openFromPlugin(Platform.getBundle(pluginId), file, locale); - else - return null; - } - /** - * Opens an input stream to a file contained in a zip in a plugin. This - * includes NL lookup. - */ - public static InputStream openFromZip(Bundle pluginDesc, String zip, - String file, String locale) { - // First try the NL lookup - InputStream is = doOpenFromZip(pluginDesc, "$nl$/" + zip, file, locale); //$NON-NLS-1$ - if (is == null) - // Default location <plugin>/doc.zip - is = doOpenFromZip(pluginDesc, zip, file, locale); - return is; - } - /** - * Opens an input stream to a file contained in a plugin. This includes NL - * lookup. - */ - public static InputStream openFromPlugin(Bundle pluginDesc, String file, - String locale) { - InputStream is = doOpenFromPlugin(pluginDesc, "$nl$/" + file, locale); //$NON-NLS-1$ - if (is == null) - // Default location - is = doOpenFromPlugin(pluginDesc, file, locale); - return is; - } - /** - * Opens an input stream to a file contained in doc.zip in a plugin - */ - private static InputStream doOpenFromZip(Bundle pluginDesc, String zip, - String file, String locale) { - String realZipURL = findZip(pluginDesc, zip, locale); - if (realZipURL == null) { - return null; - } - try { - URL jurl = new URL("jar", "", realZipURL + "!/" + file); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - URLConnection jconnection = jurl.openConnection(); - jconnection.setDefaultUseCaches(false); - jconnection.setUseCaches(false); - return jconnection.getInputStream(); - } catch (IOException ioe) { - return null; - } - } - /** - * Opens an input stream to a file contained in a plugin - */ - private static InputStream doOpenFromPlugin(Bundle pluginDesc, String file, - String locale) { - IPath flatFilePath = new Path(file); - Map override = new HashMap(1); - override.put("$nl$", locale); //$NON-NLS-1$ - URL flatFileURL = Platform.find(pluginDesc, flatFilePath, override); - if (flatFileURL != null) - try { - return flatFileURL.openStream(); - } catch (IOException e) { - return null; - } - return null; - } - /** - * @param pluginDesc - * @param zip - * zip file path as required by Plugin.find() - * @param locale - * @return String form of resolved URL of a zip or null - */ - private static String findZip(Bundle pluginDesc, String zip, String locale) { - String pluginID = pluginDesc.getSymbolicName(); - // check cache - Map cache = zipCache; - Object cached = cache.get(pluginID + '/' + zip + '/' + locale); - if (cached == null) { - // not in cache find on filesystem - IPath zipFilePath = new Path(zip); - Map override = new HashMap(1); - override.put("$nl$", locale); //$NON-NLS-1$ - try { - URL zipFileURL = Platform.find(pluginDesc, zipFilePath, - override); //PASCAL This will not activate the plugin - if (zipFileURL != null) { - URL realZipURL = Platform.asLocalURL(Platform - .resolve(zipFileURL)); - cached = realZipURL.toExternalForm(); - } else { - cached = ZIP_NOT_FOUND; - } - } catch (IOException ioe) { - cached = ZIP_NOT_FOUND; - } - // cache it - cache.put(pluginID + '/' + zip + '/' + locale, cached); - } - if (cached == ZIP_NOT_FOUND) { - return null; - } - return (String) cached; - } - public static void clearZipCache() { - zipCache = new Hashtable(); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java b/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java deleted file mode 100644 index 27ffb6aac..000000000 --- a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.help.internal.util; -import java.io.*; - -public class URLCoder { - public static String encode(String s) { - try { - return urlEncode(s.getBytes("UTF8")); //$NON-NLS-1$ - } catch (UnsupportedEncodingException uee) { - return null; - } - } - public static String decode(String s) { - try { - return new String(urlDecode(s), "UTF8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException uee) { - return null; - } - } - private static String urlEncode(byte[] data) { - StringBuffer buf = new StringBuffer(data.length); - for (int i = 0; i < data.length; i++) { - buf.append('%'); - buf.append(Character.forDigit((data[i] & 240) >>> 4, 16)); - buf.append(Character.forDigit(data[i] & 15, 16)); - } - return buf.toString(); - } - private static byte[] urlDecode(String encodedURL) { - int len = encodedURL.length(); - ByteArrayOutputStream os = new ByteArrayOutputStream(len); - for (int i = 0; i < len;) { - switch (encodedURL.charAt(i)) { - case '%' : - if (len >= i + 3) { - os.write(Integer.parseInt(encodedURL.substring(i + 1, - i + 3), 16)); - } - i += 3; - break; - case '+' : //exception from standard - os.write(' '); - i++; - break; - default : - os.write(encodedURL.charAt(i++)); - break; - } - - } - return os.toByteArray(); - } -} diff --git a/org.eclipse.help/src/org/eclipse/help/package.html b/org.eclipse.help/src/org/eclipse/help/package.html deleted file mode 100644 index 8ab6f51be..000000000 --- a/org.eclipse.help/src/org/eclipse/help/package.html +++ /dev/null @@ -1,20 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <meta name="Author" content="IBM"> - <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; U) [Netscape]"> - <title>Package-level Javadoc</title> -</head> -<body> -Provides core help system for the platform. -<h2> -Package Specification</h2> -There is a general mechanism (defined at the plug-in level) by which individual -plug-ins contribute online help and context-sensitive help for their component. - -This package defines interfaces for data objects managed by help systems, as well -as <code>HelpSystem</code> class which static methods can be used to obtain objects -managed by the help system. -</body> -</html> |