@Override public String getHref() { return getTopic(); }
private Map<String, ITopic> getHref2TopicMap() { if (href2TopicMap == null) { href2TopicMap = createHref2TopicMap(); } return href2TopicMap; }
public String getLinkTo() { return getAttribute(ATTRIBUTE_LINK_TO); }
/** * @param href * href of a topic * @param tocList * List of IToc * @return true if given topic belongs to one of enabled ITocs */ private boolean isInTocSubtree(String href, Toc[] tocList) { for (int i=0;i<tocList.length;++i) { Toc toc = tocList[i]; if (!HelpBasePlugin.getActivitySupport().isEnabled(toc.getHref())) { // TOC is not enabled, check other TOCs continue; } // Check topics in navigation if (toc.getTopic(href) != null) { return true; } // Check extra docs String[] extraDocs = toc.getTocContribution().getExtraDocuments(); for (int j=0;j<extraDocs.length;++j) { if (extraDocs[j].equals(href)) { return true; } } } return false; } /*
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()); }
@Override public short handle(UAElement element, String id) { if (element instanceof Topic) { Topic topic = (Topic)element; String href = topic.getHref(); if (href != null) { topic.setHref(normalize(href, id)); } processCriteria(element, id); return HANDLED_CONTINUE; } else if (element instanceof Toc) { Toc toc = (Toc)element; toc.setHref(id); String topic = toc.getTopic(); if (topic != null) { toc.setTopic(normalize(topic, id)); } processCriteria(element, id); return HANDLED_CONTINUE; } return UNHANDLED; }
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; }
public synchronized Toc getOwningToc(String href) { if (tocsByTopic == null) { tocsByTopic = new HashMap<>(); Toc[] tocs = HelpPlugin.getTocManager().getTocs(Platform.getNL()); for (int i=0;i<tocs.length;++i) { ITocContribution contribution = tocs[i].getTocContribution(); String[] extraDocuments = contribution.getExtraDocuments(); for (int j=0;j<extraDocuments.length;++j) { tocsByTopic.put(extraDocuments[j], tocs[i]); } } } return tocsByTopic.get(href); }
@Override public ITopic[] getTopics() { return getChildren(ITopic.class); }
@Override public ICriteria[] getCriteria() { return Toc.this.getCriteria(); }
return getHref2TopicMap().get(href);
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]); } } } }
@Override public ICriteria[] getCriteria() { return getChildren(ICriteria.class); }
public synchronized ITopic getTopic(String href, String locale) { Toc[] tocs = HelpPlugin.getTocManager().getTocs(locale); for (int i=0;i<tocs.length;++i) { ITopic topic = tocs[i].getTopic(href); if (topic != null) { return topic; } } int index = href.indexOf('#'); if (index != -1) { return getTopic(href.substring(0, index), locale); } return null; }
@Override public String getIcon() { return getAttribute(ATTRIBUTE_ICON); }
@Override public String getLabel() { return getAttribute(ATTRIBUTE_LABEL); }
@Override public String getHref() { return getAttribute(ATTRIBUTE_HREF); }
public String getTopic() { return getAttribute(ATTRIBUTE_TOPIC); }
@Override public boolean isSorted() { return "true".equalsIgnoreCase(getAttribute(ATTRIBUTE_SORT)); //$NON-NLS-1$ }