use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class OutlineDropTargetListener method drop.
public void drop(DropTargetEvent event) {
List<OutlineItem> dropItems = getDropItems(event);
if (dropItems != null) {
InsertLocation location = computeInsertLocation(event);
Object targetData = event.item.getData();
final AbstractDocumentCommand command = computeCommand(targetData, dropItems, location);
if (command != null) {
if (command.isEnabled()) {
SafeRunnable.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
WikiTextUiPlugin.getDefault().log(exception);
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.OutlineDropTargetListener_0, NLS.bind(Messages.OutlineDropTargetListener_1, new Object[] { exception.getMessage() }));
}
public void run() throws Exception {
commandManager.perform(command);
}
});
} else {
MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.OutlineDropTargetListener_2, NLS.bind(Messages.OutlineDropTargetListener_3, new Object[] { command.getProblemText() }));
}
}
}
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class WikiTextContextStructureBridge method getObjectForHandle.
@Override
public Object getObjectForHandle(String handle) {
if (handle == null) {
return null;
}
int idxOfSeparator = handle.indexOf(HANDLE_FILE_SEPARATOR);
String filename = handle;
if (idxOfSeparator != -1) {
filename = handle.substring(0, idxOfSeparator);
}
IFile file;
try {
file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
} catch (Exception e) {
// be error-tolerant since we don't know much about the handle at this point
return null;
}
if (file != null) {
if (idxOfSeparator != -1) {
String headingId = handle.substring(idxOfSeparator + 1);
OutlineItem outline = getOutline(file);
if (outline != null) {
OutlineItem item = outline.findItemById(headingId);
return item;
}
} else {
return file;
}
}
return null;
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class TableOfContentsBlock method emitToc.
private void emitToc(OutlineItem item) {
if (item.getChildren().isEmpty()) {
return;
}
if ((item.getLevel() + 1) > maxLevel) {
return;
}
Attributes nullAttributes = new Attributes();
// $NON-NLS-1$ //$NON-NLS-2$
builder.beginBlock(BlockType.NUMERIC_LIST, new Attributes(null, null, "list-style: " + style + ";", null));
for (OutlineItem child : item.getChildren()) {
builder.beginBlock(BlockType.LIST_ITEM, nullAttributes);
builder.link('#' + child.getId(), child.getLabel());
emitToc(child);
builder.endBlock();
}
builder.endBlock();
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class TableOfContentsBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineNumber++ > 0) {
setClosed(true);
return 0;
}
if (!getMarkupLanguage().isFilterGenerativeContents()) {
String options = matcher.group(1);
setOptions(options);
OutlineParser outlineParser = new OutlineParser(new ConfluenceLanguage());
OutlineItem rootItem = outlineParser.parse(state.getMarkupContent());
emitToc(rootItem);
}
setClosed(true);
return matcher.start(2);
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class SplittingHtmlDocumentBuilder method emitToc.
private void emitToc(OutlineItem item, int level) {
if (item.getChildren().isEmpty()) {
return;
}
out.beginBlock(BlockType.NUMERIC_LIST, new Attributes());
for (OutlineItem child : item.getChildren()) {
Attributes itemAttributes = new Attributes();
if (isExpandedInTableOfContents(child)) {
// $NON-NLS-1$
itemAttributes.appendCssClass("expanded");
} else {
// $NON-NLS-1$
itemAttributes.appendCssClass("collapsed");
}
out.beginBlock(BlockType.LIST_ITEM, itemAttributes);
out.link(getHrefOfHeading(child.getId()), child.getLabel());
emitToc(child, level + 1);
out.endBlock();
}
out.endBlock();
}
Aggregations