@Override public SplitOutlineItem getParent() { return (SplitOutlineItem) super.getParent(); }
public Object getParent(Object o) { if (o instanceof OutlineItem) { OutlineItem item = (OutlineItem) o; return item.getParent(); } return null; }
/** * the resource path to the resource of this outline item * * @param resourcePath * the resource path, or null if it's unknown. */ public void setResourcePath(String resourcePath) { if (getParent() != null) { getParent().setResourcePath(resourcePath); } else { this.resourcePath = resourcePath; } }
private OutlineItem computeRoot(OutlineItem item) { while (!item.isRootItem()) { item = item.getParent(); } return item; }
private String calculatePositionKey() { if (positionKey == null) { if (parent == null) { positionKey = ""; //$NON-NLS-1$ } else { positionKey = getParent().calculatePositionKey() + "/" + kind + childOffset; //$NON-NLS-1$ } } return positionKey; }
/** * get the length of the section, which is the length of the heading text plus the length of any following content * up to the next peer-leveled heading or the parent's following sibling. * * @see #getLength() */ public int getSectionLength() { if (parent == null) { return length; } List<OutlineItem> siblings = getParent().getChildren(); int index = siblings.indexOf(this); if (index < (siblings.size() - 1)) { return siblings.get(index + 1).getOffset() - getOffset(); } int parentRelativeOffset = getOffset() - parent.getOffset(); return parent.getSectionLength() - parentRelativeOffset; }
currentItem = currentItem.getParent();
private void emitToc(XmlStreamWriter writer, List<OutlineItem> children) { for (OutlineItem item : children) { writer.writeStartElement("topic"); //$NON-NLS-1$ String file = computeFile(item); file = adjustForPrefix(file); String suffix = ""; //$NON-NLS-1$ // bug 260065: only append document anchor name if this is not the first item in the file. OutlineItem previous = item.getPrevious(); if (previous != null && previous.getParent() != null) { String fileOfPrevious = computeFile(previous); fileOfPrevious = adjustForPrefix(fileOfPrevious); if (file.equals(fileOfPrevious)) { suffix = "#" + item.getId(); //$NON-NLS-1$ } } writer.writeAttribute("href", file + suffix); //$NON-NLS-1$ writer.writeAttribute("label", item.getLabel()); //$NON-NLS-1$ if (!item.getChildren().isEmpty()) { emitToc(writer, item.getChildren()); } writer.writeEndElement(); // topic } }