Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2007-02-21 21:32:58 +0000
committerChris Goldthorpe2007-02-21 21:32:58 +0000
commitc470c03bc8d0112a8280d30c04ad38ee2b6c71c6 (patch)
tree1167a64266727898a5facaaf83e7319eca3a88ad
parent24d7b2d818df7e28264fc7cbf43bda1a41a617d2 (diff)
downloadeclipse.platform.ua-c470c03bc8d0112a8280d30c04ad38ee2b6c71c6.tar.gz
eclipse.platform.ua-c470c03bc8d0112a8280d30c04ad38ee2b6c71c6.tar.xz
eclipse.platform.ua-c470c03bc8d0112a8280d30c04ad38ee2b6c71c6.zip
Bug 160939 - [Webapp] Web page for index is read from server too early, and other Index view changes.
-rw-r--r--org.eclipse.help.webapp/WEB-INF/web.xml10
-rw-r--r--org.eclipse.help.webapp/advanced/bookmarksView.jsp4
-rw-r--r--org.eclipse.help.webapp/advanced/helptree.js8
-rw-r--r--org.eclipse.help.webapp/advanced/helptreechildren.js37
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.css112
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.js302
-rw-r--r--org.eclipse.help.webapp/advanced/indexView.jsp38
-rw-r--r--org.eclipse.help.webapp/advanced/linksView.jsp5
-rw-r--r--org.eclipse.help.webapp/advanced/searchView.jsp3
-rw-r--r--org.eclipse.help.webapp/advanced/tocTree.js21
-rw-r--r--org.eclipse.help.webapp/advanced/view.jsp4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties1
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java99
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/IndexData.java64
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java303
15 files changed, 778 insertions, 233 deletions
diff --git a/org.eclipse.help.webapp/WEB-INF/web.xml b/org.eclipse.help.webapp/WEB-INF/web.xml
index e12e6971b..0045e8592 100644
--- a/org.eclipse.help.webapp/WEB-INF/web.xml
+++ b/org.eclipse.help.webapp/WEB-INF/web.xml
@@ -35,6 +35,11 @@
<servlet>
<servlet-name>tocfragment</servlet-name>
<servlet-class>org.eclipse.help.internal.webapp.servlet.TocFragmentServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>indexfragment</servlet-name>
+ <servlet-class>org.eclipse.help.internal.webapp.servlet.IndexFragmentServlet</servlet-class>
</servlet>
<servlet>
@@ -108,6 +113,11 @@
<servlet-name>tocfragment</servlet-name>
<url-pattern>/tocfragment/*</url-pattern>
</servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>indexfragment</servlet-name>
+ <url-pattern>/indexfragment/*</url-pattern>
+ </servlet-mapping>
<servlet-mapping>
<servlet-name>index</servlet-name>
diff --git a/org.eclipse.help.webapp/advanced/bookmarksView.jsp b/org.eclipse.help.webapp/advanced/bookmarksView.jsp
index ec949c0ec..13ec80037 100644
--- a/org.eclipse.help.webapp/advanced/bookmarksView.jsp
+++ b/org.eclipse.help.webapp/advanced/bookmarksView.jsp
@@ -99,6 +99,10 @@ function bookmarkKeyDownHandler(e) {
return removeBookmark();
}
+
+function onShow() {
+}
+
</script>
</head>
diff --git a/org.eclipse.help.webapp/advanced/helptree.js b/org.eclipse.help.webapp/advanced/helptree.js
index 5156550b7..b593c6bf8 100644
--- a/org.eclipse.help.webapp/advanced/helptree.js
+++ b/org.eclipse.help.webapp/advanced/helptree.js
@@ -25,7 +25,7 @@ function getActiveAnchor() {
/**
* handler for expanding / collapsing topic tree
*/
-function mouseClickHandler(e) {
+function treeMouseClickHandler(e) {
var clickedNode = getEventTarget(e);
if (!clickedNode) { return; }
@@ -45,7 +45,7 @@ function mouseClickHandler(e) {
/**
* Handler for key down (arrows)
*/
-function keyDownHandler(e)
+function treeKeyDownHandler(e)
{
var key = getKeycode(e);
@@ -99,7 +99,7 @@ function goToEnd() {
// Handle a left arrow key event
function goLeft(treeItem) {
var childClass = getChildClass(treeItem);
- if (childClass == "visible") {
+ if (childClass == "visible" && showExpanders) {
toggleExpandState(treeItem);
} else {
focusOnItem(getTreeItem(treeItem.parentNode), false);
@@ -338,5 +338,3 @@ function changeExpanderImage(treeItem, isExpanded) {
}
}
-function mouseMoveHandler(e) {
-}
diff --git a/org.eclipse.help.webapp/advanced/helptreechildren.js b/org.eclipse.help.webapp/advanced/helptreechildren.js
index c4bac5e18..776e248b6 100644
--- a/org.eclipse.help.webapp/advanced/helptreechildren.js
+++ b/org.eclipse.help.webapp/advanced/helptreechildren.js
@@ -83,10 +83,7 @@ function mergeChildren(treeItem, nodes) {
} else {
changeExpanderImage(treeItem, true);
}
- }
-
-
-
+ }
}
// Create a child if one with this if does not exist
@@ -115,29 +112,37 @@ function mergeChild(treeItem, id, name, href, image, isLeaf) {
container.className = "item";
childItem.appendChild(container);
- var topicImage = document.createElement("IMG");
- setImage(topicImage, image);
+ var topicImage;
+ if (image) {
+ topicImage = document.createElement("IMG");
+ setImage(topicImage, image);
+ }
+
var topicName=document.createTextNode(name);
- var plusMinusImage= document.createElement("IMG");
- plusMinusImage.className = "expander";
- setImage(plusMinusImage, "plus");
- if (isLeaf) {
- plusMinusImage.className = "h";
- plusMinusImage.alt = "";
+ if (showExpanders) {
+ var plusMinusImage= document.createElement("IMG");
+ plusMinusImage.className = "expander";
+ setImage(plusMinusImage, "plus");
+ if (isLeaf) {
+ plusMinusImage.className = "h";
+ plusMinusImage.alt = "";
+ }
+ container.appendChild(plusMinusImage);
}
- container.appendChild(plusMinusImage);
var anchor = document.createElement("a");
if (href === null) {
- anchor.href = "about:blank";
- // anchor.className = "nolink";
+ // anchor.href = "about:blank";
+ anchor.className = "nolink";
} else {
anchor.href = href;
}
anchor.title = name;
- anchor.appendChild(topicImage);
+ if (topicImage) {
+ anchor.appendChild(topicImage);
+ }
anchor.appendChild(topicName);
container.appendChild(anchor);
diff --git a/org.eclipse.help.webapp/advanced/indexView.css b/org.eclipse.help.webapp/advanced/indexView.css
index bfce9a481..5b633eae1 100644
--- a/org.eclipse.help.webapp/advanced/indexView.css
+++ b/org.eclipse.help.webapp/advanced/indexView.css
@@ -55,6 +55,7 @@ INPUT {
#indexList {
overflow:auto;
width: 100%;
+ height: 100px;
}
#typein {
@@ -75,7 +76,7 @@ INPUT {
}
<%
- if (data.isIE()) {
+ if (requestData.isIE()) {
%>
#go {
padding-<%=isRTL?"right":"left"%>:1px;
@@ -84,82 +85,79 @@ INPUT {
}
%>
-UL {
- border-width:0;
- margin-<%=isRTL?"right":"left"%>:20px;
-<%
- if (!data.isMozilla()) {
-%>
- padding-<%=isRTL?"right":"left"%>:0px;
-<%
- }
-%>
+#root {
+ margin-top:0px;
+ margin-<%=isRTL?"right":"left"%>:5px;
}
-#root {
- margin-top:5px;
+#innerNavigation {
+ margin-top:0px;
+ padding-bottom: 5px;
margin-<%=isRTL?"right":"left"%>:5px;
+ font-weight:bold;
+
+}
+
+DIV.root {
+ font-weight:bold;
+}
+
+DIV.visible, DIV.unopened {
+ border-width:0;
+ margin-<%=isRTL?"right":"left"%>:1.5em;
+ font-weight:normal;
}
-UL.expanded {
- display:block;
+DIV.hidden {
+ display:none;
}
-UL.collapsed {
- display:none;
+DIV.visible, DIV.root {
+ margin-top:1px;
}
-LI {
- margin:0;
- list-style-image:none;
- list-style-type:none;
- white-space: nowrap;
+SPAN.item{
+ white-space: nowrap;
}
IMG {
- border:0;
- margin:0;
- padding:0;
+ border:0px;
+ margin:0px;
+ padding:0px;
margin-<%=isRTL?"left":"right"%>:4px;
}
+IMG.expander, IMG.h {
+ margin-top:4px;
+ margin-bottom:2px;
+}
+
A {
- text-decoration:none;
+ text-decoration:none;
padding-<%=isRTL?"left":"right"%>:2px;
/* this works in ie5.5, but not in ie5.0 */
- white-space:nowrap;
-}
-
-A:link, A:visited {
- color:blue;
+ white-space: nowrap;
}
-A:hover {
+A:hover{
text-decoration:underline;
}
-A.nolink {
- text-decoration:none;
-}
-
-A.nolink:link, A.nolink:visited {
- color:WindowText;
-}
-
-A.nolink:hover {
- text-decoration:none;
-}
-
A.active{
color:HighlightText;
+ width:100%;
}
-A.active:link, A.active:visited {
- color:HighlightText;
+A.active:hover{
+ text-decoration:underline;
+}
+
+A.enabled, A:link, A:visited {
+ color:blue;
}
<%
-if (data.isSafari()){
+if (requestData.isSafari()){
%>
A.active{
@@ -178,24 +176,20 @@ A.active{
}
%>
-<%if (data.isMozilla()) {%>
-UL {
- margin-<%=isRTL?"right":"left"%>:-20px;
+A.nolink {
+ text-decoration:none;
}
-#root {
- margin-<%=isRTL?"right":"left"%>:-35px;
- margin-top:5px;
+A.nolink:link, A.nolink:visited {
+ color:WindowText;
+}
+
+A.nolink:hover {
+ text-decoration:none;
}
-<%}%>
.h {
visibility:hidden;
}
-DIV {
- padding: 0px;
- margin: 0px;
- overflow: auto;
-}
diff --git a/org.eclipse.help.webapp/advanced/indexView.js b/org.eclipse.help.webapp/advanced/indexView.js
index 410fd306b..c938b2e02 100644
--- a/org.eclipse.help.webapp/advanced/indexView.js
+++ b/org.eclipse.help.webapp/advanced/indexView.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,94 +8,59 @@
* Contributors:
* Intel Corporation - initial API and implementation
* IBM Corporation 2006, refactored index view into a single frame
+ * IBM Corporation 2007, allow partial loading of index
*******************************************************************************/
var isMozilla = navigator.userAgent.indexOf("Mozilla") != -1 && parseInt(navigator.appVersion.substring(0,1)) >= 5;
var isIE = navigator.userAgent.indexOf("MSIE") != -1;
-
-/**
- * Selects the next index list node "up" from current one
- */
-function selectNextUp() {
-
- var next = getNextUp(oldActive);
- if (next) {
- highlightTopic(next);
- scrollIntoView(next);
- setTypeinValue(next);
- }
-}
-
-/**
- * Selects the next index list node "down" from current one
- */
-function selectNextDown() {
-
- var next = getNextDown(oldActive);
- if (next) {
- highlightTopic(next);
- scrollIntoView(next);
- setTypeinValue(next);
- }
-}
-
-/**
- * Returns selected list item
- */
-function getSelection() {
- return oldActive;
-}
+var showExpanders = false;
+var shown = false;
+var typeinPrevious = "";
+var typein;
+var lines = 30;
/**
* Set value of the typein input field.
* The value can be anchor's id or anchor's text.
*/
-function setTypeinValue(anchor) {
- if (!anchor) return;
+function sizeList() {
+ resizeVertical("indexList", "typeinTable", "navigation", 100, 5);
+}
- var value = anchor.getAttribute("id");
- if (value) {
- currentId = value;
- } else {
- currentId = "";
- if (isIE)
- value = anchor.innerText;
- else
- value = anchor.lastChild.nodeValue;
- if (!value)
- value = "";
- }
- typein.value = value;
- typein.previous = value;
+function computeLines() {
+ // Compute the number of lines available using the placeholder
+ try {
+ var indexList = document.getElementById("indexList");
+ var placeholder = document.getElementById("placeholder");
+ // Add 1 to placeholder height allow for margin
+ var ratio = indexList.offsetHeight / ( placeholder.offsetHeight + 1);
+ lines = Math.floor(ratio);
+ if (lines < 1) {
+ lines = 1;
+ }
+ } catch(ex) {}
}
-/**
- * Open current selected item in the content frame
+/*
+ * Called when the "DISPLAY" button is clicked
*/
-function doDisplay() {
- if (!oldActive) return;
-
- parent.parent.parent.parent.ContentFrame.ContentViewFrame.location.replace(oldActive);
+function showIndex() {
+ loadChildren(typein.value);
}
function onloadHandler() {
- //var node = document.getElementsByTagName("A").item(0);
- //highlightTopic(node);
- //scrollToViewTop(node);
typein = document.getElementById("typein");
typein.value = "";
- typein.previous = "";
-
- currentId = "";
+ typeinPrevious = "";
if (isIE) {
- document.onclick = mouseClickHandler;
+ document.onclick = treeMouseClickHandler;
document.onkeydown = keyDownHandler;
} else {
- document.addEventListener('click', mouseClickHandler, true);
+ document.addEventListener('click', treeMouseClickHandler, true);
document.addEventListener('keydown', keyDownHandler, true);
}
@@ -103,3 +68,212 @@ function onloadHandler() {
sizeList();
}
+function setImage(imageNode, image) {
+ var imageFile = imagesDirectory + "/" + image + ".gif";
+ imageNode.src = imageFile;
+ if (image == "plus") {
+ imageNode.alt = altPlus;
+ } else if (image == "minus") {
+ imageNode.alt = altMinus;
+ } else if (image == "toc_open") {
+ imageNode.alt = altBookOpen;
+ } else if (image == "toc_closed") {
+ imageNode.alt = altBookClosed;
+ } else if (image == "container_obj") {
+ imageNode.alt = altContainer;
+ } else if (image == "container_topic") {
+ imageNode.alt = altContainerTopic;
+ } else if (image == "topic") {
+ imageNode.alt = altTopic;
+ } else {
+ imageNode.alt = "";
+ }
+}
+
+function updateImage(imageNode, isExpanded) {
+ var src = imageNode.src;
+ if (isExpanded) {
+ if (src.match( /toc_closed.gif$/)) {
+ setImage(imageNode, "toc_open");
+ }
+ } else {
+ if (src.match( /toc_open.gif$/)) {
+ setImage(imageNode, "toc_closed");
+ }
+ }
+}
+
+/*
+Remove any existing children and read new ones
+*/
+
+function loadChildren(startCharacters, mode) {
+ var parameters = "";
+ var treeRoot = document.getElementById("tree_root");
+ if (treeRoot !== null) {
+ while (treeRoot.childNodes.length > 0) {
+ treeRoot.removeChild(treeRoot.childNodes[0]);
+ }
+ var placeholder = document.createElement("DIV");
+ placeholder.className = "unopened";
+ placeholder.id = "placeholder";
+ treeRoot.appendChild(placeholder);
+ setLoadingMessage(treeRoot, loadingMessage);
+ computeLines();
+ var separator = "?";
+ if (startCharacters) {
+ parameters += "?start=";
+ parameters += startCharacters;
+ separator = "&";
+ }
+ if (lines) {
+ parameters += separator;
+ parameters += "size=";
+ parameters += lines;
+ separator = "&";
+ }
+ if (mode) {
+ parameters += separator;
+ parameters += "mode=";
+ parameters += mode;
+ }
+ makeNodeRequest(parameters);
+ }
+}
+
+function updateIndexTree(xml) {
+ updateTree(xml);
+ removePlaceholder();
+ // Enable or disable the buttons
+ var node = xml.documentElement;
+ var previous = document.getElementById("previous");
+ var enablePrevious = node.getAttribute("enablePrevious");
+ if (enablePrevious == "false") {
+ previous.className = "h";
+ } else {
+ previous.className = "enabled";
+ }
+ var next = document.getElementById("next");
+ var enableNext = node.getAttribute("enableNext");
+ if (enableNext == "false") {
+ next.className = "h";
+ } else {
+ next.className = "enabled";
+ }
+}
+
+function removePlaceholder() {
+ var treeRoot = document.getElementById("tree_root");
+ if (treeRoot == null) return;
+ var placeholderDiv = findChild(treeRoot, "DIV");
+ if (placeholderDiv && placeholderDiv.className == "unopened") {
+ treeRoot.removeChild(placeholderDiv);
+ }
+}
+
+function makeNodeRequest(parameters) {
+ var href = "../indexfragment" + parameters;
+ var callback = function(xml) { updateIndexTree(xml);};
+ var errorCallback = function() {
+ // alert("ajax error");
+ };
+ ajaxRequest(href, callback, errorCallback);
+}
+
+function loadPreviousPage() {
+ // Find the key of the first index entry
+ var treeRoot = document.getElementById("tree_root");
+ if (treeRoot == null) return;
+ var childDiv = findChild(treeRoot, "DIV");
+ var anchor = findAnchor(childDiv);
+ if (anchor && anchor.title) {
+ loadChildren(anchor.title, "previous");
+ } else {
+ loadChildren("");
+ }
+}
+
+function loadNextPage() {
+ // Find the key of the last index entry
+ var treeRoot = document.getElementById("tree_root");
+ if (treeRoot == null) return;
+ var childDiv = findLastChild(treeRoot, "DIV");
+ var anchor = findAnchor(childDiv);
+ if (anchor && anchor.title) {
+ loadChildren(anchor.title, "next");
+ } else {
+ loadChildren("");
+ }
+}
+
+function onShow() {
+ sizeList();
+ if (!shown) {
+ // View is being shown for the first time
+ loadChildren("");
+ shown = true;
+ }
+}
+
+/*
+ * Function called when the typein value may have changed
+ */
+
+function typeinChanged() {
+ if (typein.value == typeinPrevious) {
+ return;
+ }
+ typeinPrevious = typein.value;
+ loadChildren(typeinPrevious);
+}
+
+/**
+ * Handler for key down
+ */
+function keyDownHandler(e)
+{
+ var key = getKeycode(e);
+ if (key == 33) {
+ // Page up
+ cancelEventBubble(e);
+ loadPreviousPage();
+ return;
+ }
+ if (key == 34) {
+ // Page down
+ cancelEventBubble(e);
+ loadNextPage();
+ return;
+ }
+ var clickedNode = getEventTarget(e);
+ if (clickedNode && clickedNode.id == "typein") {
+ typeinKeyDownHandler(e);
+ } else {
+ treeKeyDownHandler(e);
+ }
+}
+
+function typeinKeyDownHandler(e) {
+ var key = getKeycode(e);
+
+ if (key == 13) { // enter
+ typeinChanged();
+ cancelEventBubble(e);
+ } else {
+ return treeKeyDownHandler(e);
+ }
+
+ return false;
+}
+
+/**
+ * Select the corresponding item in the index list on typein value change.
+ * Check is performed periodically in short interval.
+ */
+function intervalHandler() {
+ typeinChanged();
+}
+
+
+
+
diff --git a/org.eclipse.help.webapp/advanced/indexView.jsp b/org.eclipse.help.webapp/advanced/indexView.jsp
index b5d4bfce1..b448a868e 100644
--- a/org.eclipse.help.webapp/advanced/indexView.jsp
+++ b/org.eclipse.help.webapp/advanced/indexView.jsp
@@ -1,5 +1,5 @@
<%--
- Copyright (c) 2005, 2006 Intel Corporation and others.
+ Copyright (c) 2005, 2007 Intel 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
@@ -14,8 +14,8 @@
<%@ include file="fheader.jsp"%>
<%
- IndexData data = new IndexData(application, request, response);
- WebappPreferences prefs = data.getPrefs();
+ RequestData requestData = new RequestData(application,request, response);
+ WebappPreferences prefs = requestData.getPrefs();
%>
<html>
@@ -31,21 +31,16 @@
<base target="ContentViewFrame">
<script language="JavaScript">
-var ids = [<%data.generateIds(out);%>];
-minus = new Image();
-minus.src = "<%=prefs.getImagesDirectory()%>" + "/minus.gif";
-plus = new Image();
-plus.src = "<%=prefs.getImagesDirectory()%>" + "/plus.gif";
-altExpandTopicTitles = "<%=UrlUtil.JavaScriptEncode(ServletResources.getString("expandTopicTitles", request))%>";
-altCollapseTopicTitles = "<%=UrlUtil.JavaScriptEncode(ServletResources.getString("collapseTopicTitles", request))%>";
-usePlusMinus = <%=prefs.isIndexPlusMinus()%>;
+
+var loadingMessage = "<%=UrlUtil.JavaScriptEncode(ServletResources.getString("Loading", request))%>";
</script>
<script language="JavaScript" src="indexView.js"></script>
-<script language="JavaScript" src="indexList.js"></script>
-<script language="JavaScript" src="indexTypein.js"></script>
-<script language="JavaScript" src="utils.js"></script>
<script language="JavaScript" src="resize.js"></script>
+<script language="JavaScript" src="helptree.js"></script>
+<script language="JavaScript" src="helptreechildren.js"></script>
+<script language="JavaScript" src="xmlajax.js"></script>
+<script language="JavaScript" src="utils.js"></script>
</head>
<body dir="<%=direction%>" onload="onloadHandler()" onresize = "sizeList()">
@@ -59,16 +54,19 @@ usePlusMinus = <%=prefs.isIndexPlusMinus()%>;
<tr>
<td width="100%"><input type="text" id="typein"></td>
<%if (prefs.isIndexButton()) {%>
- <td><input type="button" id="button" value="<%=ServletResources.getString("IndexTypeinButton", request)%>" onclick="this.blur();parent.doDisplay()"></td>
+ <td><input type="button" id="button" value="<%=ServletResources.getString("IndexTypeinButton", request)%>" onclick="this.blur();showIndex()"></td>
<%}%>
</tr>
</table>
<div id = "indexList">
- <ul dir="<%=direction%>" id="root" class="expanded">
-<%
- data.generateIndex(out);
-%>
- </ul>
+<DIV class = "root" id = "tree_root">
+</DIV>
+</div>
+<div id="navigation">
+ <div id = "innerNavigation">
+ <a id = "previous" class = "enabled" onclick="this.blur();loadPreviousPage()">Previous</a>
+ <a id = "next" class = "enabled" onclick="this.blur();loadNextPage()">Next</a>
+ <div>
</div>
</body>
diff --git a/org.eclipse.help.webapp/advanced/linksView.jsp b/org.eclipse.help.webapp/advanced/linksView.jsp
index 3695ea086..df07da6ac 100644
--- a/org.eclipse.help.webapp/advanced/linksView.jsp
+++ b/org.eclipse.help.webapp/advanced/linksView.jsp
@@ -75,7 +75,10 @@ if(!data.isLinksRequest()) {
%>
-<script language="JavaScript">
+<script language="JavaScript">
+ function onShow() {
+ }
+
selectTopicById('<%=data.getSelectedTopicId()%>');
</script>
diff --git a/org.eclipse.help.webapp/advanced/searchView.jsp b/org.eclipse.help.webapp/advanced/searchView.jsp
index 462e84c86..9d8d4f860 100644
--- a/org.eclipse.help.webapp/advanced/searchView.jsp
+++ b/org.eclipse.help.webapp/advanced/searchView.jsp
@@ -42,6 +42,9 @@ function refresh()
{
window.location.replace("searchView.jsp?<%=request.getQueryString()%>");
}
+
+function onShow() {
+}
</script>
diff --git a/org.eclipse.help.webapp/advanced/tocTree.js b/org.eclipse.help.webapp/advanced/tocTree.js
index 5b46e3d73..7dd0e3f61 100644
--- a/org.eclipse.help.webapp/advanced/tocTree.js
+++ b/org.eclipse.help.webapp/advanced/tocTree.js
@@ -11,6 +11,8 @@
// Tree code specific to the help toc
+var showExpanders = true;
+
/*
* Returns the currently selected topic's href, or null if no
* topic is selected.
@@ -113,21 +115,26 @@ function loadChildren(treeItem) {
makeNodeRequest(parameters);
}
+function updateTocTree(xml) {
+ updateTree(xml);
+}
+
function makeNodeRequest(parameters) {
var href = "../tocfragment" + parameters;
- var callback = function(xml) { updateTree(xml);};
+ var callback = function(xml) { updateTocTree(xml);};
var errorCallback = function() {
// alert("ajax error");
};
ajaxRequest(href, callback, errorCallback);
}
+function onShow() {
+}
+
if (isInternetExplorer){
- document.onclick = mouseClickHandler;
- document.onmousemove = mouseMoveHandler;
- document.onkeydown = keyDownHandler;
+ document.onclick = treeMouseClickHandler;
+ document.onkeydown = treeKeyDownHandler;
} else {
- document.addEventListener('click', mouseClickHandler, true);
- document.addEventListener('mousemove', mouseMoveHandler, true);
- document.addEventListener('keydown', keyDownHandler, true);
+ document.addEventListener('click', treeMouseClickHandler, true);
+ document.addEventListener('keydown', treeKeyDownHandler, true);
}
diff --git a/org.eclipse.help.webapp/advanced/view.jsp b/org.eclipse.help.webapp/advanced/view.jsp
index f1620d465..127c56919 100644
--- a/org.eclipse.help.webapp/advanced/view.jsp
+++ b/org.eclipse.help.webapp/advanced/view.jsp
@@ -53,6 +53,10 @@ function onShow()
resize();
resized = true;
}
+ try{
+ window.<%=view.getName()%>ViewFrame.onShow();
+ } catch(ex) {}
+
}
</script>
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 d4e15f8dc..101f0d49c 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
@@ -148,3 +148,4 @@ IndexListTitle=Index List
# Index View text
IndexTypeinInstructions=Type in the word to find:
IndexTypeinButton=Display
+IndexEmpty=There are no entries in the index.
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java
new file mode 100644
index 000000000..4df0952df
--- /dev/null
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/EnabledTopicUtils.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.help.IIndexEntry;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.UAContentFilter;
+import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.HelpEvaluationContext;
+
+/**
+ * Utilities to test for enabled topics, index entries etc.
+ */
+
+public class EnabledTopicUtils {
+
+ /**
+ * Test whether a topic is enabled
+ * @param topic
+ * @return
+ */
+ public static boolean isEnabled(ITopic topic) {
+ if (UAContentFilter.isFiltered(topic, HelpEvaluationContext.getContext())) {
+ return false;
+ }
+ return HelpBasePlugin.getActivitySupport().isEnabled(topic.getHref());
+ }
+
+ /**
+ * Test whether an entry is enabled
+ * @param entry
+ * @return
+ */
+ public static boolean isEnabled(IIndexEntry entry) {
+ if (UAContentFilter.isFiltered(entry, HelpEvaluationContext.getContext())) {
+ return false;
+ }
+ ITopic[] topics = entry.getTopics();
+ for (int i=0;i<topics.length;++i) {
+ if (EnabledTopicUtils.isEnabled(topics[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Filter out any disabled entries from an array
+ * @param entries an array of entries
+ * @return an array containing only those entries which are enabled
+ */
+ public static IIndexEntry[] getEnabled(IIndexEntry[] entries) {
+ for (int i=0;i<entries.length;++i) {
+ if (!isEnabled(entries[i])) {
+ List list = new ArrayList(entries.length);
+ for (int j=0;j<entries.length;++i) {
+ if (j < i || isEnabled(entries[j])) {
+ list.add(entries[j]);
+ }
+ }
+ return (IIndexEntry[])list.toArray(new IIndexEntry[list.size()]);
+ }
+ }
+ return entries;
+ }
+
+ /**
+ * Filter out any disable topics form an array
+ * @param topics an array of topics
+ * @return an array containing only those topics which are enabled
+ */
+ public static ITopic[] getEnabled(ITopic[] topics) {
+ for (int i=0;i<topics.length;++i) {
+ if (!isEnabled(topics[i])) {
+ List list = new ArrayList(topics.length);
+ for (int j=0;j<topics.length;++i) {
+ if (j < i || isEnabled(topics[j])) {
+ list.add(topics[j]);
+ }
+ }
+ return (ITopic[])list.toArray(new ITopic[list.size()]);
+ }
+ }
+ return topics;
+ }
+
+}
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
index 391f076a1..14f6344e5 100644
--- 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
@@ -14,8 +14,6 @@ package org.eclipse.help.internal.webapp.data;
import java.io.IOException;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -24,10 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.help.IIndex;
import org.eclipse.help.IIndexEntry;
import org.eclipse.help.ITopic;
-import org.eclipse.help.UAContentFilter;
import org.eclipse.help.internal.HelpPlugin;
-import org.eclipse.help.internal.base.HelpBasePlugin;
-import org.eclipse.help.internal.base.HelpEvaluationContext;
/**
* Helper class for Index view initialization
@@ -111,7 +106,7 @@ public class IndexData extends ActivitiesData {
this.out = out;
IIndexEntry[] entries = index.getEntries();
for (int i=0;i<entries.length;++i) {
- if (isEnabled(entries[i])) {
+ if (EnabledTopicUtils.isEnabled(entries[i])) {
generateEntry(entries[i], 0);
}
}
@@ -141,8 +136,8 @@ public class IndexData extends ActivitiesData {
*/
private void generateEntry(IIndexEntry entry, int level) throws IOException {
if (entry.getKeyword() != null && entry.getKeyword().length() > 0) {
- ITopic[] topics = getEnabled(entry.getTopics());
- IIndexEntry[] subentries = getEnabled(entry.getSubentries());
+ ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics());
+ IIndexEntry[] subentries = EnabledTopicUtils.getEnabled(entry.getSubentries());
boolean multipleTopics = topics.length > 1;
boolean singleTopic = topics.length == 1;
@@ -362,57 +357,4 @@ public class IndexData extends ActivitiesData {
out.write("</ul>\n"); //$NON-NLS-1$
}
}
-
- private boolean isEnabled(ITopic topic) {
- if (UAContentFilter.isFiltered(topic, HelpEvaluationContext.getContext())) {
- return false;
- }
- return HelpBasePlugin.getActivitySupport().isEnabled(topic.getHref());
- }
-
- /*
- * Enabled if entry passes filter and has at least one enabled topic.
- */
- private boolean isEnabled(IIndexEntry entry) {
- if (UAContentFilter.isFiltered(entry, HelpEvaluationContext.getContext())) {
- return false;
- }
- ITopic[] topics = entry.getTopics();
- for (int i=0;i<topics.length;++i) {
- if (isEnabled(topics[i])) {
- return true;
- }
- }
- return false;
- }
-
- private IIndexEntry[] getEnabled(IIndexEntry[] entries) {
- for (int i=0;i<entries.length;++i) {
- if (!isEnabled(entries[i])) {
- List list = new ArrayList(entries.length);
- for (int j=0;j<entries.length;++i) {
- if (j < i || isEnabled(entries[j])) {
- list.add(entries[j]);
- }
- }
- return (IIndexEntry[])list.toArray(new IIndexEntry[list.size()]);
- }
- }
- return entries;
- }
-
- private ITopic[] getEnabled(ITopic[] topics) {
- for (int i=0;i<topics.length;++i) {
- if (!isEnabled(topics[i])) {
- List list = new ArrayList(topics.length);
- for (int j=0;j<topics.length;++i) {
- if (j < i || isEnabled(topics[j])) {
- list.add(topics[j]);
- }
- }
- return (ITopic[])list.toArray(new ITopic[list.size()]);
- }
- }
- return topics;
- }
}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java
new file mode 100644
index 000000000..d1f642064
--- /dev/null
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.servlet;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.help.IIndex;
+import org.eclipse.help.IIndexEntry;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.webapp.WebappResources;
+import org.eclipse.help.internal.webapp.data.EnabledTopicUtils;
+import org.eclipse.help.internal.webapp.data.UrlUtil;
+
+/*
+ * Creates xml representing selected parts of the index
+ * Parameter "start" represents the part of the index to start reading from
+ * Parameter "size" indicates the number of entries to read, no size parameter
+ * or a negatove size parameter indicates that all entries which match the start
+ * letters should be displayed.
+ * Parameter "offset" represents the starting point relative to the start
+ */
+public class IndexFragmentServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+ private static Map locale2Response = new WeakHashMap();
+ private String startParameter;
+ private String sizeParameter;
+ private String modeParameter;
+ private int size;
+ private static final String NEXT = "next"; //$NON-NLS-1$
+ private static final String PREVIOUS = "previous"; //$NON-NLS-1$
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ String locale = UrlUtil.getLocale(req, resp);
+ startParameter = req.getParameter("start"); //$NON-NLS-1$
+ if (startParameter == null) {
+ startParameter = ""; //$NON-NLS-1$
+ } else {
+ startParameter = startParameter.toLowerCase();
+ }
+
+ size = 30;
+ sizeParameter = req.getParameter("size"); //$NON-NLS-1$
+ if (sizeParameter != null) {
+ try {
+ size = Integer.parseInt(sizeParameter);
+ } catch (NumberFormatException n) {
+ }
+ }
+
+ modeParameter = req.getParameter("mode"); //$NON-NLS-1$
+
+ req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
+ resp.setContentType("application/xml; charset=UTF-8"); //$NON-NLS-1$
+ // Cache suppression required if not in infocenter mode because the set of disabled
+ // topics could change between requests
+ if (BaseHelpSystem.getMode() != BaseHelpSystem.MODE_INFOCENTER) {
+ resp.setHeader("Cache-Control","no-cache"); //$NON-NLS-1$//$NON-NLS-2$
+ resp.setHeader("Pragma","no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
+ resp.setDateHeader ("Expires", 0); //$NON-NLS-1$
+ }
+ Serializer serializer = new Serializer(locale);
+ String response = serializer.generateIndexXml();
+ locale2Response.put(locale, response);
+ resp.getWriter().write(response);
+ }
+
+ /*
+ * Class which creates the xml file based upon the request parameters
+ */
+ private class Serializer {
+
+ private IIndex index;
+ private StringBuffer buf;
+ private int count = 0;
+ private String locale;
+ private List entryList;
+ private IIndexEntry[] entries;
+ private boolean enablePrevious = true;
+ private boolean enableNext = true;
+
+ public Serializer(String locale) {
+ this.locale = locale;
+ index = HelpPlugin.getIndexManager().getIndex(locale);
+ buf = new StringBuffer();
+ }
+
+ /*
+ * There are three modes of generation, current page, next page and previous page.
+ * Current page returns a screenful of entries starting at the startParameter.
+ * Next page returns a screenful of entries starting after but not including the start parameter.
+ * Previous page returns a screenful of entries going back from the start parameter
+ */
+ private String generateIndexXml() {
+
+ entries = index.getEntries();
+ if (entries.length == 0) {
+ generateEmptyIndexMessage();
+ } else {
+ entryList = new ArrayList();
+ int nextEntry = findFirstEntry(entries);
+ if (PREVIOUS.equals(modeParameter)) {
+ int remaining = getPreviousEntries(nextEntry, size);
+ getNextEntries(nextEntry, remaining);
+ } else {
+ int remaining = getNextEntries(nextEntry, size);
+ if (remaining == size) {
+ // Generate just the last entry
+ size = 1;
+ getPreviousEntries(nextEntry, 1);
+ }
+ }
+ for (Iterator iter = entryList.iterator(); iter.hasNext();) {
+ generateEntry((IIndexEntry)iter.next(), 0);
+ }
+ }
+ String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tree_data enableNext = \"" //$NON-NLS-1$
+ + Boolean.toString(enableNext) + "\" enablePrevious = \"" + Boolean.toString(enablePrevious) + "\">\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("</tree_data>\n"); //$NON-NLS-1$
+ return header + buf.toString();
+ }
+
+ private int findFirstEntry(IIndexEntry[] entries) {
+ int nextEntry = 0;
+ while (nextEntry < entries.length) {
+ String keyword = entries[nextEntry].getKeyword().toLowerCase();
+ if (keyword != null) {
+ if (NEXT.equals(modeParameter)) {
+ // Go past the startParameter if there is an exact match
+ if (startParameter.compareTo(keyword) < 0) {
+ break;
+ }
+ } else {
+ if (startParameter.compareTo(keyword) <= 0) {
+ break;
+ }
+ }
+ }
+ nextEntry++;
+ }
+ return nextEntry;
+ }
+
+ private int getNextEntries(int nextEntry, int remaining) {
+ while (nextEntry < entries.length) {
+ int entrySize = enabledEntryCount(entries[nextEntry]);
+ if (remaining == size || remaining > entrySize) {
+ entryList.add(entries[nextEntry]);
+ setFlags(nextEntry);
+ remaining -= entrySize;
+ } else {
+ break;
+ }
+ nextEntry++;
+ }
+ return remaining;
+ }
+
+ private int getPreviousEntries(int nextEntry, int remaining) {
+ nextEntry--;
+ while (nextEntry >= 0) {
+ int entrySize = enabledEntryCount(entries[nextEntry]);
+ if (remaining == size || remaining > entrySize) {
+ entryList.add(0, entries[nextEntry]);
+
+ setFlags(nextEntry);
+ remaining -= entrySize;
+ } else {
+ break;
+ }
+ nextEntry--;
+ }
+ return remaining;
+ }
+
+ private void setFlags(int nextEntry) {
+ if (nextEntry == 0) {
+ enablePrevious = false;
+ }
+ if (nextEntry == entries.length - 1) {
+ enableNext = false;
+ }
+ }
+
+ private int enabledEntryCount(IIndexEntry entry) {
+ if (!EnabledTopicUtils.isEnabled(entry)) return 0;
+ if (entry.getKeyword() == null || entry.getKeyword().length() == 0) {
+ return 0;
+ }
+ int count = 1;
+ ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics());
+ IIndexEntry[] subentries = EnabledTopicUtils.getEnabled(entry.getSubentries());
+ if (topics.length > 1) {
+ count += topics.length;
+ }
+ for (int i=0;i<subentries.length;++i) {
+ count += enabledEntryCount(subentries[i]);
+ }
+ return count;
+ }
+
+ private void generateEmptyIndexMessage() {
+ buf.append("<node"); //$NON-NLS-1$
+ buf.append('\n' + " title=\"" + XMLGenerator.xmlEscape(WebappResources.getString("IndexEmpty", UrlUtil.getLocale(locale))) + '"'); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append('\n' + " id=\"no_index\""); //$NON-NLS-1$
+ buf.append(">\n"); //$NON-NLS-1$
+ buf.append("</node>\n"); //$NON-NLS-1$
+ enableNext = false;
+ enablePrevious = false;
+ }
+
+ private void generateEntry(IIndexEntry entry, int level) {
+ if (!EnabledTopicUtils.isEnabled(entry)) return;
+ if (entry.getKeyword() != null && entry.getKeyword().length() > 0) {
+ ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics());
+ IIndexEntry[] subentries = EnabledTopicUtils.getEnabled(entry.getSubentries());
+ boolean multipleTopics = topics.length > 1;
+ boolean singleTopic = topics.length == 1;
+
+ buf.append("<node"); //$NON-NLS-1$
+ if (entry.getKeyword() != null) {
+ buf.append('\n' + " title=\"" + XMLGenerator.xmlEscape(entry.getKeyword()) + '"'); //$NON-NLS-1$
+ }
+
+ count++;
+ buf.append('\n' + " id=\"i" + count + '"'); //$NON-NLS-1$
+
+ String href;
+ if (singleTopic) {
+ href = UrlUtil.getHelpURL((entry.getTopics()[0]).getHref());
+ buf.append('\n' + " href=\"" + //$NON-NLS-1$
+ XMLGenerator.xmlEscape(UrlUtil.getHelpURL(href)) + "\""); //$NON-NLS-1$
+ }
+ buf.append(">\n"); //$NON-NLS-1$
+
+ if (multipleTopics || subentries.length > 0) {
+ if (multipleTopics) generateTopicList(entry);
+ generateSubentries(entry, level + 1);
+ }
+
+ buf.append("</node>\n"); //$NON-NLS-1$
+ }
+ }
+
+ private void generateSubentries(IIndexEntry entry, int level) {
+ IIndexEntry[] subentries = entry.getSubentries();
+ for (int i=0;i<subentries.length;++i) {
+ generateEntry(subentries[i], level);
+ }
+ }
+
+ private void generateTopicList(IIndexEntry entry) {
+ ITopic[] topics = entry.getTopics();
+
+ for (int i = 0; i < topics.length; ++i) {
+ ITopic topic = (ITopic)topics[i];
+
+ //
+ String label = UrlUtil.htmlEncode(topic.getLabel());
+ if (label == null) {
+ label = UrlUtil.htmlEncode(topic.getLabel());
+ }
+
+
+ buf.append("<node"); //$NON-NLS-1$
+ if (entry.getKeyword() != null) {
+ buf.append('\n' + " title=\"" + label + '"'); //$NON-NLS-1$
+ }
+
+ count++;
+ buf.append('\n' + " id=\"i" + count + '"'); //$NON-NLS-1$
+ String href = UrlUtil.getHelpURL(topic.getHref());
+ buf.append('\n' + " href=\"" //$NON-NLS-1$
+ + XMLGenerator.xmlEscape(UrlUtil.getHelpURL(href)) + "\""); //$NON-NLS-1$
+ buf.append(">\n"); //$NON-NLS-1$
+ buf.append("</node>\n"); //$NON-NLS-1$
+
+ }
+ }
+ }
+
+}

Back to the top