Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 310611
Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/wikitext/confluence/core/block/TableBlock.java (-4 / +20 lines)
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
	}
(-)src/org/eclipse/mylyn/internal/wikitext/confluence/core/block/ExtendedPreformattedBlock.java (-3 / +22 lines)
Lines 15-23 Link Here
15
15
16
/**
16
/**
17
 * quoted text block, matches blocks that start with <code>{noformat}</code>. Creates an extended block type of
17
 * quoted text block, matches blocks that start with <code>{noformat}</code>. Creates an extended block type of
18
 * {@link ParagraphBlock paragraph}.
18
 * {@link ParagraphBlock paragraph}. In order to allow direct reuse of Confluence CSS and visually match web UI output,
19
 * an additional div wrapping is used
19
 * 
20
 * 
20
 * @author David Green
21
 * @author David Green
22
 * @author Wojciech Seliga
21
 */
23
 */
22
public class ExtendedPreformattedBlock extends AbstractConfluenceDelimitedBlock {
24
public class ExtendedPreformattedBlock extends AbstractConfluenceDelimitedBlock {
23
25
Lines 28-38 Link Here
28
	@Override
30
	@Override
29
	protected void beginBlock() {
31
	protected void beginBlock() {
30
		Attributes attributes = new Attributes();
32
		Attributes attributes = new Attributes();
31
		builder.beginBlock(BlockType.PREFORMATTED, attributes);
33
34
		attributes.appendCssClass("preformatted"); //$NON-NLS-1$
35
		attributes.appendCssClass("panel"); //$NON-NLS-1$
36
37
		// to stick to web renderer used by Confluence and Crucible 
38
		// as this style is not configured via CSS, but rather included in-line
39
		attributes.appendCssStyle("border-width: 1px;"); //$NON-NLS-1$
40
41
		builder.beginBlock(BlockType.DIV, attributes);
42
43
		Attributes attributes2 = new Attributes();
44
		attributes2.appendCssClass("preformattedContent"); //$NON-NLS-1$
45
		attributes2.appendCssClass("panelContent"); //$NON-NLS-1$
46
47
		builder.beginBlock(BlockType.DIV, attributes2);
48
		builder.beginBlock(BlockType.PREFORMATTED, new Attributes());
32
	}
49
	}
33
50
34
	@Override
51
	@Override
35
	protected void endBlock() {
52
	protected void endBlock() {
53
		builder.endBlock(); // div
54
		builder.endBlock(); // div
36
		builder.endBlock(); // pre
55
		builder.endBlock(); // pre
37
	}
56
	}
38
57
Lines 40-49 Link Here
40
	protected void handleBlockContent(String content) {
59
	protected void handleBlockContent(String content) {
41
		if (content.length() > 0) {
60
		if (content.length() > 0) {
42
			builder.characters(content);
61
			builder.characters(content);
62
			builder.characters("\n"); //$NON-NLS-1$
43
		} else if (blockLineCount == 1) {
63
		} else if (blockLineCount == 1) {
44
			return;
64
			return;
45
		}
65
		}
46
		builder.characters("\n"); //$NON-NLS-1$
47
	}
66
	}
48
67
49
	@Override
68
	@Override

Return to bug 310611