public OutlineItem findNearestMatchingOffset(int offset) { NearestItemVisitor visitor = new NearestItemVisitor(offset); accept(visitor); return visitor.nearest; }
public void accept(Visitor visitor) { if (visitor.visit(this)) { for (OutlineItem item : getChildren()) { item.accept(visitor); } } }
@Override public void beginDocument() { rootItem.clear(); currentItem = rootItem; }
private void initializeOutlineParser() { synchronized (WikiTextSourceEditor.this) { if (outlineParser == null) { outlineParser = new OutlineParser(); outlineParser.setLabelMaxLength(48); outlineModel = outlineParser.createRootItem(); } } }
public OutlineItem parse(String markup) { OutlineItem root = createRootItem(); return parse(root, markup); }
public String getLabel(Object o) { if (o instanceof OutlineItem) { OutlineItem item = (OutlineItem) o; // TODO: bug 260447 remove text prefix when icons become available if (item.getKind() == null) { return item.getLabel(); } else { return item.getKind() + ". " + item.getLabel(); //$NON-NLS-1$ } } return null; }
private OutlineItem computeRoot(OutlineItem item) { while (!item.isRootItem()) { item = item.getParent(); } return item; }
/** * 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 String calculatePositionKey() { if (positionKey == null) { if (parent == null) { positionKey = ""; //$NON-NLS-1$ } else { positionKey = getParent().calculatePositionKey() + "/" + kind + childOffset; //$NON-NLS-1$ } } return positionKey; }
/** * the resource path to the resource of this outline item * * @return the resource path, or null if it's unknown. */ public String getResourcePath() { if (getParent() != null) { return getParent().getResourcePath(); } return resourcePath; }
public Object getParent(Object o) { if (o instanceof OutlineItem) { OutlineItem item = (OutlineItem) o; return item.getParent(); } return null; }
protected OutlineItem createOutlineItem(OutlineItem current, int level, String id, int offset, int length, String label) { return new OutlineItem(current, level, id, offset, length, label); }
public OutlineItem createRootItem() { return createOutlineItem(null, 0, "<root>", 0, 0, "<root>"); //$NON-NLS-1$ //$NON-NLS-2$ }
public DocumentBuilder createOutlineUpdater(OutlineItem rootItem) { return new OutlineBuilder(rootItem, labelMaxLength); }
@Override public void imageLink(Attributes linkAttributes, Attributes imageAttributes, String href, String imageUrl) { registerId(linkAttributes.getId()); registerId(imageAttributes.getId()); }
private void detectOutlineLocationChanged() { OutlineItem nearestItem = getNearestMatchingOutlineItem(); if (nearestItem != outlineLocation && (nearestItem == null || !nearestItem.equals(outlineLocation))) { outlineLocation = nearestItem; firePropertyChange(PROP_OUTLINE_LOCATION); } }
@Override public SplitOutlineItem getParent() { return (SplitOutlineItem) super.getParent(); }