Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.help.webapp/WEB-INF/web.xml10
-rw-r--r--org.eclipse.help.webapp/advanced/images/e_index_view.gifbin0 -> 82 bytes
-rw-r--r--org.eclipse.help.webapp/advanced/images/index_view.gifbin0 -> 112 bytes
-rw-r--r--org.eclipse.help.webapp/advanced/indexToolbar.jsp29
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.jsp315
-rw-r--r--org.eclipse.help.webapp/advanced/selectTopic.jsp223
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties16
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/IndexData.java119
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/LayoutData.java36
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/SelectTopicData.java52
-rw-r--r--org.eclipse.help/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.help/plugin.properties1
-rw-r--r--org.eclipse.help/plugin.xml1
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java9
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IIndex.java29
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IIndexEntry.java35
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IIndexTopic.java17
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/Index.java51
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java133
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java51
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java89
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java139
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java114
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexTopic.java35
24 files changed, 1495 insertions, 10 deletions
diff --git a/org.eclipse.help.webapp/WEB-INF/web.xml b/org.eclipse.help.webapp/WEB-INF/web.xml
index 2ffb5b3d3..23d34761e 100644
--- a/org.eclipse.help.webapp/WEB-INF/web.xml
+++ b/org.eclipse.help.webapp/WEB-INF/web.xml
@@ -28,6 +28,11 @@
</servlet>
<servlet>
+ <servlet-name>index</servlet-name>
+ <servlet-class>org.eclipse.help.internal.webapp.servlet.IndexServlet</servlet-class>
+ </servlet>
+
+ <servlet>
<servlet-name>search</servlet-name>
<servlet-class>org.eclipse.help.internal.webapp.servlet.SearchServlet</servlet-class>
</servlet>
@@ -75,6 +80,11 @@
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>index</servlet-name>
+ <url-pattern>/index/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>search</servlet-name>
<url-pattern>/search/*</url-pattern>
</servlet-mapping>
diff --git a/org.eclipse.help.webapp/advanced/images/e_index_view.gif b/org.eclipse.help.webapp/advanced/images/e_index_view.gif
new file mode 100644
index 000000000..e1aa83d35
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/images/e_index_view.gif
Binary files differ
diff --git a/org.eclipse.help.webapp/advanced/images/index_view.gif b/org.eclipse.help.webapp/advanced/images/index_view.gif
new file mode 100644
index 000000000..c370f853b
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/images/index_view.gif
Binary files differ
diff --git a/org.eclipse.help.webapp/advanced/indexToolbar.jsp b/org.eclipse.help.webapp/advanced/indexToolbar.jsp
new file mode 100644
index 000000000..7bb14a1d9
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/indexToolbar.jsp
@@ -0,0 +1,29 @@
+<%--
+ Copyright (c) 2005 Intel Corporation.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Intel Corporation - initial API and implementation
+--%>
+<%@ include file="header.jsp"%>
+
+
+<jsp:include page="toolbar.jsp">
+ <jsp:param name="script" value="navActions.js"/>
+ <jsp:param name="view" value="index"/>
+
+ <jsp:param name="name" value="show_all"/>
+ <jsp:param name="tooltip" value='show_all'/>
+ <jsp:param name="image" value="show_all.gif"/>
+ <jsp:param name="action" value="toggleShowAll"/>
+ <jsp:param name="state" value="<%=(new ActivitiesData(application, request, response)).getButtonState()%>"/>
+
+ <jsp:param name="name" value="synchnav"/>
+ <jsp:param name="tooltip" value='SynchNav'/>
+ <jsp:param name="image" value="synch_nav.gif"/>
+ <jsp:param name="action" value="resynchNav"/>
+ <jsp:param name="state" value='off'/>
+</jsp:include>
diff --git a/org.eclipse.help.webapp/advanced/indexView.jsp b/org.eclipse.help.webapp/advanced/indexView.jsp
new file mode 100644
index 000000000..2c4131b9e
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/indexView.jsp
@@ -0,0 +1,315 @@
+<%--
+ Copyright (c) 2005 Intel Corporation.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Intel Corporation - initial API and implementation
+--%>
+<%@ include file="header.jsp"%>
+
+<%
+ IndexData data = new IndexData(application, request, response);
+ WebappPreferences prefs = data.getPrefs();
+%>
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Pragma" content="no-cache">
+<meta http-equiv="Expires" content="-1">
+<title><%=ServletResources.getString("Index", request)%></title>
+</head>
+
+<style type="text/css">
+
+/* need this one for Mozilla */
+html {
+ width:100%;
+ height:100%;
+ margin:0px;
+ padding:0px;
+ border:0px;
+}
+
+body {
+ width:100%;
+ height:100%;
+ margin:0px;
+ padding:0px;
+ background-color: window;
+ color:WindowText;
+}
+
+table {
+ width: 100%;
+ height: 100%;
+ cell-spacing: 10px;
+}
+
+td {
+ width: 100%;
+ padding: 4px;
+}
+
+td.editor {
+ height:16px;
+}
+
+input.editor {
+ color:black;
+ width:100%;
+ font-size:12px;
+ border: 1px solid ThreeDShadow;;
+ background-color: window;
+}
+
+td.index {
+ height:100%;
+}
+
+select.index {
+ width:100%;
+ height:100%;
+ color:black;
+ font-family: "sans serif";
+ font-size:10px
+ border: 1px solid;
+ background-color: window;
+}
+
+td.display {
+ height:16px;
+ text-align: right;
+}
+
+input.display {
+ background:ThreeDShadow;
+ color:Window;
+ font-weight:bold;
+ border: 1px solid ThreeDShadow;
+}
+
+</style>
+<script language="JavaScript">
+var advancedDialog;
+
+var oldEditor;
+var index;
+var editor;
+
+var w = 500;
+var h = 250;
+
+function keyListener(e){
+ if(!e){
+ //for IE
+ e = window.event;
+ }
+ switch (e.keyCode) {
+ case 38:
+ if (index.selectedIndex > 0) {
+ index.selectedIndex = index.selectedIndex - 1;
+ onIndexChange();
+ setCaretToEnd(editor);
+ return false;
+ }
+ return true;
+ case 40:
+ if (index.selectedIndex < (index.length - 1) ) {
+ index.selectedIndex = index.selectedIndex + 1;
+ onIndexChange(index);
+ setCaretToEnd(editor);
+ return false;
+ }
+ return true;
+ default:
+ return true;
+ };
+}
+
+function selectTopic(i) {
+
+<%
+if (data.isIE()){
+%>
+ var l = top.screenLeft + (top.document.body.clientWidth - w) / 2;
+ var t = top.screenTop + (top.document.body.clientHeight - h) / 2;
+<%
+} else {
+%>
+ var l = top.screenX + (top.innerWidth - w) / 2;
+ var t = top.screenY + (top.innerHeight - h) / 2;
+<%
+}
+%>
+
+ // move the dialog just a bit higher than the middle
+ if (t-50 > 0) t = t-50;
+
+ window.location="javascript://needModal";
+ advancedDialog = window.open("selectTopic.jsp?entry="+encodeURIComponent(index.options[i].value), "advancedDialog", "resizeable=no,height="+h+",width="+w+",left="+l+",top="+t );
+ advancedDialog.focus();
+}
+
+function openTopic(href) {
+ window.parent.parent.parent.parent.ContentFrame.ContentViewFrame.window.location.replace(href);
+}
+
+function alertEmpty() {
+ alert("To locate information about this keyword \nplease select one of the subentries in the list");
+}
+function onEnterKeyPress(onEvent) {
+ //alert("onEnterKeyPress");
+ if(onEvent.keyCode==13) {
+ displayTopic();
+ return false;
+ }
+ else {
+ return true;
+ }
+}
+
+function setCaretToEnd (control) {
+ if (control.createTextRange) {
+ var range = control.createTextRange();
+ range.collapse(false);
+ range.select();
+ }
+ else if (control.setSelectionRange) {
+ control.focus();
+ var length = control.value.length;
+ control.setSelectionRange(length, length);
+ }
+}
+
+function onIndexChange() {
+ //alert("onIndexChange");
+ editor.value = index.options[index.selectedIndex].value;
+ oldEditor = editor.value;
+}
+
+function compare(keyword, pattern) {
+ var kI = 0, pI = 0;
+ var kCh, pCh;
+ while ( kI < keyword.length && pI < pattern.length) {
+ kCh = keyword.charAt(kI).toLowerCase();
+ pCh = pattern.charAt(pI).toLowerCase();
+ if(kCh == ',') {
+ if(pCh != ',') {
+ return -1;
+ }
+ }
+ else if (pCh == ',') {
+ return 1;
+ }
+ else if ( kCh > pCh ) {
+ return 1;
+ }
+ else if ( kCh < pCh) {
+ return -1;
+ }
+ kI++;
+ pI++;
+ }
+ if( keyword.length >= pattern.length ) {
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+function searchPattern(pattern) {
+ var from = 0;
+ var to = index.length;
+ var i;
+ var res;
+ do {
+ i = Math.floor((to + from) / 2);
+ res = compare(index.options[i].value, pattern);
+ if( res == 0) {
+ while (i > 0) {
+ res = compare(index.options[--i].value, pattern);
+ if (res != 0) {
+ i++;
+ break;
+ }
+ };
+ index.selectedIndex = i;
+ return;
+ }
+ else if (res < 0) {
+ from = i + 1;
+ }
+ else {
+ to = i;
+ }
+ } while (to > from) ;
+}
+
+function updateIndex() {
+ var newEditor = editor.value;
+ if(oldEditor != newEditor) {
+ oldEditor = newEditor;
+ searchPattern(oldEditor);
+ }
+}
+
+function onloadHandler() {
+ editor = document.getElementById("editor");
+ index = document.getElementById("index");
+ index.selectedIndex = 0;
+ editor.value = index.options[0].value;
+ oldEditor=editor.value;
+ //editor.focus();
+ document.onkeydown = keyListener;
+ window.self.setInterval("updateIndex()", 200);
+}
+
+</script>
+<body onload="onloadHandler()">
+
+<table>
+ <tr>
+ <td><p><%=ServletResources.getString("Index_header", request)%></p>
+ </td>
+ </tr>
+ <tr>
+ <td class="editor"> <input type="text" class="editor" id="editor" onKeyPress="return onEnterKeyPress(event);" >
+ </td>
+ </tr>
+ <tr>
+ <td class="index">
+ <select name="select" size="2" class="index" id="index"
+ onChange="onIndexChange();"
+ onKeyPress="return onEnterKeyPress(event);"
+ onDblClick="javascript:displayTopic();">
+
+ <%
+ data.generateIndex(out, "&nbsp;&nbsp;");
+ %>
+ </select> </td>
+ </tr>
+ <tr>
+ <td class="display"><input class="display" type="submit" id="display" value="<%=ServletResources.getString("Index_display", request)%>" onClick="javascript:displayTopic();"></td>
+ </tr>
+</table>
+</body>
+<script language="JavaScript">
+
+function displayTopic() {
+ switch (index.selectedIndex) {
+ <%
+ data.generateHrefs(out);
+ %>
+ default:
+ selectTopic(index.selectedIndex);
+ };
+}
+
+
+</script>
+</html>
diff --git a/org.eclipse.help.webapp/advanced/selectTopic.jsp b/org.eclipse.help.webapp/advanced/selectTopic.jsp
new file mode 100644
index 000000000..bad3b20e4
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/selectTopic.jsp
@@ -0,0 +1,223 @@
+<%--
+ Copyright (c) 2005 Intel Corporation.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Intel Corporation - initial API and implementation
+--%>
+<%@ include file="header.jsp"%>
+
+<%
+ SelectTopicData data = new SelectTopicData(application, request, response);
+%>
+
+<html>
+<head>
+<title><%=ServletResources.getString("select_topic", request)%></title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Pragma" content="no-cache">
+<meta http-equiv="Expires" content="-1">
+
+<style type="text/css">
+body {
+ background-color: ButtonFace;
+ color:WindowText;
+ font: icon;
+ border:0;
+ cursor:default;
+ padding: 10px;
+ margin:0px;
+ text-align: center;
+}
+
+
+td {
+ padding: 0px;
+ margin: 0px;
+ border-width: 0px;
+}
+
+table {
+ padding: 0px;
+ margin: 0px;
+ text-align: left;
+}
+
+table table {
+ width: 447px;
+ border-width: 1px;
+ border-style: solid;
+}
+
+table table td {
+ border-width: 0px;
+ border-style: solid;
+ padding: 1px 3px 1px 3px;
+}
+
+table table td.c0 {
+ width: 25px;
+ border-bottom-width: 1px;
+}
+
+table table td.c1 {
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ width: 200px;
+}
+
+table table td.c2 {
+ border-bottom-width: 1px;
+ width: 200px;
+}
+
+table.header {
+ height: 16px;
+ border-color: black;
+ border-bottom-width: 0px;
+}
+
+table.header td {
+ background: #AAA;
+ border-color: black;
+}
+
+div.content {
+ padding: 0px;
+ margin: 0px;
+ height: 120px;
+ overflow: auto;
+ width: 463px; /*Original width + 2 pixels for border + 16 pixels for scrollbar*/
+ border-width: 0px;
+}
+
+table.content {
+ border-top-width: 0px;
+ border-bottom-width: 0px;
+ border-color: black;
+ height: 100%;
+}
+
+table.content td {
+ background: white;
+ border-color: #AAA;
+}
+
+table.footer {
+ border-width: 0px;
+ border-color: black;
+ border-top-width: 1px;
+}
+
+table.footer td{
+ text-align: right;
+ padding: 5px;
+}
+
+td.title {
+ padding: 5px;
+}
+
+</style>
+<script language="JavaScript">
+
+function findChecked(group) {
+ for(var i=0; i<group.length; i++) {
+ if(group[i].checked) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+function keyListener(e){
+ if(!e){
+ //for IE
+ e = window.event;
+ }
+ var hrefs = document.topicForm.hrefs;
+ var checked = findChecked(hrefs);
+ if(checked < 0) return;
+ switch (e.keyCode) {
+ case 38:
+ if (checked > 0) {
+ checked = checked -1;
+ break;
+ }
+ return true;
+ case 40:
+ if (checked < (hrefs.length - 1) ) {
+ checked = checked + 1;
+ break;
+ }
+ return true;
+ default:
+ return true;
+ };
+ hrefs[checked].checked = true;
+ hrefs[checked].focus();
+ return false;
+}
+
+function openTopic() {
+ var hrefs = document.topicForm.hrefs;
+ for(var i=0; i<hrefs.length; i++) {
+ if(hrefs[i].checked) {
+ window.opener.openTopic(hrefs[i].value);
+ window.close();
+ }
+ }
+}
+
+function onloadHandler() {
+ document.topicForm.hrefs[0].checked = true;
+ document.topicForm.hrefs[0].focus();
+ document.onkeydown = keyListener;
+}
+
+
+</script>
+<body onload="onloadHandler()">
+<form name="topicForm" onSubmit="javascript:openTopic();" onReset="window.close()">
+<table border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="title"><%=ServletResources.getString("select_topic_header", request)%>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table border="0" cellpadding="0" cellspacing="0" class="header">
+ <tr>
+ <td class="c0">&nbsp;</td>
+ <td class="c1"><%=ServletResources.getString("select_topic_title", request)%></td>
+ <td class="c2"><%=ServletResources.getString("select_topic_location", request)%></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div class="content">
+ <table border="0" cellpadding="0" cellspacing="0" class="content">
+<%
+ data.generateTopics(out);
+%>
+ </table>
+ </div></td>
+ </tr>
+ <tr>
+ <td> <table border="0" cellpadding="0" cellspacing="0" class="footer">
+ <tr>
+ <td> <input type="reset" value="Cancel"> &nbsp; <input type="submit" id="display" value="<%=ServletResources.getString("select_topic_display", request)%>">
+ </td>
+ </tr>
+ </table></td>
+ </tr>
+</table>
+</form>
+</body>
+</html>
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
index c4f6938b4..e05e091da 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
@@ -11,6 +11,18 @@
browserTitle = Help - {0}
Search=&Search
SearchResults=Search Results
+
+# Added for implementation of Help-Index feature
+Index=Index
+Index_header=Please type the word and then click Display button
+Index_display=Display
+select_topic=Select topic to display
+select_topic_header=Please select topic and then click Display
+select_topic_display=Display
+select_topic_title=Title
+select_topic_location=Location
+###########
+
Content=Contents
Links=Links
Bookshelf=Table of Contents
@@ -60,6 +72,10 @@ links=Links
search=Search Results
bookmarks=Bookmarks
+# Added for implementation of Help-Index feature
+index=Index
+###########
+
Views=Navigation Views
noLiveHelp=Active help is not enabled in your installation.
noLiveHelpInInfocenter=You must run help locally to perform "active help" actions.
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/IndexData.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/IndexData.java
new file mode 100644
index 000000000..fe4aff7d8
--- /dev/null
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/IndexData.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.help.internal.webapp.data;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.index.IIndex;
+import org.eclipse.help.internal.index.IIndexEntry;
+import org.eclipse.help.internal.index.IIndexTopic;
+
+/**
+ * Helper class for searchView.jsp initialization
+ */
+public class IndexData extends ActivitiesData {
+ private IIndex index;
+
+ //Temporary storage for index generation
+ int entryIndex;
+ Writer out;
+ String indent;
+ StringWriter funcOut;
+
+ /**
+ * Constructs the data for the index page.
+ * @param context
+ * @param request
+ */
+ public IndexData(
+ ServletContext context,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ super(context, request, response);
+ loadIndex();
+ }
+
+ /**
+ * Loads help index
+ */
+ private void loadIndex() {
+ this.index = HelpPlugin.getIndexManager().getIndex(Platform.getNL());
+ }
+
+ public void generateHrefs(Writer out) throws IOException{
+ out.write(funcOut.toString());
+ }
+
+ public void generateIndex(Writer out, String indent) throws IOException{
+ this.out = out;
+ this.entryIndex = 0;
+ this.indent = indent;
+ this.funcOut = new StringWriter();
+
+ Iterator iter = index.getEntries().values().iterator();
+ while(iter.hasNext()) {
+ IIndexEntry entry = (IIndexEntry) iter.next();
+ generateIndexEntry(entry, 0, "");
+ }
+ }
+
+ private void generateIndexEntry( IIndexEntry entry, int depth, String parent) throws IOException{
+ List topics = entry.getTopics();
+ int size = topics.size();
+ String label = UrlUtil.htmlEncode(entry.getKeyword());
+
+ if(size == 1) {
+ IIndexTopic topic = (IIndexTopic) topics.get(0);
+ String href = UrlUtil.getHelpURL(topic.getHref());
+ funcOut.write("case " + entryIndex + ": openTopic(\"" + href + "\"); break;\n");
+ }
+ else if (size == 0) {
+ funcOut.write("case " + entryIndex + ": alertEmpty(); break;\n");
+ }
+
+ out.write("<option value='"+ UrlUtil.htmlEncode(parent + label)+"'>");
+ for(int i=0; i<depth; i++) out.write(indent);
+ out.write(UrlUtil.htmlEncode(label) + "</option>");
+ entryIndex++;
+
+ Iterator iter = entry.getEntries().values().iterator();
+ if(iter.hasNext()) {
+ do {
+ IIndexEntry childEntry = (IIndexEntry) iter.next();
+ generateIndexEntry(childEntry, depth+1, parent+label+",");
+ } while(iter.hasNext());
+ }
+ }
+
+ public IIndexEntry getIndexEntry(String [] path) {
+ Map entries = index.getEntries();
+ IIndexEntry result = null;
+ for(int i = 0; i < path.length; i++) {
+ result = (IIndexEntry) entries.get(path[i]);
+ if(result == null)
+ return null;
+ else
+ entries = result.getEntries();
+ }
+ return result;
+ }
+}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/LayoutData.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/LayoutData.java
index 755736e52..b5a709cbb 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/LayoutData.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/LayoutData.java
@@ -10,9 +10,13 @@
*******************************************************************************/
package org.eclipse.help.internal.webapp.data;
+import java.util.ArrayList;
+
import javax.servlet.*;
import javax.servlet.http.*;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.*;
public class LayoutData extends RequestData {
@@ -81,7 +85,14 @@ public class LayoutData extends RequestData {
View searchview = new View("search", //$NON-NLS-1$
"", //$NON-NLS-1$
preferences.getImagesDirectory() + "/search_results_view.gif", 'R'); //$NON-NLS-1$
-
+
+ View indexview = null;
+ if (HelpPlugin.getIndexManager().getIndex(Platform.getNL())
+ .getEntries().size() > 0) {
+ indexview = new View("index", "", preferences.getImagesDirectory()
+ + "/index_view.gif", 'I');
+ }
+
View linksview = null;
View bookmarksview = null;
@@ -94,15 +105,20 @@ public class LayoutData extends RequestData {
"", //$NON-NLS-1$
preferences.getImagesDirectory() + "/bookmarks_view.gif", (char)0); //$NON-NLS-1$
- if (linksview != null && bookmarksview != null)
- views = new View[]{tocview, searchview, linksview, bookmarksview};
- else if (linksview != null)
- views = new View[]{tocview, searchview, linksview};
- else if (bookmarksview != null)
- views = new View[]{tocview, searchview, bookmarksview};
- else
- views = new View[]{tocview, searchview};
-
+ ArrayList viewList = new ArrayList();
+ viewList.add(tocview);
+ viewList.add(searchview);
+ if (indexview != null){
+ viewList.add(indexview);
+ }
+ if (linksview != null){
+ viewList.add(linksview);
+ }
+ if (bookmarksview !=null){
+ viewList.add(bookmarksview);
+ }
+
+ views = (View[]) viewList.toArray(new View[viewList.size()]);
return views;
}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/SelectTopicData.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/SelectTopicData.java
new file mode 100644
index 000000000..fc6df6bb1
--- /dev/null
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/SelectTopicData.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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 Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.webapp.data;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.help.internal.index.IIndexEntry;
+import org.eclipse.help.internal.index.IIndexTopic;
+
+/**
+ * This class manages help working sets
+ */
+public class SelectTopicData extends IndexData {
+
+ private IIndexEntry entry;
+ public SelectTopicData( ServletContext context,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ super(context, request, response);
+ entry = getIndexEntry(request.getParameter("entry").split("\\,"));
+
+ }
+
+ public void generateTopics(Writer out) throws IOException {
+ List topics = entry.getTopics();
+ for(int i = 0; i< topics.size(); i++) {
+ IIndexTopic topic = (IIndexTopic) topics.get(i);
+ out.write("<tr><td class=\"c0\"><input type=\"radio\" name=\"hrefs\" value=\"");
+ out.write(UrlUtil.getHelpURL(topic.getHref()));
+ out.write("\" id=\"r" + i + "\"></td>");
+ out.write("<td class=\"c1\"><label for=\"r" + i + "\">");
+ out.write(UrlUtil.htmlEncode(topic.getLabel()));
+ out.write("</label></td><td class=\"c2\"><label for=\"r" + i +"\">");
+ out.write(UrlUtil.htmlEncode(topic.getLocation()));
+ out.write("</label></td></tr>");
+ }
+ }
+}
diff --git a/org.eclipse.help/META-INF/MANIFEST.MF b/org.eclipse.help/META-INF/MANIFEST.MF
index 931080a4d..7544afecc 100644
--- a/org.eclipse.help/META-INF/MANIFEST.MF
+++ b/org.eclipse.help/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.help,
org.eclipse.help.internal;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp",
org.eclipse.help.internal.context;x-friends:="org.eclipse.help.base,org.eclipse.help.ui",
+ org.eclipse.help.internal.index;x-friends:="org.eclipse.help.webapp",
org.eclipse.help.internal.model;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp",
org.eclipse.help.internal.protocols;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp",
org.eclipse.help.internal.toc;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp",
diff --git a/org.eclipse.help/plugin.properties b/org.eclipse.help/plugin.properties
index 29c8f7da7..dfd935d7c 100644
--- a/org.eclipse.help/plugin.properties
+++ b/org.eclipse.help/plugin.properties
@@ -13,3 +13,4 @@ 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
+index_extension_point_name = Help Index Contributions
diff --git a/org.eclipse.help/plugin.xml b/org.eclipse.help/plugin.xml
index 55466abf3..47e42c42a 100644
--- a/org.eclipse.help/plugin.xml
+++ b/org.eclipse.help/plugin.xml
@@ -5,5 +5,6 @@
<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"/>
+ <extension-point id="index" name="%index_extension_point_name"/>
</plugin>
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java
index ed37af717..f1cd49c84 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java
@@ -14,6 +14,7 @@ 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.index.*;
import org.eclipse.help.internal.util.*;
import org.osgi.framework.*;
/**
@@ -39,6 +40,8 @@ public class HelpPlugin extends Plugin
protected static Object tocManagerCreateLock = new Object();
protected ContextManager contextManager;
+ protected IndexManager indexManager;
+
/**
* Logs an Error message with an exception.
*/
@@ -163,4 +166,10 @@ public class HelpPlugin extends Plugin
}
}
+ public static IndexManager getIndexManager() {
+ if (getDefault().indexManager == null)
+ getDefault().indexManager = new IndexManager();
+ return getDefault().indexManager;
+ }
+
}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IIndex.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndex.java
new file mode 100644
index 000000000..47c38cbf3
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndex.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.Map;
+
+/**
+ * @author sturmash
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public interface IIndex {
+
+ /**
+ * Returns assosiation between keywords and IIndexEntry
+ * @return Map of IIndexEntry
+ */
+
+ Map getEntries();
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexEntry.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexEntry.java
new file mode 100644
index 000000000..f2f6e52db
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexEntry.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.List;
+
+
+/**
+ * @author sturmash
+ *
+ * Represents a single entry of the help index
+ */
+public interface IIndexEntry extends IIndex {
+
+ /**
+ * Returns a keyword that this entry is associated with
+ * @return
+ */
+ public String getKeyword();
+
+ /**
+ * Returns list of topics assosiated with this index entry (i.e. keyword)
+ * @return List of IIndexTopic
+ */
+ public List getTopics();
+
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexTopic.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexTopic.java
new file mode 100644
index 000000000..c796240a4
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IIndexTopic.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import org.eclipse.help.IHelpResource;
+
+public interface IIndexTopic extends IHelpResource {
+ String getLocation();
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java
new file mode 100644
index 000000000..6a881b7de
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+/**
+ * @author sturmash
+ * Help index implementation
+ */
+public class Index implements IIndex {
+
+ Map entries;
+
+ public static final class IgnoreCaseComparator implements Comparator {
+
+ public int compare(Object left, Object right) {
+ return ((String)left).compareToIgnoreCase((String) right);
+ }
+ }
+ public Index() {
+ entries = new TreeMap(new IgnoreCaseComparator());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.help.internal.index.IIndex#addEntry(java.lang.String, java.util.Collection)
+ */
+ public IndexEntry addEntry(String keyword) {
+ IndexEntry oldEntry = (IndexEntry) entries.get(keyword);
+ if (oldEntry == null) {
+ oldEntry = new IndexEntry(keyword);
+ entries.put(keyword, oldEntry);
+ }
+ return oldEntry;
+ }
+
+ public Map getEntries() {
+ return entries;
+ }
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java
new file mode 100644
index 000000000..77105fa34
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Stack;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.model.ITocElement;
+
+
+/**
+ * @author sturmash
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class IndexBuilder {
+
+ private Collection contributedIndexFiles;
+ private Collection unprocessedIndexFiles;
+ private Index index;
+ private IndexEntry current;
+ private Stack entries;
+ private ITocElement[] tocs;
+
+ /**
+ * Constructs the index builder
+ */
+ public IndexBuilder() {
+ unprocessedIndexFiles = new ArrayList();
+ index = new Index();
+ entries = new Stack();
+ tocs = HelpPlugin.getTocManager().getTocs(Platform.getNL());
+ }
+
+ public void build(Collection contributedIndexFiles) {
+ this.contributedIndexFiles = contributedIndexFiles;
+ unprocessedIndexFiles.addAll(this.contributedIndexFiles);
+ while (!unprocessedIndexFiles.isEmpty()) {
+ IndexFile indexFile = (IndexFile) unprocessedIndexFiles.iterator().next();
+ indexFile.build(this);
+ }
+ }
+
+ /**
+ * @param file
+ */
+ public void buildIndexFile(IndexFile file) {
+ unprocessedIndexFiles.remove(file);
+ IndexFileParser parser = new IndexFileParser(this);
+ parser.parse(file);
+ }
+ /**
+ * Adds a new entry to the index
+ * @param keyword
+ * @param hrefs
+ */
+ protected void addIndexEntry(String keyword) {
+ Index currIndex = current == null ? index : current;
+ IndexEntry newEntry = currIndex.addEntry(keyword);
+ if(current != null) entries.push(current);
+ current = newEntry;
+ }
+
+ protected void exitIndexEntry() {
+ if(entries.empty())
+ current = null;
+ else
+ current = (IndexEntry)entries.pop();
+ }
+
+ protected void addTopic(String label, String href, String location) {
+ boolean emptyLabel = label == null || label.length() == 0;
+ boolean emptyLocation = location == null || location.length() == 0;
+
+ if ( emptyLabel || emptyLocation ) {
+ for (int i = 0; i < tocs.length; i++) {
+ ITopic topic = tocs[i].getTopic(href);
+ if (topic != null) {
+ if(emptyLabel) {
+ label = topic.getLabel();
+ emptyLabel = false;
+ }
+ if(emptyLocation) {
+ location = tocs[i].getLabel();
+ emptyLocation = false;
+ }
+ }
+ }
+ }
+
+ if(emptyLocation) location = ""; //$NON-NLS-1$
+ if(emptyLabel) label = ""; //$NON-NLS-1$
+ if (current != null) {
+ current.addTopic(label,href,location);
+ }
+ }
+
+// /**
+// * @param string
+// * @return
+// */
+// private ITopic findTopicByHref(String href) {
+// for (int i = 0; i < tocs.length; i++) {
+// ITopic topic = tocs[i].getTopic(href);
+// if ((topic != null) && (topic.getHref().equals(href)))
+// return topic;
+// else
+// continue;
+// }
+// return null;
+// }
+
+ /**
+ * @return
+ */
+ protected IIndex getBuiltIndex() {
+ return index;
+ }
+
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java
new file mode 100644
index 000000000..a4a4adb4d
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author sturmash
+ *
+ * An internal implementation of index entry
+ */
+class IndexEntry extends Index implements IIndexEntry {
+ String keyword;
+ List topics;
+
+ public IndexEntry(String keyword) {
+ this(keyword, new ArrayList());
+ }
+
+ public IndexEntry(String keyword, List topics) {
+ this.keyword = keyword;
+ this.topics = topics;
+ }
+
+ public void addTopic(String label, String href, String location) {
+ topics.add(new IndexTopic(label, href, location));
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.help.internal.index.IIndexEntry#getKeyword()
+ */
+ public String getKeyword() {
+ return keyword;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.help.internal.index.IIndexEntry#getTopics()
+ */
+ public List getTopics() {
+ return topics;
+ }
+
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java
new file mode 100644
index 000000000..702871ad7
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.help.internal.util.ResourceLocator;
+
+/**
+ * @author sturmash
+ *
+ * To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Generation - Code and Comments
+ */
+public class IndexFile {
+
+ private String plugin;
+
+ private String href;
+
+ private String locale;
+
+ protected IndexFile(String plugin, String href, String locale) {
+ this.plugin = plugin;
+ this.href = href;
+ this.locale = locale;
+ }
+
+ /**
+ * @return Returns the href.
+ */
+ public String getHref() {
+ return href;
+ }
+
+ /**
+ * @return Returns the locale.
+ */
+ public String getLocale() {
+ return locale;
+ }
+
+ /**
+ * @return Returns the plugin.
+ */
+ public String getPluginID() {
+ return plugin;
+ }
+
+ /**
+ * @param builder
+ */
+ public void build(IndexBuilder builder) {
+ builder.buildIndexFile(this);
+ }
+
+ /**
+ * @return
+ */
+ protected InputStream getInputStream() {
+ InputStream stream = null;
+ try {
+ if (plugin != null)
+ stream = ResourceLocator.openFromPlugin(plugin, href, locale);
+ else
+ stream = new FileInputStream(href);
+ } catch (IOException e) {
+ // Nothing to do
+ }
+ return stream;
+ }
+
+ /**
+ * Used by debugger
+ */
+ public String toString() {
+ return plugin + "/" + href; //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java
new file mode 100644
index 000000000..86a353272
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.toc.HrefUtil;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author sturmash
+ *
+ * To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Generation - Code and Comments
+ */
+public class IndexFileParser extends DefaultHandler {
+
+ private IndexBuilder builder;
+
+ private IndexFile indexFile;
+
+ private static SAXParserFactory parserFactory = SAXParserFactory
+ .newInstance();
+
+ private static XMLParserPool parserPool = new XMLParserPool();
+
+ /**
+ * @param builder
+ */
+ public IndexFileParser(IndexBuilder builder) {
+ this.builder = builder;
+ }
+
+ /**
+ * @param file
+ */
+ public void parse(IndexFile file) {
+ this.indexFile = file;
+ InputStream istream = indexFile.getInputStream();
+ if (istream == null) return;
+ InputSource isource = new InputSource(istream);
+ String filePath = "/" + file.getPluginID() + "/" + file.getHref(); //$NON-NLS-1$ //$NON-NLS-2$
+ isource.setSystemId(filePath);
+ try {
+ SAXParser parser = parserPool.obtainParser();
+ try {
+ parser.parse(isource, this);
+ istream.close();
+ } finally {
+ parserPool.releaseParser(parser);
+ }
+ } catch (ParserConfigurationException pce) {
+ HelpPlugin.logError(
+ "SAXParser implementation could not be loaded.", pce); //$NON-NLS-1$
+ } catch (SAXException se) {
+ HelpPlugin.logError("Error loading Index file " + file //$NON-NLS-1$
+ + ".", se); //$NON-NLS-1$
+ } catch (IOException ioe) {
+ HelpPlugin.logError("Error loading Index file " + file //$NON-NLS-1$
+ + ".", ioe); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * 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 = parserFactory.newSAXParser();
+ }
+ return p;
+ }
+
+ void releaseParser(SAXParser parser) {
+ pool.add(parser);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+ if (qName.equals("entry")) { //$NON-NLS-1$
+ builder.exitIndexEntry();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
+ if (qName.equals("entry")) { //$NON-NLS-1$
+ builder.addIndexEntry(attributes.getValue("keyword")); //$NON-NLS-1$
+ } else if (qName.equals("topic")) { //$NON-NLS-1$
+ builder.addTopic( attributes.getValue("title"), //$NON-NLS-1$
+ HrefUtil.normalizeHref(indexFile.getPluginID(), attributes.getValue("href")), //$NON-NLS-1$
+ attributes.getValue("location")); //$NON-NLS-1$
+ } else {
+ return;
+ }
+ }
+
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java
new file mode 100644
index 000000000..0ff3e31d0
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.HelpPlugin;
+
+
+/**
+ * @author sturmash
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class IndexManager {
+
+ private Collection contributingPlugins;
+ private Map indexesByLang;
+
+ /**
+ * IndexManager constructor
+ */
+ public IndexManager() {
+ indexesByLang = new HashMap();
+ build(Platform.getNL());
+ }
+
+ /**
+ * Builds the index from all contributed index files
+ * @param locale
+ */
+ private void build(String locale) {
+ Collection contributedIndexFiles = getContributedIndexFiles(locale);
+ IndexBuilder builder = new IndexBuilder();
+ builder.build(contributedIndexFiles);
+ IIndex index = builder.getBuiltIndex();
+ indexesByLang.put(Platform.getNL(), index);
+ }
+
+ /**
+ * Returns all index files contributed by separate help plugins
+ * @param locale
+ * @return
+ */
+ private Collection getContributedIndexFiles(String locale) {
+ contributingPlugins = new HashSet();
+ Collection contributedIndexFiles = new ArrayList();
+
+ IExtensionPoint xpt = Platform.getExtensionRegistry().getExtensionPoint(HelpPlugin.PLUGIN_ID, "index"); //$NON-NLS-1$
+ if (xpt == null)
+ return contributedIndexFiles;
+
+ IExtension[] extensions = xpt.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ contributingPlugins.add(extensions[i].getNamespace());
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ if (configElements[j].getName().equals("index")) { //$NON-NLS-1$
+ String pluginId = configElements[j].getDeclaringExtension().getNamespace();
+ String href = configElements[j].getAttribute("file"); //$NON-NLS-1$
+ if (href != null) {
+ contributedIndexFiles.add(new IndexFile(pluginId, href, Platform.getNL()));
+ }
+ }
+ }
+ }
+ return contributedIndexFiles;
+ }
+
+ /**
+ * @return Returns the contributingPlugins.
+ */
+ public Collection getContributingPlugins() {
+ return contributingPlugins;
+ }
+
+ public IIndex getIndex(String locale) {
+ if (locale == null)
+ return new Index();
+
+ IIndex index = (IIndex) indexesByLang.get(locale);
+ if (index == null) {
+ synchronized(this) {
+ if (index == null) {
+ build(locale);
+ }
+ }
+ index = (IIndex) indexesByLang.get(locale);
+ if (index == null)
+ index = new Index();
+ }
+
+ return index;
+
+ }
+
+}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexTopic.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexTopic.java
new file mode 100644
index 000000000..d91830c46
--- /dev/null
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexTopic.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.index;
+
+public class IndexTopic implements IIndexTopic {
+ String label;
+ String href;
+ String location;
+
+ public IndexTopic(String label, String href, String location) {
+ this.label = label;
+ this.href = href;
+ this.location = location;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+}

Back to the top