use of org.eclipse.mylyn.wikitext.parser.TableCellAttributes in project mylyn.docs by eclipse.
the class TableBlock method emitCell.
private void emitCell(int lineCharacterOffset, BlockType type, String cell) {
Matcher cellSplitterMatcher = cellSplitterPattern.matcher(cell);
if (!cellSplitterMatcher.matches()) {
throw new IllegalStateException();
}
String cellOptions = cellSplitterMatcher.group(1);
TableCellAttributes attributes = new TableCellAttributes();
if (cellOptions != null) {
Matcher optionsMatcher = optionsPattern.matcher(cellOptions);
while (optionsMatcher.find()) {
String optionName = optionsMatcher.group(1);
String optionValue = optionsMatcher.group(2);
if (optionName.equalsIgnoreCase("id")) {
// $NON-NLS-1$
attributes.setId(optionValue);
} else if (optionName.equalsIgnoreCase("style")) {
// $NON-NLS-1$
attributes.setCssStyle(optionValue);
} else if (optionName.equalsIgnoreCase("class")) {
// $NON-NLS-1$
attributes.setCssClass(optionValue);
} else if (optionName.equalsIgnoreCase("title")) {
// $NON-NLS-1$
attributes.setTitle(optionValue);
} else if (optionName.equalsIgnoreCase("align")) {
// $NON-NLS-1$
attributes.setAlign(optionValue);
} else if (optionName.equalsIgnoreCase("valign")) {
// $NON-NLS-1$
attributes.setValign(optionValue);
} else if (optionName.equalsIgnoreCase("bgcolor")) {
// $NON-NLS-1$
attributes.setBgcolor(optionValue);
} else if (optionName.equalsIgnoreCase("colspan")) {
// $NON-NLS-1$
attributes.setColspan(optionValue);
} else if (optionName.equalsIgnoreCase("rowspan")) {
// $NON-NLS-1$
attributes.setRowspan(optionValue);
}
}
}
String cellContents = cellSplitterMatcher.group(2);
if (cellContents == null) {
// cell was opened, no content on this line
openCell(lineCharacterOffset + cellSplitterMatcher.end(), type, attributes);
} else {
int contentsStart = cellSplitterMatcher.start(2);
openCell(lineCharacterOffset, type, attributes);
markupLanguage.emitMarkupLine(parser, state, lineCharacterOffset + contentsStart, cellContents, 0);
}
}
Aggregations