@Override public void modifyDisplayString(StyledString displayString) { for (int index : bestSequence) displayString.setStyle(index, 1, StyledString.COUNTER_STYLER); }
@Override public void setStyle(int offset, int length, Styler styler) { fStyledString.setStyle(offset, length, styler); }
/** * Sets a styler to use for the given source range. The range must be subrange of actual * string of this buffer. Stylers previously set for that range will be overwritten. * * @param offset the start offset of the range * @param length the length of the range * @param styler the styler to set * * @throws StringIndexOutOfBoundsException if <code>start</code> is less than zero, or if * offset plus length is greater than the length of this object. */ @Override public void setStyle(int offset, int length, Styler styler) { fStyledString.setStyle(offset, length, styler); }
/** * Sets the given <code>styler</code> to use for <code>matchingRegions</code> (obtained from * {@link org.eclipse.jdt.core.search.SearchPattern#getMatchingRegions}) in the * <code>styledString</code> starting from the given <code>index</code>. * * @param styledString the styled string to mark * @param index the index from which to start marking * @param matchingRegions the regions to mark * @param styler the styler to use for marking */ public static void markMatchingRegions(StyledString styledString, int index, int[] matchingRegions, Styler styler) { if (matchingRegions != null) { int offset= -1; int length= 0; for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) { if (offset == -1) offset= index + matchingRegions[i]; // Concatenate adjacent regions if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) { length= length + matchingRegions[i + 1]; } else { styledString.setStyle(offset, length + matchingRegions[i + 1], styler); offset= -1; length= 0; } } } }
/** * Sets the given <code>styler</code> to use for <code>matchingRegions</code> (obtained from * {@link org.eclipse.jdt.core.search.SearchPattern#getMatchingRegions}) in the * <code>styledString</code> starting from the given <code>index</code>. * * @param styledString the styled string to mark * @param index the index from which to start marking * @param matchingRegions the regions to mark * @param styler the styler to use for marking */ public static void markMatchingRegions(StyledString styledString, int index, int[] matchingRegions, Styler styler) { if (matchingRegions != null) { int offset= -1; int length= 0; for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) { if (offset == -1) offset= index + matchingRegions[i]; // Concatenate adjacent regions if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) { length= length + matchingRegions[i + 1]; } else { styledString.setStyle(offset, length + matchingRegions[i + 1], styler); offset= -1; length= 0; } } } }
public StyledString getStyledDisplayString(final StyledString origin) { final StyledString copy = RCPUtils.deepCopy(origin); for (int index : bestSubsequence) copy.setStyle(index, 1, BIGRAMS_STYLER); return copy; }
public static StyledString deepCopy(final StyledString displayString) { final StyledString copy = new StyledString(displayString.getString()); for (final StyleRange range : displayString.getStyleRanges()) { copy.setStyle(range.start, range.length, new Styler() { @Override public void applyStyles(final TextStyle textStyle) { textStyle.background = range.background; textStyle.borderColor = range.borderColor; textStyle.borderStyle = range.borderStyle; textStyle.font = range.font; textStyle.foreground = range.foreground; } }); } return copy; } }
@Override public StyledString getStyledText(Object element) { String text= getText(element); StyledString string= new StyledString(text); int index= text.indexOf(JavaElementLabels.CONCAT_STRING); final String namePattern= fFilter != null ? fFilter.getNamePattern() : null; if (namePattern != null && !"*".equals(namePattern)) { //$NON-NLS-1$ String typeName= index == -1 ? text : text.substring(0, index); int[] matchingRegions= SearchPattern.getMatchingRegions(namePattern, typeName, fFilter.getMatchRule()); Strings.markMatchingRegions(string, 0, matchingRegions, getBoldStylerProvider().getBoldStyler()); } if (index != -1) { string.setStyle(index, text.length() - index, StyledString.QUALIFIER_STYLER); final String packagePattern= fFilter != null ? fFilter.getPackagePattern() : null; if (packagePattern != null && !"*".equals(packagePattern)) { //$NON-NLS-1$ index= index + JavaElementLabels.CONCAT_STRING.length(); int endIndex= text.indexOf(JavaElementLabels.CONCAT_STRING, index); String packageName; if (endIndex == -1) packageName= text.substring(index); else packageName= text.substring(index, endIndex); int[] matchingRegions= SearchPattern.getMatchingRegions(packagePattern, packageName, fFilter.getPackageFlags()); Strings.markMatchingRegions(string, index, matchingRegions, getBoldQualifierStyler()); } } return string; }
@Override public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) { StyledString styledDisplayString= new StyledString(); styledDisplayString.append(getStyledDisplayString()); int start= getPrefixCompletionStart(document, offset); int patternLength= offset - start; if (patternLength > 0) { styledDisplayString.setStyle(0, patternLength, boldStylerProvider.getBoldStyler()); } return styledDisplayString; }
@Override public StyledString getStyledText(Object element) { String text= getText(element); StyledString string= new StyledString(text); int index= text.indexOf(JavaElementLabels.CONCAT_STRING); final String namePattern= fFilter != null ? fFilter.getNamePattern() : null; if (namePattern != null && !"*".equals(namePattern)) { //$NON-NLS-1$ String typeName= index == -1 ? text : text.substring(0, index); int[] matchingRegions= SearchPattern.getMatchingRegions(namePattern, typeName, fFilter.getMatchRule()); Strings.markMatchingRegions(string, 0, matchingRegions, getBoldStylerProvider().getBoldStyler()); } if (index != -1) { string.setStyle(index, text.length() - index, StyledString.QUALIFIER_STYLER); final String packagePattern= fFilter != null ? fFilter.getPackagePattern() : null; if (packagePattern != null && !"*".equals(packagePattern)) { //$NON-NLS-1$ index= index + JavaElementLabels.CONCAT_STRING.length(); int endIndex= text.indexOf(JavaElementLabels.CONCAT_STRING, index); String packageName; if (endIndex == -1) packageName= text.substring(index); else packageName= text.substring(index, endIndex); int[] matchingRegions= SearchPattern.getMatchingRegions(packagePattern, packageName, fFilter.getPackageFlags()); Strings.markMatchingRegions(string, index, matchingRegions, getBoldQualifierStyler()); } } return string; }
@Override public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) { StyledString styledDisplayString= new StyledString(); styledDisplayString.append(getStyledDisplayString()); int start= getPrefixCompletionStart(document, offset); int patternLength= offset - start; if (patternLength > 0) { styledDisplayString.setStyle(0, patternLength, boldStylerProvider.getBoldStyler()); } return styledDisplayString; }
private StyledString decorateLineMatches(MatchLine lineMatches) { String line = lineMatches.getLine(); StyledString str = new StyledString(line); for(Match m: lineMatches.getMatches()) { str.setStyle(m.getOffset(), m.getLength(), highlightStyle); } StyledString ret = new StyledString(); ret.append(lineMatches.getLineNumber() + ": ", StyledString.QUALIFIER_STYLER); ret.append(str); return ret; }
private StyledString internalGetRichText(Object element) { JavaElementLine jel= (JavaElementLine) element; String lineNumberString= getLineNumberLabel(jel); Styler highlightStyle= ColoringLabelProvider.HIGHLIGHT_STYLE; StyledString res= new StyledString(); res.append(lineNumberString, StyledString.QUALIFIER_STYLER); res.append(jel.getLineContents()); Match[] matches= getPage().getInput().getMatches(jel); for (int i= 0; i < matches.length; i++) { OccurrenceMatch curr= (OccurrenceMatch) matches[i]; int offset= curr.getOriginalOffset() - jel.getLineStartOffset() + lineNumberString.length(); int length= curr.getOriginalLength(); if (offset >= 0 && (offset + length <= res.length())) { if ((curr.getFlags() & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) { res.setStyle(offset, length, ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE); } else { res.setStyle(offset, length, highlightStyle); } } } return res; }
private StyledString internalGetRichText(Object element) { JavaElementLine jel= (JavaElementLine) element; String lineNumberString= getLineNumberLabel(jel); Styler highlightStyle= ColoringLabelProvider.HIGHLIGHT_STYLE; StyledString res= new StyledString(); res.append(lineNumberString, StyledString.QUALIFIER_STYLER); res.append(jel.getLineContents()); Match[] matches= getPage().getInput().getMatches(jel); for (int i= 0; i < matches.length; i++) { OccurrenceMatch curr= (OccurrenceMatch) matches[i]; int offset= curr.getOriginalOffset() - jel.getLineStartOffset() + lineNumberString.length(); int length= curr.getOriginalLength(); if (offset >= 0 && (offset + length <= res.length())) { if ((curr.getFlags() & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) { res.setStyle(offset, length, ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE); } else { res.setStyle(offset, length, highlightStyle); } } } return res; }
int index= description.indexOf('['); if (index != -1) { str.setStyle(index, description.length() - index, DECORATIONS_STYLE);
int index= description.indexOf('['); if (index != -1) { str.setStyle(index, description.length() - index, DECORATIONS_STYLE);
str.setStyle(termPos, searchTerm.length(), highlightStyle);