|
Lines 10-29
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.mylyn.internal.wikitext.confluence.core.block; |
11 |
package org.eclipse.mylyn.internal.wikitext.confluence.core.block; |
| 12 |
|
12 |
|
| 13 |
import java.util.regex.Matcher; |
|
|
| 14 |
import java.util.regex.Pattern; |
| 15 |
|
| 16 |
import org.eclipse.mylyn.wikitext.core.parser.Attributes; |
13 |
import org.eclipse.mylyn.wikitext.core.parser.Attributes; |
| 17 |
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType; |
14 |
import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType; |
| 18 |
import org.eclipse.mylyn.wikitext.core.parser.markup.Block; |
15 |
import org.eclipse.mylyn.wikitext.core.parser.markup.Block; |
| 19 |
|
16 |
|
|
|
17 |
import java.util.regex.Matcher; |
| 18 |
import java.util.regex.Pattern; |
| 19 |
|
| 20 |
/** |
20 |
/** |
| 21 |
* Table block, matches blocks that start with <code>table. </code> or those that start with a table row. |
21 |
* Table block, matches blocks that start with <code>table. </code> or those that start with a table row. |
| 22 |
* |
22 |
* |
| 23 |
* @author David Green |
23 |
* @author David Green |
|
|
24 |
* @author Wojciech Seliga |
| 24 |
*/ |
25 |
*/ |
| 25 |
public class TableBlock extends Block { |
26 |
public class TableBlock extends Block { |
| 26 |
|
27 |
|
|
|
28 |
private static final String TABLE_WRAP_CSS_CLASS = "table-wrap"; //$NON-NLS-1$ |
| 29 |
|
| 30 |
private static final String TABLE_CSS_CLASS = "confluenceTable"; //$NON-NLS-1$ |
| 31 |
|
| 32 |
private static final String CELL_CSS_CLASS = "confluenceTd"; //$NON-NLS-1$ |
| 33 |
|
| 34 |
private static final String HEADER_CSS_CLASS = "confluenceTh"; //$NON-NLS-1$ |
| 35 |
|
| 27 |
static final Pattern startPattern = Pattern.compile("(\\|(.*)?(\\|\\s*$))"); //$NON-NLS-1$ |
36 |
static final Pattern startPattern = Pattern.compile("(\\|(.*)?(\\|\\s*$))"); //$NON-NLS-1$ |
| 28 |
|
37 |
|
| 29 |
static final Pattern TABLE_ROW_PATTERN = Pattern.compile("\\|(\\|)?" + "((?:(?:[^\\|\\[]*)(?:\\[[^\\]]*\\])?)*)" //$NON-NLS-1$ //$NON-NLS-2$ |
38 |
static final Pattern TABLE_ROW_PATTERN = Pattern.compile("\\|(\\|)?" + "((?:(?:[^\\|\\[]*)(?:\\[[^\\]]*\\])?)*)" //$NON-NLS-1$ //$NON-NLS-2$ |
|
Lines 39-45
Link Here
|
| 39 |
@Override |
48 |
@Override |
| 40 |
public int processLineContent(String line, int offset) { |
49 |
public int processLineContent(String line, int offset) { |
| 41 |
if (blockLineCount == 0) { |
50 |
if (blockLineCount == 0) { |
|
|
51 |
Attributes tableWrapperAttributes = new Attributes(); |
| 52 |
tableWrapperAttributes.setCssClass(TABLE_WRAP_CSS_CLASS); |
| 53 |
builder.beginBlock(BlockType.DIV, tableWrapperAttributes); |
| 54 |
|
| 42 |
Attributes attributes = new Attributes(); |
55 |
Attributes attributes = new Attributes(); |
|
|
56 |
attributes.setCssClass(TABLE_CSS_CLASS); |
| 43 |
builder.beginBlock(BlockType.TABLE, attributes); |
57 |
builder.beginBlock(BlockType.TABLE, attributes); |
| 44 |
} else if (markupLanguage.isEmptyLine(line)) { |
58 |
} else if (markupLanguage.isEmptyLine(line)) { |
| 45 |
setClosed(true); |
59 |
setClosed(true); |
|
Lines 73-78
Link Here
|
| 73 |
boolean header = headerIndicator != null && "|".equals(headerIndicator); //$NON-NLS-1$ |
87 |
boolean header = headerIndicator != null && "|".equals(headerIndicator); //$NON-NLS-1$ |
| 74 |
|
88 |
|
| 75 |
Attributes attributes = new Attributes(); |
89 |
Attributes attributes = new Attributes(); |
|
|
90 |
attributes.setCssClass(header ? HEADER_CSS_CLASS : CELL_CSS_CLASS); |
| 76 |
builder.beginBlock(header ? BlockType.TABLE_CELL_HEADER : BlockType.TABLE_CELL_NORMAL, attributes); |
91 |
builder.beginBlock(header ? BlockType.TABLE_CELL_HEADER : BlockType.TABLE_CELL_NORMAL, attributes); |
| 77 |
|
92 |
|
| 78 |
markupLanguage.emitMarkupLine(getParser(), state, lineOffset, text, 0); |
93 |
markupLanguage.emitMarkupLine(getParser(), state, lineOffset, text, 0); |
|
Lines 100-106
Link Here
|
| 100 |
@Override |
115 |
@Override |
| 101 |
public void setClosed(boolean closed) { |
116 |
public void setClosed(boolean closed) { |
| 102 |
if (closed && !isClosed()) { |
117 |
if (closed && !isClosed()) { |
| 103 |
builder.endBlock(); |
118 |
builder.endBlock(); // closing wrapping div |
|
|
119 |
builder.endBlock(); // closing table |
| 104 |
} |
120 |
} |
| 105 |
super.setClosed(closed); |
121 |
super.setClosed(closed); |
| 106 |
} |
122 |
} |