@Override public String getIcon(){ return getAttribute(ATTRIBUTE_ICON); }
@Override public ITopic[] getSubtopics() { return getChildren(ITopic.class); }
public void setHref(String href) { setAttribute(ATTRIBUTE_HREF, href); }
public Topic(ITopic src) { super(NAME, src); setHref(src.getHref()); setLabel(src.getLabel()); 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) { int index = id.indexOf('/', 1); if (index != -1) { String pluginId = id.substring(1, index); topic.setHref(HrefUtil.normalizeHref(pluginId, href)); } } String title = element.getAttribute("title"); //$NON-NLS-1$ if (title != null) { topic.setLabel(title); } } return UNHANDLED; } }
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; } }
public void mergeContext(IContext src) { String text = src.getText(); if (getText() == null || getText().length() == 0) { setText(text); } if (src instanceof IContext2 && getTitle() == null) { String title = ((IContext2)src).getTitle(); if (title != null) { setAttribute(ATTRIBUTE_TITLE, title); } } if (src instanceof IContext3) { ICommandLink[] commands = ((IContext3)src).getRelatedCommands(); for (int i=0;i<commands.length;++i) { appendChild(new CommandLink(commands[i])); } } IHelpResource[] topics = src.getRelatedTopics(); for (int i=0;i<topics.length;++i) { if (topics[i] instanceof ITopic) { appendChild(new Topic((ITopic)topics[i])); } else { Topic topic = new Topic(); topic.setHref(topics[i].getHref()); topic.setLabel(topics[i].getLabel()); appendChild(topic); } } }
private void sortChildren(Topic topic) { if (topic.isSorted()) { sort(topic, topic.getSubtopics()); } ITopic[] childTopics = topic.getSubtopics(); for (int i = 0; i < childTopics.length; i++) { sortChildren((Topic)childTopics[i]); } }
private int indexOf(UAElement parent, Topic child) { ITopic[] children; if (parent instanceof Topic) { children = ((Topic)parent).getSubtopics(); } else if (parent instanceof Toc) { children = ((Toc)parent).getTopics(); } else { return -1; } for (int i=0;i<children.length;++i) { if (children[i] == child) { return i; } } return -1; }
@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; }
@Override public String getHref() { return getAttribute(ATTRIBUTE_HREF); }
@Override public ICriteria[] getCriteria() { return getChildren(ICriteria.class); }
public void setLabel(String label) { setAttribute(ATTRIBUTE_LABEL, label); }
@Override public String getLabel() { return getAttribute(ATTRIBUTE_LABEL); }
@Override public boolean isSorted(){ return "true".equalsIgnoreCase(getAttribute(ATTRIBUTE_SORT)); //$NON-NLS-1$ }