本文整理匯總了Java中org.eclipse.jface.text.TextPresentation.addStyleRange方法的典型用法代碼示例。如果您正苦於以下問題:Java TextPresentation.addStyleRange方法的具體用法?Java TextPresentation.addStyleRange怎麽用?Java TextPresentation.addStyleRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.TextPresentation
的用法示例。
在下文中一共展示了TextPresentation.addStyleRange方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
*
* @param presentation the text presentation to be extended
* @param offset the offset of the range to be styled
* @param length the length of the range to be styled
* @param attr the attribute describing the style of the range to be styled
* @param wholeLine the boolean switch to declare that the whole line should be colored
*/
private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) {
if (attr != null) {
int style= attr.getStyle();
int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
if(wholeLine) {
try {
int line = document.getLineOfOffset(offset);
int start = document.getLineOffset(line);
length = document.getLineLength(line);
offset = start;
} catch (BadLocationException e) {
}
}
StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle);
styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
presentation.addStyleRange(styleRange);
}
}
示例2: updatePresentation
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
public String updatePresentation( Drawable drawable, String hoverInfo,
TextPresentation presentation, int maxWidth, int maxHeight )
{
ZDebug.print( 5, "updatePresentation( ", drawable, ", ", hoverInfo, ", ", presentation, ", ", maxWidth, ", ", maxHeight, " )" );
HTMLFormat html = new HTMLFormat();
html.format( hoverInfo );
for( StyleRange style : html.getStyleList() ) {
presentation.addStyleRange( style );
}
if( drawable instanceof StyledText ) {
StyledText styled = (StyledText) drawable;
styled.setWordWrap( html.isWordWrap() );
if( !html.isWordWrap() ) {
SWTUtil.fontPreference( styled, ExternalPreference.FONT_EDITOR_TEXT );
}
}
return html.getBuffer();
}
示例3: makeChange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
private void makeChange(TextPresentation presentation, int point, List<StyleRangeCustom> styles, StringBuilder sb) {
List<StyleRangeCustom> activeStyles = Lists.newArrayList();
int end = Integer.MAX_VALUE;
for (StyleRangeCustom s : styles) {
if (s.start <= point) {
if (s.stop > point) {
activeStyles.add(s);
end = Math.min(end, s.stop);
}
} else {
end = Math.min(end, s.start);
}
}
if (activeStyles.isEmpty()) {
return;
}
StyleRange range = new StyleRange(point, end - point, null, null);
for (StyleRangeCustom r : activeStyles) {
r.style(range);
}
presentation.addStyleRange(range);
}
示例4: createInformationPresenter
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
@Override
protected NSISInformationControl.IInformationPresenter createInformationPresenter()
{
return new WrappingInformationPresenter("\t\t") { //$NON-NLS-1$
@Override
public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation,
int maxWidth, int maxHeight)
{
String hoverInfo2 = super.updatePresentation(display, hoverInfo, presentation, maxWidth, maxHeight);
int n = hoverInfo2.indexOf(' ');
if (n <= 0)
{
n = hoverInfo2.length();
}
presentation.addStyleRange(new StyleRange(0, n, display.getSystemColor(SWT.COLOR_INFO_FOREGROUND),
display.getSystemColor(SWT.COLOR_INFO_BACKGROUND), SWT.BOLD));
return hoverInfo2;
}
};
}
示例5: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
*
* @param presentation
* the text presentation to be extended
* @param offset
* the offset of the range to be styled
* @param length
* the length of the range to be styled
* @param attr
* the attribute describing the style of the range to be styled
*/
protected void addRange( TextPresentation presentation, int offset,
int length, TextAttribute attr )
{
if ( attr != null )
{
int style= attr.getStyle();
int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
StyleRange range = new StyleRange( offset,
length,
attr.getForeground( ),
attr.getBackground( ),
fontStyle );
range.strikeout = ( attr.getStyle( ) & TextAttribute.STRIKETHROUGH ) != 0;
range.underline = ( attr.getStyle( ) & TextAttribute.UNDERLINE ) != 0;
range.font= attr.getFont();
presentation.addStyleRange( range );
}
}
示例6: createReader
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Creates the reader and properly puts the presentation into place.
*/
public Reader createReader(String hoverInfo, TextPresentation presentation) {
String str = PyStringUtils.removeWhitespaceColumnsToLeft(hoverInfo);
str = correctLineDelimiters(str);
List<PyStyleRange> lst = new ArrayList<>();
str = handlePydevTags(lst, str);
Collections.sort(lst, new Comparator<PyStyleRange>() {
@Override
public int compare(PyStyleRange o1, PyStyleRange o2) {
return Integer.compare(o1.start, o2.start);
}
});
for (PyStyleRange pyStyleRange : lst) {
presentation.addStyleRange(pyStyleRange);
}
return new StringReader(str);
}
示例7: createDefaultRanges
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Creates the ranges from parsing the code with the PyCodeScanner.
*
* @param textPresentation this is the container of the style ranges.
* @param scanner the scanner used to parse the document.
* @param doc document to parse.
* @param partitionOffset the offset of the document we should parse.
* @param partitionLen the length to be parsed.
*/
private void createDefaultRanges(TextPresentation textPresentation, PyCodeScanner scanner, Document doc,
int partitionOffset, int partitionLen) {
scanner.setRange(doc, partitionOffset, partitionLen);
IToken nextToken = scanner.nextToken();
while (!nextToken.isEOF()) {
Object data = nextToken.getData();
if (data instanceof TextAttribute) {
TextAttribute textAttribute = (TextAttribute) data;
int offset = scanner.getTokenOffset();
int len = scanner.getTokenLength();
Color foreground = textAttribute.getForeground();
Color background = textAttribute.getBackground();
int style = textAttribute.getStyle();
textPresentation.addStyleRange(new StyleRange(offset, len, foreground, background, style));
}
nextToken = scanner.nextToken();
}
}
示例8: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
*
* @param presentation the text presentation to be extended
* @param offset the offset of the range to be styled
* @param length the length of the range to be styled
* @param attr the attribute describing the style of the range to be styled
*/
protected void addRange(
TextPresentation presentation,
int offset,
int length,
TextAttribute attr) {
if (attr != null)
presentation.addStyleRange(
new StyleRange(
offset,
length,
attr.getForeground(),
attr.getBackground(),
attr.getStyle()));
}
示例9: boldRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
private void boldRange(int start, int length, TextPresentation presentation, boolean doItalic) {
// We have found a tag and create a new style range
int fontStyle = doItalic ? (SWT.BOLD | SWT.ITALIC) : SWT.BOLD;
StyleRange range = new StyleRange(start, length, null, null, fontStyle);
// Add this style range to the presentation
presentation.addStyleRange(range);
}
示例10: applyDiffPresentation
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
private void applyDiffPresentation(SourceViewer oldViewer, SourceViewer newViewer,
UpdatableScript.TextualDiff textualDiff) {
TextPresentation oldPresentation = new TextPresentation();
TextPresentation newPresentation = new TextPresentation();
List<Long> chunkNumbers = textualDiff.getChunks();
int posOld = 0;
int posNew = 0;
for (int i = 0; i < chunkNumbers.size(); i += 3) {
int startOld = chunkNumbers.get(i + 0).intValue();
int endOld = chunkNumbers.get(i + 1).intValue();
int endNew = chunkNumbers.get(i + 2).intValue();
int startNew = startOld - posOld + posNew;
if (startOld == endOld) {
// Add
newPresentation.addStyleRange(new StyleRange(startNew, endNew - startNew,
null, colors.get(ColorName.ADDED_BACKGROUND)));
} else if (startNew == endNew) {
// Remove
oldPresentation.addStyleRange(new StyleRange(startOld, endOld - startOld,
null, colors.get(ColorName.ADDED_BACKGROUND)));
} else {
// Replace
newPresentation.addStyleRange(new StyleRange(startNew, endNew - startNew,
null, colors.get(ColorName.CHANGED_BACKGROUND)));
oldPresentation.addStyleRange(new StyleRange(startOld, endOld - startOld,
null, colors.get(ColorName.CHANGED_BACKGROUND)));
}
posOld = endOld;
posNew = endNew;
}
oldViewer.changeTextPresentation(oldPresentation, true);
newViewer.changeTextPresentation(newPresentation, true);
}
示例11: updatePresentation
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* @see IContextInformationPresenter#updatePresentation(int, TextPresentation)
*/
public boolean updatePresentation(int position, TextPresentation presentation) {
int currentParameter= -1;
try {
currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ",", "", true); //$NON-NLS-1$//$NON-NLS-2$
} catch (BadLocationException x) {
return false;
}
if (fCurrentParameter != -1) {
if (currentParameter == fCurrentParameter)
return false;
}
presentation.clear();
fCurrentParameter= currentParameter;
String s= fInformation.getInformationDisplayString();
int[] commas= computeCommaPositions(s);
if (commas.length - 2 < fCurrentParameter) {
presentation.addStyleRange(new StyleRange(0, s.length(), null, null, SWT.NORMAL));
return true;
}
int start= commas[fCurrentParameter] + 1;
int end= commas[fCurrentParameter + 1];
if (start > 0)
presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
if (end > start)
presentation.addStyleRange(new StyleRange(start, end - start, null, null, SWT.BOLD));
if (end < s.length())
presentation.addStyleRange(new StyleRange(end, s.length() - end, null, null, SWT.NORMAL));
return true;
}
示例12: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
* @param presentation
* the text presentation to be extended
* @param offset
* the offset of the range to be styled
* @param length
* the length of the range to be styled
* @param textStyle
* the style of the range to be styled
*/
protected void addRange(TextPresentation presentation, int offset, int length, TextStyle textStyle) {
if (textStyle != null) {
if (textStyle.metrics != null && length >= 1) {
for (int i = offset; i < offset + length; i++) {
try {
StyleRange styleRange = new StyleRange(textStyle);
String placeHolder = fDocument.get(i, 1);
InnerTag innerTag = InnerTagUtil.getInnerTag(fViewer.getInnerTagCacheList(), placeHolder);
if (innerTag != null) {
Point rect = innerTag.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// int ascent = 4 * rect.height / 5 + SEGMENT_LINE_SPACING / 2;
// int descent = rect.height - ascent + SEGMENT_LINE_SPACING;
styleRange.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
}
styleRange.start = i;
styleRange.length = 1;
presentation.addStyleRange(styleRange);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
} /*
* else { StyleRange styleRange = new StyleRange(textStyle); styleRange.start = offset; styleRange.length =
* length; presentation.addStyleRange(styleRange); }
*/
}
}
示例13: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
*
* @param presentation
* the text presentation to be extended
* @param offset
* the offset of the range to be styled
* @param length
* the length of the range to be styled
* @param attr
* the attribute describing the style of the range to be styled
*/
protected void addRange( TextPresentation presentation, int offset,
int length, TextAttribute attr )
{
if ( attr != null )
{
presentation.addStyleRange( new StyleRange( offset,
length,
attr.getForeground( ),
attr.getBackground( ),
attr.getStyle( ) ) );
}
}
示例14: addRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
/**
* Adds style information to the given text presentation.
*
* @param presentation the text presentation to be extended
* @param offset the offset of the range to be styled
* @param length the length of the range to be styled
* @param attr the attribute describing the style of the range
*/
protected void addRange(
TextPresentation presentation,
int offset,
int length,
TextAttribute attr) {
if (attr != null)
presentation.addStyleRange(
new StyleRange(
offset,
length,
attr.getForeground(),
attr.getBackground(),
attr.getStyle()));
}
示例15: italicizeRange
import org.eclipse.jface.text.TextPresentation; //導入方法依賴的package包/類
private void italicizeRange(int start, int length, TextPresentation presentation) {
StyleRange range = new StyleRange(start, length, null, null, SWT.ITALIC);
presentation.addStyleRange(range);
}