diff options
author | Chris Goldthorpe | 2010-11-05 19:28:46 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2010-11-05 19:28:46 +0000 |
commit | 3a4080d428bea007180b0379d9f661f1ae229539 (patch) | |
tree | b05c5964a23c070414369c5e0927393414e1f4ca /org.eclipse.help.webapp/src/org | |
parent | eb1bded5e44be4b86da60f6c02f6d79d75682515 (diff) | |
download | eclipse.platform.ua-3a4080d428bea007180b0379d9f661f1ae229539.tar.gz eclipse.platform.ua-3a4080d428bea007180b0379d9f661f1ae229539.tar.xz eclipse.platform.ua-3a4080d428bea007180b0379d9f661f1ae229539.zip |
Bug 329466 - [Webapp] Wrong topic was selected in the TOC tree
Diffstat (limited to 'org.eclipse.help.webapp/src/org')
-rw-r--r-- | org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java index 1774a3e58..1651fcc06 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java @@ -40,10 +40,16 @@ public class TopicFinder { int index = -1; do { selectedToc = findTocContainingTopic(topicHref); - - ITopic topic = findTopic(UrlUtil.getHelpURL(topicHref)); - if (topic != null && selectedToc >= 0) { - foundTopicPath = getTopicPathInToc(topic, tocs[selectedToc]); + index = topicHref.indexOf("/nav/"); //$NON-NLS-1$ + if (index != -1) { + foundTopicPath = getTopicPathFromNav(topicHref.substring(index + 5)); + + } else { + ITopic topic = findTopic(UrlUtil.getHelpURL(topicHref)); + if (topic != null && selectedToc >= 0) { + foundTopicPath = getTopicPathInToc(topic, + tocs[selectedToc]); + } } // if no match has been found, check if there is an anchor if (foundTopicPath == null && topicHref != null) { @@ -58,6 +64,28 @@ public class TopicFinder { foundTopicPath = null; } } + + public ITopic[] getTopicPathFromNav(String nav) { + StringTokenizer tok = new StringTokenizer(nav, "_"); //$NON-NLS-1$ + try { + int segments = tok.countTokens(); + ITopic[] path = new ITopic[segments - 1]; + // first number is toc index + int index = Integer.parseInt(tok.nextToken()); + IToc toc = tocs[index]; + ITopic current = toc.getTopic(null); + for (int i = 0; tok.hasMoreTokens(); i++) { + index = Integer.parseInt(tok.nextToken()); + appendFilteredIndex(index, current.getSubtopics()); + current = current.getSubtopics()[index]; + path[i] = current; + } + return path; + } catch (Exception e) { + numericPath = null; + return null; + } + } public ITopic[] getTopicPath() { return foundTopicPath; @@ -85,7 +113,7 @@ public class TopicFinder { // returns path in reverse order List reversePath = getTopicPathInTopic(topicToFind, topics[i]); if (reversePath != null) { - appendFilteredIndex(i, topics); + prependFilteredIndex(i, topics); return invertPath(reversePath); } } @@ -131,7 +159,7 @@ public class TopicFinder { // it was in a subtopic.. add to the path and return path.add(topic); // Add to the numeric path counting only enabled topics - appendFilteredIndex(i, subtopics); + prependFilteredIndex(i, subtopics); return path; } } @@ -153,6 +181,24 @@ public class TopicFinder { if (numericPath == null) { numericPath = "" + indexInFilteredList; //$NON-NLS-1$ } else { + numericPath = numericPath + '_' + indexInFilteredList; + } + } + + // Prepend an entry to the numeric path representing the position in the list + // of filtered topics. Note that we need to convert the index in the unfiltered + // list to an index in a filtered list of topics + private void prependFilteredIndex(int indexInUnfilteredList, ITopic[] unfiltered) { + int indexInFilteredList = 0; + for (int i = 0; i < indexInUnfilteredList; i++) { + if (ScopeUtils.showInTree(unfiltered[i], scope)) { + indexInFilteredList++; + } + } + + if (numericPath == null) { + numericPath = "" + indexInFilteredList; //$NON-NLS-1$ + } else { numericPath = "" + indexInFilteredList + '_' + numericPath; //$NON-NLS-1$ } |