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; } }
private void createHref2TopicMapAux(Map<String, ITopic> map, ITopic topic) { String href = topic.getHref(); if (href != null) { map.put(href, topic); int anchorIx = href.lastIndexOf("#"); //$NON-NLS-1$ if (anchorIx >= 0) { // anchor exists, drop it and add href again to map String simpleHref = href.substring(0, anchorIx); if (!map.containsKey(simpleHref)) { map.put(simpleHref, topic); } } } ITopic[] subtopics = topic.getSubtopics(); if (subtopics != null) { for (int i = 0; i < subtopics.length; ++i) { if (subtopics[i] != null) { createHref2TopicMapAux(map, subtopics[i]); } } } }
public Object[] getChildren(Object parentElement) { if (parentElement == AllTopicsPart.this) return HelpSystem.getTocs(); if (parentElement instanceof IToc) return ((IToc) parentElement).getTopics(); if (parentElement instanceof ITopic) return ((ITopic) parentElement).getSubtopics(); return new Object[0]; }
private boolean isNotEmpty(ITopic topic) { String href = topic.getHref(); ITopic[] topics = topic.getSubtopics(); return href != null || isNotEmpty(topics); }
protected void doOpen(Object obj) { if (!(obj instanceof IHelpResource)) return; IHelpResource res = (IHelpResource) obj; if (res instanceof IToc || (res instanceof ITopic && ((ITopic) obj).getSubtopics().length > 0 && res .getHref() == null)) treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(res)); if (res instanceof IToc) postUpdate(res); else if (res.getHref() != null) parent.showURL(res.getHref()); }