private Object[] getChildren(IIndexEntry entry) { /* * Index entry has two types of children: topics and subentries. * * The method returns topics among children only if number of the topics * more than 1. * * In case when the entry owns only one topic, this topic is not returned * as child because the entry will represent this topic by its keyword. */ IHelpResource[] topics = entry.getTopics(); IIndexEntry[] subentries = entry.getSubentries(); if (topics.length <= 1) { return subentries; } Object[] childrens = new Object[topics.length + subentries.length]; System.arraycopy(topics, 0, childrens, 0, topics.length); System.arraycopy(subentries, 0, childrens, topics.length, subentries.length); return childrens; }
private String getHref(Object target) { if (target instanceof ISelectionProvider) { ISelectionProvider provider = (ISelectionProvider) target; IStructuredSelection ssel = (IStructuredSelection) provider .getSelection(); Object obj = ssel.getFirstElement(); if (obj instanceof IToc) return null; if (obj instanceof IHelpResource) { IHelpResource res = (IHelpResource) obj; return res.getHref(); } if (obj instanceof IIndexEntry) { /* * if index entry has single topic * it represents the topic by itself */ IHelpResource[] topics = ((IIndexEntry) obj).getTopics(); if (topics.length == 1) return topics[0].getHref(); return null; } } else if (target instanceof FormText) { FormText text = (FormText) target; Object href = text.getSelectedLinkHref(); if (href != null) return href.toString(); } return null; }
private boolean isEnabled(IIndexEntry entry) { if (!UAContentFilter.isFiltered(entry, HelpEvaluationContext.getContext())) { IHelpResource[] topics = entry.getTopics(); for (int i = 0; i < topics.length; i++) { if (isEnabled(topics[i])) return true; } IIndexEntry[] subentries = entry.getSubentries(); for (int i = 0; i < subentries.length; i++) { if (isEnabled(subentries[i])) return true; } } return false; }
protected void doOpen(Object obj) { if (obj instanceof IHelpResource) { parent.showURL(((IHelpResource) obj).getHref()); } else if (obj instanceof IIndexEntry) { IIndexEntry entry = (IIndexEntry) obj; if (getChildren(entry).length > 0) { treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(obj)); } IHelpResource[] topics = entry.getTopics(); if (topics.length == 1) { parent.showURL(topics[0].getHref()); } } }
IHelpResource[] topics = entry.getTopics(); if (topics.length == 1) { final String href = topics[0].getHref();