Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis D'Entremont2007-03-01 21:46:40 +0000
committerCurtis D'Entremont2007-03-01 21:46:40 +0000
commit9077418527bb2eebdef1cae5e49b49c7bf0c11b3 (patch)
tree7eb54af4e9ea6ba9809fc95cd3b03eb164dfb810
parent883d67bd6bc502b1b8d898e4718df8ac48700b14 (diff)
downloadeclipse.platform.ua-9077418527bb2eebdef1cae5e49b49c7bf0c11b3.tar.gz
eclipse.platform.ua-9077418527bb2eebdef1cae5e49b49c7bf0c11b3.tar.xz
eclipse.platform.ua-9077418527bb2eebdef1cae5e49b49c7bf0c11b3.zip
166391 [Help] Add breadcrumbs support
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ShowInTocAction.java62
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java44
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java28
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java18
-rw-r--r--org.eclipse.help.webapp/advanced/breadcrumbs.css19
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/UrlUtil.java59
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/BreadcrumbsFilter.java117
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java2
-rw-r--r--org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/NavServlet.java14
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/UAElement.java10
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java27
11 files changed, 346 insertions, 54 deletions
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ShowInTocAction.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ShowInTocAction.java
new file mode 100644
index 000000000..760c6461e
--- /dev/null
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/ShowInTocAction.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.ui.internal;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.help.HelpSystem;
+import org.eclipse.help.IHelpResource;
+import org.eclipse.help.ILiveHelpAction;
+import org.eclipse.help.IToc;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.ui.internal.views.AllTopicsPart;
+import org.eclipse.help.ui.internal.views.ReusableHelpPart;
+
+public class ShowInTocAction implements ILiveHelpAction {
+
+ private String path;
+
+ public void setInitializationString(String data) {
+ path = data;
+ }
+
+ public void run() {
+ final IHelpResource res = getHelpResource();
+ final ReusableHelpPart helpPart = ReusableHelpPart.getLastActiveInstance();
+ if (helpPart != null) {
+ helpPart.getControl().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ helpPart.showPage(IHelpUIConstants.HV_ALL_TOPICS_PAGE);
+ AllTopicsPart part = (AllTopicsPart)helpPart.findPart(IHelpUIConstants.HV_TOPIC_TREE);
+ if (part != null) {
+ part.selectReveal(res);
+ }
+ }
+ });
+ }
+ }
+
+ private IHelpResource getHelpResource() {
+ StringTokenizer tok = new StringTokenizer(path, "_"); //$NON-NLS-1$
+ int index = Integer.parseInt(tok.nextToken());
+ IToc[] tocs = HelpSystem.getTocs();
+ IToc toc = tocs[index];
+ if (tok.hasMoreTokens()) {
+ ITopic topic = toc.getTopic(null);
+ while (tok.hasMoreTokens()) {
+ index = Integer.parseInt(tok.nextToken());
+ topic = topic.getSubtopics()[index];
+ }
+ return topic;
+ }
+ return toc;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java
index ed90f38ee..c04808459 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/AllTopicsPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -10,12 +10,11 @@
*******************************************************************************/
package org.eclipse.help.ui.internal.views;
-import java.util.ArrayList;
-
import org.eclipse.help.HelpSystem;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.IToc;
import org.eclipse.help.ITopic;
+import org.eclipse.help.internal.UAElement;
import org.eclipse.help.ui.internal.HelpUIResources;
import org.eclipse.help.ui.internal.IHelpUIConstants;
import org.eclipse.help.ui.internal.util.OverlayIcon;
@@ -59,6 +58,9 @@ public class AllTopicsPart extends HyperlinkTreePart implements IHelpPart {
if (element instanceof IToc) {
return AllTopicsPart.this;
}
+ else if (element instanceof UAElement) {
+ return ((UAElement)element).getParentElement();
+ }
return null;
}
@@ -238,40 +240,16 @@ public class AllTopicsPart extends HyperlinkTreePart implements IHelpPart {
IToc toc = tocs[i];
ITopic topic = toc.getTopic(href);
if (topic != null) {
- ArrayList path = getPath(toc, topic);
- for (int j = 0; j < path.size(); j++) {
- Object obj = path.get(j);
- treeViewer.expandToLevel(obj, 1);
- }
- treeViewer.setSelection(new StructuredSelection(topic), true);
+ selectReveal(topic);
return;
}
}
}
-
- private ArrayList getPath(IToc toc, ITopic topic) {
- ArrayList path = new ArrayList();
- findPath(toc.getTopics(), topic, path);
- path.add(0, toc);
- return path;
- }
-
- private boolean findPath(ITopic[] siblings, ITopic topic, ArrayList path) {
- for (int i = 0; i < siblings.length; i++) {
- ITopic sibling = siblings[i];
- if (sibling.equals(topic)) {
- return true;
- }
- ITopic[] subtopics = sibling.getSubtopics();
- if (subtopics.length > 0) {
- boolean result = findPath(subtopics, topic, path);
- if (result) {
- path.add(0, sibling);
- return true;
- }
- }
- }
- return false;
+
+ public void selectReveal(IHelpResource res) {
+ treeViewer.setSelection(new StructuredSelection(res), true);
+ treeViewer.expandToLevel(res, 1);
+ treeViewer.getControl().setFocus();
}
protected boolean canAddBookmarks() {
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
index 99b8d66f8..c998674fe 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -120,6 +120,12 @@ public class ReusableHelpPart implements IHelpUIConstants,
private static final int STATE_LT_B = 3;
private static final int STATE_LT_BR = 4;
+
+ /*
+ * Used as a bridge from live help actions back (e.g. breadcrumb links)
+ * to the originating help part.
+ */
+ private static ReusableHelpPart lastActiveInstance;
private RoleFilter roleFilter;
@@ -433,6 +439,7 @@ public class ReusableHelpPart implements IHelpUIConstants,
if (bars != null)
bars.clearGlobalActionHandlers();
ArrayList tabList = new ArrayList();
+ Control originalFocusControl = focusControl;
for (int i = 0; i < partRecs.size(); i++) {
PartRec rec = (PartRec) partRecs.get(i);
if (visible) {
@@ -444,6 +451,7 @@ public class ReusableHelpPart implements IHelpUIConstants,
}
rec.part.setVisible(visible);
}
+ focusControl = originalFocusControl;
Composite parent = mform.getForm().getBody();
parent.setTabList((Control[]) tabList.toArray(new Control[tabList
.size()]));
@@ -464,6 +472,7 @@ public class ReusableHelpPart implements IHelpUIConstants,
if (pageAction != null)
pageAction.setChecked(visible);
}
+
if (bars != null) {
if (visible)
bars.activate();
@@ -475,6 +484,7 @@ public class ReusableHelpPart implements IHelpUIConstants,
ReusableHelpPart.this.toolBarManager.update(true);
getControl().getParent().layout();
}
+
}
private void hookGlobalAction(String id, IHelpPart part) {
@@ -647,6 +657,14 @@ public class ReusableHelpPart implements IHelpUIConstants,
.addActivityManagerListener(this);
}
+ /*
+ * Used as a bridge from live help actions back (e.g. breadcrumb links)
+ * to the originating help part.
+ */
+ public static ReusableHelpPart getLastActiveInstance() {
+ return lastActiveInstance;
+ }
+
private void ensureHelpIndexed() {
// make sure we have the index but
// don't schedule the indexer job if one is
@@ -918,6 +936,11 @@ public class ReusableHelpPart implements IHelpUIConstants,
manager.addMenuListener(listener);
Menu contextMenu = manager.createContextMenu(form.getForm());
form.getForm().setMenu(contextMenu);
+ form.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ lastActiveInstance = ReusableHelpPart.this;
+ }
+ });
//contributeToDropDownMenu(mform.getForm().getForm().getMenuManager());
}
@@ -1035,6 +1058,9 @@ public class ReusableHelpPart implements IHelpUIConstants,
}
public void dispose() {
+ if (lastActiveInstance == this) {
+ lastActiveInstance = null;
+ }
for (int i = 0; i < pages.size(); i++) {
HelpPartPage page = (HelpPartPage) pages.get(i);
page.dispose();
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java
index 910150d8f..b69c543aa 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -17,10 +17,16 @@ import org.eclipse.help.HelpSystem;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.IToc;
import org.eclipse.help.search.ISearchEngineResult;
-import org.eclipse.help.ui.internal.*;
-import org.eclipse.jface.action.*;
+import org.eclipse.help.ui.internal.HelpUIPlugin;
+import org.eclipse.help.ui.internal.HelpUIResources;
+import org.eclipse.help.ui.internal.IHelpUIConstants;
+import org.eclipse.help.ui.internal.Messages;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -280,9 +286,7 @@ public class SearchResultsPart extends AbstractFormPart implements IHelpPart {
target = tocs[i];
}
if (target != null) {
- if (!part.treeViewer.getExpandedState(target))
- part.doOpen(target);
- part.treeViewer.setSelection(new StructuredSelection(target), true);
+ part.selectReveal(target);
}
}
}
diff --git a/org.eclipse.help.webapp/advanced/breadcrumbs.css b/org.eclipse.help.webapp/advanced/breadcrumbs.css
new file mode 100644
index 000000000..3c352b0cb
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/breadcrumbs.css
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+.help_breadcrumbs {
+ font: message-box;
+ margin-bottom: 10px;
+}
+
+body {
+ margin-top: 4px;
+}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/UrlUtil.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/UrlUtil.java
index 6bb5924d9..bd6152e88 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/UrlUtil.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/data/UrlUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -9,16 +9,28 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.help.internal.webapp.data;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.regex.*;
-
-import javax.servlet.http.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.help.internal.base.*;
-import org.eclipse.help.internal.base.util.*;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.Cookie;
+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.base.BaseHelpSystem;
+import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.util.TString;
public class UrlUtil {
// XML escaped characters mapping
@@ -123,6 +135,31 @@ public class UrlUtil {
url = "../topic" + url; //$NON-NLS-1$
return url;
}
+
+ /**
+ * Returns a path to the given topic in the form of child indexes. For
+ * example, if the path points to the 3rd subtopic under the 2nd topic of
+ * the 4th toc, it will return { 3, 1, 2 }.
+ *
+ * @param path the path portion of the url, e.g. "/help/topic/my.plugin/foo.html"
+ * @return path to the topic using zero-based indexes
+ */
+ public static int[] getTopicPath(String path) {
+ if (path.startsWith("/help/nav/")) { //$NON-NLS-1$
+ path = path.substring(10);
+ StringTokenizer tok = new StringTokenizer(path, "_"); //$NON-NLS-1$
+ int[] array = new int[tok.countTokens()];
+ for (int i=0;i<array.length;++i) {
+ array[i] = Integer.parseInt(tok.nextToken());
+ }
+ return array;
+ }
+ else {
+ // grab the part after /help/*topic/
+ String href = path.substring(path.indexOf('/', 6));
+ return HelpPlugin.getTocManager().getTopicPath(href);
+ }
+ }
public static boolean isBot(HttpServletRequest request) {
String agent = request.getHeader("User-Agent"); //$NON-NLS-1$
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/BreadcrumbsFilter.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/BreadcrumbsFilter.java
new file mode 100644
index 000000000..5038c3f09
--- /dev/null
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/BreadcrumbsFilter.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.webapp.HelpWebappPlugin;
+import org.eclipse.help.internal.webapp.data.UrlUtil;
+
+/**
+ * Injects breadcrumbs at the top of help documents, e.g.
+ * "Workbench User Guide > Concepts > Workbench".
+ */
+public class BreadcrumbsFilter implements IFilter {
+
+ private static final String HEAD_CONTENT =
+ "\n<link rel=\"stylesheet\" href=\"../content/PLUGINS_ROOT/" + HelpWebappPlugin.PLUGIN_ID + "/advanced/breadcrumbs.css\" charset=\"ISO-8859-1\" type=\"text/css\"></link>" //$NON-NLS-1$//$NON-NLS-2$
+ + "\n<script language=\"JavaScript\" src=\"../content/PLUGINS_ROOT/" + HelpPlugin.PLUGIN_ID + "/livehelp.js\"> </script>"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.help.internal.webapp.servlet.IFilter#filter(javax.servlet.http.HttpServletRequest, java.io.OutputStream)
+ */
+ public OutputStream filter(HttpServletRequest req, OutputStream out) {
+ String uri = req.getRequestURI();
+ if (uri == null || !uri.endsWith("html") && !uri.endsWith("htm") && !uri.startsWith("/help/nav/")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return out;
+ }
+ if (UrlUtil.isBot(req)) {
+ return out;
+ }
+ String pathInfo = req.getPathInfo();
+ if (pathInfo == null) {
+ return out;
+ }
+ int[] path = UrlUtil.getTopicPath(uri);
+ if (path != null && path.length > 1) {
+ boolean isNarrow = "/ntopic".equals(req.getServletPath()); //$NON-NLS-1$
+ String locale = UrlUtil.getLocale(req, null);
+ String bodyContent = getBodyContent(path, getBackpath(uri), isNarrow, locale);
+ try {
+ return new FilterHTMLHeadAndBodyOutputStream(out, HEAD_CONTENT.getBytes("ASCII"), bodyContent); //$NON-NLS-1$
+ }
+ catch (UnsupportedEncodingException e) {
+ }
+ }
+ return out;
+ }
+
+ private String getBackpath(String path) {
+ int num = new Path(path).segmentCount() - 2;
+ StringBuffer buf = new StringBuffer();
+ for (int i=0;i<num;++i) {
+ if (i > 0) {
+ buf.append('/');
+ }
+ buf.append(".."); //$NON-NLS-1$
+ }
+ return buf.toString();
+ }
+
+ private String getBodyContent(int[] path, String backPath, boolean isNarrow, String locale) {
+ StringBuffer buf = new StringBuffer();
+ StringBuffer pathBuf = new StringBuffer();
+ ITopic topic = HelpPlugin.getTocManager().getTocs(locale)[path[0]].getTopic(null);
+ pathBuf.append(path[0]);
+ buf.append("<div class=\"help_breadcrumbs\">"); //$NON-NLS-1$
+
+ for (int i=0;i<path.length-1;++i) {
+
+ // add the link
+ buf.append("<a href=\""); //$NON-NLS-1$
+ String href = topic.getHref();
+ if (href != null) {
+ href = backPath + (isNarrow ? "/ntopic" : "/topic") + href; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else {
+ if (isNarrow) {
+ href = "javascript:liveAction('org.eclipse.help.ui', 'org.eclipse.help.ui.internal.ShowInTocAction', '" + pathBuf.toString() + "')"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else {
+ href = backPath + "/nav/" + pathBuf.toString(); //$NON-NLS-1$
+ }
+ }
+ buf.append(href);
+ buf.append("\">"); //$NON-NLS-1$
+ buf.append(topic.getLabel());
+ buf.append("</a>"); //$NON-NLS-1$
+
+ // add separator
+ if (i < path.length - 2 || path.length == 2) {
+ // always add if there's only one link
+ buf.append(" > "); //$NON-NLS-1$
+ }
+
+ // move to the next topic in the path
+ topic = topic.getSubtopics()[path[i + 1]];
+ pathBuf.append('_');
+ pathBuf.append(path[i + 1]);
+ }
+ buf.append("</div>"); //$NON-NLS-1$
+ return buf.toString();
+ }
+}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
index abc403212..29cc03f29 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
@@ -45,7 +45,7 @@ public class EclipseConnector {
+ "<body><p>\n"; //$NON-NLS-1$
private static final String errorPageEnd = "</p></body></html>"; //$NON-NLS-1$
private static final IFilter filters[] = new IFilter[]{
- new HighlightFilter(), new FramesetFilter(), new InjectionFilter(), new DynamicXHTMLFilter() };
+ new HighlightFilter(), new FramesetFilter(), new InjectionFilter(), new DynamicXHTMLFilter(), new BreadcrumbsFilter() };
public EclipseConnector(ServletContext context) {
}
diff --git a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/NavServlet.java b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/NavServlet.java
index ff1cdbcec..0e76a0ac3 100644
--- a/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/NavServlet.java
+++ b/org.eclipse.help.webapp/src_servlets/org/eclipse/help/internal/webapp/servlet/NavServlet.java
@@ -11,6 +11,7 @@
package org.eclipse.help.internal.webapp.servlet;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;
@@ -35,6 +36,9 @@ public class NavServlet extends HttpServlet {
private static final String XHTML_2 = "</title>\n</head>\n<body>\n"; //$NON-NLS-1$
private static final String XHTML_3 = "</body>\n</html>"; //$NON-NLS-1$
+ private static final IFilter filters[] = new IFilter[]{
+ new FramesetFilter(), new InjectionFilter(), new BreadcrumbsFilter() };
+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Locale locale = req.getLocale();
req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
@@ -42,7 +46,15 @@ public class NavServlet extends HttpServlet {
String path = req.getPathInfo().substring(1);
ITopic topic = getTopic(path, locale);
- writeContent(topic, path, locale, resp.getWriter());
+
+ OutputStream out = resp.getOutputStream();
+ for (int i = 0; i < filters.length; i++) {
+ out = filters[i].filter(req, out);
+ }
+
+ PrintWriter writer = new PrintWriter(out);
+ writeContent(topic, path, locale, writer);
+ writer.close();
}
private ITopic getTopic(String topicPath, Locale locale) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java b/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java
index b3004a976..06b2fa4a8 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java
@@ -156,6 +156,16 @@ public class UAElement implements IUAElement {
return parent;
}
+ public int indexOf(UAElement child) {
+ IUAElement[] children = getChildren();
+ for (int i=0;i<children.length;++i) {
+ if (child == children[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
public void insertBefore(UAElement newChild, UAElement refChild) {
importElement(newChild);
element.insertBefore(newChild.element, refChild.element);
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
index d2c53c824..522aba875 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java
@@ -31,6 +31,7 @@ import org.eclipse.help.ITocContribution;
import org.eclipse.help.internal.HelpData;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.Topic;
+import org.eclipse.help.internal.UAElement;
import org.eclipse.help.internal.UAElementFactory;
import org.eclipse.help.internal.util.ProductPreferences;
@@ -117,6 +118,32 @@ public class TocManager {
return null;
}
+ public synchronized int[] getTopicPath(String href) {
+ Topic topic = getTopic(href);
+ if (topic != null) {
+ List path = new ArrayList();
+ UAElement element = topic;
+ while (!(element instanceof Toc)) {
+ UAElement parent = element.getParentElement();
+ path.add(new Integer(parent.indexOf(element)));
+ element = parent;
+ }
+ Toc[] tocs = getTocs(Platform.getNL());
+ for (int i=0;i<tocs.length;++i) {
+ if (tocs[i] == element) {
+ path.add(new Integer(i));
+ int[] array = new int[path.size()];
+ for (int j=0;j<array.length;++j) {
+ array[j] = ((Integer)path.get(array.length - 1 - j)).intValue();
+ }
+ return array;
+ }
+ }
+ }
+ // no path; not in toc
+ return null;
+ }
+
/*
* Returns all toc contributions for the given locale, from all toc
* providers.

Back to the top