private boolean isNotEmpty(ITopic topic) { String href = topic.getHref(); ITopic[] topics = topic.getSubtopics(); return href != null || isNotEmpty(topics); }
public Topic(ITopic src) { super(NAME, src); setHref(src.getHref()); setLabel(src.getLabel()); appendChildren(src.getChildren()); }
private Map<String, ITopic> createHref2TopicMap() { Map<String, ITopic> map = new HashMap<>(); if (topic != null) { map.put(topic.getHref(), topic); } ITopic[] topics = getTopics(); for (int i = 0; i < topics.length; ++i) { createHref2TopicMapAux(map, topics[i]); } return map; }
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; } }
String descriptionHref = tocs[t].getTopic(null).getHref(); if (descriptionHref != null && descriptionHref.length() > 0
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 String getLabel(IUAElement element) { if (element instanceof Topic) { Topic topic = (Topic)element; if (topic.getLabel() == null) { ITopic topic2 = HelpPlugin.getTocManager().getTopic(topic.getHref(), locale); if (topic2 != null) { topic.setLabel(topic2.getLabel()); } else { String msg = "Unable to look up label for help keyword index topic \"" + topic.getHref() + "\" with missing \"" + Topic.ATTRIBUTE_LABEL + "\" attribute (topic does not exist in table of contents; using href as label)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ HelpPlugin.logError(msg); topic.setLabel(topic.getHref()); } } return topic.getLabel(); } else if (element instanceof IndexEntry) { return ((IndexEntry)element).getKeyword(); } return null; } }
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 Image getImage(Object obj) { if (obj instanceof IToc) { boolean expanded = treeViewer.getExpandedState(obj); String key = expanded ? IHelpUIConstants.IMAGE_TOC_OPEN : IHelpUIConstants.IMAGE_TOC_CLOSED; return HelpUIResources.getImage(key); } if (obj instanceof ITopic) { boolean expandable = treeViewer.isExpandable(obj); if (expandable) { ITopic topic = (ITopic) obj; if (topic.getHref() != null) return containerWithTopicImage; } String key = expandable ? IHelpUIConstants.IMAGE_CONTAINER : IHelpUIConstants.IMAGE_FILE_F1TOPIC; return HelpUIResources.getImage(key); } return super.getImage(obj); } }
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()); }
public Toc(IToc src) { super(NAME, src); setHref(src.getHref()); setLabel(src.getLabel()); ITopic topic = src.getTopic(null); if (topic != null) { setTopic(topic.getHref()); } appendChildren(src.getChildren()); }