blob: c912feff5bfe2f0dfa5852b786325e24b2401faf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*******************************************************************************
* Copyright (c) 2007, 2011 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Green - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.wikitext.ui.viewer;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.mylyn.wikitext.parser.MarkupParser;
import org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage;
import org.eclipse.swt.graphics.Drawable;
/**
* An information presenter that supports markup. Uses the {@link MarkupParser} to parse the markup to HTML, and passes
* the HTML to the superclass.
*
* @author David Green
* @since 1.0
*/
public class MarkupTextPresenter extends HtmlTextPresenter {
private MarkupLanguage markupLanguage;
/**
* the markup language used by this presenter
*
* @since 3.0
*/
public MarkupLanguage getMarkupLanguage() {
return markupLanguage;
}
/**
* the markup language used by this presenter
*
* @since 3.0
*/
public void setMarkupLanguage(MarkupLanguage markupLanguage) {
this.markupLanguage = markupLanguage;
}
@Override
public String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth,
int maxHeight) {
if (markupLanguage == null) {
throw new IllegalStateException();
}
if (hoverInfo == null || hoverInfo.length() == 0) {
return hoverInfo;
}
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(markupLanguage);
String html = parser.parseToHtml(hoverInfo);
return super.updatePresentation(drawable, html, presentation, maxWidth, maxHeight);
}
}
|