public synchronized int[] getTopicPath(String href, String locale) { ITopic topic = getTopic(href, locale); try { if (topic != null && topic instanceof UAElement) { List<Integer> path = new ArrayList<>(); UAElement element = (UAElement) topic; while (!(element instanceof Toc)) { UAElement parent = element.getParentElement(); path.add(Integer.valueOf(indexOf(parent, (Topic)element))); element = parent; } Toc[] tocs = getTocs(locale); for (int i=0;i<tocs.length;++i) { if (tocs[i] == element) { path.add(Integer.valueOf(i)); int[] array = new int[path.size()]; for (int j=0;j<array.length;++j) { array[j] = path.get(array.length - 1 - j).intValue(); } return array; } } } } catch (Exception e) { return null; } // no path; not in toc return null; }
/** * Notifies the platform that the content managed by this provider may * have changed since the last time <code>getTocContributions()</code> * was called, and needs to be updated. */ protected void contentChanged() { // will force a reload next time around HelpPlugin.getTocManager().clearCache(); }
public TocContribution[] getTocContributions(String locale) { return getAndCacheTocContributions(locale, tocContributionsByLocale); }
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; }
public synchronized Toc getToc(String id, String locale) { getTocs(locale); return tocsById.get(id); }
System.out.println("Start to build toc for locale " + locale); //$NON-NLS-1$ Set<String> tocsToFilter = getIgnoredTocContributions(); TocContribution[] raw = getRootTocContributions(locale, tocsToFilter); TocContribution[] filtered = filterTocContributions(raw, tocsToFilter); ITocContribution[] ordered = new TocSorter().orderTocContributions(filtered); List<Toc> orderedTocs = new ArrayList<>(ordered.length);
private TocContribution[] getRootTocContributions(String locale, Set<String> tocsToFilter) { TocContribution[] contributions = getTocContributionsForToc(locale); List<TocContribution> unassembled = new ArrayList<>(Arrays.asList(contributions)); TocAssembler assembler = new TocAssembler(tocsToFilter); List<TocContribution> assembled = assembler.assemble(unassembled); return assembled.toArray(new TocContribution[assembled.size()]); }
/** * Used to obtain Toc Navigation Manager * * @return instance of TocManager */ public static TocManager getTocManager() { if (getDefault().tocManager == null) { synchronized (tocManagerCreateLock) { if (getDefault().tocManager == null) { getDefault().tocManager = new TocManager(); } } } return getDefault().tocManager; }
if (cached == null) { HashMap<String, TocContribution> contributions = new HashMap<>(); AbstractTocProvider[] providers = getTocProviders(); for (int i=0;i<providers.length;++i) { ITocContribution[] contrib;
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; } }
/** * Returns the list of all integrated tables of contents available. Each * entry corresponds of a different help "book". * * @return an array of TOC's */ public static IToc[] getTocs() { return HelpPlugin.getTocManager().getTocs(Platform.getNL()); }
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 TocContribution[] getTocContributionsForToc(String locale) { return getAndCacheTocContributions(locale, tocContributionsForTocByLocale); }
public synchronized ICriteriaDefinition getCriteriaDefinition(String locale) { CriteriaDefinition criteriaDefinition = criteriaDefinitionsByLocale.get(locale); if (null == criteriaDefinition) { HelpPlugin.getTocManager().getTocs(locale); long start = System.currentTimeMillis(); if (HelpPlugin.DEBUG_CRITERIA) { System.out.println("Start to update criteria definition for locale " + locale); //$NON-NLS-1$ } List<CriteriaDefinitionContribution> contributions = new ArrayList<>( Arrays.asList(readCriteriaDefinitionContributions(locale))); CriteriaDefinitionAssembler assembler = new CriteriaDefinitionAssembler(); criteriaDefinition = assembler.assemble(contributions); criteriaDefinitionsByLocale.put(locale, criteriaDefinition); long stop = System.currentTimeMillis(); if (HelpPlugin.DEBUG_CRITERIA) { System.out.println("Milliseconds to update criteria definition for locale " + locale + " = " + (stop - start)); //$NON-NLS-1$ //$NON-NLS-2$ } } return criteriaDefinition; }
public synchronized IIndex getIndex(String locale) { Index index = indexesByLocale.get(locale); if (index == null) { HelpPlugin.getTocManager().getTocs(locale); // Ensure Tocs and index not built simultaneously long start = System.currentTimeMillis(); if (HelpPlugin.DEBUG_INDEX) { System.out.println("Start to update keyword index for locale " + locale); //$NON-NLS-1$ } List<IndexContribution> contributions = new ArrayList<>(Arrays.asList(readIndexContributions(locale))); filterIndexContributions(contributions); IndexAssembler assembler = new IndexAssembler(); index = assembler.assemble(contributions, locale); indexesByLocale.put(locale, index); long stop = System.currentTimeMillis(); if (HelpPlugin.DEBUG_INDEX) { System.out.println("Milliseconds to update keyword index for locale " + locale + " = " + (stop - start)); //$NON-NLS-1$ //$NON-NLS-2$ } } return index; }
private String getTopicCategory(String href, String locale) { IToc[] tocs = HelpPlugin.getTocManager().getTocs(locale); for (int i = 0; i < tocs.length; i++) { ITopic topic = tocs[i].getTopic(href); if (topic != null) return tocs[i].getLabel(); } return null; }
Toc[] tocs = HelpPlugin.getTocManager().getTocs(locale); for (int t = 0; t < tocs.length; t++) { String descriptionHref = tocs[t].getTopic(null).getHref();