use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class OutlineParserTest method testSimple.
public void testSimple() {
OutlineItem outline = outlineParser.parse("h1. First Header\n\nh2. Second Header\n\nh1. Third Header\n");
assertEquals(2, outline.getChildren().size());
assertEquals(1, outline.getChildren().get(0).getChildren().size());
assertEquals(0, outline.getChildren().get(1).getChildren().size());
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class OutlineParserTest method testMoveChildren.
public void testMoveChildren() {
String textile = "h1. First Header\n\nh2. Second Header\n\nh1. Third Header\n";
OutlineItem outline = outlineParser.parse(textile);
assertEquals(2, outline.getChildren().size());
OutlineItem outline2 = outlineParser.createRootItem();
outline2.moveChildren(outline);
assertEquals(0, outline.getChildren().size());
assertEquals(2, outline2.getChildren().size());
assertSame(outline2, outline2.getChildren().get(0).getParent());
assertSame(outline2, outline2.getChildren().get(1).getParent());
outline = outlineParser.parse(textile);
outline.moveChildren(outline2);
assertEquals(0, outline2.getChildren().size());
assertEquals(4, outline.getChildren().size());
assertSame(outline, outline.getChildren().get(0).getParent());
assertSame(outline, outline.getChildren().get(1).getParent());
assertSame(outline, outline.getChildren().get(2).getParent());
assertSame(outline, outline.getChildren().get(3).getParent());
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class ActiveFoldingListener method updateFolding.
private void updateFolding(boolean elementsDeleted) {
if (!foldingStructure.isFoldingEnabled()) {
return;
}
if (!foldingEnabled || !ContextCore.getContextManager().isContextActive()) {
foldingStructure.expandAll();
} else {
OutlineItem outline = (OutlineItem) part.getAdapter(OutlineItem.class);
if (outline != null) {
final List<OutlineItem> toExpand = new ArrayList<OutlineItem>();
outline.accept(new Visitor() {
public boolean visit(OutlineItem item) {
String identifier = bridge.getHandleIdentifier(item);
IInteractionElement element = ContextCore.getContextManager().getElement(identifier);
if (element != null && element.getInterest().isInteresting()) {
toExpand.add(item);
}
return true;
}
});
if (toExpand.isEmpty()) {
foldingStructure.collapseAll(elementsDeleted);
} else {
foldingStructure.expandElementsExclusive(toExpand, elementsDeleted);
}
}
}
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class XslfoDocumentBuilder method emitToc.
private void emitToc(XmlStreamWriter writer, List<OutlineItem> children) {
for (OutlineItem item : children) {
// $NON-NLS-1$
writer.writeStartElement("bookmark");
// $NON-NLS-1$
writer.writeAttribute("internal-destination", item.getId());
// $NON-NLS-1$
writer.writeStartElement("bookmark-title");
writer.writeCharacters(item.getLabel());
writer.writeEndElement();
if (!item.getChildren().isEmpty()) {
emitToc(writer, item.getChildren());
}
// bookmark
writer.writeEndElement();
}
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class MarkupToEclipseToc method emitToc.
private void emitToc(XmlStreamWriter writer, List<OutlineItem> children) {
for (OutlineItem item : children) {
// $NON-NLS-1$
writer.writeStartElement("topic");
String file = computeFile(item);
file = adjustForPrefix(file);
// $NON-NLS-1$
String suffix = "";
// bug 260065: only append document anchor name if this is not the first item in the file.
OutlineItem previous = item.getPrevious();
boolean hasPrevious = previous != null && previous.getParent() != null;
if (hasPrevious) {
String fileOfPrevious = computeFile(previous);
fileOfPrevious = adjustForPrefix(fileOfPrevious);
if (file.equals(fileOfPrevious)) {
// $NON-NLS-1$
suffix = "#" + item.getId();
}
}
// $NON-NLS-1$
writer.writeAttribute("href", file + suffix);
// $NON-NLS-1$
writer.writeAttribute("label", item.getLabel());
if (!item.getChildren().isEmpty()) {
emitToc(writer, item.getChildren());
}
if (item.getLevel() <= anchorLevel) {
// $NON-NLS-1$
writer.writeEmptyElement("anchor");
// $NON-NLS-1$ //$NON-NLS-2$
writer.writeAttribute("id", item.getId() + "-additions");
}
// topic
writer.writeEndElement();
}
}
Aggregations