Search in sources :

Example 6 with TableCellAttributes

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);
    }
}
Also used : Matcher(java.util.regex.Matcher) TableCellAttributes(org.eclipse.mylyn.wikitext.parser.TableCellAttributes)

Aggregations

TableCellAttributes (org.eclipse.mylyn.wikitext.parser.TableCellAttributes)6 Matcher (java.util.regex.Matcher)4 TableAttributes (org.eclipse.mylyn.wikitext.parser.TableAttributes)3 TableRowAttributes (org.eclipse.mylyn.wikitext.parser.TableRowAttributes)3 CharMatcher (com.google.common.base.CharMatcher)1 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)1 BlockType (org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType)1 ImageAttributes (org.eclipse.mylyn.wikitext.parser.ImageAttributes)1 LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)1