for (int j=0;j<contrib.length;++j) { TocContribution contribution = new TocContribution(); contribution.setCategoryId(contrib[j].getCategoryId()); contribution.setContributorId(contrib[j].getContributorId()); contribution.setExtraDocuments(contrib[j].getExtraDocuments()); contribution.setId(contrib[j].getId()); contribution.setLocale(contrib[j].getLocale()); contribution.setPrimary(contrib[j].isPrimary()); IToc toc = contrib[j].getToc(); Toc t = toc instanceof Toc ? (Toc)toc : (Toc)UAElementFactory.newElement(toc); t.setLinkTo(contrib[j].getLinkTo()); contribution.setToc(t); if(!contributions.containsKey(contrib[j].getId())) contributions.put(contrib[j].getId(), contribution);
private void process(ITocContribution contribution) { if (processedContributions == null) { processedContributions = new HashSet<>(); } // don't process the same one twice if (!processedContributions.contains(contribution)) { if (processor == null) { processor = new DocumentProcessor(); } if (handlers == null) { DocumentReader reader = new DocumentReader(); handlers = new ProcessorHandler[] { new NormalizeHandler(), new LinkHandler(), new AnchorHandler(), new IncludeHandler(reader, contribution.getLocale()), new ExtensionHandler(reader, contribution.getLocale()), }; } processor.setHandlers(handlers); processor.process((Toc)contribution.getToc(), contribution.getId()); processedContributions.add(contribution); } }
for (int i=0;i<srcContributions.length;++i) { process(srcContributions[i]); IUAElement[] children = srcContributions[i].getToc().getChildren(); for (int j=0;j<children.length;++j) { parent.insertBefore((UAElement)children[j], anchor); addExtraDocuments(destContribution, srcContributions[i].getExtraDocuments());
String categoryId; try { categoryId = toc.getCategoryId(); } else { String tocLabel = toc.getToc().getLabel(); boolean done = false; for (int next = 0; next < category.size() && !done; next++ ) { String nextName = category.get(next).getToc().getLabel(); if (tocLabel.compareToIgnoreCase(nextName) < 0) { done = true; id = toc.getId();
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); }
private Map<String, String> createNameIdMap(Map<String, Object> categorized) { Map<String, String> map = new HashMap<>(); for (Iterator<String> iter = categorized.keySet().iterator(); iter.hasNext();) { String key = iter.next(); Object value = categorized.get(key); ITocContribution toc; if (value instanceof TocCategory) { TocCategory category = (TocCategory)value; toc = category.get(0); } else { toc = (ITocContribution)value; } map.put(key, toc.getToc().getLabel()); } return map; }
private String normalize(String href, String id) { ITocContribution contribution = getContribution(id); if (contribution != null) { String pluginId = contribution.getContributorId(); return HrefUtil.normalizeHref(pluginId, href); } else { int index = id.indexOf('/', 1); if (index != -1) { String pluginId = id.substring(1, index); return HrefUtil.normalizeHref(pluginId, href); } } return href; }
if (srcContribution.getId().equals(array[i].getId())) { isAlreadyIncluded = true;
private void processCriteria(UAElement element, String id) { if(HelpPlugin.getCriteriaManager().isCriteriaEnabled()){ ITocContribution contribution = getContribution(id); String locale = contribution.getLocale(); ICriteria[] criteria = new ICriteria[0]; if (element instanceof Topic) { Topic topic = (Topic) element; criteria = CriteriaProviderRegistry.getInstance().getAllCriteria(topic); } else if (element instanceof Toc) { Toc toc = (Toc) element; criteria = CriteriaProviderRegistry.getInstance().getAllCriteria(toc); } HelpPlugin.getCriteriaManager().addCriteriaValues(criteria, locale); } } }
/** * @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; } /*