public boolean visit(OutlineItem item) { if (item != outline) { String id = item.getId(); if (id != null && id.length() > 0) { suggestions.add(createProposal(prefix, prefixOffset, id)); } } return true; }
Set<String> idsOf(Collection<OutlineItem> items) { if (items == null || items.isEmpty()) { return Collections.emptySet(); } Set<String> ids = new HashSet<String>(); for (OutlineItem item : items) { ids.add(item.getId()); } return ids; }
/** * @since 1.1 */ @Override public String toString() { return "OutlineItem(" + calculatePositionKey() + "/" + getId() + "/" + System.identityHashCode(this) + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ } }
private String computeTargetFilename(OutlineItem item) { String filenameSuffix = filename.substring(filename.lastIndexOf('.')); return computeName(item.getLevel() == topicBreakLevel ? item.getId() : null, filenameSuffix); }
private void createProjectionAnnotations(List<Annotation> newProjectionAnnotations, Map<HeadingProjectionAnnotation, Position> annotationToPosition, List<OutlineItem> children, int endOffset) { final int size = children.size(); final int lastIndex = size - 1; for (int x = 0; x < size; ++x) { OutlineItem child = children.get(x); if (child.getId() == null || child.getId().length() == 0) { continue; } int offset = child.getOffset(); int end; if (x == lastIndex) { end = endOffset; } else { end = children.get(x + 1).getOffset(); } int length = end - offset; if (length > 0) { HeadingProjectionAnnotation annotation = new HeadingProjectionAnnotation(child.getId()); Position position = new Position(offset, length); newProjectionAnnotations.add(annotation); annotationToPosition.put(annotation, position); } if (!child.getChildren().isEmpty()) { createProjectionAnnotations(newProjectionAnnotations, annotationToPosition, child.getChildren(), end); } } }
private void emitToc(OutlineItem item) { if (item.getChildren().isEmpty()) { return; } Attributes nullAttributes = new Attributes(); builder.beginBlock(BlockType.NUMERIC_LIST, new Attributes()); for (OutlineItem child : item.getChildren()) { builder.beginBlock(BlockType.LIST_ITEM, nullAttributes); builder.link('#' + child.getId(), child.getLabel()); emitToc(child); builder.endBlock(); } builder.endBlock(); }
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 } }
private void emitToc(OutlineItem item) { if (item.getChildren().isEmpty()) { return; } if ((item.getLevel() + 1) > maxLevel) { return; } Attributes nullAttributes = new Attributes(); builder.beginBlock(BlockType.NUMERIC_LIST, new Attributes(null, null, "list-style: " + style + ";", null)); //$NON-NLS-1$ //$NON-NLS-2$ for (OutlineItem child : item.getChildren()) { builder.beginBlock(BlockType.LIST_ITEM, nullAttributes); builder.link('#' + child.getId(), child.getLabel()); emitToc(child); builder.endBlock(); } builder.endBlock(); }
protected void emitToc(OutlineItem item) { if (item.getChildren().isEmpty()) { return; } if ((item.getLevel() + 1) > maxLevel) { return; } Attributes nullAttributes = new Attributes(); builder.beginBlock(BlockType.NUMERIC_LIST, new Attributes(null, null, "list-style: " + style + ";", null)); //$NON-NLS-1$ //$NON-NLS-2$ for (OutlineItem child : item.getChildren()) { builder.beginBlock(BlockType.LIST_ITEM, nullAttributes); builder.link('#' + child.getId(), child.getLabel()); emitToc(child); builder.endBlock(); } builder.endBlock(); }
private void emitToc(OutlineItem item) { if (item.getChildren().isEmpty()) { return; } if ((item.getLevel() + 1) > maxLevel) { return; } Attributes nullAttributes = new Attributes(); builder.beginBlock(BlockType.NUMERIC_LIST, new Attributes(null, null, "list-style: " + style + ";", null)); //$NON-NLS-1$ //$NON-NLS-2$ for (OutlineItem child : item.getChildren()) { builder.beginBlock(BlockType.LIST_ITEM, nullAttributes); builder.link('#' + child.getId(), child.getLabel()); emitToc(child); builder.endBlock(); } builder.endBlock(); }